Author: paperwing
Date: 2012-03-20 15:06:51 -0700 (Tue, 20 Mar 2012)
New Revision: 28598

Added:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutContext.java
Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/CyActivator.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/ContextMenuInputHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithm.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSelectionBoxProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/task/PopupMenuCreator.java
Log:
Completed basic layout algorithm to arrange nodes on surface of sphere, 
temporarily disabled right-click popup menu due to recent change in TaskFactory 
API

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/CyActivator.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/CyActivator.java
      2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/CyActivator.java
      2012-03-20 22:06:51 UTC (rev 28598)
@@ -99,10 +99,7 @@
                                RenderingEngineFactory.class,
                                windBirdsEyeRenderingEngineFactoryProps);
 
-               
-               UndoSupport undoSupportServiceRef = getService(bc, 
UndoSupport.class);
-               
-               SphericalLayoutAlgorithm sphericalLayoutAlgorithm = new 
SphericalLayoutAlgorithm(undoSupportServiceRef);
+               SphericalLayoutAlgorithm sphericalLayoutAlgorithm = new 
SphericalLayoutAlgorithm();
                Properties sphericalLayoutAlgorithmProps = new Properties();
                
sphericalLayoutAlgorithmProps.setProperty("preferredMenu","Layout.3D Layouts");
                
sphericalLayoutAlgorithmProps.setProperty("preferredTaskManager","menu");

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
      2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
      2012-03-20 22:06:51 UTC (rev 28598)
@@ -109,7 +109,7 @@
                                // Use the system's default version of OpenGL
                                GLProfile profile = GLProfile.getDefault();
                                GLCapabilities capabilities = new 
GLCapabilities(profile);
-                               
+                               capabilities.setHardwareAccelerated(true);
                                // TODO: check if this line should be moved to 
graphics object
                                capabilities.setDoubleBuffered(true);
                                

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/ContextMenuInputHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/ContextMenuInputHandler.java
    2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/ContextMenuInputHandler.java
    2012-03-20 22:06:51 UTC (rev 28598)
@@ -28,46 +28,46 @@
        }
 
        private void processNetworkRightClickMenu(MouseMonitor mouse, 
GraphicsData graphicsData){
-               if (popupMenuCreator == null) {
-                       popupMenuCreator = new 
PopupMenuCreator(graphicsData.getTaskManager(),
-                                       graphicsData.getSubmenuTaskManager());
-               }
-               
-               Set<Integer> pressed = mouse.getPressed();
-               
-               CyNetworkView networkView = graphicsData.getNetworkView();
-               
-               CyNode node = 
networkView.getModel().getNode(graphicsData.getSelectionData().getHoverNodeIndex());
-               CyEdge edge = 
networkView.getModel().getEdge(graphicsData.getSelectionData().getHoverEdgeIndex());
-               
-               if (pressed.contains(MouseEvent.BUTTON3)) {
-                       
-                       JPopupMenu popupMenu = null;
-                       
-                       if (node != null) {
-                               View<CyNode> nodeView = 
networkView.getNodeView(node);;
-                               
-                               popupMenu = 
popupMenuCreator.createNodeMenu(nodeView, 
-                                               networkView, 
graphicsData.getVisualLexicon(), 
-                                               
graphicsData.getTaskFactoryListener().getNodeViewTaskFactories());
-                       } else if (edge != null) {
-                               View<CyEdge> edgeView = 
networkView.getEdgeView(edge);
-                               
-                               popupMenu = 
popupMenuCreator.createEdgeMenu(edgeView, 
-                                               networkView, 
graphicsData.getVisualLexicon(), 
-                                               
graphicsData.getTaskFactoryListener().getEdgeViewTaskFactories());
-                       } else {
-                               popupMenu = 
popupMenuCreator.createNetworkMenu(networkView, 
-                                               graphicsData.getVisualLexicon(),
-                                               
graphicsData.getTaskFactoryListener().getNetworkViewTaskFactories());
-                       }
-                       
-                       // menu.add(new JMenuItem("Sample Action"));
-                       
-                       if (popupMenu != null) {
-                               popupMenu.show(graphicsData.getContainer(), 
mouse.x(), mouse.y());
-                       }
-               }
-               
+//             if (popupMenuCreator == null) {
+//                     popupMenuCreator = new 
PopupMenuCreator(graphicsData.getTaskManager(),
+//                                     graphicsData.getSubmenuTaskManager());
+//             }
+//             
+//             Set<Integer> pressed = mouse.getPressed();
+//             
+//             CyNetworkView networkView = graphicsData.getNetworkView();
+//             
+//             CyNode node = 
networkView.getModel().getNode(graphicsData.getSelectionData().getHoverNodeIndex());
+//             CyEdge edge = 
networkView.getModel().getEdge(graphicsData.getSelectionData().getHoverEdgeIndex());
+//             
+//             if (pressed.contains(MouseEvent.BUTTON3)) {
+//                     
+//                     JPopupMenu popupMenu = null;
+//                     
+//                     if (node != null) {
+//                             View<CyNode> nodeView = 
networkView.getNodeView(node);;
+//                             
+//                             popupMenu = 
popupMenuCreator.createNodeMenu(nodeView, 
+//                                             networkView, 
graphicsData.getVisualLexicon(), 
+//                                             
graphicsData.getTaskFactoryListener().getNodeViewTaskFactories());
+//                     } else if (edge != null) {
+//                             View<CyEdge> edgeView = 
networkView.getEdgeView(edge);
+//                             
+//                             popupMenu = 
popupMenuCreator.createEdgeMenu(edgeView, 
+//                                             networkView, 
graphicsData.getVisualLexicon(), 
+//                                             
graphicsData.getTaskFactoryListener().getEdgeViewTaskFactories());
+//                     } else {
+//                             popupMenu = 
popupMenuCreator.createNetworkMenu(networkView, 
+//                                             graphicsData.getVisualLexicon(),
+//                                             
graphicsData.getTaskFactoryListener().getNetworkViewTaskFactories());
+//                     }
+//                     
+//                     // menu.add(new JMenuItem("Sample Action"));
+//                     
+//                     if (popupMenu != null) {
+//                             popupMenu.show(graphicsData.getContainer(), 
mouse.x(), mouse.y());
+//                     }
+//             }
+//             
        }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithm.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithm.java
 2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithm.java
 2012-03-20 22:06:51 UTC (rev 28598)
@@ -1,21 +1,25 @@
 package org.cytoscape.paperwing.internal.layouts;
 
 import org.cytoscape.view.layout.AbstractLayoutAlgorithm;
+import org.cytoscape.view.layout.CyLayoutContext;
+import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.work.TaskIterator;
 import org.cytoscape.work.undo.UndoSupport;
 
-public class SphericalLayoutAlgorithm extends AbstractLayoutAlgorithm {
+public class SphericalLayoutAlgorithm extends 
AbstractLayoutAlgorithm<SphericalLayoutContext> {
 
-       public SphericalLayoutAlgorithm(UndoSupport undo) {
-               
-               super(undo, "spherical", "Spherical Layout", false);
+       public SphericalLayoutAlgorithm() {
+               super("spherical", "Spherical Layout", false);
        }
-       
+
        @Override
-       public TaskIterator createTaskIterator() {
+       public TaskIterator createTaskIterator(SphericalLayoutContext context) {
                return new TaskIterator(
-                               new SphericalLayoutAlgorithmTask(
-                                               networkView, getName(), 
selectedOnly, staticNodes));
+                               new SphericalLayoutAlgorithmTask(getName(), 
context));
        }
        
+       @Override
+       public SphericalLayoutContext createLayoutContext() {
+               return new SphericalLayoutContext(supportsSelectedOnly(), 
supportsNodeAttributes(), supportsEdgeAttributes());
+       }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
     2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutAlgorithmTask.java
     2012-03-20 22:06:51 UTC (rev 28598)
@@ -4,6 +4,7 @@
 
 import org.cytoscape.model.CyNode;
 import org.cytoscape.view.layout.AbstractBasicLayoutTask;
+import org.cytoscape.view.layout.AbstractLayoutAlgorithmContext;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
@@ -11,9 +12,12 @@
 
 public class SphericalLayoutAlgorithmTask extends AbstractBasicLayoutTask {
 
-       public SphericalLayoutAlgorithmTask(CyNetworkView networkView, String 
name,
-                       boolean selectedOnly, Set<View<CyNode>> staticNodes) {
-               super(networkView, name, selectedOnly, staticNodes);
+       private SphericalLayoutContext context;
+       
+       public SphericalLayoutAlgorithmTask(String name,
+                       SphericalLayoutContext context) {
+               super(name, context);
+               this.context = context;
        }
 
        @Override
@@ -28,10 +32,13 @@
                double x, y, z;
                
                for (View<CyNode> nodeView : networkView.getNodeViews()) {
-                       x = Math.cos((double) current / nodeCount * Math.PI * 
2);
-                       y = Math.sin((double) current / nodeCount * Math.PI * 
2);
-                       z = -Math.sin((double) current / nodeCount * Math.PI * 
2);
                        
+                       double phi = Math.random() * Math.PI * 2;
+                       
+                       x = Math.cos((double) current / nodeCount * Math.PI * 
2) * Math.sin(phi);
+                       y = Math.sin((double) current / nodeCount * Math.PI * 
2) * Math.sin(phi);
+                       z = Math.cos(phi);
+                       
                        x *= sphereRadius;
                        y *= sphereRadius;
                        z *= sphereRadius;

Added: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutContext.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutContext.java
                           (rev 0)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutContext.java
   2012-03-20 22:06:51 UTC (rev 28598)
@@ -0,0 +1,19 @@
+package org.cytoscape.paperwing.internal.layouts;
+
+import java.util.Set;
+
+import org.cytoscape.view.layout.AbstractLayoutAlgorithmContext;
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.TunableValidator;
+
+public class SphericalLayoutContext extends AbstractLayoutAlgorithmContext 
implements TunableValidator {
+       
+       public SphericalLayoutContext(boolean supportsSelectedOnly, 
Set<Class<?>> supportedNodeAttributes, Set<Class<?>> supportedEdgeAttributes) {
+               super(supportsSelectedOnly, supportedNodeAttributes, 
supportedEdgeAttributes);
+       }
+
+       @Override //TODO how to validate these values?
+       public ValidationState getValidationState(final Appendable errMsg) {
+               return ValidationState.OK;
+       }
+}


Property changes on: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/layouts/SphericalLayoutContext.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
     2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderBoundingBoxProcedure.java
     2012-03-20 22:06:51 UTC (rev 28598)
@@ -56,7 +56,11 @@
                Vector3 bottomRightUp = bottomRight.towards(topRight, fraction);
                Vector3 bottomRightLeft = bottomRight.towards(bottomLeft, 
fraction);
                
-               gl.glDisable(GL2.GL_LIGHTING);
+               boolean disabledLighting = false;
+               if (gl.glIsEnabled(GL2.GL_LIGHTING)) {
+                       gl.glDisable(GL2.GL_LIGHTING);
+                       disabledLighting = true;
+               }
                gl.glDisable(GL.GL_DEPTH_TEST);
                
                RenderColor.setNonAlphaColors(gl, DEFAULT_COLOR);
@@ -87,7 +91,9 @@
                gl.glEnd();
                
                gl.glEnable(GL.GL_DEPTH_TEST);
-               gl.glEnable(GL2.GL_LIGHTING);
+               if (disabledLighting) {
+                       gl.glEnable(GL2.GL_LIGHTING);
+               }
        }
 
        private void drawFullBox(GraphicsData graphicsData) {
@@ -101,7 +107,11 @@
                Vector3 bottomLeft = bounds.getBottomLeft();
                Vector3 bottomRight = bounds.getBottomRight();
                
-               gl.glDisable(GL2.GL_LIGHTING);
+               boolean disabledLighting = false;
+               if (gl.glIsEnabled(GL2.GL_LIGHTING)) {
+                       gl.glDisable(GL2.GL_LIGHTING);
+                       disabledLighting = true;
+               }
                gl.glDisable(GL.GL_DEPTH_TEST);
                
                gl.glColor3f(0.7f, 0.7f, 0.7f);
@@ -115,7 +125,9 @@
                gl.glEnd();
                
                gl.glEnable(GL.GL_DEPTH_TEST);
-               gl.glEnable(GL2.GL_LIGHTING);
+               if (disabledLighting) {
+                       gl.glEnable(GL2.GL_LIGHTING);
+               }
        }
        
        /** Draws a portion of the viewing volume.
@@ -127,7 +139,11 @@
                Quadrilateral frontFace = 
graphicsData.getCoordinatorData().getNearBounds();
                Quadrilateral backFace = 
graphicsData.getCoordinatorData().getFarBounds();
 
-               gl.glDisable(GL2.GL_LIGHTING);
+               boolean disabledLighting = false;
+               if (gl.glIsEnabled(GL2.GL_LIGHTING)) {
+                       gl.glDisable(GL2.GL_LIGHTING);
+                       disabledLighting = true;
+               }
                gl.glDisable(GL.GL_DEPTH_TEST);
                
                gl.glColor3f(0.7f, 0.7f, 0.7f);
@@ -166,7 +182,8 @@
                gl.glEnd();
                
                gl.glEnable(GL.GL_DEPTH_TEST);
-               gl.glEnable(GL2.GL_LIGHTING);
-               
+               if (disabledLighting) {
+                       gl.glEnable(GL2.GL_LIGHTING);
+               }
        }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSelectionBoxProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSelectionBoxProcedure.java
    2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderSelectionBoxProcedure.java
    2012-03-20 22:06:51 UTC (rev 28598)
@@ -74,7 +74,11 @@
                 * drawSingleSelectEdge(gl, bottomLeft, bottomRight);
                 **/
 
-               gl.glDisable(GL2.GL_LIGHTING);
+               boolean disabledLighting = false;
+               if (gl.glIsEnabled(GL2.GL_LIGHTING)) {
+                       gl.glDisable(GL2.GL_LIGHTING);
+                       disabledLighting = true;
+               }
                gl.glDisable(GL.GL_DEPTH_TEST);
                RenderColor.setNonAlphaColors(gl, DEFAULT_COLOR);
                
@@ -95,7 +99,9 @@
                // gl.glEnd();
 
                gl.glEnable(GL.GL_DEPTH_TEST);
-               gl.glEnable(GL2.GL_LIGHTING);
+               if (disabledLighting) {
+                       gl.glEnable(GL2.GL_LIGHTING);
+               }
        }
 
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/task/PopupMenuCreator.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/task/PopupMenuCreator.java
    2012-03-20 20:56:04 UTC (rev 28597)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/task/PopupMenuCreator.java
    2012-03-20 22:06:51 UTC (rev 28598)
@@ -24,7 +24,7 @@
 import org.cytoscape.view.model.VisualLexicon;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.work.TaskFactory;
-import org.cytoscape.work.TaskFactoryPredicate;
+//import org.cytoscape.work.TaskFactoryPredicate;
 import org.cytoscape.work.swing.DialogTaskManager;
 import org.cytoscape.work.swing.DynamicSubmenuListener;
 import org.cytoscape.work.swing.SubmenuTaskManager;
@@ -33,209 +33,209 @@
  * This class is responsible for creating and populating pop-up menus created 
when right-clicking the network.
  */
 public class PopupMenuCreator {
-       
-       /** For creating popup menu items for the network, only use task 
factories that match the preferred action*/
-       private static final String NETWORK_PREFFERED_ACTION = "NEW";
-       
-       private DialogTaskManager taskManager;
-       private SubmenuTaskManager submenuTaskManager;
-       
-       // Large value to be used for the gravity value of 
org.cytoscape.util.swing.GravityTracker
-       private double largeValue = Double.MAX_VALUE / 2.0;
-
-       public PopupMenuCreator(DialogTaskManager taskManager, 
SubmenuTaskManager submenuTaskManager) {
-               this.taskManager = taskManager;
-               this.submenuTaskManager = submenuTaskManager;
-       }
-       
-       public JPopupMenu createEdgeMenu(View<CyEdge> edgeView, 
-                       CyNetworkView networkView, 
-                       VisualLexicon visualLexicon,
-                       Map<EdgeViewTaskFactory, Map<String, Object>> 
taskFactories) {
                
-               JPopupMenu popupMenu = new JPopupMenu();
-               JMenuTracker tracker = new JMenuTracker(popupMenu);
-               
-               if (taskFactories.size() >= 1) {
-                       for (Entry<EdgeViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
-
-                               EdgeViewTaskFactory edgeViewTaskFactory = 
entry.getKey();
-                               Map<String, Object> properties = 
entry.getValue();
-                               
-                               edgeViewTaskFactory.setEdgeView(edgeView, 
networkView);
-                               
-                               createMenuItem(edgeView, visualLexicon, 
popupMenu, edgeViewTaskFactory, tracker, properties);
-                       }
-               }
-               
-               return popupMenu;
-       }
-       
-       public JPopupMenu createNodeMenu(View<CyNode> nodeView, 
-                       CyNetworkView networkView, 
-                       VisualLexicon visualLexicon,
-                       Map<NodeViewTaskFactory, Map<String, Object>> 
taskFactories) {
-               
-               JPopupMenu popupMenu = new JPopupMenu();
-               JMenuTracker tracker = new JMenuTracker(popupMenu);
-               
-               if (taskFactories.size() >= 1) {
-                       for (Entry<NodeViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
-
-                               NodeViewTaskFactory nodeViewTaskFactory = 
entry.getKey();
-                               Map<String, Object> properties = 
entry.getValue();
-                               
-                               nodeViewTaskFactory.setNodeView(nodeView, 
networkView);
-                               
-                               createMenuItem(nodeView, visualLexicon, 
popupMenu, nodeViewTaskFactory, tracker, properties);
-                       }
-               }
-               
-               return popupMenu;
-       }
-       
-       public JPopupMenu createNetworkMenu(CyNetworkView networkView, 
VisualLexicon visualLexicon,
-                       Map<NetworkViewTaskFactory, Map<String, Object>> 
taskFactories) {
-               
-               JPopupMenu popupMenu = new JPopupMenu();
-               JMenuTracker tracker = new JMenuTracker(popupMenu);
-               
-               if (taskFactories.size() >= 1) {
-                       for (Entry<NetworkViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
-
-                               NetworkViewTaskFactory networkViewTaskFactory = 
entry.getKey();
-                               Map<String, Object> properties = 
entry.getValue();
-                               
-                               Object preferredAction = 
properties.get("preferredAction");
-                               
-                               if (preferredAction != null && 
preferredAction.toString().equals(NETWORK_PREFFERED_ACTION)) {
-                                       
networkViewTaskFactory.setNetworkView(networkView);
-                                       
-                                       createMenuItem(null, visualLexicon, 
popupMenu, networkViewTaskFactory, tracker, properties);
-                               }
-                       }
-               }
-               
-               return popupMenu;
-       }
-       
-       private void createMenuItem(View<?> view, VisualLexicon visualLexicon, 
JPopupMenu popupMenu, TaskFactory taskFactory,
-                                   JMenuTracker tracker, Map<String, Object> 
properties) {
-               
-               String title = null;
-               if (properties.get("title") != null) {
-                       title = properties.get("title").toString();
-               }
-               
-               String tooltip = null;
-               if (properties.get("tooltip") != null) {
-                       tooltip = properties.get("tooltip").toString();
-               }
-               
-               String preferredMenu = null;
-               if (properties.get("preferredMenu") != null) {
-                       preferredMenu = 
properties.get("preferredMenu").toString();
-               }
-               
-               // TODO: Ding implementation refers to a DynamicSubmenuListener 
related to the SubMenuTaskManager,
-               // check if this is necessary for this implementation
-               
-               // Below based on implementation from Ding
-
-               // check if the menus are created dynamically, and if so add 
the listener
-               Object preferredTaskManager = 
properties.get("preferredTaskManager");
-               if (preferredTaskManager != null && 
preferredTaskManager.toString().equals("menu")) {
-                       if (title == null)
-                               title = "Dynamic";
-                       DynamicSubmenuListener submenu = 
submenuTaskManager.getConfiguration(taskFactory);
-               submenu.setMenuTitle(title);
-                       popupMenu.addPopupMenuListener(submenu);
-                       return;
-               }
-
-               
-               Boolean useCheckBoxMenuItem = 
Boolean.parseBoolean(String.valueOf(properties.get("useCheckBoxMenuItem")));
-               Object targetVisualProperty = properties.get("targetVP");
-               boolean isSelected = false;
-               
-               // Update value for isSelected
-               if(view != null) {
-                       if (targetVisualProperty != null && 
targetVisualProperty instanceof String) {
-
-                               Class<?> targetClass = CyNetwork.class;
-                               
-                               if (view.getModel() instanceof CyNode)
-                                       targetClass = CyNode.class;
-                               else if (view.getModel() instanceof CyEdge)
-                                       targetClass = CyEdge.class;
-                               
-                               VisualProperty<?> visualProperty = 
visualLexicon.lookup(CyNode.class, targetVisualProperty.toString());
-                               if (visualProperty == null)
-                                       isSelected = false;
-                               else
-                                       isSelected = 
view.isValueLocked(visualProperty);
-                       } else if ( targetVisualProperty instanceof 
VisualProperty)
-                               isSelected = 
view.isValueLocked((VisualProperty<?>) targetVisualProperty);
-               }
-               
-
-               // no title and no preferred menu
-               if (title == null && preferredMenu == null) {
-                       title = "Unidentified Task: " + 
Integer.toString(taskFactory.hashCode());
-                       popupMenu.add(createMenuItem(taskFactory, title, 
useCheckBoxMenuItem, tooltip));
-
-               // title, but no preferred menu
-               } else if (title != null && preferredMenu == null) {
-                       popupMenu.add(createMenuItem(taskFactory, title, 
useCheckBoxMenuItem, tooltip));
-
-               // no title, but preferred menu
-               } else if (title == null && preferredMenu != null) {
-                       int last = preferredMenu.lastIndexOf(".");
-
-                       // if the preferred menu is delimited
-                       if (last > 0) {
-                               title = preferredMenu.substring(last + 1);
-                               preferredMenu = preferredMenu.substring(0, 
last);
-                               final GravityTracker gravityTracker = 
tracker.getGravityTracker(preferredMenu);
-                               final JMenuItem item = 
createMenuItem(taskFactory, title,useCheckBoxMenuItem, tooltip);
-                               if (useCheckBoxMenuItem) {
-                                       final JCheckBoxMenuItem checkBox = 
(JCheckBoxMenuItem)item; 
-                                       checkBox.setSelected(isSelected);
-                               }
-                               gravityTracker.addMenuItem(item, ++largeValue);
-                       // otherwise just use the preferred menu as the 
menuitem name
-                       } else {
-                               title = preferredMenu;
-                               popupMenu.add(createMenuItem(taskFactory, 
title, useCheckBoxMenuItem, tooltip));
-                       }
-
-               // title and preferred menu
-               } else {
-                       final GravityTracker gravityTracker = 
tracker.getGravityTracker(preferredMenu);
-                       gravityTracker.addMenuItem(createMenuItem(taskFactory, 
title,useCheckBoxMenuItem, tooltip), ++largeValue);
-               }
-       }
-               
-       private JMenuItem createMenuItem(final TaskFactory taskFactory, String 
title, boolean useCheckBoxMenuItem, String toolTipText) {
-               JMenuItem item;
-               AbstractAction action = new AbstractAction(title){
-
-                       @Override
-                       public void actionPerformed(ActionEvent event) {
-                               taskManager.execute(taskFactory);
-                       }
-                       
-               };
-               
-               if (useCheckBoxMenuItem)
-                       item = new JCheckBoxMenuItem(action);
-               else
-                       item = new JMenuItem(action);
-
-               if (taskFactory instanceof TaskFactoryPredicate)
-                       item.setEnabled(((TaskFactoryPredicate) 
taskFactory).isReady());
-
-               item.setToolTipText(toolTipText);
-               return item;
-       }
+//     /** For creating popup menu items for the network, only use task 
factories that match the preferred action*/
+//     private static final String NETWORK_PREFFERED_ACTION = "NEW";
+//     
+//     private DialogTaskManager taskManager;
+//     private SubmenuTaskManager submenuTaskManager;
+//     
+//     // Large value to be used for the gravity value of 
org.cytoscape.util.swing.GravityTracker
+//     private double largeValue = Double.MAX_VALUE / 2.0;
+//
+//     public PopupMenuCreator(DialogTaskManager taskManager, 
SubmenuTaskManager submenuTaskManager) {
+//             this.taskManager = taskManager;
+//             this.submenuTaskManager = submenuTaskManager;
+//     }
+//     
+//     public JPopupMenu createEdgeMenu(View<CyEdge> edgeView, 
+//                     CyNetworkView networkView, 
+//                     VisualLexicon visualLexicon,
+//                     Map<EdgeViewTaskFactory, Map<String, Object>> 
taskFactories) {
+//             
+//             JPopupMenu popupMenu = new JPopupMenu();
+//             JMenuTracker tracker = new JMenuTracker(popupMenu);
+//             
+//             if (taskFactories.size() >= 1) {
+//                     for (Entry<EdgeViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
+//
+//                             EdgeViewTaskFactory edgeViewTaskFactory = 
entry.getKey();
+//                             Map<String, Object> properties = 
entry.getValue();
+//                             
+//                             edgeViewTaskFactory.setEdgeView(edgeView, 
networkView);
+//
+//                             createMenuItem(edgeView, visualLexicon, 
popupMenu, edgeViewTaskFactory, tracker, properties);
+//                     }
+//             }
+//             
+//             return popupMenu;
+//     }
+//     
+//     public JPopupMenu createNodeMenu(View<CyNode> nodeView, 
+//                     CyNetworkView networkView, 
+//                     VisualLexicon visualLexicon,
+//                     Map<NodeViewTaskFactory, Map<String, Object>> 
taskFactories) {
+//             
+//             JPopupMenu popupMenu = new JPopupMenu();
+//             JMenuTracker tracker = new JMenuTracker(popupMenu);
+//             
+//             if (taskFactories.size() >= 1) {
+//                     for (Entry<NodeViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
+//
+//                             NodeViewTaskFactory nodeViewTaskFactory = 
entry.getKey();
+//                             Map<String, Object> properties = 
entry.getValue();
+//                             
+//                             nodeViewTaskFactory.setNodeView(nodeView, 
networkView);
+//                             
+//                             createMenuItem(nodeView, visualLexicon, 
popupMenu, nodeViewTaskFactory, tracker, properties);
+//                     }
+//             }
+//             
+//             return popupMenu;
+//     }
+//     
+//     public JPopupMenu createNetworkMenu(CyNetworkView networkView, 
VisualLexicon visualLexicon,
+//                     Map<NetworkViewTaskFactory, Map<String, Object>> 
taskFactories) {
+//             
+//             JPopupMenu popupMenu = new JPopupMenu();
+//             JMenuTracker tracker = new JMenuTracker(popupMenu);
+//             
+//             if (taskFactories.size() >= 1) {
+//                     for (Entry<NetworkViewTaskFactory, Map<String, Object>> 
entry : taskFactories.entrySet()) {
+//
+//                             NetworkViewTaskFactory networkViewTaskFactory = 
entry.getKey();
+//                             Map<String, Object> properties = 
entry.getValue();
+//                             
+//                             Object preferredAction = 
properties.get("preferredAction");
+//                             
+//                             if (preferredAction != null && 
preferredAction.toString().equals(NETWORK_PREFFERED_ACTION)) {
+//                                     
networkViewTaskFactory.setNetworkView(networkView);
+//                                     
+//                                     createMenuItem(null, visualLexicon, 
popupMenu, networkViewTaskFactory, tracker, properties);
+//                             }
+//                     }
+//             }
+//             
+//             return popupMenu;
+//     }
+//     
+//     private void createMenuItem(View<?> view, VisualLexicon visualLexicon, 
JPopupMenu popupMenu, TaskFactory taskFactory,
+//                                 JMenuTracker tracker, Map<String, Object> 
properties) {
+//             
+//             String title = null;
+//             if (properties.get("title") != null) {
+//                     title = properties.get("title").toString();
+//             }
+//             
+//             String tooltip = null;
+//             if (properties.get("tooltip") != null) {
+//                     tooltip = properties.get("tooltip").toString();
+//             }
+//             
+//             String preferredMenu = null;
+//             if (properties.get("preferredMenu") != null) {
+//                     preferredMenu = 
properties.get("preferredMenu").toString();
+//             }
+//             
+//             // TODO: Ding implementation refers to a DynamicSubmenuListener 
related to the SubMenuTaskManager,
+//             // check if this is necessary for this implementation
+//             
+//             // Below based on implementation from Ding
+//
+//             // check if the menus are created dynamically, and if so add 
the listener
+//             Object preferredTaskManager = 
properties.get("preferredTaskManager");
+//             if (preferredTaskManager != null && 
preferredTaskManager.toString().equals("menu")) {
+//                     if (title == null)
+//                             title = "Dynamic";
+//                     DynamicSubmenuListener submenu = 
submenuTaskManager.getConfiguration(taskFactory);
+//             submenu.setMenuTitle(title);
+//                     popupMenu.addPopupMenuListener(submenu);
+//                     return;
+//             }
+//
+//             
+//             Boolean useCheckBoxMenuItem = 
Boolean.parseBoolean(String.valueOf(properties.get("useCheckBoxMenuItem")));
+//             Object targetVisualProperty = properties.get("targetVP");
+//             boolean isSelected = false;
+//             
+//             // Update value for isSelected
+//             if(view != null) {
+//                     if (targetVisualProperty != null && 
targetVisualProperty instanceof String) {
+//
+//                             Class<?> targetClass = CyNetwork.class;
+//                             
+//                             if (view.getModel() instanceof CyNode)
+//                                     targetClass = CyNode.class;
+//                             else if (view.getModel() instanceof CyEdge)
+//                                     targetClass = CyEdge.class;
+//                             
+//                             VisualProperty<?> visualProperty = 
visualLexicon.lookup(CyNode.class, targetVisualProperty.toString());
+//                             if (visualProperty == null)
+//                                     isSelected = false;
+//                             else
+//                                     isSelected = 
view.isValueLocked(visualProperty);
+//                     } else if ( targetVisualProperty instanceof 
VisualProperty)
+//                             isSelected = 
view.isValueLocked((VisualProperty<?>) targetVisualProperty);
+//             }
+//             
+//
+//             // no title and no preferred menu
+//             if (title == null && preferredMenu == null) {
+//                     title = "Unidentified Task: " + 
Integer.toString(taskFactory.hashCode());
+//                     popupMenu.add(createMenuItem(taskFactory, title, 
useCheckBoxMenuItem, tooltip));
+//
+//             // title, but no preferred menu
+//             } else if (title != null && preferredMenu == null) {
+//                     popupMenu.add(createMenuItem(taskFactory, title, 
useCheckBoxMenuItem, tooltip));
+//
+//             // no title, but preferred menu
+//             } else if (title == null && preferredMenu != null) {
+//                     int last = preferredMenu.lastIndexOf(".");
+//
+//                     // if the preferred menu is delimited
+//                     if (last > 0) {
+//                             title = preferredMenu.substring(last + 1);
+//                             preferredMenu = preferredMenu.substring(0, 
last);
+//                             final GravityTracker gravityTracker = 
tracker.getGravityTracker(preferredMenu);
+//                             final JMenuItem item = 
createMenuItem(taskFactory, title,useCheckBoxMenuItem, tooltip);
+//                             if (useCheckBoxMenuItem) {
+//                                     final JCheckBoxMenuItem checkBox = 
(JCheckBoxMenuItem)item; 
+//                                     checkBox.setSelected(isSelected);
+//                             }
+//                             gravityTracker.addMenuItem(item, ++largeValue);
+//                     // otherwise just use the preferred menu as the 
menuitem name
+//                     } else {
+//                             title = preferredMenu;
+//                             popupMenu.add(createMenuItem(taskFactory, 
title, useCheckBoxMenuItem, tooltip));
+//                     }
+//
+//             // title and preferred menu
+//             } else {
+//                     final GravityTracker gravityTracker = 
tracker.getGravityTracker(preferredMenu);
+//                     gravityTracker.addMenuItem(createMenuItem(taskFactory, 
title,useCheckBoxMenuItem, tooltip), ++largeValue);
+//             }
+//     }
+//             
+//     private JMenuItem createMenuItem(final TaskFactory taskFactory, String 
title, boolean useCheckBoxMenuItem, String toolTipText) {
+//             JMenuItem item;
+//             AbstractAction action = new AbstractAction(title){
+//
+//                     @Override
+//                     public void actionPerformed(ActionEvent event) {
+//                             taskManager.execute(taskFactory);
+//                     }
+//                     
+//             };
+//             
+//             if (useCheckBoxMenuItem)
+//                     item = new JCheckBoxMenuItem(action);
+//             else
+//                     item = new JMenuItem(action);
+//
+//             if (taskFactory instanceof TaskFactoryPredicate)
+//                     item.setEnabled(((TaskFactoryPredicate) 
taskFactory).isReady());
+//
+//             item.setToolTipText(toolTipText);
+//             return item;
+//     }
 }

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