Author: paperwing
Date: 2012-01-13 14:14:49 -0800 (Fri, 13 Jan 2012)
New Revision: 28015
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/CyActivator.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.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/cytoscape/view/DefaultValueVault.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
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/RenderNodesProcedure.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderColor.java
Log:
completed first stage of circular arc edge drawing algorithm (to draw curved
edges with arbitrary radius and coordinates), in progress of implementing final
stage (allow for multiple edges between the same pair of nodes to be drawn, at
different rotations/curvatures)
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-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/BirdsEyeGraphicsHandler.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -17,6 +17,7 @@
import org.cytoscape.paperwing.internal.input.MouseMonitor;
import org.cytoscape.paperwing.internal.picking.ShapePickingProcessor;
import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
+import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderBoundingBoxProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderEdgesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
@@ -33,7 +34,7 @@
renderProcedures = new LinkedHashMap<String,
ReadOnlyGraphicsProcedure>();
renderProcedures.put("nodes", new RenderNodesProcedure());
- renderProcedures.put("edges", new RenderEdgesProcedure());
+ renderProcedures.put("edges", new RenderArcEdgesProcedure());
renderProcedures.put("boundingBox", new
RenderBoundingBoxProcedure());
renderProcedures.put("resetScene", new ResetSceneProcedure());
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-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/CyActivator.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -42,7 +42,7 @@
windNetworkViewFactoryProps.setProperty("serviceType",
"factory");
registerService(bc, windNetworkViewFactory,
CyNetworkViewFactory.class, windNetworkViewFactoryProps);
-
+
// Main RenderingEngine factory
WindMainRenderingEngineFactory windMainRenderingEngineFactory =
new WindMainRenderingEngineFactory(
cyNetworkViewManagerRef,
cyRenderingEngineManagerRef,
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -14,6 +14,7 @@
import org.cytoscape.paperwing.internal.picking.DefaultShapePickingProcessor;
import org.cytoscape.paperwing.internal.picking.ShapePickingProcessor;
import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
+import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderEdgesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderSelectionBoxProcedure;
@@ -28,7 +29,7 @@
renderProcedures = new LinkedHashMap<String,
ReadOnlyGraphicsProcedure>();
renderProcedures.put("nodes", new RenderNodesProcedure());
- renderProcedures.put("edges", new RenderEdgesProcedure());
+ renderProcedures.put("edges", new RenderArcEdgesProcedure());
renderProcedures.put("selectionBox", new
RenderSelectionBoxProcedure());
renderProcedures.put("resetScene", new ResetSceneProcedure());
@@ -68,7 +69,7 @@
@Override
public ShapePickingProcessor getShapePickingProcessor() {
- return new DefaultShapePickingProcessor(new
RenderNodesProcedure(), new RenderEdgesProcedure());
+ return new DefaultShapePickingProcessor(new
RenderNodesProcedure(), new RenderArcEdgesProcedure());
}
@Override
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-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngine.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -69,7 +69,7 @@
// Needs to be called before setUpCanvas
public void setUpNetworkView(CyNetworkViewManager networkViewManager) {
if (networkViewManager != null) {
- this.networkView =
networkViewManager.getNetworkView(viewModel.getModel().getSUID());
+ this.networkView =
networkViewManager.getNetworkView(viewModel.getModel());
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/cytoscape/view/DefaultValueVault.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -1,5 +1,6 @@
package org.cytoscape.paperwing.internal.cytoscape.view;
+import java.awt.Color;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -11,6 +12,7 @@
import org.cytoscape.model.CyTableEntry;
import org.cytoscape.view.model.VisualLexicon;
import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
public class DefaultValueVault {
@@ -36,7 +38,12 @@
defaultValueSets.put(CyEdge.class, edgeDefaultValues);
defaultValueSets.put(CyNetwork.class, networkDefaultValues);
+ // Populate with default values from the relevant VisualLexicon
(eg. RichVisualLexicon, MinimalVisualLexicon)
populateDefaultValues();
+
+ // Override VisualLexicon default values with custom
+ // Wind values, useful for old MinimalVisualLexicon values
+// updateDefaultValues();
}
// Sets initial default values
@@ -54,6 +61,11 @@
}
}
+ // Override selected values from VisualProperties
+ private void updateDefaultValues() {
+ modifyDefaultValue(RichVisualLexicon.NODE_FILL_COLOR, new
Color(120, 120, 120));
+ }
+
// @Override
// public <T, V extends T> void setViewDefault(VisualProperty<? extends T>
visualProperty,
// V defaultValue) {
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -148,9 +148,8 @@
/ Math.sqrt(lengthSquare * otherLengthSquare);
if (Double.isNaN(cosArgument)) {
- System.out.println("cosArgument NaN");
- System.out.println("lengthSquare: " + lengthSquare);
- System.out.println("otherLengthSquare: " +
otherLengthSquare);
+ System.out.println("cosArgument NaN for
Vector3.angle(Vector3)");
+ Thread.dumpStack();
return 0;
} else if (cosArgument >= 1) {
return 0;
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-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -1,22 +1,93 @@
package org.cytoscape.paperwing.internal.rendering;
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNode;
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
+import org.cytoscape.paperwing.internal.tools.RenderColor;
import org.cytoscape.paperwing.internal.tools.RenderToolkit;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
+import org.cytoscape.view.presentation.property.RichVisualLexicon;
public class RenderArcEdgesProcedure implements ReadOnlyGraphicsProcedure {
- private static final double SEGMENT_RADIUS = 0.05;
+ private static final double SEGMENT_RADIUS = 0.009;
private static final int SEGMENT_SLICES = 4;
private static final int SEGMENT_STACKS = 1;
+ private static final double MIN_LENGTH = Double.MIN_NORMAL;
+
+ private static final RenderColor DEFAULT_COLOR =
+ new RenderColor(0.67, 0.67, 0.67);
+ private static final RenderColor DEFAULT_SELECTED_COLOR =
+ new RenderColor(0.73, 0.73, 0.6);
+ private static final RenderColor DEFAULT_HOVER_COLOR =
+ new RenderColor(0.5, 0.5, 0.7);
+
private int segmentListIndex;
+ private class EdgeViewContainer {
+ private View<CyEdge> edgeView;
+
+ private int edgeNumber;
+ private int totalCoincidentEdges;
+ }
+
+ // Analyze the network to obtain whether each edge is connecting 2
nodes that
+ // are already connected by other nodes
+ // Maybe add an optimization so we only have to re-analyze the network
each time it changes?
+ private Set<EdgeViewContainer> analyzeEdges(CyNetworkView networkView) {
+
+ // A pair of nodes will be identified by index1 * index2 +
index1, where index1
+ // is the higher of the 2 indices
+ Map<Long, Integer> pairs = new HashMap<Long, Integer>(
+ networkView.getModel().getNodeCount());
+ long identifier;
+ int sourceIndex, targetIndex;
+ int nodeCount = networkView.getModel().getNodeCount();
+
+ for (CyEdge edge : networkView.getModel().getEdgeList()) {
+ sourceIndex = edge.getSource().getIndex();
+ targetIndex = edge.getTarget().getIndex();
+
+ if (sourceIndex >= targetIndex) {
+ identifier = (long) nodeCount * sourceIndex +
targetIndex;
+ } else {
+ identifier = (long) nodeCount * targetIndex +
sourceIndex;
+ }
+
+ if (!pairs.containsKey(identifier)) {
+ pairs.put(identifier, 1);
+ } else {
+ pairs.put(identifier, pairs.get(identifier) +
1);
+ }
+ }
+
+ Set<EdgeViewContainer> edgeViewContainers = new
HashSet<EdgeViewContainer>(
+ networkView.getModel().getEdgeCount());
+
+ EdgeViewContainer container;
+ for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
+ // container = new
+ }
+
+ return null;
+ }
+
@Override
public void initialize(GraphicsData graphicsData) {
GL2 gl = graphicsData.getGlContext();
@@ -39,14 +110,87 @@
@Override
public void execute(GraphicsData graphicsData) {
- // TODO Auto-generated method stub
+ CyNetworkView networkView = graphicsData.getNetworkView();
+ GL2 gl = graphicsData.getGlContext();
+ for (View<CyEdge> edgeView : networkView.getEdgeViews()) {
+
+ chooseColor(gl, edgeView, graphicsData);
+
+ CyEdge edge = edgeView.getModel();
+ Vector3 start = obtainCoordinates(edge.getSource(),
networkView, graphicsData.getDistanceScale());
+ Vector3 end = obtainCoordinates(edge.getTarget(),
networkView, graphicsData.getDistanceScale());
+
+ // TODO: Check for case where source() == target(), ie.
self-edge
+
+ if (start != null && end != null) {
+ // Load name for edge picking
+ gl.glLoadName(edge.getIndex());
+
+ // drawSegment(gl, start, end);
+ drawArcSegments(gl, start, end, 0.2, Math.PI,
4);
+ } else {
+// System.out.println("Null coordinates: " + start
+ ", " + end);
+ }
+ }
}
+ // Picks a color according to the edgeView and passes it to OpenGL
+ private void chooseColor(GL2 gl, View<CyEdge> edgeView, GraphicsData
graphicsData) {
+ Color visualPropertyColor = null;
+ visualPropertyColor = (Color)
edgeView.getVisualProperty(RichVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT);
+
+ RenderColor color = new RenderColor(DEFAULT_COLOR);
+
+ if (visualPropertyColor != null) {
+ color.set((double) visualPropertyColor.getRed() / 255,
+ (double) visualPropertyColor.getGreen()
/ 255,
+ (double) visualPropertyColor.getBlue()
/ 255);
+ }
+
+ if
(edgeView.getVisualProperty(MinimalVisualLexicon.EDGE_SELECTED)) {
+
+ // Make selected edges appear greener
+ color.multiplyRed(0.7, 0, 1);
+ color.multiplyGreen(1.5, 0.5, 1);
+ color.multiplyBlue(0.7, 0, 1);
+ } else if (edgeView.getModel().getIndex() ==
graphicsData.getSelectionData().getHoverEdgeIndex()) {
+ // Make hovered edges appear bluer
+ color.multiplyRed(0.7, 0, 1);
+ color.multiplyGreen(0.7, 0, 1);
+ color.multiplyBlue(1.5, 0.5, 1);
+ }
+
+ RenderColor.setNonAlphaColors(gl, color);
+ }
+
+ // Obtain the coordinates of a given node, eg. source or target node
+ // Returns null if failed to find coordinates
+ private Vector3 obtainCoordinates(CyNode node, CyNetworkView
networkView, double distanceScale) {
+ Vector3 coordinates = null;
+
+ View<CyNode> nodeView = networkView.getNodeView(node);
+
+ if (nodeView != null) {
+ double x =
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION) / distanceScale;
+ double y =
nodeView.getVisualProperty(RichVisualLexicon.NODE_Y_LOCATION) / distanceScale;
+ double z =
nodeView.getVisualProperty(RichVisualLexicon.NODE_Z_LOCATION) / distanceScale;
+
+ // TODO: Perform a check to ensure none of x, y, z are
null?
+ coordinates = new Vector3(x, y, z);
+ }
+
+ return coordinates;
+ }
+
private void drawArcSegments(GL2 gl, Vector3 start, Vector3 end, double
radius, double angle, int segments) {
Vector3 displacement = end.subtract(start);
double displacementLength = displacement.magnitude();
+ // Radius adjustment (can't draw an arc from start to end if
the radius of the arc is less than half that
+ // distance)
+ radius = Math.max(displacementLength * 2, radius);
+
// Use cosine law
double arcAngle;
arcAngle = GeometryToolkit.saferArcCos(
@@ -54,20 +198,60 @@
/ (2 * radius * radius));
double nearCornerAngle = Math.PI / 2 - (arcAngle / 2);
+
+ Vector3 targetDirection = new Vector3(0, 0, 1);
+ targetDirection = targetDirection.rotate(displacement, angle);
+ Vector3 circleCenterOffset =
displacement.rotate(targetDirection.cross(displacement), nearCornerAngle);
+ circleCenterOffset.normalizeLocal();
+ circleCenterOffset.multiplyLocal(radius);
+
+ Vector3 circleCenter = start.plus(circleCenterOffset);
+// drawSegment(gl, start, circleCenter);
+// drawSegment(gl, circleCenter, end);
+
+ Vector3 rotationNormal = displacement.cross(circleCenterOffset);
+
+ if (segments <= 1) {
+ drawSegment(gl, start, end);
+ } else {
+ // Draw segments along the length of the arc
+ double angleIncrement = arcAngle / segments;
+ // Displacement vector from circle center to current
point
+ Vector3 currentPointOffset =
start.subtract(circleCenter);
+ Vector3 currentPoint =
circleCenter.plus(currentPointOffset);
+ Vector3 previousPoint = currentPoint.copy();
+
+ for (int i = 1; i <= segments; i ++) {
+ currentPointOffset =
currentPointOffset.rotate(rotationNormal, angleIncrement);
+ currentPoint =
circleCenter.plus(currentPointOffset);
+ drawSegment(gl, previousPoint, currentPoint);
+ previousPoint.set(currentPoint);
+ }
+ }
+
+ // Need to obtain circle's center, and use a parametric
equation to obtain points along the arc between
+ // start and end
}
private void drawSegment(GL2 gl, Vector3 start, Vector3 end) {
Vector3 displacement = end.subtract(start);
+ double length = displacement.magnitude();
- RenderToolkit.setUpFacingTransformation(gl, start,
displacement);
+ if (length > MIN_LENGTH) {
- gl.glScaled(1, 1, displacement.magnitude());
-
- // need a scale transformation for segment radius?
-
- gl.glCallList(segmentListIndex);
+ gl.glPushMatrix();
+ RenderToolkit.setUpFacingTransformation(gl, start,
displacement);
+ gl.glScaled(1, 1, length);
+
+ // need a scale transformation for segment radius?
+
+ gl.glCallList(segmentListIndex);
+ gl.glPopMatrix();
+ } else {
+// System.out.println("Edge length too small: " + length);
+ }
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -8,6 +8,7 @@
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;
+import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNode;
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
@@ -102,70 +103,49 @@
.floatValue() / distanceScale;
index = nodeView.getModel().getIndex();
- gl.glLoadName(index);
+
// gl.glLoadName(33);
- gl.glPushMatrix();
- gl.glTranslatef(x, y, z);
-
- /*
- * gl.glScalef(nodeView.getVisualProperty(
- * MinimalVisualLexicon.NODE_WIDTH).floatValue() /
DISTANCE_SCALE,
- * nodeView.getVisualProperty(
- * MinimalVisualLexicon.NODE_HEIGHT).floatValue() /
DISTANCE_SCALE,
- * nodeView.getVisualProperty(
- * RichVisualLexicon.NODE_DEPTH).floatValue() /
DISTANCE_SCALE);
- */
-
- Color color = null;
-
-// if (selectedNodeIndices.contains(index)) {
-// if (NetworkToolkit.checkNodeSelected(index,
networkView)) {
- if
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_SELECTED)) {
-
- gl.glScalef(1.1f, 1.1f, 1.1f);
-
- color = (Color) nodeView
-
.getVisualProperty(RichVisualLexicon.NODE_SELECTED_PAINT);
-
-// gl.glColor3f(color.getRed() / 255.0f,
-// color.getGreen() / 255.0f,
color.getBlue() / 255.0f);
-
-
- RenderColor.setNonAlphaColors(gl,
DEFAULT_SELECTED_COLOR);
- } else if (index == hoverNodeIndex) {
- RenderColor.setNonAlphaColors(gl,
DEFAULT_HOVER_COLOR);
-
-
nodeView.setVisualProperty(RichVisualLexicon.NODE_SELECTED,
- false);
- } else {
-// color = (Color) nodeView
-//
.getVisualProperty(MinimalVisualLexicon.NODE_PAINT);
-
- Object colorObject =
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_FILL_COLOR);
-
- if (colorObject != null
- && colorObject.getClass() ==
Color.class) {
- color = (Color) colorObject;
- }
-
- if (color != null) {
- gl.glColor3f(color.getRed() / 255.0f,
- color.getGreen() / 255.0f,
color.getBlue() / 255.0f);
- } else {
- RenderColor.setNonAlphaColors(gl,
DEFAULT_COLOR);
- }
-
- // RenderColor.setNonAlphaColors(gl,
DEFAULT_COLOR);
- }
-
// Draw it only if the visual property says it is
visible
if
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_VISIBLE)) {
+ gl.glPushMatrix();
+ gl.glTranslatef(x, y, z);
+ gl.glLoadName(index);
+
+ chooseColor(gl, nodeView, graphicsData);
gl.glCallList(nodeListIndex);
+
+ gl.glPopMatrix();
}
-
- gl.glPopMatrix();
}
}
+
+ private void chooseColor(GL2 gl, View<CyNode> nodeView, GraphicsData
graphicsData) {
+ Color visualPropertyColor = null;
+ visualPropertyColor = (Color)
nodeView.getVisualProperty(RichVisualLexicon.NODE_FILL_COLOR);
+
+ RenderColor color = new RenderColor(DEFAULT_COLOR);
+
+ if (visualPropertyColor != null) {
+ color.set((double) visualPropertyColor.getRed() / 255,
+ (double) visualPropertyColor.getGreen()
/ 255,
+ (double) visualPropertyColor.getBlue()
/ 255);
+ }
+
+ if
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_SELECTED)) {
+
+ // Make selected nodes appear greener
+ color.multiplyRed(0.7, 0, 1);
+ color.multiplyGreen(1.5, 0.5, 1);
+ color.multiplyBlue(0.7, 0, 1);
+ } else if (nodeView.getModel().getIndex() ==
graphicsData.getSelectionData().getHoverNodeIndex()) {
+ // Make hovered nodes appear bluer
+ color.multiplyRed(0.7, 0, 1);
+ color.multiplyGreen(0.7, 0, 1);
+ color.multiplyBlue(1.5, 0.5, 1);
+ }
+
+ RenderColor.setNonAlphaColors(gl, color);
+ }
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/NetworkToolkit.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -210,8 +210,13 @@
public static boolean checkEdgeSelected(int index, CyNetworkView
networkView) {
CyNetwork network = networkView.getModel();
CyTable table = network.getDefaultNodeTable();
- CyRow row = table.getRow(network.getEdge(index).getSUID());
+ CyEdge edge = network.getEdge(index);
- return row.get(SELECTED_COLUMN_NAME, Boolean.class);
+ if (edge != null) {
+ CyRow row = table.getRow(edge.getSUID());
+ return row.get(SELECTED_COLUMN_NAME, Boolean.class);
+ } else {
+ return false;
+ }
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderColor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderColor.java
2012-01-13 21:52:00 UTC (rev 28014)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderColor.java
2012-01-13 22:14:49 UTC (rev 28015)
@@ -10,17 +10,25 @@
private double blue;
private double alpha;
+ public static void setNonAlphaColors(GL2 gl, RenderColor color) {
+ gl.glColor3d(color.getRed(), color.getGreen(), color.getBlue());
+ }
+
public RenderColor(double red, double green, double blue, double alpha)
{
- this.red = red;
- this.green = green;
- this.blue = blue;
- this.alpha = alpha;
+ set(red, green, blue, alpha);
}
public RenderColor(double red, double green, double blue) {
this(red, green, blue, DEFAULT_ALPHA);
}
+ public RenderColor(RenderColor other) {
+ this.red = other.red;
+ this.green = other.green;
+ this.blue = other.blue;
+ this.alpha = other.alpha;
+ }
+
public RenderColor() {
this(1, 1, 1, 1);
}
@@ -40,8 +48,57 @@
public double getAlpha() {
return alpha;
}
+
+ public void set(double red, double green, double blue, double alpha) {
+ this.red = red;
+ this.green = green;
+ this.blue = blue;
+ this.alpha = alpha;
+ }
+
+ public void set(double red, double green, double blue) {
+ set(red, green, blue, this.alpha);
+ }
- public static void setNonAlphaColors(GL2 gl, RenderColor color) {
- gl.glColor3d(color.getRed(), color.getGreen(), color.getBlue());
+ // Does not allow colors to escape range [0, 1]
+ public void multiplyNonAlphaColors(double multiplier) {
+ if (multiplier < 0) {
+ return;
+ }
+
+ set(Math.min(red * multiplier, 1),
+ Math.min(green * multiplier, 1),
+ Math.min(blue * multiplier, 1));
}
+
+ public void multiplyRed(double multiplier, double minimum, double
maximum) {
+ if (multiplier < 0) {
+ return;
+ }
+
+ red = Math.max(red, minimum);
+ red = Math.min(red * multiplier, maximum);
+ red = Math.min(red, 1);
+ }
+
+ public void multiplyGreen(double multiplier, double minimum, double
maximum) {
+ if (multiplier < 0) {
+ return;
+ }
+
+ green = Math.max(green, minimum);
+ green = Math.min(green * multiplier, maximum);
+ green = Math.min(green, 1);
+ }
+
+ public void multiplyBlue(double multiplier, double minimum, double
maximum) {
+ if (multiplier < 0) {
+ return;
+ }
+
+ blue = Math.max(blue, minimum);
+ blue = Math.min(blue * multiplier, maximum);
+ blue = Math.min(blue, 1);
+ }
+
}
--
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.