站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ConnectionWidget (Visual Library API) - NetBeans API Javadoc (Current Development Version)

org.netbeans.api.visual 2.2

org.netbeans.api.visual.widget
Class ConnectionWidget

java.lang.Object
  extended by org.netbeans.api.visual.widget.Widget
      extended by org.netbeans.api.visual.widget.ConnectionWidget
Direct Known Subclasses:
FreeConnectionWidget, VMDConnectionWidget

public class ConnectionWidget
extends Widget

This class represents a connection between two location. The locations are resolved by Anchors. The path of the connection is specified by control points which are resolved by Routers (DirectRouter is used by default).

The connection is rendered using the foreground color and a specified stroke. It also renders control points, end points (first and last control points) and anchors. The shape of points are defined by assigned AnchorShape and PointShape.

For speed optimalization, the connection widget are usually placed in the a separate layer widget that is rendered after the main layer with widgets (that used anchors depends on) is rendered.

Line color is defined by foregroundColor property. Note: If you are changing a state of the ConnectionWidget (e.g. using it as a representation of an object in ObjectScene, GraphScene or GraphPinScene classes, then the ConnectionWidget.notifyStateChanged method is automatically called. The built-in implementation of this method overrides foregroundColor based on a new state of the widget (the particular color is resolved by the LookFeel of the scene).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.netbeans.api.visual.widget.Widget
Widget.Dependency
 
Constructor Summary
ConnectionWidget(Scene scene)
          Creates a connection widget.
 
Method Summary
protected  Rectangle calculateClientArea()
          Calculates a client area of the connection widget.
 void calculateRouting()
          Forces path routing.
 Point getControlPoint(int index)
          Returns a location of control point at the specified index in the list of control points.
 int getControlPointHitAt(Point localLocation)
          Returns an index of a control point that is hit by the local location
 List<Point> getControlPoints()
          Returns a list of control points.
 PointShape getControlPointShape()
          Returns a point shape of control points of the connection widget.
 PointShape getEndPointShape()
          Returns a point shape of end points of the connection widget.
 Point getFirstControlPoint()
          Returns the first control point.
 Point getLastControlPoint()
          Returns the last control point.
 Color getLineColor()
          Returns line color of the widget.
 Router getRouter()
          Returns the control-points-based path router of the connection widget.
 Anchor getSourceAnchor()
          Returns a source anchor of the connection widget.
 Anchor.Entry getSourceAnchorEntry()
          Returns an anchor entry representing the source of the connection widget.
 AnchorShape getSourceAnchorShape()
          Returns an anchor shape of the source of the connection widget.
 Stroke getStroke()
          Returns a stroke of the connection widget.
 Anchor getTargetAnchor()
          Returns a target anchor of the connection widget.
 Anchor.Entry getTargetAnchorEntry()
          Returns an anchor entry representing the target of the connection widget.
 AnchorShape getTargetAnchorShape()
          Returns an anchor shape of the target of the connection widget.
 double getTargetAnchorShapeRotation()
          Returns the rotation of the target anchor shape.
 boolean isFirstControlPointHitAt(Point localLocation)
          Returns whether the local location hits the first control point (also meant to be the source anchor).
 boolean isHitAt(Point localLocation)
          Returns whether a specified local location is a part of the connection widget.
 boolean isLastControlPointHitAt(Point localLocation)
          Returns whether the local location hits the last control point (also meant to be the target anchor).
 boolean isPaintControlPoints()
          Returns whether the control (and end) points are painted
 boolean isRouted()
          Returns whether the connection widget is routed.
 boolean isValidated()
          Returns whether the connection widget is validated and routed.
 void notifyStateChanged(ObjectState previousState, ObjectState state)
          Implements the widget-state specific look of the widget.
protected  void paintWidget()
          Paints the connection widget (the path, the anchor shapes, the control points, the end points).
 void removeConstraint(Widget childWidget)
          Removes a constraint for a child widget.
 void reroute()
          Schedules the connection widget for re-routing its path.
 void setConstraint(Widget childWidget, LayoutFactory.ConnectionWidgetLayoutAlignment alignment, float placementInPercentage)
          Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.
 void setConstraint(Widget childWidget, LayoutFactory.ConnectionWidgetLayoutAlignment alignment, int placementAtDistance)
          Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.
 void setControlPoints(Collection<Point> controlPoints, boolean sceneLocations)
          Sets control points.
 void setControlPointShape(PointShape controlPointShape)
          Sets a point shape of control points of the connection widget.
 void setEndPointShape(PointShape endPointShape)
          Sets a point shape of end points of the connection widget.
 void setLineColor(Color lineColor)
          Sets a line color of the widget.
 void setPaintControlPoints(boolean paintControlPoints)
          Sets whether the control (and end) points are painted
 void setRouter(Router router)
          Sets a control-points-based path router of the connection widget.
 void setSourceAnchor(Anchor sourceAnchor)
          Sets a source anchor of the connection widget.
 void setSourceAnchorShape(AnchorShape sourceAnchorShape)
          Sets the anchor shape of the source of the connection widget.
 void setStroke(Stroke stroke)
          Sets a stroke.
 void setTargetAnchor(Anchor targetAnchor)
          Sets a target anchor of the connection widget.
 void setTargetAnchorShape(AnchorShape targetAnchorShape)
          Sets the anchor shape of the target of the connection widget.
 
Methods inherited from class org.netbeans.api.visual.widget.Widget
addChild, addChild, addChild, addChild, addChildren, addDependency, bringToBack, bringToFront, convertLocalToScene, convertLocalToScene, convertSceneToLocal, convertSceneToLocal, createActions, equals, getAccessibleContext, getActions, getActions, getBackground, getBorder, getBounds, getChildConstraint, getChildren, getClientArea, getCursor, getFont, getForeground, getGraphics, getLayout, getLocation, getLookup, getMaximumSize, getMinimumSize, getParentWidget, getPreferredBounds, getPreferredLocation, getPreferredSize, getScene, getState, getToolTipText, hashCode, isCheckClipping, isEnabled, isOpaque, isPreferredBoundsSet, isRepaintRequiredForRevalidating, isVisible, notifyAdded, notifyRemoved, paint, paintBackground, paintBorder, paintChildren, removeChild, removeChildren, removeChildren, removeDependency, removeFromParent, repaint, resolveBounds, revalidate, revalidate, setAccessibleContext, setBackground, setBorder, setBorder, setCheckClipping, setChildConstraint, setCursor, setEnabled, setFont, setForeground, setLayout, setMaximumSize, setMinimumSize, setOpaque, setPreferredBounds, setPreferredLocation, setPreferredSize, setState, setToolTipText, setVisible
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionWidget

public ConnectionWidget(Scene scene)
Creates a connection widget.

Parameters:
scene - the scene
Method Detail

notifyStateChanged

public void notifyStateChanged(ObjectState previousState,
                               ObjectState state)
Implements the widget-state specific look of the widget.

Overrides:
notifyStateChanged in class Widget
Parameters:
previousState - the previous state
state - the new state

getStroke

public final Stroke getStroke()
Returns a stroke of the connection widget.

Returns:
the stroke

setStroke

public final void setStroke(Stroke stroke)
Sets a stroke.

Parameters:
stroke - the stroke

getLineColor

public final Color getLineColor()
Returns line color of the widget.

Returns:
the line color; null if no line color is specified

setLineColor

public final void setLineColor(Color lineColor)
Sets a line color of the widget.

Parameters:
lineColor - the line color; if null, then the line color will be resolved from LookFeel of the scene.

isPaintControlPoints

public final boolean isPaintControlPoints()
Returns whether the control (and end) points are painted

Returns:
true, if the control points (and end points) are painted

setPaintControlPoints

public final void setPaintControlPoints(boolean paintControlPoints)
Sets whether the control (and end) points are painted

Parameters:
paintControlPoints -

getSourceAnchor

public final Anchor getSourceAnchor()
Returns a source anchor of the connection widget.

Returns:
the source anchor

setSourceAnchor

public final void setSourceAnchor(Anchor sourceAnchor)
Sets a source anchor of the connection widget.

Parameters:
sourceAnchor - the source anchor

getTargetAnchor

public final Anchor getTargetAnchor()
Returns a target anchor of the connection widget.

Returns:
the target anchor

setTargetAnchor

public final void setTargetAnchor(Anchor targetAnchor)
Sets a target anchor of the connection widget.

Parameters:
targetAnchor - the target anchor

getSourceAnchorEntry

public Anchor.Entry getSourceAnchorEntry()
Returns an anchor entry representing the source of the connection widget.

Returns:
the anchor entry representing the source of the connection widget

getTargetAnchorEntry

public Anchor.Entry getTargetAnchorEntry()
Returns an anchor entry representing the target of the connection widget.

Returns:
the anchor entry representing the target of the connection widget

getSourceAnchorShape

public AnchorShape getSourceAnchorShape()
Returns an anchor shape of the source of the connection widget.

Returns:
the source anchor shape

setSourceAnchorShape

public void setSourceAnchorShape(AnchorShape sourceAnchorShape)
Sets the anchor shape of the source of the connection widget.

Parameters:
sourceAnchorShape - the source anchor shape

getTargetAnchorShape

public AnchorShape getTargetAnchorShape()
Returns an anchor shape of the target of the connection widget.

Returns:
the target anchor shape

setTargetAnchorShape

public void setTargetAnchorShape(AnchorShape targetAnchorShape)
Sets the anchor shape of the target of the connection widget.

Parameters:
targetAnchorShape - the target anchor shape

getControlPointShape

public PointShape getControlPointShape()
Returns a point shape of control points of the connection widget.

Returns:
the control points shape

setControlPointShape

public void setControlPointShape(PointShape controlPointShape)
Sets a point shape of control points of the connection widget.

Parameters:
controlPointShape - the control points shape

getEndPointShape

public PointShape getEndPointShape()
Returns a point shape of end points of the connection widget.

Returns:
the end points shape

setEndPointShape

public void setEndPointShape(PointShape endPointShape)
Sets a point shape of end points of the connection widget.

Parameters:
endPointShape - the end points shape

getRouter

public final Router getRouter()
Returns the control-points-based path router of the connection widget.

Returns:
the path router

setRouter

public final void setRouter(Router router)
Sets a control-points-based path router of the connection widget.

Parameters:
router - the path router

getControlPoints

public List<Point> getControlPoints()
Returns a list of control points.

Returns:
the list of control points

getControlPoint

public Point getControlPoint(int index)
Returns a location of control point at the specified index in the list of control points.

Parameters:
index - index of the control point to return
Returns:
the point; null if the control point does not exist

setControlPoints

public void setControlPoints(Collection<Point> controlPoints,
                             boolean sceneLocations)
Sets control points.

Parameters:
controlPoints - the list of control points
sceneLocations - if true, then controlPoints argyment is taken as a list of scene locations; if false, then controlPoints argument is taken as a list of local locations

setConstraint

public void setConstraint(Widget childWidget,
                          LayoutFactory.ConnectionWidgetLayoutAlignment alignment,
                          float placementInPercentage)
Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.

Parameters:
childWidget - the child widget for which the constraint is set
alignment - the alignment specified relatively to the origin point
placementInPercentage - the placement on a path in percentage of the path length

setConstraint

public void setConstraint(Widget childWidget,
                          LayoutFactory.ConnectionWidgetLayoutAlignment alignment,
                          int placementAtDistance)
Sets a constraint for a child widget when ConnectionWidgetLayout (by default) is used.

Parameters:
childWidget - the child widget for which the constraint is set
alignment - the alignment specified relatively to the origin point
placementAtDistance - the placement on a path in pixels as a distance from the source anchor

removeConstraint

public void removeConstraint(Widget childWidget)
Removes a constraint for a child widget.

Parameters:
childWidget - the child widget

calculateRouting

public final void calculateRouting()
Forces path routing.


calculateClientArea

protected Rectangle calculateClientArea()
Calculates a client area of the connection widget.

Overrides:
calculateClientArea in class Widget
Returns:
the calculated client area

isValidated

public boolean isValidated()
Returns whether the connection widget is validated and routed.

Overrides:
isValidated in class Widget
Returns:
true, if the connection widget is validated and routed

isRouted

public final boolean isRouted()
Returns whether the connection widget is routed.

Returns:
true if the connection widget is routed

reroute

public final void reroute()
Schedules the connection widget for re-routing its path.


getFirstControlPoint

public final Point getFirstControlPoint()
Returns the first control point.

Returns:
the first control point; null, if list of control points is empty

getLastControlPoint

public final Point getLastControlPoint()
Returns the last control point.

Returns:
the last control point; null, if list of control points is empty

getTargetAnchorShapeRotation

public double getTargetAnchorShapeRotation()
Returns the rotation of the target anchor shape.

Returns:
the target anchor shape rotation

isHitAt

public boolean isHitAt(Point localLocation)
Returns whether a specified local location is a part of the connection widget. It checks whether the location is close to the control-points-based path (up to 4px from the line), close to the anchors (defined by AnchorShape) or close to the control points (PointShape).

Overrides:
isHitAt in class Widget
Parameters:
localLocation - the local locaytion
Returns:
true, if the location is a part of the connection widget

isFirstControlPointHitAt

public final boolean isFirstControlPointHitAt(Point localLocation)
Returns whether the local location hits the first control point (also meant to be the source anchor).

Parameters:
localLocation - the local location
Returns:
true if it hits the first control point

isLastControlPointHitAt

public final boolean isLastControlPointHitAt(Point localLocation)
Returns whether the local location hits the last control point (also meant to be the target anchor).

Parameters:
localLocation - the local location
Returns:
true if it hits the last control point

getControlPointHitAt

public final int getControlPointHitAt(Point localLocation)
Returns an index of a control point that is hit by the local location

Parameters:
localLocation - the local location
Returns:
the index; -1 if no control point was hit

paintWidget

protected void paintWidget()
Paints the connection widget (the path, the anchor shapes, the control points, the end points).

Overrides:
paintWidget in class Widget

org.netbeans.api.visual 2.2

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.