Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Diagram defaults



A diagram have several default parameters which allow to set default values for all nodes and edges created in this diagram.

The DiagramDefaults is accessible through the following methods:

Default properties

General default properties

Main Article: Node autosizing

The DiagramDefaults has the following general parameters:
  • autosized: The autosized property
  • padWidth: The width pad for the autosized property. It will be the width of the node box compare to the width of the text
  • padHeight: The height pad for the autosized property. It will be the height of the node box compare to the height of the text

Default properties on edges

The DiagramDefaults has the following parameters on edges:
  • arrowSource: The type for the edge arrows. The value is one of the enumeration states in the ArrowType interface
  • arrowTarget: The type for the edge arrows. The value is one of the enumeration states in the ArrowType interface
  • edgeLabelAutoRotate: True if the edge labels should autorotate
  • edgeLabelAutoFlip: True if the edge labels should flip
  • edgeFontSize: The font size for edges
  • edgeFontStyle: The font style for edges. The value is one of the enumeration states in the LabelStyle interface
  • edgeLabelPosition: The edge label position. The value is one of the enumeration states in the EdgeLabelPosition interface
  • edgeHasLabelDistance: True if by default the edges have a label distance
  • edgeLabelDistance: The edge label distance
  • edgeLabelAnchorX: The edge label X anchor
  • edgeLabelAnchorY: The edge label Y anchor
  • edgeColor: The edge color
  • edgeBorderWidth: The edge border width
  • edgeType: The edge type. The value is one of the enumeration states in the EdgeType interface
  • edgeSmoothed: True if the edges must have the smooth style

Default properties on regular nodes

The DiagramDefaults has the following parameters on regular nodes:
  • nodeFontSize: The font size for nodes
  • nodeFontStyle: The font style for nodes. The value is one of the enumeration states in the LabelStyle interface
  • nodeFillColor: The node fill color
  • nodeBorderColor: The node border color
  • nodeBorderWidth: The node border width
  • nodeBorderLineStyle: The node border line style. The value is one of the enumeration states in the LineStyle interface
  • nodeWidth: The node width[1]
    The nodeWidth and nodeHeight properties will have an effect only if the autosized property is set to false, else the node sizes will be automatically fitted to match their content
  • nodeHeight: The node height[1]
    The nodeWidth and nodeHeight properties will have an effect only if the autosized property is set to false, else the node sizes will be automatically fitted to match their content
  • nodeDropShadow: The node drop shadow (by default this is null, meaning that nodes have no drop shadow by default)

Default properties on group nodes

The DiagramDefaults has the following parameters on group nodes:
  • groupNodeFontSize: The font size for group nodes
  • groupNodeFontStyle: The font style for group nodes. The value is one of the enumeration states in the LabelStyle interface
  • groupNodeOpenedSizeType: The group node size type
  • groupNodePadding: The group node padding used to compute its size
  • groupNodeFillColor: The group node fill color
  • groupNodeBorderColor: The group node border color
  • groupNodeBorderWidth: The group node border width
  • groupNodeBorderLineStyle: The group node border line style. The value is one of the enumeration states in the LineStyle interface
  • groupNodeOpenedWidth: The group node width for the opened state
  • groupNodeOpenedHeight: The group node height for the opened state
  • groupNodeClosedWidth: The group node width for the closed state
  • groupNodeClosedHeight: The group node height for the closed state
  • groupDefaultRealizedState: The group node group realized state (true for opened, false for closed)
  • closedGroupInnerGraphDisplayEnabled: True if a small icon of the group content must be shown for the closed state

Resetting the defaults


DiagramDefaults.reset() method resets the defaults to their initial values.

Global defaults

The DiagramDefaults.GLOBAL static instance is a global defaults which will be used whenever you create a new diagram without specifying the defaults. For example:

Note that modifying the defaults after creation will not change the global defaults. For example:
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramDefaults defaults = diagram.getDefaults();
      defaults.edgeLabelAutoRotate = true; // the DiagramDefaults.GLOBAL has not changed
Modifying the DiagramDefaults.GLOBAL static instance defaults will apply for all the following diagram creation. For example:
      DiagramDefaults.GLOBAL.edgeLabelAutoRotate = true
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramDefaults defaults = diagram.getDefaults();
      // defaults.edgeLabelAutoRotate is true

Examples

Changing the default background for nodes

In the following example, we will change the default background color for nodes:
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramDefaults defaults = diagram.getDefaults();
      defaults.nodeFillColor = "#FFFFFF";

Having the labels alongside the edges

Main Article: Edge labels

In the following example, we set the default properties to have the labels alongside the edges:
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramDefaults defaults = diagram.getDefaults();
      defaults.edgeLabelAutoRotate = true;
      defaults.edgeLabelAutoFlip = true;

Autosizing the nodes

Main Article: Node autosizing

In the following example, the nodes will be autosized to enclose their text:
      GraphmlFactory factory = GraphmlFactory.getInstance();
      GraphmlDiagram diagram = factory.newDiagram();

      DiagramDefaults defaults = diagram.getDefaults();
      defaults.autosized = true;
      defaults.padWidth = 15;
      defaults.padHeight = 15;

Notes

  1. ^ [1] [2] The nodeWidth and nodeHeight properties will have an effect only if the autosized property is set to false, else the node sizes will be automatically fitted to match their content

See also


Categories: general

Copyright 2021 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence