Author: kono
Date: 2009-11-30 15:35:46 -0800 (Mon, 30 Nov 2009)
New Revision: 18606
Modified:
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/CustomGraphic.java
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/GraphRenderer.java
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/NodeDetails.java
Log:
Nested network graphics renderer has been added.
Modified:
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/CustomGraphic.java
===================================================================
---
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/CustomGraphic.java
2009-11-30 22:14:10 UTC (rev 18605)
+++
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/CustomGraphic.java
2009-11-30 23:35:46 UTC (rev 18606)
@@ -89,16 +89,18 @@
private Shape _shape;
private Paint _paint;
private byte _anchor;
+
public CustomGraphic (Shape shape, Paint paint, byte anchor) {
- if ((shape == null) || (paint == null))
- throw new IllegalArgumentException("The shape or paint given was
null.");
- if ((anchor < 0) || (anchor > NodeDetails.MAX_ANCHOR_VAL)) {
- throw new IllegalArgumentException("The anchor value " + anchor + "
is not in the range 0 <= anchor <= " + NodeDetails.MAX_ANCHOR_VAL + ".");
- }
- _shape = shape;
- _paint = paint;
- _anchor = anchor;
+ if ((shape == null) || (paint == null))
+ throw new IllegalArgumentException("The shape or paint
given was null.");
+ if ((anchor < 0) || (anchor > NodeDetails.MAX_ANCHOR_VAL)) {
+ throw new IllegalArgumentException("The anchor value "
+ anchor + " is not in the range 0 <= anchor <= " + NodeDetails.MAX_ANCHOR_VAL
+ ".");
+ }
+ _shape = shape;
+ _paint = paint;
+ _anchor = anchor;
}
+
/**
* Return the Shape that makes up this CustomGraphic.
*/
Modified:
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/GraphRenderer.java
===================================================================
---
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/GraphRenderer.java
2009-11-30 22:14:10 UTC (rev 18605)
+++
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/GraphRenderer.java
2009-11-30 23:35:46 UTC (rev 18606)
@@ -36,26 +36,23 @@
package cytoscape.render.stateful;
+import java.awt.Font;
+import java.awt.Paint;
+import java.awt.Stroke;
+import java.awt.TexturePaint;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.util.Iterator;
+
import cytoscape.geom.spacial.SpacialEntry2DEnumerator;
import cytoscape.geom.spacial.SpacialIndex2D;
-
import cytoscape.graph.fixed.FixedGraph;
-
import cytoscape.render.immed.EdgeAnchors;
import cytoscape.render.immed.GraphGraphics;
-
import cytoscape.util.intr.IntEnumerator;
import cytoscape.util.intr.IntHash;
-import java.awt.Font;
-import java.awt.Paint;
-import java.awt.Stroke;
-import java.awt.Shape;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.PathIterator;
-import java.util.Iterator;
-
/**
* This class contains a chunk of procedural code that stitches together
* several external modules in an effort to efficiently render graphs.
@@ -669,92 +666,12 @@
floatBuff1[3], nodeDetails.colorLowDetail(node));
}
} else { // High detail.
-
while (nodeHits.numRemaining() > 0) {
final int node =
nodeHits.nextExtents(floatBuff1, 0);
+
+ renderNodeHigh(graph, grafx, node,
floatBuff1, doubleBuff1, doubleBuff2, nodeDetails, lodBits);
+
- if ((floatBuff1[0] != floatBuff1[2]) &&
(floatBuff1[1] != floatBuff1[3])) {
- // Compute visual attributes
that do not depend on LOD.
- final byte shape =
nodeDetails.shape(node);
- final Paint fillPaint =
nodeDetails.fillPaint(node);
-
- // Compute node border
information.
- final float borderWidth;
- final Paint borderPaint;
-
- if ((lodBits &
LOD_NODE_BORDERS) == 0) { // Not rendering borders.
- borderWidth = 0.0f;
- borderPaint = null;
- } else { // Rendering node
borders.
- borderWidth =
nodeDetails.borderWidth(node);
-
- if (borderWidth == 0.0f)
- borderPaint =
null;
- else
- borderPaint =
nodeDetails.borderPaint(node);
- }
-
- // Draw the node.
- grafx.drawNodeFull(shape,
floatBuff1[0], floatBuff1[1], floatBuff1[2],
-
floatBuff1[3], fillPaint, borderWidth, borderPaint);
- }
-
- // Take care of custom graphic
rendering.
- if ((lodBits & LOD_CUSTOM_GRAPHICS) !=
0) {
- // NOTE: The following block of
code should be removed when the deprecated index-based API
- // methods are removed:
- // BEGIN BLOCK TO REMOVE.
- final int graphicCount =
nodeDetails.graphicCount(node);
-
- for (int graphicInx = 0;
graphicInx < graphicCount; graphicInx++) {
- final Shape gShape =
nodeDetails.graphicShape(node, graphicInx);
- final Paint paint =
nodeDetails.graphicPaint(node, graphicInx);
- final byte anchor =
nodeDetails.graphicNodeAnchor(node, graphicInx);
- // Shouldn't these be
graphicOffsetVectorX and Y versus labelOffsetVectorX and Y:
- final float
offsetVectorX = nodeDetails.labelOffsetVectorX(node,
-
graphicInx);
- final float
offsetVectorY = nodeDetails.labelOffsetVectorY(node,
-
graphicInx);
- doubleBuff1[0] =
floatBuff1[0];
- doubleBuff1[1] =
floatBuff1[1];
- doubleBuff1[2] =
floatBuff1[2];
- doubleBuff1[3] =
floatBuff1[3];
-
lemma_computeAnchor(anchor, doubleBuff1, doubleBuff2);
-
grafx.drawCustomGraphicFull(gShape,
-
(float) (doubleBuff2[0] + offsetVectorX),
-
(float) (doubleBuff2[1] + offsetVectorY),
-
paint);
- }
- // END BLOCK TO REMOVE.
-
- // don't allow our custom
graphics to mutate while we iterate over them:
- synchronized
(nodeDetails.customGraphicsLock(node)) {
- // This iterator will
return CustomGraphics in rendering order:
- Iterator<CustomGraphic>
dNodeIt = nodeDetails.customGraphics (node);
- CustomGraphic cg = null;
- // The graphic index used
to retrieve non custom graphic info corresponds to the zero-based
- // index of the
CustomGraphic returned by the iterator:
- int graphicInx = 0;
- while (dNodeIt.hasNext()) {
- cg = dNodeIt.next();
- final float
offsetVectorX = nodeDetails.labelOffsetVectorX(node,
-
graphicInx);
- final float
offsetVectorY = nodeDetails.labelOffsetVectorY(node,
-
graphicInx);
- doubleBuff1[0] =
floatBuff1[0];
- doubleBuff1[1] =
floatBuff1[1];
- doubleBuff1[2] =
floatBuff1[2];
- doubleBuff1[3] =
floatBuff1[3];
-
lemma_computeAnchor(cg.getAnchor(), doubleBuff1, doubleBuff2);
-
grafx.drawCustomGraphicFull(cg.getShape(),
-
(float) (doubleBuff2[0] + offsetVectorX),
-
(float) (doubleBuff2[1] + offsetVectorY),
-
cg.getPaint());
- graphicInx++;
- }
- }
- }
-
// Take care of label rendering.
if ((lodBits & LOD_NODE_LABELS) != 0) {
// Potential label rendering.
@@ -1211,4 +1128,99 @@
return true;
}
}
+
+
+ private static final void renderNodeHigh(final FixedGraph graph, final
GraphGraphics grafx, final int node, final float[] floatBuff1, final double[]
doubleBuff1, final double[] doubleBuff2, final NodeDetails nodeDetails, final
int lodBits) {
+ if ((floatBuff1[0] != floatBuff1[2]) && (floatBuff1[1] !=
floatBuff1[3])) {
+ // Compute visual attributes that do not depend
on LOD.
+ final byte shape = nodeDetails.shape(node);
+ final Paint fillPaint =
nodeDetails.fillPaint(node);
+
+ // Compute node border information.
+ final float borderWidth;
+ final Paint borderPaint;
+
+ if ((lodBits & LOD_NODE_BORDERS) == 0) { // Not
rendering borders.
+ borderWidth = 0.0f;
+ borderPaint = null;
+ } else { // Rendering node borders.
+ borderWidth =
nodeDetails.borderWidth(node);
+
+ if (borderWidth == 0.0f)
+ borderPaint = null;
+ else
+ borderPaint =
nodeDetails.borderPaint(node);
+ }
+
+ // Draw the node.
+
+ grafx.drawNodeFull(shape, floatBuff1[0],
floatBuff1[1], floatBuff1[2], floatBuff1[3],
+ fillPaint, borderWidth,
borderPaint);
+ }
+
+ // Take care of custom graphic rendering.
+ if ((lodBits & LOD_CUSTOM_GRAPHICS) != 0) {
+ final TexturePaint nestedNetworkPaint =
nodeDetails.getNestedNetworkTexturePaint(node);
+ if (nestedNetworkPaint != null) {
+ doubleBuff1[0] = floatBuff1[0];
+ doubleBuff1[1] = floatBuff1[1];
+ doubleBuff1[2] = floatBuff1[2];
+ doubleBuff1[3] = floatBuff1[3];
+
lemma_computeAnchor(NodeDetails.ANCHOR_CENTER, doubleBuff1, doubleBuff2);
+
grafx.drawCustomGraphicFull(nestedNetworkPaint.getAnchorRect(),
(float)doubleBuff2[0], (float)doubleBuff2[1], nestedNetworkPaint);
+ }
+ // NOTE: The following block of code should be
removed when the deprecated index-based API
+ // methods are removed:
+// // BEGIN BLOCK TO REMOVE.
+// final int graphicCount =
nodeDetails.graphicCount(node);
+//
+// for (int graphicInx = 0; graphicInx <
graphicCount; graphicInx++) {
+// final Shape gShape =
nodeDetails.graphicShape(node, graphicInx);
+// final Paint paint =
nodeDetails.graphicPaint(node, graphicInx);
+// final byte anchor =
nodeDetails.graphicNodeAnchor(node, graphicInx);
+// // Shouldn't these be
graphicOffsetVectorX and Y versus labelOffsetVectorX and Y:
+// final float offsetVectorX =
nodeDetails.labelOffsetVectorX(node,
+//
graphicInx);
+// final float offsetVectorY =
nodeDetails.labelOffsetVectorY(node,
+//
graphicInx);
+// doubleBuff1[0] = floatBuff1[0];
+// doubleBuff1[1] = floatBuff1[1];
+// doubleBuff1[2] = floatBuff1[2];
+// doubleBuff1[3] = floatBuff1[3];
+// lemma_computeAnchor(anchor,
doubleBuff1, doubleBuff2);
+// grafx.drawCustomGraphicFull(gShape,
+// (float)
(doubleBuff2[0] + offsetVectorX),
+// (float)
(doubleBuff2[1] + offsetVectorY),
+// paint);
+// }
+// // END BLOCK TO REMOVE.
+
+ // don't allow our custom graphics to mutate
while we iterate over them:
+ synchronized
(nodeDetails.customGraphicsLock(node)) {
+ // This iterator will return CustomGraphics
in rendering order:
+ Iterator<CustomGraphic> dNodeIt =
nodeDetails.customGraphics (node);
+ CustomGraphic cg = null;
+ // The graphic index used to retrieve non
custom graphic info corresponds to the zero-based
+ // index of the CustomGraphic returned by
the iterator:
+ int graphicInx = 0;
+ while (dNodeIt.hasNext()) {
+ cg = dNodeIt.next();
+ final float offsetVectorX =
nodeDetails.labelOffsetVectorX(node,
+
graphicInx);
+ final float offsetVectorY =
nodeDetails.labelOffsetVectorY(node,
+
graphicInx);
+ doubleBuff1[0] = floatBuff1[0];
+ doubleBuff1[1] = floatBuff1[1];
+ doubleBuff1[2] = floatBuff1[2];
+ doubleBuff1[3] = floatBuff1[3];
+
lemma_computeAnchor(cg.getAnchor(), doubleBuff1, doubleBuff2);
+
grafx.drawCustomGraphicFull(cg.getShape(),
+ (float)
(doubleBuff2[0] + offsetVectorX),
+ (float)
(doubleBuff2[1] + offsetVectorY),
+
cg.getPaint());
+ graphicInx++;
+ }
+ }
+ }
+ }
}
Modified:
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/NodeDetails.java
===================================================================
---
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/NodeDetails.java
2009-11-30 22:14:10 UTC (rev 18605)
+++
corelibs/trunk/render.stateful/src/cytoscape/render/stateful/NodeDetails.java
2009-11-30 23:35:46 UTC (rev 18606)
@@ -36,17 +36,17 @@
package cytoscape.render.stateful;
-import cytoscape.render.immed.GraphGraphics;
-import cytoscape.render.stateful.CustomGraphic;
-
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import java.awt.Shape;
+import java.awt.TexturePaint;
import java.util.ArrayList;
import java.util.Iterator;
+import cytoscape.render.immed.GraphGraphics;
+
/**
* Defines visual properties of a node modulo the node size and location
* Even though this class is not declared abstract, in most situations it
@@ -566,4 +566,9 @@
public double labelWidth(final int node) {
return 100.0;
}
+
+
+ public TexturePaint getNestedNetworkTexturePaint(final int node) {
+ return null;
+ }
}
--
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.