Cytoscape 2.8.0 API

cytoscape.render.stateful
Class NodeDetails

java.lang.Object
  extended by cytoscape.render.stateful.NodeDetails

public class NodeDetails
extends Object

Defines visual properties of a node modulo the node size and location Even though this class is not declared abstract, in most situations it makes sense to override at least some of its methods in order to gain control over node visual properties.

To understand the significance of each method's return value, it makes sense to become familiar with the API cytoscape.render.immed.GraphGraphics.


Field Summary
static byte ANCHOR_CENTER
          Specifies that an anchor point lies at the center of a bounding box.
static byte ANCHOR_EAST
          Specifies that an anchor point lies on the east edge of a bounding box, halfway between the north and south edges.
static byte ANCHOR_NORTH
          Specifies that an anchor point lies on the north edge of a bounding box, halfway between the east and west edges.
static byte ANCHOR_NORTHEAST
          Specifies that an anchor point lies on the northeast corner of a bounding box.
static byte ANCHOR_NORTHWEST
          Specifies that an anchor point lies on the northwest corner of a bounding box.
static byte ANCHOR_SOUTH
          Specifies that an anchor point lies on the south edge of a bounding box, halfway between the east and west edges.
static byte ANCHOR_SOUTHEAST
          Specifies that an anchor point lies on the southeast corner of a bounding box.
static byte ANCHOR_SOUTHWEST
          Specifies that an anchor point lies on the southwest corner of a bounding box.
static byte ANCHOR_WEST
          Specifies that an anchor point lies on the west edge of a bounding box, halfway between the north and south edges.
static byte LABEL_WRAP_JUSTIFY_CENTER
          Specifies that the lines in a multi-line node label should each have a center point with similar X coordinate.
static byte LABEL_WRAP_JUSTIFY_LEFT
          Specifies that the lines of a multi-line node label should each have a leftmost point with similar X coordinate.
static byte LABEL_WRAP_JUSTIFY_RIGHT
          Specifies that the lines of a multi-line node label should each have a rightmost point with similar X coordinate.
static byte MAX_ANCHOR_VAL
          Used for range checking the anchor values.
 
Constructor Summary
NodeDetails()
          Instantiates node details with defaults.
 
Method Summary
 Paint borderPaint(int node)
          Returns the paint of the border of the node shape.
 float borderWidth(int node)
          Returns the border width of the node shape.
 Color colorLowDetail(int node)
          Returns the color of node in low detail rendering mode.
 int customGraphicCount(int node)
          A thread-safe method returning the number of custom graphics associated with a given Node.
 Iterator<CustomGraphic> customGraphics(int node)
          Return a non-null, read-only Iterator over all CustomGraphics contained in this Node.
 Object customGraphicsLock(int node)
          Return the object used for synchronizing custom graphics operations for a given Node.
 Paint fillPaint(int node)
          Returns the paint of the interior of the node shape.
 TexturePaint getNestedNetworkTexturePaint(int node)
          Child class should ovrride this method to render correct Nexted Network Image.
 boolean getSelected(Integer node)
          Used to get selected state of given node.
 float graphicOffsetVectorX(int node, int graphicInx)
          Specifies the X component of the vector that separates the location of a rendered graphic from the node's anchor point for that graphic.
 float graphicOffsetVectorY(int node, int graphicInx)
          Specifies the Y component of the vector that separates the location of a rendered graphic from the node's anchor point for that graphic.
 int labelCount(int node)
          Returns the number of labels that this node has.
 Font labelFont(int node, int labelInx)
          Returns the font to use when rendering this label.
 byte labelJustify(int node, int labelInx)
          By returning one of the LABEL_WRAP_JUSTIFY_* constants, determines how to justify a node label spanning multiple lines.
 byte labelNodeAnchor(int node, int labelInx)
          By returning one of the ANCHOR_* constants, specifies where on the node's extents rectangle an anchor point lies.
 float labelOffsetVectorX(int node, int labelInx)
          Specifies the X component of the vector that separates a text anchor point from a node anchor point.
 float labelOffsetVectorY(int node, int labelInx)
          Specifies the Y component of the vector that separates a text anchor point from a node anchor point.
 Paint labelPaint(int node, int labelInx)
          Returns the paint of a text label.
 double labelScaleFactor(int node, int labelInx)
          Returns an additional scaling factor that is to be applied to the font used to render this label; this scaling factor, applied to the point size of the font returned by labelFont(node, labelInx), yields a new virtual font that is used to render the text label.
 String labelText(int node, int labelInx)
          Returns a label's text.
 byte labelTextAnchor(int node, int labelInx)
          By returning one of the ANCHOR_* constants, specifies where on a text label's logical bounds box an anchor point lies.
 double labelWidth(int node)
          Returns the label width of the node.
 void setSelected(Integer node, Boolean selected)
          Used to set selected state of given node.
 byte shape(int node)
          Returns a GraphGraphics.SHAPE_* constant (or a custom node shape that an instance of GraphGraphics understands); this defines the shape that this node takes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCHOR_CENTER

public static final byte ANCHOR_CENTER
Specifies that an anchor point lies at the center of a bounding box.

See Also:
Constant Field Values

ANCHOR_NORTH

public static final byte ANCHOR_NORTH
Specifies that an anchor point lies on the north edge of a bounding box, halfway between the east and west edges.

See Also:
Constant Field Values

ANCHOR_NORTHEAST

public static final byte ANCHOR_NORTHEAST
Specifies that an anchor point lies on the northeast corner of a bounding box.

See Also:
Constant Field Values

ANCHOR_EAST

public static final byte ANCHOR_EAST
Specifies that an anchor point lies on the east edge of a bounding box, halfway between the north and south edges.

See Also:
Constant Field Values

ANCHOR_SOUTHEAST

public static final byte ANCHOR_SOUTHEAST
Specifies that an anchor point lies on the southeast corner of a bounding box.

See Also:
Constant Field Values

ANCHOR_SOUTH

public static final byte ANCHOR_SOUTH
Specifies that an anchor point lies on the south edge of a bounding box, halfway between the east and west edges.

See Also:
Constant Field Values

ANCHOR_SOUTHWEST

public static final byte ANCHOR_SOUTHWEST
Specifies that an anchor point lies on the southwest corner of a bounding box.

See Also:
Constant Field Values

ANCHOR_WEST

public static final byte ANCHOR_WEST
Specifies that an anchor point lies on the west edge of a bounding box, halfway between the north and south edges.

See Also:
Constant Field Values

ANCHOR_NORTHWEST

public static final byte ANCHOR_NORTHWEST
Specifies that an anchor point lies on the northwest corner of a bounding box.

See Also:
Constant Field Values

MAX_ANCHOR_VAL

public static final byte MAX_ANCHOR_VAL
Used for range checking the anchor values.

See Also:
Constant Field Values

LABEL_WRAP_JUSTIFY_CENTER

public static final byte LABEL_WRAP_JUSTIFY_CENTER
Specifies that the lines in a multi-line node label should each have a center point with similar X coordinate.

See Also:
Constant Field Values

LABEL_WRAP_JUSTIFY_LEFT

public static final byte LABEL_WRAP_JUSTIFY_LEFT
Specifies that the lines of a multi-line node label should each have a leftmost point with similar X coordinate.

See Also:
Constant Field Values

LABEL_WRAP_JUSTIFY_RIGHT

public static final byte LABEL_WRAP_JUSTIFY_RIGHT
Specifies that the lines of a multi-line node label should each have a rightmost point with similar X coordinate.

See Also:
Constant Field Values
Constructor Detail

NodeDetails

public NodeDetails()
Instantiates node details with defaults. Documentation on each method describes defaults. To override defaults, extend this class.

Method Detail

colorLowDetail

public Color colorLowDetail(int node)
Returns the color of node in low detail rendering mode. By default this method returns Color.red. It is an error to return null in this method.

In low detail rendering mode, this is the only method from this class that is looked at. The rest of the methods in this class define visual properties that are used in full detail rendering mode. In low detail rendering mode translucent colors are not supported whereas in full detail rendering mode they are.


shape

public byte shape(int node)
Returns a GraphGraphics.SHAPE_* constant (or a custom node shape that an instance of GraphGraphics understands); this defines the shape that this node takes. By default this method returns GraphGraphics.SHAPE_RECTANGLE. Take note of certain constraints specified in GraphGraphics.drawNodeFull() that pertain to rounded rectangles.


fillPaint

public Paint fillPaint(int node)
Returns the paint of the interior of the node shape. By default this method returns Color.red. It is an error to return null in this method.


borderWidth

public float borderWidth(int node)
Returns the border width of the node shape. By default this method returns zero. Take note of certain constraints specified in GraphGraphics.drawNodeFull().


borderPaint

public Paint borderPaint(int node)
Returns the paint of the border of the node shape. By default this method returns null. This return value is ignored if borderWidth(node) returns zero; it is an error to return null if borderWidth(node) returns a value greater than zero.


labelCount

public int labelCount(int node)
Returns the number of labels that this node has. By default this method returns zero.


labelText

public String labelText(int node,
                        int labelInx)
Returns a label's text. By default this method always returns null. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero. It is an error to return null if this method is called by the rendering engine.

To specify multiple lines of text in a node label, simply insert the '\n' character between lines of text.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.

labelFont

public Font labelFont(int node,
                      int labelInx)
Returns the font to use when rendering this label. By default this method always returns null. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero. It is an error to return null if this method is called by the rendering engine.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.

labelScaleFactor

public double labelScaleFactor(int node,
                               int labelInx)
Returns an additional scaling factor that is to be applied to the font used to render this label; this scaling factor, applied to the point size of the font returned by labelFont(node, labelInx), yields a new virtual font that is used to render the text label. By default this method always returns 1.0. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.

labelPaint

public Paint labelPaint(int node,
                        int labelInx)
Returns the paint of a text label. By default this method always returns null. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero. It is an error to return null if this method is called by the rendering engine.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.

labelTextAnchor

public byte labelTextAnchor(int node,
                            int labelInx)
By returning one of the ANCHOR_* constants, specifies where on a text label's logical bounds box an anchor point lies. This text anchor point together with the node anchor point and label offset vector determines where, relative to the node, the text's logical bounds box is to be placed. The text's logical bounds box is placed such that the label offset vector plus the node anchor point equals the text anchor point.

By default this method always returns ANCHOR_CENTER. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.
See Also:
ANCHOR_CENTER, labelNodeAnchor(int, int), labelOffsetVectorX(int, int), labelOffsetVectorY(int, int)

labelNodeAnchor

public byte labelNodeAnchor(int node,
                            int labelInx)
By returning one of the ANCHOR_* constants, specifies where on the node's extents rectangle an anchor point lies. This node anchor point together with the text anchor point and label offset vector determines where, relative to the node, the text's logical bounds box is to be placed. The text's logical bounds box is placed such that the label offset vector plus the node anchor point equals the text anchor point.

By default this method always returns ANCHOR_CENTER. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.
See Also:
ANCHOR_CENTER, labelTextAnchor(int, int), labelOffsetVectorX(int, int), labelOffsetVectorY(int, int)

labelOffsetVectorX

public float labelOffsetVectorX(int node,
                                int labelInx)
Specifies the X component of the vector that separates a text anchor point from a node anchor point. This label offset vector together with the text anchor point and node anchor point determines where, relative to the node, the text's logical bounds box is to be placed. The text's logical bounds box is placed such that the label offset vector plus the node anchor point equals the text anchor point.

By default this method always returns zero. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.
See Also:
labelOffsetVectorY(int, int), labelTextAnchor(int, int), labelNodeAnchor(int, int)

labelOffsetVectorY

public float labelOffsetVectorY(int node,
                                int labelInx)
Specifies the Y component of the vector that separates a text anchor point from a node anchor point. This label offset vector together with the text anchor point and node anchor point determines where, relative to the node, the text's logical bounds box is to be placed. The text's logical bounds box is placed such that the label offset vector plus the node anchor point equals the text anchor point.

By default this method always returns zero. This method is only called by the rendering engine if labelCount(node) returns a value greater than zero.

Parameters:
labelInx - a value in the range [0, labelCount(node)-1] indicating which node label in question.
See Also:
labelOffsetVectorX(int, int), labelTextAnchor(int, int), labelNodeAnchor(int, int)

labelJustify

public byte labelJustify(int node,
                         int labelInx)
By returning one of the LABEL_WRAP_JUSTIFY_* constants, determines how to justify a node label spanning multiple lines. The choice made here does not affect the size of the logical bounding box of a node label's text. The lines of text are justified within that logical bounding box.

By default this method always returns LABEL_WRAP_JUSTIFY_CENTER. This return value is ignored if labelText(node, labelInx) returns a text string that does not span multiple lines.

See Also:
LABEL_WRAP_JUSTIFY_CENTER

graphicOffsetVectorX

public float graphicOffsetVectorX(int node,
                                  int graphicInx)
Specifies the X component of the vector that separates the location of a rendered graphic from the node's anchor point for that graphic. By default this method always returns zero. This method is only called by the rendering engine if graphicCount(node) returns a value greater than zero.

Parameters:
graphicInx - a value in the range [0, graphicCount(node)-1] indicating which node graphic in question.
See Also:
graphicOffsetVectorY(int, int), #graphicNodeAnchor(int, int)

graphicOffsetVectorY

public float graphicOffsetVectorY(int node,
                                  int graphicInx)
Specifies the Y component of the vector that separates the location of a rendered graphic from the node's anchor point for that graphic. By default this method always returns zero. This method is only called by the rendering engine if graphicCount(node) returns a value greater than zero.

Parameters:
graphicInx - a value in the range [0, graphicCount(node)-1] indicating which node graphic in question.
See Also:
graphicOffsetVectorX(int, int), #graphicNodeAnchor(int, int)

customGraphicCount

public int customGraphicCount(int node)
A thread-safe method returning the number of custom graphics associated with a given Node. If none are associated, zero is returned. NOTE: This method should be abstract, but since it isn't, any real use should override this method in a subclass.

Since:
Cytoscape 2.6
See Also:
customGraphics(int)

customGraphics

public Iterator<CustomGraphic> customGraphics(int node)
Return a non-null, read-only Iterator over all CustomGraphics contained in this Node. The Iterator will return each CustomGraphic in draw order. The Iterator cannot be used to modify the underlying set of CustomGraphics. NOTE: This method should be abstract, but since it isn't, any real use should override this method in a subclass.

Returns:
The CustomGraphics Iterator. If no CustomGraphics are associated with this Node, an empty Iterator is returned.
Throws:
UnsupportedOperationException - if an attempt is made to use the Iterator's remove() method.
Since:
Cytoscape 2.6
See Also:
customGraphicsLock(int)

customGraphicsLock

public Object customGraphicsLock(int node)
Return the object used for synchronizing custom graphics operations for a given Node. This is used in conjunction with the customGraphics() Iterator to allow iteration over the custom graphics without fear of the underlying CustomGraphics mutating. For example:
    NodeDetails nd = ...;
    synchronized (nd.customGraphicsLock(node)) {
       Iterator dNodeIt = nodeDetails.customGraphics (node);
       CustomGraphic cg = null;
       while (dNodeIt.hasNext()) {
          cg = dNodeIt.next();
          // DO STUFF WITH cg HERE.
       }
    }
 
NOTE: This method should be abstract, but since it isn't, any real use should override this method in a subclass.

Since:
Cytoscape 2.6

setSelected

public void setSelected(Integer node,
                        Boolean selected)
Used to set selected state of given node.

Parameters:
node - Integer
selected - Boolean

getSelected

public boolean getSelected(Integer node)
Used to get selected state of given node. If node does not exist in map, false is returned. Used in GraphRenderer.renderGraph() to provide rendering of selected nodes above unselected nodes.

Returns:
boolean

labelWidth

public double labelWidth(int node)
Returns the label width of the node. By default this method returns 100. Take note of certain constraints specified in GraphGraphics.drawNodeFull().


getNestedNetworkTexturePaint

public TexturePaint getNestedNetworkTexturePaint(int node)
Child class should ovrride this method to render correct Nexted Network Image.

Parameters:
node -
Returns:

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.