Class GraphNode
java.lang.Object
com.codename1.graph.GraphNode
A box in a graph: a position and a size in world units, a label, and optionally ports and a group.
World units are pixels at zoom 1. The position is the top left corner and may be negative: a graph has no origin it must stay to the right of.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an input port.Adds an output port.Adds a port, as an input or an output by its direction.booleancontains(double px, double py) True when the world point lies inside the node.doubleThe horizontal centre.doubleThe vertical centre.A second line painted under the title, or null.The id of theGraphGroupthe node is drawn inside, or null.doubleThe height in world units.getId()The id, unique within the model.The input ports, in order.getLabel()The title painted on the node.The output ports, in order.The port with this id, or null.A key a renderer may map to a colour or a UIID, or null.Anything the application keeps with the node.doublegetWidth()The width in world units.doublegetX()The left edge in world units.doublegetY()The top edge in world units.booleanhasPorts()True when the node has any port.booleanisPinned()True when automatic arrangements must leave the node where it is.voidsetDescription(String description) Sets the second line.voidsetGroupId(String groupId) Puts the node in a group, or takes it out with null.voidSets the title.voidsetPinned(boolean pinned) Pins the node in place for automatic arrangements.voidsetPosition(double x, double y) Moves the node.voidsetSize(double width, double height) Resizes the node.voidsetStyleKey(String styleKey) Sets the style key.voidsetUserData(Object userData) Sets the application's data.
-
Constructor Details
-
GraphNode
-
GraphNode
-
-
Method Details
-
getId
The id, unique within the model. -
getLabel
The title painted on the node. -
setLabel
Sets the title. -
getDescription
A second line painted under the title, or null. -
setDescription
Sets the second line. -
getX
public double getX()The left edge in world units. -
getY
public double getY()The top edge in world units. -
getWidth
public double getWidth()The width in world units. -
getHeight
public double getHeight()The height in world units. -
getCenterX
public double getCenterX()The horizontal centre. -
getCenterY
public double getCenterY()The vertical centre. -
setPosition
public void setPosition(double x, double y) Moves the node. A model shown by a component is told throughGraphModel.moveNode, which calls this and notifies the listeners. -
setSize
public void setSize(double width, double height) Resizes the node. -
getGroupId
The id of theGraphGroupthe node is drawn inside, or null. -
setGroupId
Puts the node in a group, or takes it out with null. -
getStyleKey
A key a renderer may map to a colour or a UIID, or null. -
setStyleKey
Sets the style key. -
isPinned
public boolean isPinned()True when automatic arrangements must leave the node where it is. -
setPinned
public void setPinned(boolean pinned) Pins the node in place for automatic arrangements. -
getUserData
Anything the application keeps with the node. -
setUserData
Sets the application's data. -
addPort
-
addInput
-
addOutput
-
getInputs
-
getOutputs
-
hasPorts
public boolean hasPorts()True when the node has any port. -
getPort
-
contains
public boolean contains(double px, double py) True when the world point lies inside the node.
-