Author: sfederow
Date: 2009-08-13 03:24:01 -0700 (Thu, 13 Aug 2009)
New Revision: 17807

Modified:
   csplugins/trunk/soc/sfederow/CyAnimator/src/CyAnimatorDialog.java
   csplugins/trunk/soc/sfederow/CyAnimator/src/CyFrame.java
   csplugins/trunk/soc/sfederow/CyAnimator/src/FrameManager.java
   csplugins/trunk/soc/sfederow/CyAnimator/src/Interpolator.java
Log:


Modified: csplugins/trunk/soc/sfederow/CyAnimator/src/CyAnimatorDialog.java
===================================================================
--- csplugins/trunk/soc/sfederow/CyAnimator/src/CyAnimatorDialog.java   
2009-08-13 10:05:23 UTC (rev 17806)
+++ csplugins/trunk/soc/sfederow/CyAnimator/src/CyAnimatorDialog.java   
2009-08-13 10:24:01 UTC (rev 17807)
@@ -124,13 +124,16 @@
        private FrameManager frameManager;
        
        int thumbnailPopupIndex = 0;
-       ArrayList<CyFrame> frameList; // = new ArrayList<CyFrame>();
+       ArrayList<CyFrame> frameList;
               
        
        public CyAnimatorDialog(){
                
Cytoscape.getSwingPropertyChangeSupport().addPropertyChangeListener(this);
+               
                //add as listener to CytoscapeDesktop
                
Cytoscape.getDesktop().getSwingPropertyChangeSupport().addPropertyChangeListener(this);
+       
+               this.setTitle("CyAnimator");
                frameManager = new FrameManager();
                
                
@@ -143,11 +146,12 @@
                framePanel = new JPanel();
                
                dragnDrop = new DragAndDropManager();
-               //timer = frameManage.getTimer();
+               
+               
                initialize();
        }
        
-       /*
+       /**
         * Create the control buttons, panels, and initialize the main JDialog.
         */
        public void initialize(){
@@ -351,7 +355,7 @@
        }
 
        
-       /*
+       /**
         * Takes the current frameList and cycles through it to create a JButton
         * for each frame with the corresponding thumbnail image.  It also 
creates
         * a JPopupMenu for each frame in the frameList so that the right click 
controls
@@ -473,52 +477,12 @@
                
        }
        
-       /*
-       int frameid = 0;
-       
-       public CyFrame captureCurrentFrame(){
-               
-               CyNetwork currentNetwork = Cytoscape.getCurrentNetwork();
-               CyFrame frame = new CyFrame(currentNetwork);
-               
-               CyNetworkView networkView = Cytoscape.getCurrentNetworkView();
-               
-               frame.populate(); // Initialize the frame
-               frame.setInterCount(30);
-               frame.setID(networkView.getIdentifier()+"_"+frameid);
-               System.out.println("Frame ID: "+frameid);
-               frame.captureImage();
-               frameid++;
-               return frame;
-               
-       }
-       
-       public void recordAnimation() throws IOException {
-       
-               String curDir = System.getProperty("user.dir");
-               System.out.println(curDir);
-               
-               File file = new File(curDir+"/outputImgs");
-               file.mkdir();
-               
-               for(int i=0; i<frames.length; i++){
-                       DecimalFormat frame = new DecimalFormat("#000");
-                       //String name = 
curDir+"/outputImgs/Frame_"+frame.format(i)+".png";
-                       String name = 
curDir+"/outputImgs/Frame_"+frame.format(i)+".jpeg";
-                       
-                       
-                       frames[i].writeImage(name);
-                       }
-       }
-       */
-       
+
        public void propertyChange ( PropertyChangeEvent e ) {
                if(e.getPropertyName().equals("ATTRIBUTES_CHANGED")){
                        //initialize();
                        setVisible(true);
                }
-               
-       
        }
        
        public void focusGained(FocusEvent e){
@@ -529,8 +493,8 @@
                
        }
        
-       /*
-        * Listens for changes to the slider which then adjusts the speed of 
animation
+       /**
+        * Listens for changes to the slider which then adjusts the speed of 
animation.
         */
        class SliderListener implements ChangeListener {
            public void stateChanged(ChangeEvent e) {

Modified: csplugins/trunk/soc/sfederow/CyAnimator/src/CyFrame.java
===================================================================
--- csplugins/trunk/soc/sfederow/CyAnimator/src/CyFrame.java    2009-08-13 
10:05:23 UTC (rev 17806)
+++ csplugins/trunk/soc/sfederow/CyAnimator/src/CyFrame.java    2009-08-13 
10:24:01 UTC (rev 17807)
@@ -90,6 +90,11 @@
        private Point2D centerPoint = null;
        private DGraphView dview = null; 
        
+       /**
+        * Creates this CyFrame by initializing and populating all of the 
fields.
+        * 
+        * @param currentNetwork
+        */
        public CyFrame(CyNetwork currentNetwork){
                nodePosMap = new HashMap<String, double[]>();
                nodeColMap = new HashMap<String, Color>();
@@ -146,41 +151,44 @@
                
                dview = (DGraphView)networkView;
                
-               for(Node node: nodeList)
-               {
+               for(Node node: nodeList){
                
                        NodeView nodeView = networkView.getNodeView(node);
                        if(nodeView == null){ continue; }
-
+                       
+                       //stores the x and y position of the node
                        double[] xy = new double[2];
                        xy[0] = nodeView.getXPosition();
                        xy[1] = nodeView.getYPosition();
-                   centerPoint = dview.getCenter();
                        nodePosMap.put(node.getIdentifier(), xy);
+                       
+                       //grab color and opacity
                        Color nodeColor = (Color)nodeView.getUnselectedPaint();
                        Integer trans = nodeColor.getAlpha();
+                       //store in respective hashmap
                        nodeColMap.put(node.getIdentifier(), 
(Color)nodeView.getUnselectedPaint());
                        nodeOpacityMap.put(node.getIdentifier(), trans);
                        
-                       //System.out.println(nodeView.getUnselectedPaint()+"    
X: "+nodeView.getXPosition()+"    Y: "+nodeView.getYPosition());
-                  
+                       centerPoint = dview.getCenter();
+                       
                }
 
-               for(Edge edge: edgeList)
-               {
+               for(Edge edge: edgeList){
+                       
                        EdgeView edgeView = networkView.getEdgeView(edge);
                        if(edgeView == null){  continue; }
+                       
+                       //grab color and opacity
                        Color p = (Color)edgeView.getUnselectedPaint();
                        Integer trans = p.getAlpha();
-                       
-                       //if(edge == null || p == null){ return; }
+                       //store in respective hashmap
                        edgeColMap.put(edge.getIdentifier(), p);
                        edgeOpacityMap.put(edge.getIdentifier(), trans);
                
                }
        }
        
-       /*
+       /**
         * Captures and stores a thumbnail image from the current CyNetworkView 
for
         * this frame.
         */
@@ -200,7 +208,9 @@
 
                Graphics2D g = (Graphics2D) image.getGraphics();
                g.scale(scale, scale);
-               ifc.print(g);
+               
+               ifc.paint(g);
+               //ifc.print(g);
                g.dispose();
 
                networkImage = image;
@@ -292,7 +302,7 @@
                currentView.updateView();
        }
 
-       /*
+       /**
         * Return the frame ID for this frame
         * 
         * @return the frame ID
@@ -564,6 +574,7 @@
                InternalFrameComponent ifc =
                         
Cytoscape.getDesktop().getNetworkViewManager().getInternalFrameComponent(curView);
                
+       
                // Handle the exportTextAsShape property
                DGraphView theViewToPrint = (DingNetworkView) curView;
                boolean exportTextAsShape =
@@ -585,7 +596,7 @@
                System.out.println("written?");
        }
 
-       /*
+       /**
         * Get the center point for the frame
         * 
         * @return the center for this frame
@@ -594,7 +605,7 @@
                return this.centerPoint;
        }
 
-       /*
+       /**
         * Set the center point of the frame
         * 
         * @param center point for a frame

Modified: csplugins/trunk/soc/sfederow/CyAnimator/src/FrameManager.java
===================================================================
--- csplugins/trunk/soc/sfederow/CyAnimator/src/FrameManager.java       
2009-08-13 10:05:23 UTC (rev 17806)
+++ csplugins/trunk/soc/sfederow/CyAnimator/src/FrameManager.java       
2009-08-13 10:24:01 UTC (rev 17807)
@@ -49,7 +49,7 @@
                
        }
        
-       /*
+       /**
         * Creates a CyFrame from the current network and view.
         * 
         * @return CyFrame of the current CyNetworkView 
@@ -79,7 +79,7 @@
                
        }
        
-       /*
+       /**
         * Deletes a key frame from the key frame list.
         * 
         * @param index in keyFrameList of frame to be deleted
@@ -98,7 +98,7 @@
        }
        
        
-       /*
+       /**
         * Adds the current frame to the keyFrameList and creates a new timer or
         * updates the existing timer.
         */
@@ -113,7 +113,7 @@
        }
        
        
-       /*
+       /**
         * Creates a timer that fires continually at a delay set in 
milliseconds.
         * Each firing of the timer causes the next the frame in the array to be
         * displayed thus animating the array of CyFrames.  
@@ -146,7 +146,7 @@
        }
 
        
-       /*
+       /**
         * Updates the timer by making a new one while also checking to see 
whether
         * or not the animation was already playing.
         */
@@ -161,7 +161,7 @@
        }
        
        
-       /*
+       /**
         * "Records" the animation in the sense that it dumps an image of each 
frame to 
         * a specified directory.  It also numbers the frames automatically so 
that they
         * can be easily compressed into a standard movie format.
@@ -190,7 +190,7 @@
                }
        }
        
-       /*
+       /**
         * Starts the the timer and plays the animation.
         */
        public void play(){
@@ -200,7 +200,7 @@
                timer.start();
        }
        
-       /*
+       /**
         * Stops the timer and the animation.
         */
        public void stop(){
@@ -209,7 +209,7 @@
                makeTimer();
        }
        
-       /*
+       /**
         * Pauses the timer and the animation.
         */
        public void pause(){
@@ -217,7 +217,7 @@
                timer.stop();
        }
        
-       /*
+       /**
         * Steps forward one frame in the animation.
         */
        public void stepForward(){
@@ -231,7 +231,7 @@
                frames[frameIndex].display();
        }
        
-       /*
+       /**
         * Steps backwards one frame in the animation.
         */
        public void stepBackward(){
@@ -245,10 +245,20 @@
                frames[frameIndex].display();
        }
        
+       /**
+        * Returns the key frame list.
+        * 
+        * @return
+        */
        public ArrayList<CyFrame> getKeyFrameList(){
                return keyFrameList;
        }
        
+       /**
+        * Sets the key frame list.
+        * 
+        * @param frameList
+        */
        public void setKeyFrameList(ArrayList<CyFrame> frameList){
                keyFrameList = frameList;       
                
@@ -259,6 +269,11 @@
                }
        }
        
+       /**
+        * Returns the current timer.
+        * 
+        * @return
+        */
        public Timer getTimer(){
                return timer;
        }

Modified: csplugins/trunk/soc/sfederow/CyAnimator/src/Interpolator.java
===================================================================
--- csplugins/trunk/soc/sfederow/CyAnimator/src/Interpolator.java       
2009-08-13 10:05:23 UTC (rev 17806)
+++ csplugins/trunk/soc/sfederow/CyAnimator/src/Interpolator.java       
2009-08-13 10:24:01 UTC (rev 17807)
@@ -41,8 +41,8 @@
        
        /*
         * These lists of FrameInterpolators define the set of visual properties
-        * which will be 
-        * 
+        * which will be interpolated for and updated in the CyNetworkView 
during
+        * the animation.
         */
        List<FrameInterpolator> nodeInterpolators = new 
ArrayList<FrameInterpolator>();
        List<FrameInterpolator> edgeInterpolators = new 
ArrayList<FrameInterpolator>();
@@ -65,7 +65,7 @@
                
        }
 
-       /*
+       /**
         * This is the driver method which takes a list of key frames and runs 
the frames
         * in sets of two through the interpolators to generate the 
intermediate frames.
         * 
@@ -151,7 +151,7 @@
        }
        
        
-       /*
+       /**
         * Takes two CyFrames and returns a list of NodeViews which is the 
union of the list of 
         * NodeViews that are in each of the two frames.  This is done to 
accomodate the adding/deleting
         * of nodes between frames in animation as the union provides a 
complete set of nodes when
@@ -179,7 +179,7 @@
        }
        
        
-       /*
+       /**
         * Takes two CyFrames and returns the union of the EdgeView lists that 
are contained
         * within each frame.  This is to ensure that when edges are 
added/deleted they will
         * be able to be interpolated from one frame to the next instead of 
just instantly
@@ -209,7 +209,7 @@
        }
 
        
-       /*
+       /**
         * This method performs a generic color interpolation and is used by 
many of the interpolators
         * to do their color interpolations.  It simply takes the absolute 
difference between the R, G, and B
         * values from the two colors, divides the difference by the number of 
intervals which will
@@ -315,7 +315,7 @@
        }
 
        
-       /*
+       /**
         * Interpolates the node position, using the standard linear 
interpolation formula described
         * at http://en.wikipedia.org/wiki/Linear_interpolation. It essentially 
just finds the absolute
         * difference between the position of a node in frame one, and in frame 
two.  It then divides
@@ -331,7 +331,7 @@
                        
                }
                
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is in this case a list of NodeViews
@@ -404,7 +404,7 @@
                }
        }
        
-       /*
+       /**
         * Fills in the interpolated color values for NodeViews.  Works by 
using the inner
         * interpolateColor() method.
         * 
@@ -416,7 +416,7 @@
                }
                
                
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is in this case a list of NodeViews
@@ -430,10 +430,6 @@
                public CyFrame[] interpolate(List valueList, CyFrame frameOne, 
CyFrame frameTwo, 
                                             int start, int stop, CyFrame[] 
cyFrameArray){
 
-                       // 
if(!frameOne.getCurrentNetwork().getIdentifier().equals(frameTwo.getCurrentNetwork().getIdentifier())){
-                       //      System.out.println("Frames Cannot be 
interpolated across different networks.");
-                       // }
-                       
                        CyNetwork currentNetwork = frameOne.getCurrentNetwork();
                        
                        int framenum = (stop-start) - 1;
@@ -474,7 +470,7 @@
        }
        
        
-       /*
+       /**
         * Interpolates node opacity by linearly incrementing or decrementing 
the opacity value. 
         * 
         */
@@ -485,7 +481,7 @@
                }
                
                
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is in this case a list of NodeViews
@@ -537,7 +533,7 @@
        }
        
        
-       /*
+       /**
         * Interpolates edgeColor using the interpolateColor() method.
         */
        class interpolateEdgeColor implements FrameInterpolator {
@@ -546,7 +542,7 @@
                        
                }
        
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is in this case a list of EdgeViews
@@ -597,7 +593,7 @@
        }
                
        
-       /*
+       /**
         * Linearly interpolates the edge opacity.
         */
        class interpolateEdgeOpacity implements FrameInterpolator {
@@ -605,7 +601,7 @@
                        
                }
                
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is in this case a list of EdgeViews
@@ -656,7 +652,7 @@
                }
        }
        
-       /*
+       /**
         * Linearly interpolates the network zoom.
         * 
         */
@@ -666,7 +662,7 @@
                        
                }
        
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is not used in this case 
@@ -711,7 +707,7 @@
                        
                }
        
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is not used in this case
@@ -742,7 +738,7 @@
        
                public interpolateNetworkCenter(){}
                
-               /*
+               /**
                 * Performs the interpolation.
                 *  
                 * @param valueList is not used in this case


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to