org.netbeans.api.visual.anchor.Anchor Java Examples
The following examples show how to use
org.netbeans.api.visual.anchor.Anchor.
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: BestPathAnchor.java From Llunatic with GNU General Public License v3.0 | 6 votes |
@Override public Result compute(Entry entry) { Widget widget = getRelatedWidget(); Widget otherWidget = entry.getOppositeAnchor().getRelatedWidget(); Rectangle bounds = widget.convertLocalToScene(widget.getBounds()); Rectangle otherBounds = otherWidget.convertLocalToScene(otherWidget.getBounds()); Point center = getCenter(bounds); int leftBound = bounds.x; int rightBound = bounds.x + bounds.width; int oppositeLeftBound = otherBounds.x; int oppositeRightBound = otherBounds.x + otherBounds.width; if (leftBound >= oppositeRightBound) { return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT); } else if (rightBound <= oppositeLeftBound) { return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT); } else { int leftDist = Math.abs(leftBound - oppositeLeftBound); int rightDist = Math.abs(rightBound - oppositeRightBound); if (leftDist <= rightDist) { return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT); } else { return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT); } } }
Example #2
Source File: ReconnectAction.java From netbeans with Apache License 2.0 | 6 votes |
private boolean move (Widget widget, Point point) { if (connectionWidget != widget) return false; Point replacementSceneLocation = widget.convertLocalToScene (point); replacementWidget = resolveReplacementWidgetCore (connectionWidget.getScene (), replacementSceneLocation); Anchor replacementAnchor = null; if (replacementWidget != null) replacementAnchor = decorator.createReplacementWidgetAnchor (replacementWidget); if (replacementAnchor == null) replacementAnchor = decorator.createFloatAnchor (replacementSceneLocation); if (reconnectingSource) connectionWidget.setSourceAnchor (replacementAnchor); else connectionWidget.setTargetAnchor (replacementAnchor); return true; }
Example #3
Source File: OrthogonalSearchRouterRegion.java From netbeans with Apache License 2.0 | 6 votes |
public OrthogonalSearchRouterRegion (/*OrthogonalLinkRouterRegion parentRegion, */int x, int y, int width, int height, Anchor.Direction direction, int depth) { super (x, y, width, height); // this.parent = parentRegion; this.direction = direction; switch (direction) { case LEFT: case RIGHT: horizontal = true; break; case TOP: case BOTTOM: horizontal = false; break; default: throw new IllegalArgumentException (); } this.depth = depth; }
Example #4
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 #5
Source File: DirectionalAnchor.java From netbeans with Apache License 2.0 | 6 votes |
public Result compute (Entry entry) { Point relatedLocation = getRelatedSceneLocation (); Point oppositeLocation = getOppositeSceneLocation (entry); Widget widget = getRelatedWidget (); Rectangle bounds = widget.convertLocalToScene (widget.getBounds ()); Point center = GeomUtil.center (bounds); switch (kind) { case HORIZONTAL: if (relatedLocation.x >= oppositeLocation.x) return new Anchor.Result (new Point (bounds.x - gap, center.y), Direction.LEFT); else return new Anchor.Result (new Point (bounds.x + bounds.width + gap, center.y), Direction.RIGHT); case VERTICAL: if (relatedLocation.y >= oppositeLocation.y) return new Anchor.Result (new Point (center.x, bounds.y - gap), Direction.TOP); else return new Anchor.Result (new Point (center.x, bounds.y + bounds.height + gap), Direction.BOTTOM); } return null; }
Example #6
Source File: RectangularAnchor.java From netbeans with Apache License 2.0 | 6 votes |
public Result compute(Entry entry) { Point relatedLocation = getRelatedSceneLocation(); Point oppositeLocation = null; if (oppositeLocation == null) { oppositeLocation = getOppositeSceneLocation(entry); } Result boundaryIntersection = computeBoundaryIntersectionPoint(relatedLocation, oppositeLocation); if (boundaryIntersection == null) { return new Anchor.Result(relatedLocation, Anchor.DIRECTION_ANY); } return boundaryIntersection ; }
Example #7
Source File: ConnectionWidget.java From netbeans with Apache License 2.0 | 5 votes |
/** * Sets a source anchor of the connection widget. * @param sourceAnchor the source anchor */ public final void setSourceAnchor (Anchor sourceAnchor) { if (this.sourceAnchor != null) this.sourceAnchor.removeEntry (sourceEntry); this.sourceAnchor = sourceAnchor; if (this.sourceAnchor != null) sourceAnchor.addEntry (sourceEntry); reroute (); }
Example #8
Source File: ConnectionWidget.java From netbeans with Apache License 2.0 | 5 votes |
/** * Sets a target anchor of the connection widget. * @param targetAnchor the target anchor */ public final void setTargetAnchor (Anchor targetAnchor) { if (this.targetAnchor != null) this.targetAnchor.removeEntry (targetEntry); this.targetAnchor = targetAnchor; if (targetAnchor != null) targetAnchor.addEntry (targetEntry); reroute (); }
Example #9
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 5 votes |
private Anchor getPinAnchor(Pin pin) { if (pin == null) { return null; } VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget(getPinNode(pin)); Widget pinMainWidget = findWidget(pin); Anchor anchor; if (pinMainWidget != null) { anchor = AnchorFactory.createDirectionalAnchor(pinMainWidget, AnchorFactory.DirectionalAnchorKind.HORIZONTAL, 8); anchor = nodeWidget.createAnchorPin(anchor); } else { anchor = nodeWidget.getNodeAnchor(); } return anchor; }
Example #10
Source File: AbegoTreeLayoutForNetbeansDemo.java From treelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void attachEdgeSourceAnchor(String edge, String oldSourceNode, String sourceNode) { ConnectionWidget edgeWidget = (ConnectionWidget) findWidget(edge); Widget sourceNodeWidget = findWidget(sourceNode); Anchor sourceAnchor = AnchorFactory .createRectangularAnchor(sourceNodeWidget); edgeWidget.setSourceAnchor(sourceAnchor); }
Example #11
Source File: VMDNodeWidget.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates an extended pin anchor with an ability of reconnecting to the node anchor when the node is minimized. * @param anchor the original pin anchor from which the extended anchor is created * @return the extended pin anchor, the returned anchor is cached and returns a single extended pin anchor instance of each original pin anchor */ public Anchor createAnchorPin (Anchor anchor) { Anchor proxyAnchor = proxyAnchorCache.get (anchor); if (proxyAnchor == null) { proxyAnchor = AnchorFactory.createProxyAnchor (stateModel, anchor, nodeAnchor); proxyAnchorCache.put (anchor, proxyAnchor); } return proxyAnchor; }
Example #12
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); }
Example #13
Source File: VMDGraphScene.java From netbeans with Apache License 2.0 | 5 votes |
private Anchor getPinAnchor (String pin) { if (pin == null) return null; VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget (getPinNode (pin)); Widget pinMainWidget = findWidget (pin); Anchor anchor; if (pinMainWidget != null) { anchor = AnchorFactory.createDirectionalAnchor (pinMainWidget, AnchorFactory.DirectionalAnchorKind.HORIZONTAL, 8); anchor = nodeWidget.createAnchorPin (anchor); } else anchor = nodeWidget.getNodeAnchor (); return anchor; }
Example #14
Source File: CircularAnchor.java From netbeans with Apache License 2.0 | 5 votes |
public Result compute (Entry entry) { Point relatedLocation = getRelatedSceneLocation (); Point oppositeLocation = getOppositeSceneLocation (entry); double angle = Math.atan2 (oppositeLocation.y - relatedLocation.y, oppositeLocation.x - relatedLocation.x); Point location = new Point (relatedLocation.x + (int) (radius * Math.cos (angle)), relatedLocation.y + (int) (radius * Math.sin (angle))); return new Anchor.Result (location, Anchor.DIRECTION_ANY); // TODO - resolve direction }
Example #15
Source File: LunaticDepScene.java From Llunatic with GNU General Public License v3.0 | 5 votes |
private Anchor getPinAnchor(PinNode pin) { if (pin == null) { return null; } VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget(super.getPinNode(pin)); Widget pinMainWidget = findWidget(pin); Anchor anchor; if (pinMainWidget != null) { anchor = new BestPathAnchor(pinMainWidget); anchor = nodeWidget.createAnchorPin(anchor); } else { anchor = nodeWidget.getNodeAnchor(); } return anchor; }
Example #16
Source File: RectangularAnchor.java From netbeans with Apache License 2.0 | 5 votes |
private Result computeBoundaryIntersectionPoint(Point relatedLocation, Point oppositeLocation) { Widget widget = getRelatedWidget(); Rectangle bounds = widget.getBounds(); if (!includeBorders) { Insets insets = widget.getBorder().getInsets(); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= insets.left + insets.right; bounds.height -= insets.top + insets.bottom; } bounds = widget.convertLocalToScene(bounds); if (bounds.isEmpty() || relatedLocation.equals(oppositeLocation)) { return null; } float dx = oppositeLocation.x - relatedLocation.x; float dy = oppositeLocation.y - relatedLocation.y; float ddx = Math.abs(dx) / (float) bounds.width; float ddy = Math.abs(dy) / (float) bounds.height; Anchor.Direction direction; if (ddx >= ddy) { direction = dx >= 0.0f ? Direction.RIGHT : Direction.LEFT; } else { direction = dy >= 0.0f ? Direction.BOTTOM : Direction.TOP; } float scale = 0.5f / Math.max(ddx, ddy); Point point = new Point(Math.round(relatedLocation.x + scale * dx), Math.round(relatedLocation.y + scale * dy)); return new Anchor.Result(point, direction); }
Example #17
Source File: BestPathObjectAnchor.java From Llunatic with GNU General Public License v3.0 | 5 votes |
@Override public Result compute(Entry entry) { Widget widget = getRelatedWidget(); Widget otherWidget = entry.getOppositeAnchor().getRelatedWidget(); Rectangle bounds = widget.convertLocalToScene(widget.getBounds()); Rectangle otherBounds = otherWidget.convertLocalToScene(otherWidget.getBounds()); Point center = getCenter(bounds); Connection minimum = getMin(new Connection(bounds.x, otherBounds.x, Direction.LEFT), new Connection(bounds.x, otherBounds.x + otherBounds.width, Direction.LEFT)); minimum = getMin(minimum, new Connection(bounds.x + bounds.width, otherBounds.x, Direction.RIGHT)); minimum = getMin(minimum, new Connection(bounds.x + bounds.width, otherBounds.x + otherBounds.width, Direction.RIGHT)); return new Anchor.Result(new Point(minimum.getStartX(), center.y), minimum.getDirection()); }
Example #18
Source File: ConnectAction.java From netbeans with Apache License 2.0 | 5 votes |
private boolean move (Widget widget, Point point) { if (sourceWidget != widget) return false; Point targetSceneLocation = widget.convertLocalToScene (point); targetWidget = resolveTargetWidgetCore (interractionLayer.getScene (), targetSceneLocation); Anchor targetAnchor = null; if (targetWidget != null) targetAnchor = decorator.createTargetAnchor (targetWidget); if (targetAnchor == null) targetAnchor = decorator.createFloatAnchor (targetSceneLocation); connectionWidget.setTargetAnchor (targetAnchor); return true; }
Example #19
Source File: FixedPathAnchor.java From Llunatic with GNU General Public License v3.0 | 5 votes |
@Override public Result compute(Entry entry) { Widget widget = getRelatedWidget(); Rectangle bounds = widget.convertLocalToScene(widget.getBounds()); Point center = getCenter(bounds); int leftBound = bounds.x; int rightBound = bounds.x + bounds.width; if (direction == Direction.LEFT) { return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT); } else { return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT); } }
Example #20
Source File: OrthogonalSearchRouterRegion.java From netbeans with Apache License 2.0 | 5 votes |
private OrthogonalSearchRouterRegion cloneWithEdge (/*OrthogonalLinkRouterRegion parent, */Anchor.Direction dir, int depth) { switch (dir) { case LEFT: return new OrthogonalSearchRouterRegion (/*parent, */x, y, 0, height, dir, depth); case RIGHT: return new OrthogonalSearchRouterRegion (/*parent, */x + width, y, 0, height, dir, depth); case TOP: return new OrthogonalSearchRouterRegion (/*parent, */x, y, width, 0, dir, depth); case BOTTOM: return new OrthogonalSearchRouterRegion (/*parent, */x, y + height, width, 0, dir, depth); default: throw new IllegalArgumentException (); } }
Example #21
Source File: OrthogonalSearchRouterRegion.java From netbeans with Apache License 2.0 | 5 votes |
public static Anchor.Direction getCounterClockWiseDirection (Anchor.Direction direction) { switch (direction) { case LEFT: return Anchor.Direction.BOTTOM; case RIGHT: return Anchor.Direction.TOP; case TOP: return Anchor.Direction.LEFT; case BOTTOM: return Anchor.Direction.RIGHT; default: throw new IllegalArgumentException (); } }
Example #22
Source File: OrthogonalSearchRouterRegion.java From netbeans with Apache License 2.0 | 5 votes |
public static Anchor.Direction getClockWiseDirection (Anchor.Direction direction) { switch (direction) { case LEFT: return Anchor.Direction.TOP; case RIGHT: return Anchor.Direction.BOTTOM; case TOP: return Anchor.Direction.RIGHT; case BOTTOM: return Anchor.Direction.LEFT; default: throw new IllegalArgumentException (); } }
Example #23
Source File: OrthogonalSearchRouterCore.java From netbeans with Apache License 2.0 | 5 votes |
public OrthogonalSearchRouterCore (Scene scene, ArrayList<Rectangle> verticalCollisions, ArrayList<Rectangle> horizontalCollisions, Point sourcePoint, Anchor.Direction sourceDirection, Point targetPoint, Anchor.Direction targetDirection) { this.scene = scene; this.verticalCollisions = verticalCollisions; this.horizontalCollisions = horizontalCollisions; this.sourcePoint = sourcePoint; this.sourceDirection = sourceDirection; this.targetPoint = targetPoint; this.targetDirection = targetDirection; }
Example #24
Source File: DirectRouter.java From netbeans with Apache License 2.0 | 5 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) { list.add (sourceAnchor.compute(widget.getSourceAnchorEntry ()).getAnchorSceneLocation()); list.add (targetAnchor.compute(widget.getTargetAnchorEntry ()).getAnchorSceneLocation()); } return list; }
Example #25
Source File: ProxyAnchor.java From netbeans with Apache License 2.0 | 5 votes |
public ProxyAnchor(StateModel model, Anchor... anchors) { super (null); // assert model != null && model.getMaxStates () == anchors.length; this.model = model; this.anchors = anchors; this.index = model.getState (); }
Example #26
Source File: DocumentWidget.java From jeddict with Apache License 2.0 | 4 votes |
@Override public Anchor getAnchor() { return new CustomRectangularAnchor(this, -5, true); }
Example #27
Source File: FlowNodeWidget.java From jeddict with Apache License 2.0 | 4 votes |
@Override public Anchor getAnchor() { return new CustomRectangularAnchor(this, 0, true); }
Example #28
Source File: TableWidget.java From jeddict with Apache License 2.0 | 4 votes |
public Anchor getAnchor() { return new CustomRectangularAnchor(this, -5, true); }
Example #29
Source File: ConnectionAnchor.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public Result compute(Entry entry) { return new Result(getRelatedSceneLocation(), Anchor.DIRECTION_ANY); }
Example #30
Source File: ConnectionAnchor.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public Result compute(Entry entry) { return new Result(getRelatedSceneLocation(), Anchor.DIRECTION_ANY); }