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 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 getPort(String portId)The port with this id, or null.
public boolean contains(double px, double py)True when the world point lies inside the node.

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.

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.

getPort

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

contains

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