Cytoscape 2.8.0 API

cytoscape.render.immed
Class GraphGraphics

java.lang.Object
  extended by cytoscape.render.immed.GraphGraphics

public final class GraphGraphics
extends Object

The purpose of this class is to make the proper calls on a Graphics2D object to efficiently render nodes, labels, and edges. This is procedural programming at its finest [sarcasm].

This class deals with two coordinate systems: an image coordinate system and a node coordinate system. The programmer who uses this API will be dealing mostly with the node coordinate system, especially when rendering individual nodes and edges. The clear() method specifies the mapping from the node coordinate system to the image coordinate system. The two coordinate systems do have the same orientations: increasing X values point to the right and increasing Y values point to the bottom. The image coordinate system dictates that (0,0) is the upper left corner of the image and that each unit represents a pixel width (or height). if (m_debug) { if (!EventQueue.isDispatchThread()) throw new IllegalStateException( "calling thread is not AWT event dispatcher"); if (!(xMin < xMax)) throw new IllegalArgumentException("xMin not less than xMax"); if (!(yMin < yMax)) throw new IllegalArgumentException("yMin not less than yMax"); if (nodeShape == SHAPE_ROUNDED_RECTANGLE) { final double width = ((double) xMax) - xMin; final double height = ((double) yMax) - yMin; if (!(Math.max(width, height) < (2.0d * Math.min(width, height)))) throw new IllegalArgumentException( "rounded rectangle does not meet cotextnstraint " + "max(width, height) < 2 * min(width, height)"); } }

NOTE: Every method on an instance of this class needs to be called by the AWT event dispatching thread save the constructor. However, checks for this are made only if debug is set to true (see constructur). In fact, in certain situations [such as rendering to a non-image such as a vector graphic] it may make sense to never call any of the methods from the AWT event dispatching thread.


Field Summary
static byte ARROW_ARROWHEAD
           
static byte ARROW_DELTA
           
static byte ARROW_DIAMOND
           
static byte ARROW_DISC
           
static byte ARROW_HALF_BOTTOM
           
static byte ARROW_HALF_TOP
           
static byte ARROW_NONE
           
static byte ARROW_TEE
           
static int CUSTOM_SHAPE_MAX_VERTICES
          This value is currently 100.
 Image image
          The image that was passed into the constructor.
static int MAX_EDGE_ANCHORS
          This value is currently 64.
static byte SHAPE_DIAMOND
           
static byte SHAPE_ELLIPSE
           
static byte SHAPE_HEXAGON
           
static byte SHAPE_OCTAGON
           
static byte SHAPE_PARALLELOGRAM
           
static byte SHAPE_RECTANGLE
          Node shape constants
static byte SHAPE_ROUNDED_RECTANGLE
           
static byte SHAPE_TRIANGLE
           
static byte SHAPE_VEE
           
 
Constructor Summary
GraphGraphics(Image image, boolean debug)
          All rendering operations will be performed on the specified image.
 
Method Summary
 void clear(Paint bgPaint, double xCenter, double yCenter, double scaleFactor)
          Clears image area with background paint specified and sets an appropriate transformation of coordinate systems.
 boolean computeEdgeIntersection(byte nodeShape, float xMin, float yMin, float xMax, float yMax, float offset, float ptX, float ptY, float[] returnVal)
          Computes the intersection point between a node outline and a line segment; one point of the line segment lies at the center of the node outline.
 boolean customNodeShapeExists(byte shape)
          Determines whether the specified shape is a custom defined node shape.
 byte defineCustomNodeShape(float[] coords, int offset, int vertexCount)
          The custom node shape that is defined is a polygon specified by the coordinates supplied.
 void drawCustomGraphicFull(Shape shape, float xOffset, float yOffset, Paint paint)
          Fills an arbitrary graphical shape with high detail.
 void drawEdgeFull(byte arrow0Type, float arrow0Size, Paint arrow0Paint, byte arrow1Type, float arrow1Size, Paint arrow1Paint, float x0, float y0, EdgeAnchors anchors, float x1, float y1, float edgeThickness, Stroke edgeStroke, Paint edgePaint)
          Draws an edge with medium to high detail, depending on parameters specified.
 void drawEdgeLow(float x0, float y0, float x1, float y1, Color edgeColor)
          This is the method that will render an edge very quickly.
 void drawNodeFull(byte nodeShape, float xMin, float yMin, float xMax, float yMax, Paint fillPaint, float borderWidth, Paint borderPaint)
          Draws a node with medium to high detail, depending on parameters specified.
 void drawNodeLow(float xMin, float yMin, float xMax, float yMax, Color fillColor)
          This is the method that will render a node very quickly.
 void drawTextFull(Font font, double scaleFactor, String text, float xCenter, float yCenter, float theta, Paint paint, boolean drawTextAsShape)
          Renders text onto the underlying image with medium to high detail, depending on parameters specified.
 void drawTextLow(Font font, String text, float xCenter, float yCenter, Color color)
          This method will render text very quickly.
static Map<Byte,Shape> getArrowShapes()
          Get list of arrow heads.
 float[] getCustomNodeShape(byte customShape)
          Returns the vertices of a previously defined custom node shape.
 byte[] getCustomNodeShapes()
          DOCUMENT ME!
 boolean getEdgePath(byte arrow0Type, float arrow0Size, byte arrow1Type, float arrow1Size, float x0, float y0, EdgeAnchors anchors, float x1, float y1, GeneralPath path)
          Computes the path that an edge takes; this method is useful if a user interface would allow user selection of edges, for example.
 FontRenderContext getFontRenderContextFull()
          Returns the context that is used by drawTextFull() to produce text shapes to be drawn to the screen.
 FontRenderContext getFontRenderContextLow()
          Returns the context that is used by drawTextLow() to produce text shapes to be drawn to the screen.
 void getNodeShape(byte nodeShape, float xMin, float yMin, float xMax, float yMax, GeneralPath path)
          Computes the path a node shape takes; this method is useful if a user interface would allow user selection of nodes, for example.
static Map<Byte,Shape> getNodeShapes()
          get list of node shapes.
 AffineTransform getTransform()
          Called to get the current AffineTransform Matrix.
 void importCustomNodeShapes(GraphGraphics grafx)
          If this is a new instance, imports the custom node shapes from the GraphGraphics specified into this GraphGraphics.
 void xformImageToNodeCoords(double[] coords)
          Uses the current transform to map the specified image coordinates to node coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHAPE_RECTANGLE

public static final byte SHAPE_RECTANGLE
Node shape constants

See Also:
Constant Field Values

SHAPE_DIAMOND

public static final byte SHAPE_DIAMOND
See Also:
Constant Field Values

SHAPE_ELLIPSE

public static final byte SHAPE_ELLIPSE
See Also:
Constant Field Values

SHAPE_HEXAGON

public static final byte SHAPE_HEXAGON
See Also:
Constant Field Values

SHAPE_OCTAGON

public static final byte SHAPE_OCTAGON
See Also:
Constant Field Values

SHAPE_PARALLELOGRAM

public static final byte SHAPE_PARALLELOGRAM
See Also:
Constant Field Values

SHAPE_ROUNDED_RECTANGLE

public static final byte SHAPE_ROUNDED_RECTANGLE
See Also:
Constant Field Values

SHAPE_TRIANGLE

public static final byte SHAPE_TRIANGLE
See Also:
Constant Field Values

SHAPE_VEE

public static final byte SHAPE_VEE
See Also:
Constant Field Values

CUSTOM_SHAPE_MAX_VERTICES

public static final int CUSTOM_SHAPE_MAX_VERTICES
This value is currently 100.

See Also:
Constant Field Values

ARROW_NONE

public static final byte ARROW_NONE
See Also:
Constant Field Values

ARROW_DELTA

public static final byte ARROW_DELTA
See Also:
Constant Field Values

ARROW_DIAMOND

public static final byte ARROW_DIAMOND
See Also:
Constant Field Values

ARROW_DISC

public static final byte ARROW_DISC
See Also:
Constant Field Values

ARROW_TEE

public static final byte ARROW_TEE
See Also:
Constant Field Values

ARROW_HALF_TOP

public static final byte ARROW_HALF_TOP
See Also:
Constant Field Values

ARROW_HALF_BOTTOM

public static final byte ARROW_HALF_BOTTOM
See Also:
Constant Field Values

ARROW_ARROWHEAD

public static final byte ARROW_ARROWHEAD
See Also:
Constant Field Values

MAX_EDGE_ANCHORS

public static final int MAX_EDGE_ANCHORS
This value is currently 64.

See Also:
Constant Field Values

image

public final Image image
The image that was passed into the constructor.

Constructor Detail

GraphGraphics

public GraphGraphics(Image image,
                     boolean debug)
All rendering operations will be performed on the specified image. No rendering operations are performed as a result of calling this constructor. It is safe to call this constructor from any thread.

The image argument passed to this constructor must support at least three methods: getGraphics(), getWidth(ImageObserver), and getHeight(ImageObserver). The image.getGraphics() method must return an instance of java.awt.Graphics2D. The hypothetical method calls image.getWidth(null) and image.getHeight(null) must return the corresponding dimension immediately.

Notice that it is not possible to resize the image area with this API. This is not a problem; instances of this class are very lightweight and are for the most part stateless; simply instantiate a new GraphGraphics when the image area changes.

Parameters:
image - an off-screen image; passing an image gotten from a call to java.awt.Component.createImage(int, int) works well, although experience shows that for full support of non-opaque colors, java.awt.image.BufferedImage should be used instead.
debug - if this is true, extra [and time-consuming] error checking will take place in each method call; it is recommended to have this value set to true during the testing phase; set it to false once you are sure that code does not mis-use this module.
Method Detail

clear

public final void clear(Paint bgPaint,
                        double xCenter,
                        double yCenter,
                        double scaleFactor)
Clears image area with background paint specified and sets an appropriate transformation of coordinate systems. See the class description for a definition of the two coordinate systems: the node coordinate system and the image coordinate system.

The background paint is not blended with colors that may already be on the underlying image; if a translucent color is used in the background paint, the underlying image itself becomes translucent.

It is mandatory to call this method before making the first rendering call.

Parameters:
bgPaint - paint to use when clearing the image before painting a new frame; translucency is honored, provided that the underlying image supports it.
xCenter - the X component of the translation transform for the frame about to be rendered; a node whose center is at the X coordinate xCenter will be rendered exactly in the middle of the image going across; increasing X values (in the node coordinate system) result in movement towards the right on the image.
yCenter - the Y component of the translation transform for the frame about to be rendered; a node whose center is at the Y coordinate yCenter will be rendered exactly in the middle of the image going top to bottom; increasing Y values (in the node coordinate system) result in movement towards the bottom on the image.
scaleFactor - the scaling that is to take place when rendering; a distance of 1 in node coordinates translates to a distance of scaleFactor in the image coordinate system (usually one unit in the image coordinate system equates to one pixel width).
Throws:
IllegalArgumentException - if scaleFactor is not positive.

xformImageToNodeCoords

public final void xformImageToNodeCoords(double[] coords)
Uses the current transform to map the specified image coordinates to node coordinates. The transform used is defined by the last call to clear(). It does not make sense to call this method if clear() has not been called at least once previously, and this method will cause errors in this case.

Parameters:
coords - an array of length [at least] two which acts both as the input and as the output of this method; coords[0] is the input X coordinate in the image coordinate system and is written as the X coordinate in the node coordinate system by this method; coords[1] is the input Y coordinate in the image coordinate system and is written as the Y coordinate in the node coordinate system by this method; the exact transform which takes place is defined by the previous call to the clear() method.

getTransform

public final AffineTransform getTransform()
Called to get the current AffineTransform Matrix.

Returns:
AffineTransform

drawNodeLow

public final void drawNodeLow(float xMin,
                              float yMin,
                              float xMax,
                              float yMax,
                              Color fillColor)
This is the method that will render a node very quickly. The node shape used by this method is SHAPE_RECTANGLE. Translucent colors are not supported by the low detail rendering methods.

xMin, yMin, xMax, and yMax specify the extents of the node in the node coordinate space, not the image coordinate space. Thus, these values will likely not change from frame to frame, as zoom and pan operations are performed.

This method will not work unless clear() has been called at least once previously.

Parameters:
xMin - an extent of the node to draw, in node coordinate space.
yMin - an extent of the node to draw, in node coordinate space.
xMax - an extent of the node to draw, in node coordinate space.
yMax - an extent of the node to draw, in node coordinate space.
fillColor - the [fully opaque] color to use when drawing the node.
Throws:
IllegalArgumentException - if xMin is not less than xMax, if yMin is not less than yMax, or if fillColor is not opaque.

drawNodeFull

public final void drawNodeFull(byte nodeShape,
                               float xMin,
                               float yMin,
                               float xMax,
                               float yMax,
                               Paint fillPaint,
                               float borderWidth,
                               Paint borderPaint)
Draws a node with medium to high detail, depending on parameters specified. The xMin, yMin, xMax, and yMax parameters specify the extents of the node shape (in the node coordinate system), including the border width. That is, the drawn border won't extend beyond the extents specified.

There is an imposed constraint on borderWidth which, using the implemented algorithms, prevents strange-looking borders. The constraint is that borderWidth may not exceed the minimum of the node width and node height divided by six. In addition, for custom node shapes, this requirement may be more constrained, depending on the kinks in the custom node shape.

There is a constraint that only applies to SHAPE_ROUNDED_RECTANGLE which imposes that the maximum of the width and height be strictly less than twice the minimum of the width and height of the node.

This method will not work unless clear() has been called at least once previously.

Parameters:
nodeShape - the shape of the node to draw (one of the SHAPE_* constants or a custom node shape).
xMin - an extent of the node shape to draw, in node coordinate space; the drawn shape will theoretically contain a point that lies on this X coordinate.
yMin - an extent of the node shape to draw, in node coordinate space; the drawn shape will theoretically contain a point that lies on this Y coordinate.
xMax - an extent of the node shape to draw, in node coordinate space; the drawn shape will theoretically contain a point that lies on this X coordinate.
yMax - an extent of the node shape to draw, in node coordinate space; the drawn shape will theoretically contain a point that lies on this Y coordinate.
fillPaint - the paint to use when drawing the node area minus the border (the "interior" of the node).
borderWidth - the border width, in node coordinate space; if this value is zero, the rendering engine skips over the process of rendering the border, which gives a significant performance boost.
borderPaint - if borderWidth is not zero, this paint is used for rendering the node border; otherwise, this parameter is ignored (and may be null).
Throws:
IllegalArgumentException - if xMin is not less than xMax or if yMin is not less than yMax, if borderWidth is negative or is greater than Math.min(xMax - xMin, yMax - yMin) / 6 (for custom node shapes borderWidth may be even more limited, depending on the specific shape), if nodeShape is SHAPE_ROUNDED_RECTANGLE and the condition max(width, height) < 2 * min(width, height) does not hold, or if nodeShape is neither one of the SHAPE_* constants nor a previously defined custom node shape.

getNodeShape

public final void getNodeShape(byte nodeShape,
                               float xMin,
                               float yMin,
                               float xMax,
                               float yMax,
                               GeneralPath path)
Computes the path a node shape takes; this method is useful if a user interface would allow user selection of nodes, for example. Use the same parameter values that were used to render corresponding node.

Parameters:
nodeShape - the shape (SHAPE_* constant or custom shape) of the node in question.
xMin - an extent of the node in question, in node coordinate space.
yMin - an extent of the node in question, in node coordinate space.
xMax - an extent of the node in question, in node coordinate space.
yMax - an extent of the node in question, in node coordinate space.
path - the computed path is returned in this parameter; the computed path's coordinate system is the node coordinate system; the computed path is closed.

defineCustomNodeShape

public final byte defineCustomNodeShape(float[] coords,
                                        int offset,
                                        int vertexCount)
The custom node shape that is defined is a polygon specified by the coordinates supplied. The polygon must meet several constraints listed below.

If we define the value xCenter to be the average of the minimum and maximum X values of the vertices and if we define yCenter likewise, then the specified polygon must meet the following constraints:

  1. Each polygon line segment must have nonzero length.
  2. No two consecutive polygon line segments can be parallel (this essentially implies that the polygon must have at least three vertices).
  3. No two distinct non-consecutive polygon line segments may intersect (not even at the endpoints); this makes possible the notion of interior of the polygon.
  4. The polygon must be star-shaped with respect to the point (xCenter, yCenter); a polygon is said to be star-shaped with respect to a point (a,b) if and only if for every point (x,y) in the interior or on the boundary of the polygon, the interior of the segment (a,b)->(x,y) lies in the interior of the polygon.
  5. The path traversed by the polygon must be clockwise where +X points right and +Y points down.

In addition to these constraints, when rendering custom nodes with nonzero border width, possible problems may arise if the border width is large with respect to the kinks in the polygon.

Parameters:
coords - vertexCount * 2 consecutive coordinate values are read from this array starting at coords[offset]; coords[offset], coords[offset + 1], coords[offset + 2], coords[offset + 3] and so on are interpreted as x0, y0, x1, y1, and so on; the initial vertex need not be repeated as the last vertex specified.
offset - the starting index of where to read coordinates from in the coords parameter.
vertexCount - the number of vertices to read from coords; vertexCount * 2 entries in coords are read.
Returns:
the node shape identifier to be used in future rendering calls (to be used as parameter nodeShape in method drawNodeFull()).
Throws:
IllegalArgumentException - if any of the constraints are not met, or if the specified polygon has more than CUSTOM_SHAPE_MAX_VERTICES vertices.
IllegalStateException - if too many custom node shapes are already defined; a little over one hundered custom node shapes can be defined.

customNodeShapeExists

public final boolean customNodeShapeExists(byte shape)
Determines whether the specified shape is a custom defined node shape.


getCustomNodeShapes

public final byte[] getCustomNodeShapes()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getCustomNodeShape

public final float[] getCustomNodeShape(byte customShape)
Returns the vertices of a previously defined custom node shape. The polygon will be normalized to fit within the [-0.5, 0.5] x [-0.5, 0.5] square. Returns null if specified shape is not a previously defined custom shape.


importCustomNodeShapes

public final void importCustomNodeShapes(GraphGraphics grafx)
If this is a new instance, imports the custom node shapes from the GraphGraphics specified into this GraphGraphics.

Parameters:
grafx - custom node shapes will be imported from this GraphGraphics.
Throws:
IllegalStateException - if at least one custom node shape is already defined in this GraphGraphics.

getNodeShapes

public static Map<Byte,Shape> getNodeShapes()
get list of node shapes.

Returns:
A map of node shape bytes to Shape objects.

getArrowShapes

public static Map<Byte,Shape> getArrowShapes()
Get list of arrow heads.

Returns:
A map of arrow shape bytes to Shape objects.

drawEdgeLow

public final void drawEdgeLow(float x0,
                              float y0,
                              float x1,
                              float y1,
                              Color edgeColor)
This is the method that will render an edge very quickly. Translucent colors are not supported by the low detail rendering methods.

The points (x0, y0) and (x1, y1) specify the endpoints of edge to be rendered in the node coordinate space, not the image coordinate space. Thus, these values will likely not change from frame to frame, as zoom and pan operations are performed. If these two points are identical, nothing is drawn.

This method will not work unless clear() has been called at least once previously.

Parameters:
x0 - the X coordinate of the begin point of edge to render.
y0 - the Y coordinate of the begin point of edge to render.
x1 - the X coordinate of the end point of edge to render.
y1 - the Y coordinate of the end point of edge to render.
edgeColor - the [fully opaque] color to use when drawing the edge.
Throws:
IllegalArgumentException - if edgeColor is not opaque.

drawEdgeFull

public final void drawEdgeFull(byte arrow0Type,
                               float arrow0Size,
                               Paint arrow0Paint,
                               byte arrow1Type,
                               float arrow1Size,
                               Paint arrow1Paint,
                               float x0,
                               float y0,
                               EdgeAnchors anchors,
                               float x1,
                               float y1,
                               float edgeThickness,
                               Stroke edgeStroke,
                               Paint edgePaint)
Draws an edge with medium to high detail, depending on parameters specified. Something is rendered in all cases except where the length of the edge is zero (because in that case directionality cannot be determined for at least some arrowheads).

The arrow types must each be one of the ARROW_* constants. The arrow at endpoint 1 is always "on top of" the arrow at endpoint 0 if they overlap because the arrow at endpoint 0 gets rendered first.

If an arrow other than ARROW_NONE is rendered, its size must be greater than or equal to edge thickness specified. The table below describes, to some extent, the nature of each arrow type.

arrow type description
ARROW_NONE the edge line segment has endpoint specified, and the line segment has a round end (center of round semicircle end exactly equal to endpoint specified); arrow size and arrow paint are ignored
ARROW_DELTA the sharp tip of the arrowhead is exactly at the endpint specified; the delta is as wide as the arrow size specified and twice that in length
ARROW_DIAMOND the sharp tip of the arrowhead is exactly at the endpoint specified; the diamond is as wide as the arrow size specified and twice that in length
ARROW_DISC the disc arrowhead is placed such that its center is at the specified endpoint; the diameter of the disk is the arrow size specified
ARROW_TEE the center of the tee intersection lies at the specified endpoint; the width of the top of the tee is one quarter of the arrow size specified, and the span of the top of the tee is two times the arrow size
ARROW_HALF_TOP Draws a line the width of the stroke away from the node at the midpoint between the edge and the node on the "top" of the edge.
ARROW_HALF_BOTTOM Draws a line the width of the stroke away from the node at the midpoint between the edge and the node on the "bottom" of the edge.

Note that if the edge segment length is zero then nothing gets rendered.

This method will not work unless clear() has been called at least once previously.

A discussion pertaining to edge anchors. At most MAX_EDGE_ANCHORS edge anchors may be specified. The edge anchors are used to define cubic Bezier curves. The exact algorithm for determining the Bezier curves from the input parameters is too complicated to describe in this Javadoc. Some parts of the algorithm:

  • the conglomerated curve is [probably] not going to pass through the edge anchors points specified; the curve will pass through the midpoint between every consecutive pair of anchors
  • when determining the edge path as a whole, an ordered list of points is created by putting point (x0, y0) at the beginning of the list, followed by the anchor points, followed by point (x1, y1); then, duplicate points are removed from the beginning and end of this list
  • from the list described above, the first two points define the arrow direction at point (x0, y0) and the initial curve direction; likewise, the last two points in this list define the arrow direction at point (x1, y1) and the ending curve direction
In order to specify a straight-line edge path, simply duplicate each edge anchor in the EdgeAnchors instance. For example, a smooth curve would be drawn by specifying consecutive-pairwise disctinct points {(x0,y0), A0, A1, A2, (x1,y1)}; a straight-line edge path would be drawn by specifying {(x0, y0), A0, A0, A1, A1, A2, A2, (x1, y1)}.

Parameters:
arrow0Type - the type of arrow shape to use for drawing the arrow at point (x0, y0); this value must be one of the ARROW_* constants.
arrow0Size - the size of arrow at point (x0, y0); how size is interpreted for different arrow types is described in the table above.
arrow0Paint - the paint to use when drawing the arrow at point (x0, y0).
arrow1Type - the type of arrow shape to use for drawing the arrow at point (x1, y1); this value must be one of the ARROW_* constants.
arrow1Size - the size of arrow at point (x1, y1); how size is interpreted for different arrow types is described in the table above.
arrow1Paint - the paint to use when drawing the arrow at point (x1, y1).
x0 - the X coordinate of the first edge endpoint.
y0 - the Y coordinate of the first edge endpoint.
anchors - anchor points between the two edge endpoints; null is an acceptable value to indicate no edge anchors.
x1 - the X coordinate of the second edge endpoint.
y1 - the Y coordinate of the second edge endpoint.
edgeThickness - the thickness of the edge segment; the edge segment is the part of the edge between the two endpoint arrows.
edgeStroke - the Stroke to use when drawing the edge segment.
edgePaint - the paint to use when drawing the edge segment.
Throws:
IllegalArgumentException - if edgeThickness is less than zero, if any one of the arrow configurations does not meet specified criteria, or if more than MAX_EDGE_ANCHORS anchors are specified.

getEdgePath

public final boolean getEdgePath(byte arrow0Type,
                                 float arrow0Size,
                                 byte arrow1Type,
                                 float arrow1Size,
                                 float x0,
                                 float y0,
                                 EdgeAnchors anchors,
                                 float x1,
                                 float y1,
                                 GeneralPath path)
Computes the path that an edge takes; this method is useful if a user interface would allow user selection of edges, for example. The returned path is the path along the center of the edge segment, extending to the points which specify the arrow locations. Note that this path therefore disregards edge thickness and arrow outline. Use the same parameter values that were used to render corresponding edge.

Parameters:
arrow0Type - the type of arrow shape used for drawing the arrow at point (x0, y0); this value must be one of the ARROW_* constants.
arrow0Size - the size of arrow at point (x0, y0).
arrow1Type - the type of arrow shape used for drawing the arrow at point (x1, y1); this value must be one of the ARROW_* constants.
arrow1Size - the size of arrow at point (x1, y1).
x0 - the X coordinate of the first edge endpoint.
y0 - the Y coordinate of the first edge endpoint.
anchors - anchor points between the two edge endpoints; null is an acceptable value to indicate no edge anchors.
x1 - the X coordinate of the second edge endpoint.
y1 - the Y coordinate of the second edge endpoint.
path - the computed path is returned in this parameter; the computed path's coordinate system is the node coordinate system; the computed path is not closed.
Returns:
true if and only if the specified edge would be drawn (which is if and only if any two points from the edge anchor set plus the beginning and end point are distinct); if false is returned, the path parameter is not modified.
Throws:
IllegalArgumentException - if any one of the edge arrow criteria specified in drawEdgeFull() is not satisfied.

computeEdgeIntersection

public final boolean computeEdgeIntersection(byte nodeShape,
                                             float xMin,
                                             float yMin,
                                             float xMax,
                                             float yMax,
                                             float offset,
                                             float ptX,
                                             float ptY,
                                             float[] returnVal)
Computes the intersection point between a node outline and a line segment; one point of the line segment lies at the center of the node outline.

There is a constraint that only applies to SHAPE_ROUNDED_RECTANGLE which imposes that the maximum of the width and height be strictly less than twice the minimum of the width and height of the node.

Parameters:
nodeShape - the shape of the node in question; this must be one of the SHAPE_* constants or a custom node shape.
xMin - an extent of the node in question, in node coordinate space.
yMin - an extent of the node in question, in node coordinate space.
xMax - an extent of the node in question, in node coordinate space.
yMax - an extent of the node in question, in node coordinate space.
offset - most of the time this value will be zero, in which case the point computed is the exact intersection point of line segment and node outline; if this value is greater than zero, the point computed is one that lies on the line segment, is "outside" of the node outline, and is distance offset from the node outline.
ptX - specifies the X coordinate of the endpoint of the line segment that is not the endpoint lying in the center of the node shape.
ptY - specifies the Y coordinate of the endpoint of the line segment that is not the endpoint lying in the center of the node shape.
returnVal - if true is returned, returnVal[0] is set to be the X coordinate of the computed point and returnVal[1] is set to be the Y coordinate of the computed point; if false is returned, this array is not modified.
Returns:
true if and only if a point matching our criteria exists.
Throws:
IllegalArgumentException - if xMin is not less than xMax or if yMin is not less than yMax, if offset is negative, if nodeShape is SHAPE_ROUNDED_RECTANGLE and the condition max(width, height) < 2 * min(width, height) does not hold, or if nodeShape is neither one of the SHAPE_* constants nor a previously defined custom node shape.

drawTextLow

public final void drawTextLow(Font font,
                              String text,
                              float xCenter,
                              float yCenter,
                              Color color)
This method will render text very quickly. Translucent colors are not supported by the low detail rendering methods.

For the sake of maximum performance, this method works differently from the other rendering methods with respect to the scaling factor specified in clear(). That is, the font used to render the specified text will not be scaled; its exact size will be used when the text is rendered onto the underlying image. On the other hand, the parameters xCenter and yCenter specify coordinates in the node coordinate system, and so the point (xCenter, yCenter) will be transformed according the clear() transform in determining the location of the text on the underlying image.

Parameters:
font - the font to use in drawing text; the size of this font specifies the actual point size of what will be rendered onto the underlying image.
text - the text to render.
xCenter - the X coordinate of the center point of where to place the rendered text; specified in the node coordinate system.
yCenter - the Y coordinate of the center point of where to place the rendered text; specified in the node coordinate system.
color - the [fully opaque] color to use in rendering the text.
Throws:
IllegalArgumentException - if color is not opaque.

getFontRenderContextLow

public final FontRenderContext getFontRenderContextLow()
Returns the context that is used by drawTextLow() to produce text shapes to be drawn to the screen. The transform contained in the returned context specifies the only scaling that will be done to fonts when rendering text using drawTextLow(). This transform does not change between frames no matter what scaling factor is specified in clear().


drawTextFull

public final void drawTextFull(Font font,
                               double scaleFactor,
                               String text,
                               float xCenter,
                               float yCenter,
                               float theta,
                               Paint paint,
                               boolean drawTextAsShape)
Renders text onto the underlying image with medium to high detail, depending on parameters specified.

Parameters:
font - the font to be used when rendering specified text; the rendering of glyph shapes generated by this font (using the context returned by getFontRenderContextFull()) is subjected to the same transformation as are nodes and edges (the transformation is defined by the clear() method); therefore, it is the point size of the font in addition to the scaling factor defined by clear() that determines the resulting size of text rendered to the graphics context.
scaleFactor - in order to prevent very small fonts from "degenerating" it is necessary to allow users to specify a scale factor in addition to the font size and transform defined by the clear() method; if this value is 1.0, no additional scaling is performed; otherwise, the size of the font is multiplied by this value to yield a new virtual font size.
text - the text to render.
xCenter - the text string is drawn such that its logical bounds rectangle with specified font is centered on this X coordinate (in the node coordinate system).
yCenter - the text string is drawn such that its logical bounds rectangle with specified font is centered on this Y coordinate (in the node coordinate system).
theta - in radians, specifies the angle of the text.
paint - the paint to use in rendering the text.
drawTextAsShape - this flag controls the way that text is drawn to the underlying graphics context; by default, all text rendering operations involve calling the operation Graphics2D.drawString(String, float, float) after setting specified font in the underlying graphics context; however, if this flag is set, the text to be rendered is converted to a primitive shape using font specified, and this shape is then rendered using Graphics2D.fill(Shape); on some systems, the shape filling method produces better-looking results when the graphics context is associated with an image that is to be rendered to the screen; however, on all systems tested, the shape filling method results in a substantial performance hit when the graphics context is associated with an image that is to be rendered to the screen; it is recommended to set this flag to true when either not much text is being rendered or when the zoom level is very high; the Graphics2D.drawString() operation has a difficult time when it needs to render text under a transformation with a very large scale factor.

getFontRenderContextFull

public final FontRenderContext getFontRenderContextFull()
Returns the context that is used by drawTextFull() to produce text shapes to be drawn to the screen. This context always has the identity transform.


drawCustomGraphicFull

public final void drawCustomGraphicFull(Shape shape,
                                        float xOffset,
                                        float yOffset,
                                        Paint paint)
Fills an arbitrary graphical shape with high detail.

This method will not work unless clear() has been called at least once previously.

Parameters:
shape - the shape to fill; the shape is specified in node coordinates.
xOffset - in node coordinates, a value to add to the X coordinates of the shape's definition.
yOffset - in node coordinates, a value to add to the Y coordinates of the shape's definition.
paint - the paint to use when filling the shape.

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.