JavaFX Utils

Connectable

Component to connect 2 Node objects.

For this component it was created some other classes to permits some extensibility.

  • Coordinates : class which contains X and Y fields that can be accessed via getters.
  • Connector : component to create connector between 2 Node objects. There is a ConnectorPointer with a triangle at the end of line to create an arrow.
  • ConnectorTips : class which contains 2 Node objects. This objects will be the tips of connector.
  • IConnection : responsible for supplying the coordinates of existent connections points. There are 4 implementations.

Line used with Connector should be child of Pane because it is added to Parent the init and end tips of line.

Constructors

	public Connectable(Connector connector, IConnection initPoint, IConnection endPoint)
					

There are more constructors with different parameters, but all will internally call this first one.

Variations :

  • Constructors that receive Line line will use it to instantiate Connector.
  • Constructors that receive IComponent<Line> component will obtain Line from component.getNode().
  • Constructors that don't receive any of the above options will instantiate Line via empty constructor.
  • Constructors that receive Node initNode and Node endNode will use them to instantiate Connection.
  • Constructors that receive IComponent<?> initComponent and IComponent<?> endComponent will obtain initNode and endNode from initComponent.getNode() and endComponent.getNode() respectively.
	public Connectable(Connector connector, Node initNode, Node endNode)
					
	public Connectable(Connector connector, IComponent initComponent, IComponent endComponent)
					
	public Connectable(Line line, IConnection initPoint, IConnection endPoint)
					
	public Connectable(Line line, Node initNode, Node endNode)
					
	public Connectable(Line line, IComponent initComponent, IComponent endComponent)
					
	public Connectable(IComponent component, IConnection initPoint, IConnection endPoint)
					
	public Connectable(IComponent component, Node initNode, Node endNode)
					
	public Connectable(IComponent component, IComponent initComponent, IComponent endComponent)
					
	public Connectable(IConnection initPoint, IConnection endPoint)
					
	public Connectable(Node initNode, Node endNode)
					
	public Connectable(IComponent initComponent, IComponent endComponent)
					

Usage

	Pane pane;
	Button buttonA;
	Button buttonB;

	Connectable connectable = new Connectable(buttonA, buttonB);
	connectable.connect();

	pane.getChildren().add(connectable.getNode());
				

Links