org.netbeans.api.visual.widget.ConnectionWidget Java Examples
The following examples show how to use
org.netbeans.api.visual.widget.ConnectionWidget.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionWidgetCollisionsCollectorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testConnectionWidgetCollisionsCollector () { Scene scene = new Scene (); final ConnectionWidget widget = new ConnectionWidget (scene); widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100))); widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200))); widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new ConnectionWidgetCollisionsCollector () { public void collectCollisions (ConnectionWidget connectionWidget, List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) { getRef ().println ("ConnectionWidgetCollisionsCollector invoked - is widget valid: " + (connectionWidget == widget)); } })); scene.addChild (widget); JFrame frame = showFrame (scene); frame.setVisible(false); frame.dispose (); compareReferenceFiles (); }
Example #2
Source File: ConnectionWidgetCollisionsCollectorTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCollisionsCollector () { Scene scene = new Scene (); ConnectionWidget widget = new ConnectionWidget (scene); widget.setSourceAnchor (AnchorFactory.createFixedAnchor (new Point (100, 100))); widget.setTargetAnchor (AnchorFactory.createFixedAnchor (new Point (300, 200))); widget.setRouter (RouterFactory.createOrthogonalSearchRouter (new CollisionsCollector() { public void collectCollisions (List<Rectangle> verticalCollisions, List<Rectangle> horizontalCollisions) { getRef ().println ("CollisionsCollector invoked"); } })); scene.addChild (widget); JFrame frame = showFrame (scene); frame.setVisible(false); frame.dispose (); compareReferenceFiles (); }
Example #3
Source File: FreeRouter.java From netbeans with Apache License 2.0 | 6 votes |
public List<Point> routeConnection(ConnectionWidget widget) { ArrayList<Point> list = new ArrayList<Point> (); Anchor sourceAnchor = widget.getSourceAnchor(); Anchor targetAnchor = widget.getTargetAnchor(); if (sourceAnchor == null || targetAnchor == null) return Collections.emptyList(); list.add(sourceAnchor.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation()); List<Point> oldControlPoints = widget.getControlPoints (); if(oldControlPoints !=null) { ArrayList<Point> oldList = new ArrayList<Point> (oldControlPoints); oldList.remove(widget.getFirstControlPoint()); oldList.remove(widget.getLastControlPoint()); list.addAll(oldList); } list.add(targetAnchor.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation()); return list; }
Example #4
Source File: MoveControlPointAction.java From netbeans with Apache License 2.0 | 6 votes |
@Override public State mousePressed (Widget widget, WidgetMouseEvent event) { if (isLocked ()) return State.createLocked (widget, this); if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) { if (widget instanceof ConnectionWidget) { ConnectionWidget conn = (ConnectionWidget) widget; controlPointIndex = conn.getControlPointHitAt (event.getPoint ()); if (controlPointIndex >= 0) { movingWidget = conn; controlPointLocation = new Point (conn.getControlPoints (). get (controlPointIndex)); lastLocation = new Point (event.getPoint ()); return State.createLocked (widget, this); } else { movingWidget = null; } } } return State.REJECTED; }
Example #5
Source File: AddRemoveControlPointAction.java From netbeans with Apache License 2.0 | 6 votes |
/** * Adds or removes a control point on a specified location * @param widget the connection widget * @param localLocation the local location */ private void addRemoveControlPoint (ConnectionWidget widget, Point localLocation) { ArrayList<Point> list = new ArrayList<Point> (widget.getControlPoints ()); if (!removeControlPoint (localLocation, list, deleteSensitivity)) { Point exPoint = null; int index = 0; for (Point elem : list) { if (exPoint != null) { Line2D l2d = new Line2D.Double (exPoint, elem); if (l2d.ptSegDist (localLocation) < createSensitivity) { list.add (index, localLocation); break; } } exPoint = elem; index++; } } if (routingPolicy != null) widget.setRoutingPolicy (routingPolicy); widget.setControlPoints (list, false); }
Example #6
Source File: AddRemoveControlPointAction.java From netbeans with Apache License 2.0 | 5 votes |
public State mouseClicked(Widget widget, WidgetMouseEvent event) { if(event.getButton()==MouseEvent.BUTTON1 && event.getClickCount()==2 && widget instanceof ConnectionWidget) { addRemoveControlPoint ((ConnectionWidget) widget, event.getPoint ()); return State.CONSUMED; } return State.REJECTED; }
Example #7
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns control point of source widget. * @return Point representing control point of source widget. */ public Point getSourceControlPoint() { return (Point) runMapping(new MapAction("getFirstControlPoint") { public Object map() { return ((ConnectionWidget) widget).getFirstControlPoint(); } }); }
Example #8
Source File: AnchorNotificationTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testNotify () { StringBuffer log = new StringBuffer (); Scene scene = new Scene (); Widget w = new Widget (scene); scene.addChild (w); ConnectionWidget c = new ConnectionWidget (scene); scene.addChild (c); TestAnchor testAnchor = new TestAnchor (w, log); c.setSourceAnchor (testAnchor); c.setTargetAnchor (testAnchor); JFrame frame = showFrame (scene); c.setSourceAnchor (null); c.setTargetAnchor (null); scene.validate (); frame.setVisible (false); frame.dispose (); assertEquals (log.toString (), "notifyEntryAdded\n" + "notifyUsed\n" + "notifyRevalidate\n" + "notifyEntryAdded\n" + "notifyRevalidate\n" + "notifyRevalidate\n" + "compute\n" + "compute\n" + "notifyEntryRemoved\n" + "notifyRevalidate\n" + "notifyEntryRemoved\n" + "notifyUnused\n" + "notifyRevalidate\n" ); }
Example #9
Source File: BasicTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testShow () { Scene scene = new Scene (); LayerWidget mainLayer = new LayerWidget (scene); scene.addChild(mainLayer); Widget w1 = new Widget (scene); w1.setBorder (BorderFactory.createLineBorder ()); w1.setPreferredLocation (new Point (100, 100)); w1.setPreferredSize (new Dimension (40, 20)); mainLayer.addChild(w1); Widget w2 = new Widget (scene); w2.setBorder (BorderFactory.createLineBorder ()); w2.setPreferredLocation (new Point (200, 100)); w2.setPreferredSize (new Dimension (40, 20)); mainLayer.addChild(w2); LayerWidget connLayer = new LayerWidget (scene); scene.addChild(connLayer); ConnectionWidget conn = new ConnectionWidget(scene); conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(w1)); conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(w2)); connLayer.addChild(conn); Color color = (Color) (new DefaultLookFeel()).getBackground(); assertScene (scene, color, new Rectangle (99, 99, 42, 22), new Rectangle (199, 99, 42, 22), new Rectangle (138, 108, 64, 4) ); }
Example #10
Source File: ControlFlowScene.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected Widget attachEdgeWidget(InputBlockEdge edge) { ConnectionWidget w = new BlockConnectionWidget(this, edge); w.setRouter(RouterFactory.createDirectRouter()); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); edgeLayer.addChild(w); return w; }
Example #11
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns index-th control point. * @param index index of requested control point * @return Point representing control point of source widget. */ public Point getControlPoint(final int index) { return (Point) runMapping(new MapAction("getControlPoint") { public Object map() { return ((ConnectionWidget) widget).getControlPoint(index); } }); }
Example #12
Source File: ReconnectAction.java From netbeans with Apache License 2.0 | 5 votes |
public State mousePressed (Widget widget, WidgetMouseEvent event) { if (isLocked ()) return State.createLocked (widget, this); if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) { if (widget instanceof ConnectionWidget) { ConnectionWidget conn = (ConnectionWidget) widget; int index = conn.getControlPointHitAt (event.getPoint ()); List<Point> controlPoints = conn.getControlPoints (); if (index == 0 && provider.isSourceReconnectable (conn)) { reconnectingSource = true; } else if (controlPoints != null && index == controlPoints.size () - 1 && provider.isTargetReconnectable (conn)) { reconnectingSource = false; } else { return State.REJECTED; } floatPoint = new Point (event.getPoint ()); replacementWidget = null; connectionWidget = conn; provider.reconnectingStarted (conn, reconnectingSource); if (reconnectingSource) originalAnchor = connectionWidget.getSourceAnchor (); else originalAnchor = connectionWidget.getTargetAnchor (); return State.createLocked (widget, this); } } return State.REJECTED; }
Example #13
Source File: FreeMoveControlPointProvider.java From netbeans with Apache License 2.0 | 5 votes |
public List<Point> locationSuggested(ConnectionWidget connectionWidget, int index, Point suggestedLocation) { List<Point> controlPoints = connectionWidget.getControlPoints(); int cpSize=controlPoints.size()-1; ArrayList<Point> list = new ArrayList<Point> (controlPoints); if (index <= 0 || index >= cpSize)return null; if(index==1)list.set(0,connectionWidget.getSourceAnchor().compute(connectionWidget.getSourceAnchorEntry()).getAnchorSceneLocation()); if(index==cpSize - 1) list.set(cpSize,connectionWidget.getTargetAnchor().compute(connectionWidget.getTargetAnchorEntry()).getAnchorSceneLocation()); list.set(index, suggestedLocation); return list; }
Example #14
Source File: ConnectionWidgetLayout.java From netbeans with Apache License 2.0 | 5 votes |
private Rectangle getTargetBounds(ConnectionWidget connectionWidget) { Widget target = connectionWidget.getTargetAnchor().getRelatedWidget(); if (target == null) return null; Point targetLocation = target.getLocation(); Rectangle targetArea = target.getClientArea(); return new Rectangle(targetLocation, targetArea.getSize()); }
Example #15
Source File: ConnectionWidgetLayout.java From netbeans with Apache License 2.0 | 5 votes |
private Rectangle getSourceBounds(ConnectionWidget connectionWidget) { Widget source = connectionWidget.getSourceAnchor().getRelatedWidget(); if (source == null) return null; Point sourceLocation = source.getLocation(); Rectangle clientArea = source.getClientArea(); return new Rectangle(sourceLocation, clientArea.getSize()); }
Example #16
Source File: ConnectionWidgetLayout.java From netbeans with Apache License 2.0 | 5 votes |
private void layoutSingleChildAt (Point linePoint, ConnectionWidgetLayoutAlignment alignment, ConnectionWidget connectionWidget, Widget childWidget) { Rectangle preferredBounds = childWidget.getPreferredBounds (); Point referencePoint = getReferencePointForAdjustedAlignment (alignment, preferredBounds); Point location = childWidget.getPreferredLocation (); if (location != null) referencePoint.translate (-location.x, -location.y); childWidget.resolveBounds (new Point (linePoint.x - referencePoint.x, linePoint.y - referencePoint.y), preferredBounds); }
Example #17
Source File: DefaultAnchorShapeResolver.java From netbeans with Apache License 2.0 | 5 votes |
public DefaultAnchorShapeResolver(ConnectionWidget connection, ConnectionEnd attachedTo, Widget attachedWidget) { this.connection = connection; this.attachedEnd = attachedTo; this.attachedWidget = attachedWidget; }
Example #18
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns control point of target widget. * @return Point representing control point of target widget. */ public Point getTargetControlPoint() { return (Point) runMapping(new MapAction("getLastControlPoint") { public Object map() { return ((ConnectionWidget) widget).getLastControlPoint(); } }); }
Example #19
Source File: ControlFlowScene.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected Widget attachEdgeWidget(InputBlockEdge edge) { ConnectionWidget w = new BlockConnectionWidget(this, edge); w.setRouter(RouterFactory.createDirectRouter()); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); edgeLayer.addChild(w); return w; }
Example #20
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns list of control points. * @return List<Point> of control points */ @SuppressWarnings("unchecked") public List<Point> getControlPoints() { return (List<Point>) runMapping(new MapAction("getControlPoints") { public Object map() { return ((ConnectionWidget) widget).getControlPoints(); } }); }
Example #21
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns WidgetOperator of source widget of this connection. * @return WidgetOperator instance of source widget of this connection. */ public WidgetOperator getSourceWidgetOperator() { return new WidgetOperator((Widget) runMapping(new MapAction("getSourceAnchor().getRelatedWidget()") { public Object map() { return ((ConnectionWidget) widget).getSourceAnchor().getRelatedWidget(); } })); }
Example #22
Source File: ConnectionWidgetOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns WidgetOperator of target widget of this connection. * @return WidgetOperator instance of target widget of this connection. */ public WidgetOperator getTargetWidgetOperator() { return new WidgetOperator((Widget) runMapping(new MapAction("getTargetAnchor().getRelatedWidget()") { public Object map() { return ((ConnectionWidget) widget).getTargetAnchor().getRelatedWidget(); } })); }
Example #23
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
protected Widget attachEdgeWidget(String edge) { ConnectionWidget connection = new ConnectionWidget(this); connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); connection.setEndPointShape(PointShape.SQUARE_FILLED_BIG); connection.getActions().addAction(createObjectHoverAction()); connection.getActions().addAction(createSelectAction()); connection.getActions().addAction(reconnectAction); connectionLayer.addChild(connection); return connection; }
Example #24
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
public ConnectorState isReplacementWidget(ConnectionWidget connectionWidget, Widget replacementWidget, boolean reconnectingSource) { Object object = findObject(replacementWidget); replacementNode = isNode(object) ? (String) object : null; if (replacementNode != null) { return ConnectorState.ACCEPT; } return object != null ? ConnectorState.REJECT_AND_STOP : ConnectorState.REJECT; }
Example #25
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
public void reconnect(ConnectionWidget connectionWidget, Widget replacementWidget, boolean reconnectingSource) { if (replacementWidget == null) { removeEdge(edge); } else if (reconnectingSource) { setEdgeSource(edge, replacementNode); } else { setEdgeTarget(edge, replacementNode); } }
Example #26
Source File: ConnectionWrapperLayout.java From netbeans with Apache License 2.0 | 5 votes |
private static final void resetLabelConstraint(ConnectionWidget connectionWidget, LabelWidget label) { assert connectionWidget != null; if (label != null) { connectionWidget.removeConstraint(label); connectionWidget.removeChild(label); Anchor sourceAnchor = connectionWidget.getSourceAnchor(); Entry sourceAnchorEntry = connectionWidget.getSourceAnchorEntry(); assert sourceAnchor != null; assert sourceAnchorEntry != null; if (sourceAnchor != null && sourceAnchorEntry != null) { EnumSet<Anchor.Direction> directions = sourceAnchor.compute(sourceAnchorEntry).getDirections(); if (directions.contains(Anchor.Direction.TOP)) { label.setOrientation(LabelWidget.Orientation.ROTATE_90); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 10); } else if (directions.contains(Anchor.Direction.BOTTOM)) { label.setOrientation(LabelWidget.Orientation.ROTATE_90); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.BOTTOM_RIGHT, 10); } else if (directions.contains(Anchor.Direction.RIGHT)) { connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_RIGHT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } else { connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_LEFT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } } else { LogRecord record = new LogRecord(Level.FINE, "Problems Reseting Label Constraint"); record.setSourceClassName("ConnectionWrapperLayout"); record.setSourceMethodName("resetLabelConstraint"); record.setParameters(new Object[]{connectionWidget, label, new Date()}); LOGGER.log(record); connectionWidget.setConstraint(label, LayoutFactory.ConnectionWidgetLayoutAlignment.TOP_LEFT, 10); label.setOrientation(LabelWidget.Orientation.NORMAL); } connectionWidget.addChild(label); } }
Example #27
Source File: ControlFlowScene.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected Widget attachEdgeWidget(InputBlockEdge edge) { ConnectionWidget w = new BlockConnectionWidget(this, edge); w.setRouter(RouterFactory.createDirectRouter()); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); edgeLayer.addChild(w); return w; }
Example #28
Source File: ControlFlowScene.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected Widget attachEdgeWidget(InputBlockEdge edge) { ConnectionWidget w = new BlockConnectionWidget(this, edge); w.setRouter(RouterFactory.createDirectRouter()); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); edgeLayer.addChild(w); return w; }
Example #29
Source File: AbegoTreeLayoutForNetbeansDemo.java From treelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected Widget attachEdgeWidget(String e) { ConnectionWidget connectionWidget = new ConnectionWidget(this); connectionWidget.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); connectionLayer.addChild(connectionWidget); return connectionWidget; }
Example #30
Source File: AbegoTreeLayoutForNetbeansDemo.java From treelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void attachEdgeTargetAnchor(String edge, String oldTargetNode, String targetNode) { ConnectionWidget edgeWidget = (ConnectionWidget) findWidget(edge); Widget targetNodeWidget = findWidget(targetNode); Anchor targetAnchor = AnchorFactory .createRectangularAnchor(targetNodeWidget); edgeWidget.setTargetAnchor(targetAnchor); }