Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class GraphNode

  1. Object
  2. 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.

Constructors

public GraphNode(String id, String label)A node of the default size, 160 by 64, at the origin.
public GraphNode(String id, String label, double x, double y, double width, double height)A node at a position.

Methods

public String getId()The id, unique within the model.
public String getLabel()The title painted on the node.
public void setLabel(String label)Sets the title.
public String getDescription()A second line painted under the title, or null.
public void setDescription(String description)Sets the second line.
public double getX()The left edge in world units.
public double getY()The top edge in world units.
public double getWidth()The width in world units.
public double getHeight()The height in world units.
public double getCenterX()The horizontal centre.
public double getCenterY()The vertical centre.
public void setPosition(double x, double y)Moves the node.
public void setSize(double width, double height)Resizes the node.
public String getGroupId()The id of the GraphGroup the node is drawn inside, or null.
public void setGroupId(String groupId)Puts the node in a group, or takes it out with null.
public String getStyleKey()A key a renderer may map to a colour or a UIID, or null.
public void setStyleKey(String styleKey)Sets the style key.
public String getShape()The outline the node is drawn with, one of the GraphShapes names or a name registered with com.codename1.ui.graph.GraphShapeRegistry.
public GraphNode setShape(String shape)Sets the outline, for instance GraphShapes.DECISION for the diamond of a flow chart.
public boolean isPinned()True when automatic arrangements must leave the node where it is.
public void setPinned(boolean pinned)Pins the node in place for automatic arrangements.
public Object getUserData()Anything the application keeps with the node.
public void setUserData(Object userData)Sets the application’s data.
public GraphNode addPort(GraphPort port)Adds a port, as an input or an output by its direction.
public GraphNode addInput(String id, String label, String type)Adds an input port.
public GraphNode addOutput(String id, String label, String type)Adds an output port.
public List<GraphPort> getInputs()The input ports, in order.
public List<GraphPort> getOutputs()The output ports, in order.
public boolean hasPorts()True when the node has any port.
public GraphPort getInput(String portId)The input port with this id, or null.
public GraphPort getOutput(String portId)The output port with this id, or null.
public GraphPort getPort(String portId)The port with this id, inputs searched first, or null.
public GraphNode copy(String newId)A node like this one under another id: the same label, bounds, shape, style, group and ports, with their values, and the same user data object.
public boolean contains(double px, double py)True when the world point lies inside the node’s bounds.

Inherited methods

Constructor details

GraphNode

public GraphNode(String id, String label)
A node of the default size, 160 by 64, at the origin.

GraphNode

public GraphNode(String id, String label, double x, double y, double width, double height)
A node at a position.

Method details

getId

public String getId()
The id, unique within the model.

getLabel

public String getLabel()
The title painted on the node.

setLabel

public void setLabel(String label)
Sets the title.

getDescription

public String getDescription()
A second line painted under the title, or null.

setDescription

public void setDescription(String description)
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 through GraphModel.moveNode, which calls this and notifies the listeners.

setSize

public void setSize(double width, double height)
Resizes the node.

getGroupId

public String getGroupId()
The id of the GraphGroup the node is drawn inside, or null.

setGroupId

public void setGroupId(String groupId)
Puts the node in a group, or takes it out with null.

getStyleKey

public String getStyleKey()
A key a renderer may map to a colour or a UIID, or null.

setStyleKey

public void setStyleKey(String styleKey)
Sets the style key.

getShape

public String getShape()
The outline the node is drawn with, one of the GraphShapes names or a name registered with com.codename1.ui.graph.GraphShapeRegistry. Null, the default, is the view’s ordinary box.

setShape

public GraphNode setShape(String shape)
Sets the outline, for instance GraphShapes.DECISION for the diamond of a flow chart.

Returns

this node, so calls can be chained

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

public Object getUserData()
Anything the application keeps with the node.

setUserData

public void setUserData(Object userData)
Sets the application’s data.

addPort

public GraphNode addPort(GraphPort port)
Adds a port, as an input or an output by its direction.

Returns

this node, so calls can be chained

addInput

public GraphNode addInput(String id, String label, String type)
Adds an input port.

addOutput

public GraphNode addOutput(String id, String label, String type)
Adds an output port.

getInputs

public List<GraphPort> getInputs()
The input ports, in order. The list is the node’s own; do not change it.

getOutputs

public List<GraphPort> getOutputs()
The output ports, in order. The list is the node’s own; do not change it.

hasPorts

public boolean hasPorts()
True when the node has any port.

getInput

public GraphPort getInput(String portId)
The input port with this id, or null. An input and an output may share an id, so an edge’s target port is looked up here and its source port in getOutput(String).

getOutput

public GraphPort getOutput(String portId)
The output port with this id, or null.

getPort

public GraphPort getPort(String portId)
The port with this id, inputs searched first, or null.

copy

public GraphNode copy(String newId)
A node like this one under another id: the same label, bounds, shape, style, group and ports, with their values, and the same user data object. For pasting and duplicating.

contains

public boolean contains(double px, double py)
True when the world point lies inside the node’s bounds.