Author: kono
Date: 2010-08-31 16:56:11 -0700 (Tue, 31 Aug 2010)
New Revision: 21651

Modified:
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphViewChangeEvent.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DNodeView.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
   
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
   
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyDataTableImpl.java
   
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
   
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AttributeEventsListener.java
   
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
Log:
View update process is optimized.  Still need to optimize default-mappings 
module to minimize setVisualProperty calls.

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphViewChangeEvent.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphViewChangeEvent.java
       2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/GraphViewChangeEvent.java
       2010-08-31 23:56:11 UTC (rev 21651)
@@ -8,39 +8,56 @@
 /**
  * The event source must be the GraphPerspective that changed.
  */
-public abstract class GraphViewChangeEvent
-  extends EventObject {
+public abstract class GraphViewChangeEvent extends EventObject {
 
-  public static final int NODES_RESTORED_TYPE = 1;
-  public static final int EDGES_RESTORED_TYPE = 2;
-  public static final int NODES_HIDDEN_TYPE = 4;
-  public static final int EDGES_HIDDEN_TYPE = 8;
-  public static final int NODES_SELECTED_TYPE = 16;
-  public static final int NODES_UNSELECTED_TYPE = 32;
-  public static final int EDGES_SELECTED_TYPE = 64;
-  public static final int EDGES_UNSELECTED_TYPE = 128;
+       
+       private static final long serialVersionUID = 7718801897482070648L;
+       
+       public static final int NODES_RESTORED_TYPE = 1;
+       public static final int EDGES_RESTORED_TYPE = 2;
+       public static final int NODES_HIDDEN_TYPE = 4;
+       public static final int EDGES_HIDDEN_TYPE = 8;
+       public static final int NODES_SELECTED_TYPE = 16;
+       public static final int NODES_UNSELECTED_TYPE = 32;
+       public static final int EDGES_SELECTED_TYPE = 64;
+       public static final int EDGES_UNSELECTED_TYPE = 128;
 
-  public GraphViewChangeEvent ( GraphView source ) {
-    super( source );
-  }
+       public GraphViewChangeEvent(GraphView source) {
+               super(source);
+       }
 
-  public abstract int getType ();
-  public abstract boolean isNodesRestoredType ();
-  public abstract boolean isEdgesRestoredType ();
-  public abstract boolean isNodesHiddenType ();
-  public abstract boolean isEdgesHiddenType ();
-  public abstract boolean isNodesSelectedType ();
-  public abstract boolean isNodesUnselectedType ();
-  public abstract boolean isEdgesSelectedType ();
-  public abstract boolean isEdgesUnselectedType ();
+       public abstract int getType();
 
-  public abstract CyNode[] getRestoredNodes ();
-  public abstract CyEdge[] getRestoredEdges ();
-  public abstract CyNode[] getHiddenNodes ();
-  public abstract CyEdge[] getHiddenEdges ();
-  public abstract CyNode[] getSelectedNodes ();
-  public abstract CyNode[] getUnselectedNodes ();
-  public abstract CyEdge[] getSelectedEdges ();
-  public abstract CyEdge[] getUnselectedEdges ();
+       public abstract boolean isNodesRestoredType();
 
+       public abstract boolean isEdgesRestoredType();
+
+       public abstract boolean isNodesHiddenType();
+
+       public abstract boolean isEdgesHiddenType();
+
+       public abstract boolean isNodesSelectedType();
+
+       public abstract boolean isNodesUnselectedType();
+
+       public abstract boolean isEdgesSelectedType();
+
+       public abstract boolean isEdgesUnselectedType();
+
+       public abstract CyNode[] getRestoredNodes();
+
+       public abstract CyEdge[] getRestoredEdges();
+
+       public abstract CyNode[] getHiddenNodes();
+
+       public abstract CyEdge[] getHiddenEdges();
+
+       public abstract CyNode[] getSelectedNodes();
+
+       public abstract CyNode[] getUnselectedNodes();
+
+       public abstract CyEdge[] getSelectedEdges();
+
+       public abstract CyEdge[] getUnselectedEdges();
+
 } // abstract class GraphPerspectiveChangeEvent

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
    2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DGraphView.java
    2010-08-31 23:56:11 UTC (rev 21651)
@@ -34,8 +34,6 @@
  */
 package org.cytoscape.ding.impl;
 
-import static org.cytoscape.model.GraphObject.EDGE;
-import static org.cytoscape.model.GraphObject.NETWORK;
 import static org.cytoscape.model.GraphObject.NODE;
 
 import java.awt.Color;
@@ -72,6 +70,7 @@
 import org.cytoscape.ding.GraphViewObject;
 import org.cytoscape.ding.NodeView;
 import org.cytoscape.ding.PrintLOD;
+import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.graph.render.immed.GraphGraphics;
 import org.cytoscape.graph.render.stateful.GraphLOD;
 import org.cytoscape.graph.render.stateful.GraphRenderer;
@@ -83,7 +82,6 @@
 import org.cytoscape.model.CyTableManager;
 import org.cytoscape.model.subnetwork.CyRootNetworkFactory;
 import org.cytoscape.model.subnetwork.CySubNetwork;
-import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.spacial.SpacialEntry2DEnumerator;
 import org.cytoscape.spacial.SpacialIndex2D;
 import org.cytoscape.spacial.SpacialIndex2DFactory;
@@ -129,11 +127,14 @@
  * 
  * @author Nerius Landys
  */
-public class DGraphView implements RenderingEngine<CyNetwork>, GraphView, 
Printable,
-               PhoebeCanvasDroppable, NetworkViewChangeMicroListener, 
NodeViewChangeMicroListener, EdgeViewChangeMicroListener, 
FitContentEventListener, FitSelectedEventListener {
-       
-       private static final Logger logger = 
LoggerFactory.getLogger(DGraphView.class);
+public class DGraphView implements RenderingEngine<CyNetwork>, GraphView,
+               Printable, PhoebeCanvasDroppable, 
NetworkViewChangeMicroListener,
+               NodeViewChangeMicroListener, EdgeViewChangeMicroListener,
+               FitContentEventListener, FitSelectedEventListener {
 
+       private static final Logger logger = LoggerFactory
+                       .getLogger(DGraphView.class);
+
        private static enum ZOrder {
                BACKGROUND_PANE, NETWORK_PANE, FOREGROUND_PANE;
                int layer() {
@@ -342,7 +343,6 @@
         */
        Paint m_lastTexturePaint = null;
 
-
        Map<NodeViewTaskFactory, Map> nodeViewTFs;
        Map<EdgeViewTaskFactory, Map> edgeViewTFs;
        Map<NetworkViewTaskFactory, Map> emptySpaceTFs;
@@ -352,10 +352,10 @@
 
        // Will be injected.
        private VisualLexicon dingLexicon;
-               
-       // This is the view model.  This should be immutable.
+
+       // This is the view model. This should be immutable.
        final CyNetworkView cyNetworkView;
-       
+
        private final RootVisualLexicon rootLexicon;
 
        /**
@@ -371,24 +371,26 @@
                        Map<NodeViewTaskFactory, Map> nodeViewTFs,
                        Map<EdgeViewTaskFactory, Map> edgeViewTFs,
                        Map<NetworkViewTaskFactory, Map> emptySpaceTFs,
-                       TunableInterceptor interceptor, TaskManager manager, 
+                       TunableInterceptor interceptor, TaskManager manager,
                        CyEventHelper eventHelper, CyTableManager tableMgr) {
-               
-               if(view == null)
-                       throw new IllegalArgumentException("Network View Model 
cannot be null.");
-               
+
+               if (view == null)
+                       throw new IllegalArgumentException(
+                                       "Network View Model cannot be null.");
+
                long start = System.currentTimeMillis();
                logger.debug("Phase 1: rendering start.");
                networkModel = view.getModel();
                cyNetworkView = view;
-               
-               // Register this presentation as a service.  And this should 
maintain all children.
+
+               // Register this presentation as a service. And this should 
maintain all children.
                eventHelper.addMicroListener(this, 
NetworkViewChangeMicroListener.class, cyNetworkView);
                eventHelper.addMicroListener(this, 
NodeViewChangeMicroListener.class, cyNetworkView);
                eventHelper.addMicroListener(this, 
EdgeViewChangeMicroListener.class, cyNetworkView);
-               
-               logger.debug("Phase 2: service registered: time = " + 
(System.currentTimeMillis()- start));
-               
+
+               logger.debug("Phase 2: service registered: time = "
+                               + (System.currentTimeMillis() - start));
+
                rootLexicon = vpc;
                this.dingLexicon = dingLexicon;
 
@@ -399,11 +401,11 @@
                this.interceptor = interceptor;
                this.manager = manager;
 
-               CyDataTable nodeCAM = dataFactory.createTable("node view", 
false);
+               final CyDataTable nodeCAM = dataFactory.createTable("node 
view", false);
                nodeCAM.createColumn("hidden", Boolean.class, false);
                tableMgr.getTableMap("NODE", networkModel).put("VIEW", nodeCAM);
 
-               CyDataTable edgeCAM = dataFactory.createTable("edge view", 
false);
+               final CyDataTable edgeCAM = dataFactory.createTable("edge 
view", false);
                edgeCAM.createColumn("hidden", Boolean.class, false);
                tableMgr.getTableMap("EDGE", networkModel).put("VIEW", edgeCAM);
 
@@ -431,26 +433,31 @@
                m_selectedNodes = new IntBTree();
                m_selectedEdges = new IntBTree();
                m_selectedAnchors = new IntBTree();
-               
-               logger.debug("Phase 3: Canvas created: time = " + 
(System.currentTimeMillis()- start));
 
+               logger.debug("Phase 3: Canvas created: time = "
+                               + (System.currentTimeMillis() - start));
+
                // from DingNetworkView
                this.title = networkModel.attrs().get("name", String.class);
 
-               for (CyNode nn : networkModel.getNodeList())            
+               // Create presentations for the graph objects
+               for (CyNode nn : networkModel.getNodeList())
                        addNodeView(nn);
 
                for (CyEdge ee : networkModel.getEdgeList())
                        addEdgeView(ee);
 
                // read in visual properties from view obj
-               final Collection<VisualProperty<?>> netVPs = 
rootLexicon.getVisualProperties(NETWORK);
-               for (VisualProperty<?> vp : netVPs)
-                       networkVisualPropertySet(cyNetworkView, vp, 
cyNetworkView.getVisualProperty(vp));
+               // FIXME TODO: this process is not necessary
+               // final Collection<VisualProperty<?>> netVPs =
+               // rootLexicon.getVisualProperties(NETWORK);
+               // for (VisualProperty<?> vp : netVPs)
+               // networkVisualPropertySet(cyNetworkView, vp,
+               // cyNetworkView.getVisualProperty(vp));
 
                new FlagAndSelectionHandler(this);
-               
-               logger.debug("Phase 4: Everything created: time = " + 
(System.currentTimeMillis()- start));
+
+               logger.debug("Phase 4: Everything created: time = " + 
(System.currentTimeMillis() - start));
        }
 
        /**
@@ -752,28 +759,28 @@
                final int nodeInx = node.getIndex();
                final NodeView oldView = m_nodeViewMap.get(nodeInx);
 
-               if (oldView != null) {
+               if (oldView != null)
                        return null;
-               }
 
                m_drawPersp.addNode(node);
 
-               final View<CyNode> nv = cyNetworkView.getNodeView(node);
-               // This is the node presentation.
-               final NodeView newView = new DNodeView(this, nodeInx, nv);
-               
-               m_nodeViewMap.put(nodeInx, newView);
+               final View<CyNode> nodeViewModel = 
cyNetworkView.getNodeView(node);
+               final NodeView dNodeView = new DNodeView(this, nodeInx, 
nodeViewModel);
+
+               m_nodeViewMap.put(nodeInx, dNodeView);
                m_spacial.insert(nodeInx, m_defaultNodeXMin, m_defaultNodeYMin,
                                m_defaultNodeXMax, m_defaultNodeYMax);
 
                // read in visual properties from view obj
+               // FIXME TODO: this process is not necessary
                final Collection<VisualProperty<?>> nodeVPs = rootLexicon
                                .getVisualProperties(NODE);
-               
+
                for (VisualProperty<?> vp : nodeVPs)
-                       nodeVisualPropertySet(nv, vp, nv.getVisualProperty(vp));
-               
-               return newView;
+                       nodeVisualPropertySet(nodeViewModel, vp,
+                                       nodeViewModel.getVisualProperty(vp));
+
+               return dNodeView;
        }
 
        /**
@@ -811,11 +818,14 @@
                        m_contentChanged = true;
 
                        // read in visual properties from view obj
-                       final Collection<VisualProperty<?>> edgeVPs = 
rootLexicon
-                                       .getVisualProperties(EDGE);
-                       
-                       for (VisualProperty<?> vp : edgeVPs)
-                               edgeVisualPropertySet(edgeViewModel, vp, 
edgeViewModel.getVisualProperty(vp));
+                       // FIXME TODO: this process is not necessary in 
construction
+                       // process.
+                       // final Collection<VisualProperty<?>> edgeVPs = 
rootLexicon
+                       // .getVisualProperties(EDGE);
+                       //
+                       // for (VisualProperty<?> vp : edgeVPs)
+                       // edgeVisualPropertySet(edgeViewModel, vp,
+                       // edgeViewModel.getVisualProperty(vp));
 
                }
 
@@ -1058,7 +1068,7 @@
                        m_viewportChanged = true;
                }
 
-               //updateView();
+               // updateView();
        }
 
        /**
@@ -1076,16 +1086,15 @@
                        m_networkCanvas.m_xCenter = (((double) 
m_extentsBuff[0]) + ((double) m_extentsBuff[2])) / 2.0d;
                        m_networkCanvas.m_yCenter = (((double) 
m_extentsBuff[1]) + ((double) m_extentsBuff[3])) / 2.0d;
                        final double zoom = Math
-                                       .min(
-                                                       ((double) 
m_networkCanvas.getWidth())
-                                                                       / 
(((double) m_extentsBuff[2]) - ((double) m_extentsBuff[0])),
+                                       .min(((double) 
m_networkCanvas.getWidth())
+                                                       / (((double) 
m_extentsBuff[2]) - ((double) m_extentsBuff[0])),
                                                        ((double) 
m_networkCanvas.getHeight())
                                                                        / 
(((double) m_extentsBuff[3]) - ((double) m_extentsBuff[1])));
                        m_networkCanvas.m_scaleFactor = checkZoom(zoom,
                                        m_networkCanvas.m_scaleFactor);
                        m_viewportChanged = true;
                }
-               
+
                // Redraw camvas.
                updateView();
        }
@@ -1094,9 +1103,11 @@
         * DOCUMENT ME!
         */
        public void updateView() {
-               Thread.dumpStack();
-               logger.debug("Update view called.  repainting canvas...\n\n");
+               final long start = System.currentTimeMillis();
+               logger.debug("Update view called.  repainting canvas...");
                m_networkCanvas.repaint();
+               logger.debug("Repaint finised.  Time = "
+                               + (System.currentTimeMillis() - start));
        }
 
        /**
@@ -1369,9 +1380,8 @@
 
                                if (listener != null) {
                                        if (edges.size() > 0) {
-                                               listener
-                                                               
.graphViewChanged(new GraphViewEdgesHiddenEvent(
-                                                                               
this, edges));
+                                               listener.graphViewChanged(new 
GraphViewEdgesHiddenEvent(
+                                                               this, edges));
                                        }
 
                                        listener.graphViewChanged(new 
GraphViewNodesHiddenEvent(
@@ -1471,15 +1481,13 @@
 
                                if (listener != null) {
                                        if (sourceNode != null) {
-                                               listener
-                                                               
.graphViewChanged(new GraphViewNodesRestoredEvent(
-                                                                               
this, makeList(sourceNode)));
+                                               listener.graphViewChanged(new 
GraphViewNodesRestoredEvent(
+                                                               this, 
makeList(sourceNode)));
                                        }
 
                                        if (targetNode != null) {
-                                               listener
-                                                               
.graphViewChanged(new GraphViewNodesRestoredEvent(
-                                                                               
this, makeList(targetNode)));
+                                               listener.graphViewChanged(new 
GraphViewNodesRestoredEvent(
+                                                               this, 
makeList(targetNode)));
                                        }
 
                                        listener.graphViewChanged(new 
GraphViewEdgesRestoredEvent(
@@ -1889,7 +1897,7 @@
                        m_viewportChanged = true;
                }
 
-               //updateView();
+               // updateView();
        }
 
        /**
@@ -2105,8 +2113,8 @@
                                                        || ((m_extentsBuff[0] < 
xMin) && (m_extentsBuff[3] > yMax))
                                                        || ((m_extentsBuff[2] > 
xMax) && (m_extentsBuff[3] > yMax))
                                                        || ((m_extentsBuff[2] > 
xMax) && (m_extentsBuff[1] < yMin))) {
-                                               
m_networkCanvas.m_grafx.getNodeShape(m_nodeDetails
-                                                               .shape(node), 
m_extentsBuff[0],
+                                               
m_networkCanvas.m_grafx.getNodeShape(
+                                                               
m_nodeDetails.shape(node), m_extentsBuff[0],
                                                                
m_extentsBuff[1], m_extentsBuff[2],
                                                                
m_extentsBuff[3], m_path);
 
@@ -2263,15 +2271,16 @@
         */
        public int print(Graphics g, PageFormat pageFormat, int page) {
                if (page == 0) {
-                       ((Graphics2D) g).translate(pageFormat.getImageableX(), 
pageFormat
-                                       .getImageableY());
+                       ((Graphics2D) g).translate(pageFormat.getImageableX(),
+                                       pageFormat.getImageableY());
 
                        // make sure the whole image on the screen will fit to 
the printable
                        // area of the paper
-                       double image_scale = 
Math.min(pageFormat.getImageableWidth()
-                                       / m_networkCanvas.getWidth(), pageFormat
-                                       .getImageableHeight()
-                                       / m_networkCanvas.getHeight());
+                       double image_scale = Math
+                                       .min(pageFormat.getImageableWidth()
+                                                       / 
m_networkCanvas.getWidth(),
+                                                       
pageFormat.getImageableHeight()
+                                                                       / 
m_networkCanvas.getHeight());
 
                        if (image_scale < 1.0d) {
                                ((Graphics2D) g).scale(image_scale, 
image_scale);
@@ -2283,8 +2292,8 @@
                        // getComponent().print(g);
 
                        // from InternalFrameComponent
-                       g.clipRect(0, 0, m_backgroundCanvas.getWidth(), 
m_backgroundCanvas
-                                       .getHeight());
+                       g.clipRect(0, 0, m_backgroundCanvas.getWidth(),
+                                       m_backgroundCanvas.getHeight());
                        m_backgroundCanvas.print(g);
                        m_networkCanvas.print(g);
                        m_foregroundCanvas.print(g);
@@ -2691,32 +2700,32 @@
 
                return l;
        }
-       
-       //// Micro event handlers ////
+
+       // // Micro event handlers ////
        @Override
-       public void nodeVisualPropertySet(final View<CyNode> nodeView, final 
VisualProperty<?> vp, final Object value) {
+       public void nodeVisualPropertySet(final View<CyNode> nodeView,
+                       final VisualProperty<?> vp, final Object value) {
                // Both objects should exist.
-               if ( value == null || nodeView == null)
+               if (value == null || nodeView == null)
                        return;
-               
-               // Convert to Ding's view object.
-               
m_nodeViewMap.get(nodeView.getModel().getIndex()).setVisualPropertyValue(vp, 
value);
-               //logger.debug("Visual Prop appled to node: " + 
vp.getDisplayName() + " = " + value);
-       }
-       
-       
+
+               m_nodeViewMap.get(nodeView.getModel()
+                               .getIndex()).setVisualPropertyValue(vp, value);
+       } 
+
        /**
         * This should be called from DGraphView.
         * 
         */
        @Override
-       public void edgeVisualPropertySet(final View<CyEdge> edgeView, final 
VisualProperty<?> vp, final Object value) {
-               if ( value == null || edgeView == null)
+       public void edgeVisualPropertySet(final View<CyEdge> edgeView,
+                       final VisualProperty<?> vp, final Object value) {
+               if (value == null || edgeView == null)
                        return;
-       
+
                // Convert to Ding's view object.
-               
m_edgeViewMap.get(edgeView.getModel().getIndex()).setVisualPropertyValue(vp, 
value);
-               //logger.debug("Visual Prop appled to edge: " + 
vp.getDisplayName() + " = " + value);
+               m_edgeViewMap.get(edgeView.getModel().getIndex())
+                               .setVisualPropertyValue(vp, value);
        }
 
        /**
@@ -2724,8 +2733,9 @@
         * 
         */
        @Override
-       public void networkVisualPropertySet(View<CyNetwork> target, 
VisualProperty<?> vp, Object o) {
-               
+       public void networkVisualPropertySet(View<CyNetwork> target,
+                       VisualProperty<?> vp, Object o) {
+
                if (o == null)
                        return;
 
@@ -2750,10 +2760,7 @@
                } else if (vp == TwoDVisualLexicon.NETWORK_SCALE_FACTOR) {
                        setZoom(((Double) o).doubleValue());
                }
-               
-               //logger.debug("Visual Prop appled to network: " + 
vp.getDisplayName() + " = " + o);
        }
-       
 
        // ////// The following implements Presentation API ////////////
 
@@ -2775,7 +2782,6 @@
 
        }
 
-
        public Image createImage(int width, int height) {
                // TODO Auto-generated method stub
                return null;
@@ -2797,13 +2803,17 @@
 
        @Override
        public void handleEvent(FitSelectedEvent e) {
-               logger.info("Fit Selected Called by event.");
-               fitSelected();
+               if (e.getSource().equals(cyNetworkView)) {
+                       logger.info("Fit Selected Called by event.");
+                       fitSelected();
+               }
        }
 
        @Override
        public void handleEvent(FitContentEvent e) {
-               logger.info("Fit Content called by event.");
-               fitContent();
+               if (e.getSource().equals(cyNetworkView)) {
+                       logger.info("Fit Content called by event.");
+                       fitContent();
+               }
        }
 }

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DNodeView.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DNodeView.java
     2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DNodeView.java
     2010-08-31 23:56:11 UTC (rev 21651)
@@ -66,6 +66,8 @@
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Ding implementation of node presentation.
@@ -73,7 +75,7 @@
  * @author $author$
  */
 public class DNodeView implements NodeView, Label {
-
+       
        static final float DEFAULT_WIDTH = 20.0f;
        static final float DEFAULT_HEIGHT = 20.0f;
        static final int DEFAULT_SHAPE = GraphGraphics.SHAPE_ELLIPSE;
@@ -613,6 +615,7 @@
         *            DOCUMENT ME!
         */
        public void setXPosition(double xPos) {
+               
                synchronized (dGraphView.m_lock) {
                        if (!dGraphView.m_spacial.exists(m_inx, 
dGraphView.m_extentsBuff, 0)
                                        || Double.isNaN(xPos))

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
    2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DingRenderingEngineFactory.java
    2010-08-31 23:56:11 UTC (rev 21651)
@@ -135,7 +135,7 @@
        @Override
        public void handleEvent(NetworkViewChangedEvent nvce) {
                DGraphView gv = viewMap.get(nvce.getSource());
-               logger.debug("NetworkViewChangedEvent listener got view: " + 
nvce.getSource().getSUID());
+               logger.debug("NetworkViewChangedEvent listener got view update 
request: " + nvce.getSource().getSUID());
                if ( gv != null )
                        gv.updateView();
        }

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
       2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/FlagAndSelectionHandler.java
       2010-08-31 23:56:11 UTC (rev 21651)
@@ -175,7 +175,7 @@
 
                        for (final CyNode node : selectedNodes)
                                node.attrs().set(SELECT_ATTR, true);
-
+                       
                } else if (event.isNodesUnselectedType() || 
event.isNodesHiddenType()) {
                        final CyNode[] objIndecies;
                        if (event.isNodesUnselectedType())

Modified: 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
===================================================================
--- 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
     2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/model-api/trunk/src/main/java/org/cytoscape/model/events/RowSetMicroListener.java
     2010-08-31 23:56:11 UTC (rev 21651)
@@ -37,7 +37,6 @@
 package org.cytoscape.model.events;
 
 import org.cytoscape.event.CyMicroListener;
-import org.cytoscape.model.CyRow;
 
 
 /**
@@ -45,5 +44,7 @@
  * will the be CyRow that is being modified. 
  */
 public interface RowSetMicroListener extends CyMicroListener {
-       void handleRowSet(String columnName, Object value);
+       
+       void handleRowSet(final String columnName, final Object value);
+
 }

Modified: 
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyDataTableImpl.java
===================================================================
--- 
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyDataTableImpl.java
      2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyDataTableImpl.java
      2010-08-31 23:56:11 UTC (rev 21651)
@@ -311,10 +311,9 @@
                Map<Long, Object> vls = attributes.get(attrName);
 
                if (types.get(attrName).isAssignableFrom(value.getClass())) {
-                       // TODO this is an implicit addRow - not sure if we 
want to refactor
-                       // this or not
+                       // TODO this is an implicit addRow - not sure if we 
want to refactor this or not
                        vls.put(suid, value);
-                       eventHelper.getMicroListener(RowSetMicroListener.class, 
getRow(suid)).handleRowSet(attrName,value);
+                       eventHelper.getMicroListener(RowSetMicroListener.class, 
getRow(suid)).handleRowSet(attrName, value);
                } else
                        throw new IllegalArgumentException("value is not of 
type: "
                                        + types.get(attrName));

Modified: 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
===================================================================
--- 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
     2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/viewmodel-impl/trunk/src/main/java/org/cytoscape/view/model/internal/NetworkViewImpl.java
     2010-08-31 23:56:11 UTC (rev 21651)
@@ -143,7 +143,6 @@
                        return;
 
                final CyEdge edge = e.getEdge();
-               System.out.println(" Adding edge to view! " + edge.toString());
                final View<CyEdge> ev = new EdgeViewImpl(edge, cyEventHelper, 
this);
                edgeViews.put(edge, ev); // FIXME: View creation here and in
                                                                        // 
initializer: should be in one place

Modified: 
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AttributeEventsListener.java
===================================================================
--- 
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AttributeEventsListener.java
       2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AttributeEventsListener.java
       2010-08-31 23:56:11 UTC (rev 21651)
@@ -179,4 +179,10 @@
                // TODO Auto-generated method stub
                
        }
+
+       @Override
+       public void handleRowSet(String columnName, Object value) {
+               // TODO Auto-generated method stub
+               
+       }
 }

Modified: 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
===================================================================
--- 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
       2010-08-31 23:53:21 UTC (rev 21650)
+++ 
core3/vizmap-impl/trunk/src/main/java/org/cytoscape/view/vizmap/internal/VisualStyleImpl.java
       2010-08-31 23:56:11 UTC (rev 21651)
@@ -38,9 +38,9 @@
 import static org.cytoscape.model.GraphObject.NETWORK;
 import static org.cytoscape.model.GraphObject.NODE;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 import org.cytoscape.model.CyEdge;
@@ -64,10 +64,12 @@
        
        private static final Logger logger = 
LoggerFactory.getLogger(VisualStyleImpl.class);
        
-       private Map<VisualProperty<?>, VisualMappingFunction<?, ?>> mappings;
-       private Map<VisualProperty<?>, Object> perVSDefaults;
-       private RootVisualLexicon rootLexicon;
        private static final String DEFAULT_TITLE = "?";
+       
+       private final Map<VisualProperty<?>, VisualMappingFunction<?, ?>> 
mappings;
+       private final Map<VisualProperty<?>, Object> perVSDefaults;
+       private final RootVisualLexicon rootLexicon;
+       
        private String title;
 
        /**
@@ -97,12 +99,12 @@
                this.rootLexicon = rootLexicon;
                mappings = new HashMap<VisualProperty<?>, 
VisualMappingFunction<?, ?>>();
                perVSDefaults = new HashMap<VisualProperty<?>, Object>();
+               
                // Copy immutable defaults from each VP
                for(VisualProperty<?> vp: 
this.rootLexicon.getAllVisualProperties())
                        perVSDefaults.put(vp, vp.getDefault());
                
-               logger.info("New Visual Style Constructed: " + this.title);
-               
+               logger.info("New Visual Style Created: Style Name = " + 
this.title);
        }
 
        /**
@@ -165,29 +167,30 @@
                perVSDefaults.put(vp, value);
        }
 
-       // ??
        /**
         *  DOCUMENT ME!
         *
-        * @param view DOCUMENT ME!
+        * @param networkView DOCUMENT ME!
         */
-       public void apply(final CyNetworkView view) {
+       public void apply(final CyNetworkView networkView) {
                
                logger.debug("Visual Style Apply method called: " + this.title);
                
-               final Collection<View<CyNode>> nodeviews = view.getNodeViews();
-               final Collection<View<CyEdge>> edgeviews = view.getEdgeViews();
+               final Collection<View<CyNode>> nodeviews = 
networkView.getNodeViews();
+               final Collection<View<CyEdge>> edgeviews = 
networkView.getEdgeViews();
+               final Collection<View<CyNetwork>> networkviews = new 
HashSet<View<CyNetwork>>();
+               networkviews.add(networkView);
 
-               applyImpl(view, nodeviews,
+               applyImpl(networkView, nodeviews,
                          rootLexicon.getVisualProperties(nodeviews, NODE));
-               applyImpl(view, edgeviews,
+               applyImpl(networkView, edgeviews,
                          rootLexicon.getVisualProperties(edgeviews, EDGE));
+               applyImpl(networkView, networkviews,
+                         rootLexicon.getVisualProperties(NETWORK));
                
-               applyImpl(view, Arrays.asList((View<CyNetwork>) view),
-                         rootLexicon.getVisualProperties(NETWORK));
+               logger.debug("Visual Style applied: " + this.title + "\n");
        }
 
-       // note: can't use applyImpl(List<View<?>>views ... ) because that does 
not compile
        /**
         *  DOCUMENT ME!
         *
@@ -216,16 +219,21 @@
                
                final VisualMappingFunction<?, V> mapping = 
getVisualMappingFunction(vp);
                final V defaultValue = getDefaultValue(vp);
-
                
                // If mapping is available for this VP, apply the mapping.
                if (mapping != null) {
                        mapping.apply(views);
-               } else {
+               } else if(!vp.isIgnoreDefault()) { // Check ignore flag first.
                        // reset all rows to allow usage of default value:
-                       for(View<G> viewModel: views)
+                       for(final View<G> viewModel: views) {
+                               
if(viewModel.getVisualProperty(vp).equals(defaultValue))
+                                       continue;
+                               
                                viewModel.setVisualProperty(vp, defaultValue);
-               }
+                               //logger.debug(vp.getDisplayName() + " updated: 
" + defaultValue);
+                       }
+               } else
+                       logger.debug(vp.getDisplayName() + " is set to ignore 
defaults.  Skipping...");
        }
 
        /**

-- 
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