Class DefaultGraphNodeRenderer

java.lang.Object
com.codename1.ui.graph.DefaultGraphNodeRenderer
All Implemented Interfaces:
GraphNodeRenderer

public class DefaultGraphNodeRenderer extends Object implements GraphNodeRenderer

Paints a node as a rounded card: a coloured strip on the leading edge, the label, the description under it, and the ports on the sides with their labels inside the card.

Colours come from the NodeGraphNode UIID (background, text) and NodeGraphNodeSelected (the outline of a selected node), ports from NodeGraphPort. A node's style key picks its strip colour from setAccent; a node without one uses the selection colour.

  • Constructor Details

    • DefaultGraphNodeRenderer

      public DefaultGraphNodeRenderer()
  • Method Details

    • setAccent

      public void setAccent(String styleKey, int rgb)
      Maps a node style key to the colour of its strip and its ports.
    • getAccent

      public int getAccent(String styleKey, int fallback)
      The colour of a style key, or fallback when none was set.
    • paintNode

      public void paintNode(Graphics g, NodeGraph graph, GraphNode node, int x, int y, int w, int h, boolean selected)
      Description copied from interface: GraphNodeRenderer

      Paints node into the rectangle.

      Parameters
      • g: the graphics, with the colour and alpha the renderer may change
      • graph: the component, for its zoom and its port geometry
      • node: the node
      • x, y, w, h: the node on screen
      • selected: true when the node is in the selection
      Specified by:
      paintNode in interface GraphNodeRenderer