|
org.netbeans.api.visual 2.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.ConnectionWidget
public class ConnectionWidget
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 java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConnectionWidget(Scene scene)
scene
- the sceneMethod Detail |
---|
public void notifyStateChanged(ObjectState previousState, ObjectState state)
notifyStateChanged
in class Widget
previousState
- the previous statestate
- the new statepublic final Stroke getStroke()
public final void setStroke(Stroke stroke)
stroke
- the strokepublic final Color getLineColor()
public final void setLineColor(Color lineColor)
lineColor
- the line color; if null, then the line color will be resolved from LookFeel of the scene.public final boolean isPaintControlPoints()
public final void setPaintControlPoints(boolean paintControlPoints)
paintControlPoints
- public final Anchor getSourceAnchor()
public final void setSourceAnchor(Anchor sourceAnchor)
sourceAnchor
- the source anchorpublic final Anchor getTargetAnchor()
public final void setTargetAnchor(Anchor targetAnchor)
targetAnchor
- the target anchorpublic Anchor.Entry getSourceAnchorEntry()
public Anchor.Entry getTargetAnchorEntry()
public AnchorShape getSourceAnchorShape()
public void setSourceAnchorShape(AnchorShape sourceAnchorShape)
sourceAnchorShape
- the source anchor shapepublic AnchorShape getTargetAnchorShape()
public void setTargetAnchorShape(AnchorShape targetAnchorShape)
targetAnchorShape
- the target anchor shapepublic PointShape getControlPointShape()
public void setControlPointShape(PointShape controlPointShape)
controlPointShape
- the control points shapepublic PointShape getEndPointShape()
public void setEndPointShape(PointShape endPointShape)
endPointShape
- the end points shapepublic final Router getRouter()
public final void setRouter(Router router)
router
- the path routerpublic List<Point> getControlPoints()
public Point getControlPoint(int index)
index
- index of the control point to return
public void setControlPoints(Collection<Point> controlPoints, boolean sceneLocations)
controlPoints
- the list of control pointssceneLocations
- 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 locationspublic void setConstraint(Widget childWidget, LayoutFactory.ConnectionWidgetLayoutAlignment alignment, float placementInPercentage)
childWidget
- the child widget for which the constraint is setalignment
- the alignment specified relatively to the origin pointplacementInPercentage
- the placement on a path in percentage of the path lengthpublic void setConstraint(Widget childWidget, LayoutFactory.ConnectionWidgetLayoutAlignment alignment, int placementAtDistance)
childWidget
- the child widget for which the constraint is setalignment
- the alignment specified relatively to the origin pointplacementAtDistance
- the placement on a path in pixels as a distance from the source anchorpublic void removeConstraint(Widget childWidget)
childWidget
- the child widgetpublic final void calculateRouting()
protected Rectangle calculateClientArea()
calculateClientArea
in class Widget
public boolean isValidated()
isValidated
in class Widget
public final boolean isRouted()
public final void reroute()
public final Point getFirstControlPoint()
public final Point getLastControlPoint()
public double getTargetAnchorShapeRotation()
public boolean isHitAt(Point localLocation)
localLocation
- the local locaytion
public final boolean isFirstControlPointHitAt(Point localLocation)
localLocation
- the local location
public final boolean isLastControlPointHitAt(Point localLocation)
localLocation
- the local location
public final int getControlPointHitAt(Point localLocation)
localLocation
- the local location
protected void paintWidget()
paintWidget
in class Widget
|
org.netbeans.api.visual 2.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |