Author: paperwing
Date: 2012-03-07 11:58:53 -0800 (Wed, 07 Mar 2012)
New Revision: 28446
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/BirdsEyeCytoscapeDataProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CytoscapeDataSubprocessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/LightingCytoscapeDataSubprocessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
Log:
CytoscapeDataProcessors now use CytoscapeDataSubprocessors to handle Cytoscape
data to allow having reusable subprocessors that handle specific tasks;
lighting data is now obtained via visual properties.
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
2012-03-07 18:18:43 UTC (rev 28445)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -9,6 +9,7 @@
import org.cytoscape.paperwing.internal.coordinator.CoordinatorProcessor;
import org.cytoscape.paperwing.internal.coordinator.MainCoordinatorProcessor;
import org.cytoscape.paperwing.internal.coordinator.ViewingCoordinator;
+import
org.cytoscape.paperwing.internal.cytoscape.processing.BirdsEyeCytoscapeDataProcessor;
import
org.cytoscape.paperwing.internal.cytoscape.processing.CytoscapeDataProcessor;
import
org.cytoscape.paperwing.internal.cytoscape.processing.MainCytoscapeDataProcessor;
import org.cytoscape.paperwing.internal.data.GraphicsData;
@@ -135,16 +136,7 @@
@Override
public CytoscapeDataProcessor getCytoscapeDataProcessor() {
- // Return a CytoscapeDataProcessor that does not do any
processing,
- // because the bird's eye rendering object will not need to
access Cytoscape
- // data.
- return new CytoscapeDataProcessor() {
-
- @Override
- public void processCytoscapeData(GraphicsData
graphicsData) {
-
- }
- };
+ return new BirdsEyeCytoscapeDataProcessor();
}
@Override
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/BirdsEyeCytoscapeDataProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/BirdsEyeCytoscapeDataProcessor.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/BirdsEyeCytoscapeDataProcessor.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -0,0 +1,32 @@
+package org.cytoscape.paperwing.internal.cytoscape.processing;
+
+import java.awt.Color;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.cytoscape.paperwing.internal.WindVisualLexicon;
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.data.LightingData;
+import org.cytoscape.paperwing.internal.lighting.Light;
+import org.cytoscape.view.model.CyNetworkView;
+
+public class BirdsEyeCytoscapeDataProcessor implements CytoscapeDataProcessor {
+
+ /** The list of CytoscapeDataSubprocessors used by this processor */
+ private List<CytoscapeDataSubprocessor> subprocessors;
+
+ public BirdsEyeCytoscapeDataProcessor() {
+ subprocessors = new LinkedList<CytoscapeDataSubprocessor>();
+
+ // Populate the list of subprocessors; they are called in the
order added.
+ subprocessors.add(new LightingCytoscapeDataSubprocessor());
+ }
+
+ @Override
+ public void processCytoscapeData(GraphicsData graphicsData) {
+
+ for (CytoscapeDataSubprocessor subprocessor : subprocessors) {
+ subprocessor.processCytoscapeData(graphicsData);
+ }
+ }
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/BirdsEyeCytoscapeDataProcessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CytoscapeDataSubprocessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CytoscapeDataSubprocessor.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CytoscapeDataSubprocessor.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -0,0 +1,17 @@
+package org.cytoscape.paperwing.internal.cytoscape.processing;
+
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+
+/**
+ * This interface represents a Cytoscape data sub-processor, which provides
more specific functionalities relating
+ * to obtaining and transferring data to Cytoscape via its API.
+ */
+public interface CytoscapeDataSubprocessor {
+
+ /**
+ * Transfer data to or from Cytoscape given the graphics data object.
This could be data relating to CyTable objects
+ * or visual properties.
+ * @param graphicsData
+ */
+ public void processCytoscapeData(GraphicsData graphicsData);
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/CytoscapeDataSubprocessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/LightingCytoscapeDataSubprocessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/LightingCytoscapeDataSubprocessor.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/LightingCytoscapeDataSubprocessor.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -0,0 +1,67 @@
+package org.cytoscape.paperwing.internal.cytoscape.processing;
+
+import java.awt.Color;
+
+import org.cytoscape.paperwing.internal.WindVisualLexicon;
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.data.LightingData;
+import org.cytoscape.paperwing.internal.lighting.Light;
+import org.cytoscape.view.model.CyNetworkView;
+
+/**
+ * This {@link CytoscapeDataSubprocessor} is used to obtain updated lighting
data from the network view's
+ * visual property set.
+ */
+public class LightingCytoscapeDataSubprocessor implements
CytoscapeDataSubprocessor {
+
+ @Override
+ public void processCytoscapeData(GraphicsData graphicsData) {
+ updateLightingData(graphicsData);
+ }
+
+ /**
+ * Transfer lighting data from the visual property set
+ */
+ private void updateLightingData(GraphicsData graphicsData) {
+ CyNetworkView networkView = graphicsData.getNetworkView();
+
+ LightingData lightingData = graphicsData.getLightingData();
+
+ // Try to get it working with a single light first (index 0)
+ Light light = lightingData.getLight(0);
+
+ // Transfer color properties
+ Color ambient = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_COLOR);
+ double ambientAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_ALPHA);
+
+ Color diffuse = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_COLOR);
+ double diffuseAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_ALPHA);
+
+ Color specular = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_COLOR);
+ double specularAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_ALPHA);
+
+ light.setAmbient((float) ambient.getRed() / 255,
+ (float) ambient.getGreen() / 255,
+ (float) ambient.getBlue() / 255,
+ (float) ambientAlpha);
+
+ light.setDiffuse((float) diffuse.getRed() / 255,
+ (float) diffuse.getGreen() / 255,
+ (float) diffuse.getBlue() / 255,
+ (float) diffuseAlpha);
+
+ light.setSpecular((float) specular.getRed() / 255,
+ (float) specular.getGreen() / 255,
+ (float) specular.getBlue() / 255,
+ (float) specularAlpha);
+
+ // Transfer position properties
+
light.setPosition(networkView.getVisualProperty(WindVisualLexicon.LIGHT_X_LOCATION).floatValue(),
+
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Y_LOCATION).floatValue(),
+
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Z_LOCATION).floatValue(),
+ 1.0f);
+
+ // Transfer remaining properties
+
light.setTurnedOn(networkView.getVisualProperty(WindVisualLexicon.LIGHT_ENABLED));
+ }
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/LightingCytoscapeDataSubprocessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
2012-03-07 18:18:43 UTC (rev 28445)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/MainCytoscapeDataProcessor.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -1,6 +1,8 @@
package org.cytoscape.paperwing.internal.cytoscape.processing;
import java.awt.Color;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import org.cytoscape.model.CyEdge;
@@ -10,116 +12,32 @@
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
import org.cytoscape.paperwing.internal.data.LightingData;
+import org.cytoscape.paperwing.internal.input.BoundsInputHandler;
+import org.cytoscape.paperwing.internal.input.InputHandler;
+import org.cytoscape.paperwing.internal.input.KeyboardMonitor;
+import org.cytoscape.paperwing.internal.input.MouseMonitor;
import org.cytoscape.paperwing.internal.lighting.Light;
import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
import org.cytoscape.view.model.CyNetworkView;
public class MainCytoscapeDataProcessor implements CytoscapeDataProcessor {
+ /** The list of CytoscapeDataSubprocessors used by this processor */
+ private List<CytoscapeDataSubprocessor> subprocessors;
+
+ public MainCytoscapeDataProcessor() {
+ subprocessors = new LinkedList<CytoscapeDataSubprocessor>();
+
+ // Populate the list of subprocessors; they are called in the
order added.
+ subprocessors.add(new
TableSelectionCytoscapeDataSubprocessor());
+ subprocessors.add(new LightingCytoscapeDataSubprocessor());
+ }
+
@Override
public void processCytoscapeData(GraphicsData graphicsData) {
- // Perform on second frame, first frame performs initial drawing
- // TODO: Check if necessary, the ding renderer doesn't do this
-// if (graphicsData.getFramesElapsed() == 1) {
-// initializeTableSelectionState(graphicsData);
-// }
-
- processDeselectedData(graphicsData);
- }
-
- // Performs deselection in Cytoscape data objects, such as CyTable
- private void processDeselectedData(GraphicsData graphicsData) {
-
- CyNetworkView networkView = graphicsData.getNetworkView();
- GraphicsSelectionData selectionData =
graphicsData.getSelectionData();
-
- Set<Integer> toBeDeselectedNodeIndices =
selectionData.getToBeDeselectedNodeIndices();
- Set<Integer> toBeDeselectedEdgeIndices =
selectionData.getToBeDeselectedEdgeIndices();
-
- NetworkToolkit.deselectNodes(toBeDeselectedNodeIndices,
networkView);
- NetworkToolkit.deselectEdges(toBeDeselectedEdgeIndices,
networkView);
- toBeDeselectedNodeIndices.clear();
- toBeDeselectedEdgeIndices.clear();
-
- // Select nodes
- for (int index : selectionData.getSelectedNodeIndices()) {
- if (!NetworkToolkit.checkNodeSelected(index,
networkView)) {
- NetworkToolkit.setNodeSelected(index,
networkView, true);
- }
+ for (CytoscapeDataSubprocessor subprocessor : subprocessors) {
+ subprocessor.processCytoscapeData(graphicsData);
}
-
- // Select edges
- for (int index : selectionData.getSelectedEdgeIndices()) {
- if (!NetworkToolkit.checkEdgeSelected(index,
networkView)) {
- NetworkToolkit.setEdgeSelected(index,
networkView, true);
- }
- }
}
-
- // Note: For the below method, Ding does not fill in selected states,
so for now the 3d renderer will not do so either.
- /**
- * Fills in the missing "selected" boolean values in CyTable.
- *
- * @param graphicsData The {@link GraphicsData} object containing a
reference to the network view.
- */
- private void initializeTableSelectionState(GraphicsData graphicsData) {
- CyNetworkView networkView = graphicsData.getNetworkView();
- CyNetwork network = graphicsData.getNetworkView().getModel();
-
- for (CyNode node : network.getNodeList()) {
- NetworkToolkit.setNodeSelected(node.getIndex(),
networkView, false);
- }
-
- for (CyEdge edge : network.getEdgeList()) {
- NetworkToolkit.setEdgeSelected(edge.getIndex(),
networkView, false);
- }
- }
-
- /**
- * Transfer lighting data from the visual property set
- */
- private void updateLightingData(GraphicsData graphicsData) {
- CyNetworkView networkView = graphicsData.getNetworkView();
-
- LightingData lightingData = graphicsData.getLightingData();
-
- // Try to get it working with a single light first (index 0)
- Light light = lightingData.getLight(0);
-
- // Transfer color properties
- Color ambient = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_COLOR);
- double ambientAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_AMBIENT_ALPHA);
-
- Color diffuse = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_COLOR);
- double diffuseAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_DIFFUSE_ALPHA);
-
- Color specular = (Color)
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_COLOR);
- double specularAlpha =
networkView.getVisualProperty(WindVisualLexicon.LIGHT_SPECULAR_ALPHA);
-
- light.setAmbient((float) ambient.getRed() / 255,
- (float) ambient.getGreen() / 255,
- (float) ambient.getBlue() / 255,
- (float) ambientAlpha);
-
- light.setDiffuse((float) diffuse.getRed() / 255,
- (float) diffuse.getGreen() / 255,
- (float) diffuse.getBlue() / 255,
- (float) diffuseAlpha);
-
- light.setSpecular((float) specular.getRed() / 255,
- (float) specular.getGreen() / 255,
- (float) specular.getBlue() / 255,
- (float) specularAlpha);
-
- // Transfer position properties
-
light.setPosition(networkView.getVisualProperty(WindVisualLexicon.LIGHT_X_LOCATION).floatValue(),
-
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Y_LOCATION).floatValue(),
-
networkView.getVisualProperty(WindVisualLexicon.LIGHT_Z_LOCATION).floatValue(),
- 1.0f);
-
- // Transfer remaining properties
-
light.setTurnedOn(networkView.getVisualProperty(WindVisualLexicon.LIGHT_ENABLED));
- }
-
}
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -0,0 +1,76 @@
+package org.cytoscape.paperwing.internal.cytoscape.processing;
+
+import java.util.Set;
+
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
+import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
+import org.cytoscape.view.model.CyNetworkView;
+
+/**
+ * This {@link CytoscapeDataSubprocessor} is used to update data in the
relevant {@link CyTable}
+ * objects to match the currently selected nodes and edges.
+ */
+public class TableSelectionCytoscapeDataSubprocessor implements
CytoscapeDataSubprocessor {
+
+ @Override
+ public void processCytoscapeData(GraphicsData graphicsData) {
+
+ // Note: For the below method, Ding does not fill in selected
states, so for now the 3d renderer will not do so either.
+ // initializeTableSelectionState(graphicsData);
+
+ // Update CyTable with the currently selected set of nodes and
edges
+ processSelectionData(graphicsData);
+ }
+
+ // Performs selection in Cytoscape data objects, such as CyTable
+ private void processSelectionData(GraphicsData graphicsData) {
+
+ CyNetworkView networkView = graphicsData.getNetworkView();
+ GraphicsSelectionData selectionData =
graphicsData.getSelectionData();
+
+ Set<Integer> toBeDeselectedNodeIndices =
selectionData.getToBeDeselectedNodeIndices();
+ Set<Integer> toBeDeselectedEdgeIndices =
selectionData.getToBeDeselectedEdgeIndices();
+
+ NetworkToolkit.deselectNodes(toBeDeselectedNodeIndices,
networkView);
+ NetworkToolkit.deselectEdges(toBeDeselectedEdgeIndices,
networkView);
+ toBeDeselectedNodeIndices.clear();
+ toBeDeselectedEdgeIndices.clear();
+
+ // Select nodes
+ for (int index : selectionData.getSelectedNodeIndices()) {
+ if (!NetworkToolkit.checkNodeSelected(index,
networkView)) {
+ NetworkToolkit.setNodeSelected(index,
networkView, true);
+ }
+ }
+
+ // Select edges
+ for (int index : selectionData.getSelectedEdgeIndices()) {
+ if (!NetworkToolkit.checkEdgeSelected(index,
networkView)) {
+ NetworkToolkit.setEdgeSelected(index,
networkView, true);
+ }
+ }
+ }
+
+ /**
+ * Fills in the missing "selected" boolean values in CyTable.
+ *
+ * @param graphicsData The {@link GraphicsData} object containing a
reference to the network view.
+ */
+ private void initializeTableSelectionState(GraphicsData graphicsData) {
+ CyNetworkView networkView = graphicsData.getNetworkView();
+ CyNetwork network = graphicsData.getNetworkView().getModel();
+
+ for (CyNode node : network.getNodeList()) {
+ NetworkToolkit.setNodeSelected(node.getIndex(),
networkView, false);
+ }
+
+ for (CyEdge edge : network.getEdgeList()) {
+ NetworkToolkit.setEdgeSelected(edge.getIndex(),
networkView, false);
+ }
+ }
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/processing/TableSelectionCytoscapeDataSubprocessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-03-07 18:18:43 UTC (rev 28445)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-03-07 19:58:53 UTC (rev 28446)
@@ -57,7 +57,7 @@
/**
* The number of straight segments used to approximate a curved edge
*/
- private static final int NUM_SEGMENTS = 11;
+ private static final int NUM_SEGMENTS = 8;
private EdgeShapeDrawer shapeDrawer;
@@ -177,6 +177,8 @@
CyNetworkView networkView = graphicsData.getNetworkView();
GL2 gl = graphicsData.getGlContext();
+ gl.glDisable(GL2.GL_LIGHTING);
+
float[] specularReflection = { 0.1f, 0.1f, 0.1f, 1.0f };
gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR,
FloatBuffer.wrap(specularReflection));
@@ -264,6 +266,8 @@
}
}
}
+
+ gl.glEnable(GL2.GL_LIGHTING);
}
// Picks a color according to the edgeView and passes it to OpenGL
--
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.