本文整理汇总了Java中org.netbeans.api.visual.anchor.Anchor类的典型用法代码示例。如果您正苦于以下问题:Java Anchor类的具体用法?Java Anchor怎么用?Java Anchor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Anchor类属于org.netbeans.api.visual.anchor包,在下文中一共展示了Anchor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: move
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
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;
}
示例2: OrthogonalSearchRouterRegion
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
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;
}
示例3: routeConnection
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
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;
}
示例4: compute
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
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 ;
}
示例5: compute
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
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;
}
示例6: childElementAdded
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
@Override
public void childElementAdded(Competence parent, PoshElement child) {
if (isChoice(child)) {
Anchor envelopeAnchor = choicesEnvelope.getCommonAnchor();
List<CompetenceElement> choices = parent.getChildDataNodes();
CompetenceElement choice = extractChoice(choices, child);
int choicePosition = getPosition(choices, choice);
LapPath competencePath = chain.toPath();
LapPath choicePath = competencePath.concat(LapType.COMPETENCE_ELEMENT, choicePosition);
ShedCreationContainer<SlotEnvelope> choiceContainer = scene.getWidgetFactory().createChoiceEnvelope(choicePath, choice, envelopeAnchor);
choicesEnvelope.add(choiceContainer.getWidget(), choicePosition);
scene.update();
scene.addArrows(choiceContainer.getArrows());
scene.update();
} else {
throw new IllegalArgumentException();
}
}
示例7: childElementRemoved
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
@Override
public void childElementRemoved(TRIGGER_OWNER triggerOwner, PoshElement child, int removedChildIndex) {
if (isSense(child)) {
// XXX: This is rather unpleasant hack, I should use custom layout or something. What I want is to have gap when trigger has at least one sense in it, but no gap, when there is not sense in the trigger.
if (trigger.isEmpty()) {
triggerEnvelope.getParentWidget().setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.LEFT_TOP, 0));
}
ShedSenseWidget removedSenseWidget = triggerEnvelope.getChild(removedChildIndex);
triggerEnvelope.remove(removedSenseWidget);
boolean triggerIsEmpty = (triggerEnvelope.numberOfChildren() == 0);
boolean removedSenseWasLast = (removedChildIndex == triggerEnvelope.numberOfChildren());
boolean triggerIsMissingArrow = (!triggerIsEmpty && !removedSenseWasLast);
if (triggerIsMissingArrow) {
Anchor sourceAnchor = getAnchorBeforePosition(removedChildIndex);
Anchor targetAnchor = triggerEnvelope.getChild(removedChildIndex).getCommonAnchor();
scene.addArrow(sourceAnchor, targetAnchor);
}
scene.update();
}
}
示例8: childElementAdded
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
@Override
public void childElementAdded(ActionPattern parent, PoshElement child) {
if (isAction(child)) {
TriggeredAction addedAction = extractAction(parent.getActions(), child);
int addedActionPosition = getPosition(parent.getActions(), addedAction);
LapPath actionPatternPath = chain.toPath();
LapPath addedActionPath = actionPatternPath.concat(LapType.ACTION, addedActionPosition);
ShedCreationContainer<ExpandedActionEnvelope> addedExpandedActionContainer = scene.getWidgetFactory().createdExpandedActionEnvelope(addedActionPath);
actionsEnvelope.add(addedExpandedActionContainer.getWidget(), addedActionPosition);
scene.addArrows(addedExpandedActionContainer.getArrows());
Anchor attachmentAnchor = addedExpandedActionContainer.getWidget().getAnchor();
scene.addArrow(actionsEnvelope.getSourceAnchor(), attachmentAnchor);
scene.update();
} else {
throw new IllegalArgumentException("Only action allowed, got " + child);
}
}
示例9: findArrows
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Find all arrows in the scene that have one of anchors attached to the
* @arrowEndpointWidget
* @param arrowEndpointWidget Widget that is used for anchor of each returned arrow.
* @return Set of found arrows
*/
List<Widget> findArrows(Set<Widget> arrowEndpointWidgets) {
List<Widget> foundArrows = new LinkedList<Widget>();
for (Widget arrow : connectionLayer.getChildren()) {
ArrowWidget arrowWidget = (ArrowWidget) arrow;
Anchor sourceAnchor = arrowWidget.getSourceAnchor();
Widget sourceWidget = sourceAnchor.getRelatedWidget();
Anchor targetAnchor = arrowWidget.getTargetAnchor();
Widget targetWidget = targetAnchor.getRelatedWidget();
if (arrowEndpointWidgets.contains(targetWidget) || arrowEndpointWidgets.contains(sourceWidget)) {
foundArrows.add(arrow);
}
}
return foundArrows;
}
示例10: createTriggerEnvelope
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Create envelope for the trigger of some element. The envelope will have
* newly created {@link ShedSenseWidget}s and {@link SensePresenter}.
*
* @param parentPath Path to the @parent element with trigger, e.g.
* <tt>../DE:1</tt>, <tt>../CE:0</tt> or <tt>../AD:4</tt>.
* @param parent Posh element with the trigger.
* @param trigger Trigger from which the {@link SensePresenter}s and {@link ShedSenseWidget}s
* will be created and connected to.
* @return Newly created envelope for the trigger sense widgets.
*/
private <TRIGGER_PARENT extends PoshElement> ShedCreationContainer<ShedTriggerEnvelope> createTriggerEnvelope(LapPath parentPath, TRIGGER_PARENT parent, Anchor firstSenseAnchor, Trigger<TRIGGER_PARENT> trigger) {
assert parentPath.traversePath(plan) == parent;
ShedTriggerEnvelope envelope = new ShedTriggerEnvelope(lapScene, firstSenseAnchor);
IPresenter triggerPresenter = presenterFactory.createTriggerPresenter(parentPath, envelope);
triggerPresenter.register();
ShedCreationContainer<ShedTriggerEnvelope> creationContainer = new ShedCreationContainer<ShedTriggerEnvelope>(envelope);
Anchor sourceAnchor = firstSenseAnchor;
// TODO: check that it works
for (int senseId = 0; senseId < trigger.size(); senseId++) {
LapPath sensePath = parentPath.concat(LapType.SENSE, senseId);
ShedSenseWidget senseWidget = createSenseWidget(sensePath);
envelope.add(senseWidget);
ArrowWidget arrowWidget = new ArrowWidget(lapScene, sourceAnchor, senseWidget.getCommonAnchor());
creationContainer.addArrow(arrowWidget);
sourceAnchor = senseWidget.getCommonAnchor();
}
return creationContainer;
}
示例11: createChoicesEnvelope
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Create envelope that contains all choices of the competence.
*
* @param competencePath Path to the @competence, ends with <tt>../C:?</tt>
* @param competence Competence from which we extract necessary data
* @param sourceAnchor source anchor for arrows in the scene. All created
* choices will have an arrow from sourceAnchor to the choice envelope.
* @return created envelope.
*/
private ShedCreationContainer<ShedChoicesEnvelope> createChoicesEnvelope(LapPath competencePath, Competence competence, Anchor sourceAnchor) {
assert competencePath.traversePath(plan) == competence;
ShedChoicesEnvelope choicesEnvelope = new ShedChoicesEnvelope(lapScene, sourceAnchor);
IPresenter choicesPresenter = presenterFactory.createChoicesPresenter(competencePath, choicesEnvelope);
choicesPresenter.register();
ShedCreationContainer<ShedChoicesEnvelope> choicesContainer = new ShedCreationContainer<ShedChoicesEnvelope>(choicesEnvelope);
int choiceId = 0;
for (CompetenceElement choice : competence.getChildDataNodes()) {
LapPath choicePath = competencePath.concat(LapType.COMPETENCE_ELEMENT, choiceId++);
ShedCreationContainer<SlotEnvelope> choiceContainer = createChoiceEnvelope(choicePath, choice, sourceAnchor);
choicesEnvelope.add(choiceContainer.getWidget());
choicesContainer.addArrows(choiceContainer.getArrows());
}
return choicesContainer;
}
示例12: createActionsEnvelope
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Create envelope containing visualized expanded actions of the AP.
*
* @param actionPatternPath Path to the AP for which we want to create
* envelope (ends with ../A:?/AP:?)
* @param sourceAnchor TODO: not used, implement proper arrows in the scene.
* @return
*/
private ShedCreationContainer<ShedActionsEnvelope> createActionsEnvelope(LapPath actionPatternPath, Anchor sourceAnchor) {
ActionPattern actionPattern = actionPatternPath.traversePath(plan);
ShedActionsEnvelope actionsEnvelope = new ShedActionsEnvelope(lapScene, sourceAnchor);
IPresenter actionsPresenter = presenterFactory.createActionsPresenter(actionPatternPath, actionsEnvelope);
actionsPresenter.register();
ShedCreationContainer<ShedActionsEnvelope> actionsContainer = new ShedCreationContainer<ShedActionsEnvelope>(actionsEnvelope);
int actionId = 0;
for (TriggeredAction action : actionPattern.getActions()) {
LapPath actionPath = actionPatternPath.concat(LapType.ACTION, actionId++);
ShedCreationContainer<ExpandedActionEnvelope> expandedActionContainer = createdExpandedActionEnvelope(actionPath);
actionsEnvelope.add(expandedActionContainer.getWidget());
actionsContainer.addArrows(expandedActionContainer.getArrows());
Anchor expandedActionAnchor = expandedActionContainer.getWidget().getAnchor();
ArrowWidget arrowToParent = new ArrowWidget(lapScene, sourceAnchor, expandedActionAnchor);
actionsContainer.addArrow(arrowToParent);
}
return actionsContainer;
}
示例13: createDriveEnvelope
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Create envelope containing fully expanded drive along with all inside
* widgets and presenters.
*
* @param scene Scene into which the widget belongs to.
* @param drive Drive that will be used to create the envelope and all
* elements inside.
* @return Newly created envelope for the drive
*/
public ShedCreationContainer<SlotEnvelope> createDriveEnvelope(LapPath drivePath, DriveElement drive) {
ShedCollapseWidget driveWidget = createDriveWidget(drivePath, drive);
Anchor driveAnchor = new LeveledHorizontalAnchor(driveWidget);
ShedCreationContainer<ShedTriggerEnvelope> driveTriggerContainer = createTriggerEnvelope(drivePath, drive, driveAnchor, drive.getTrigger());
LapPath driveActionPath = drivePath.concat(LapType.ACTION, 0);
ShedCreationContainer<ExpandedActionEnvelope> expandedActionEnvelope = createdExpandedActionEnvelope(driveActionPath);
SlotEnvelope driveEnvelope = new SlotEnvelope(lapScene, driveWidget, driveTriggerContainer.getWidget(), expandedActionEnvelope.getWidget());
ShedCreationContainer<SlotEnvelope> driveContainer = new ShedCreationContainer<SlotEnvelope>(driveEnvelope);
driveContainer.addArrows(driveTriggerContainer.getArrows());
driveContainer.addArrows(expandedActionEnvelope.getArrows());
driveContainer.addArrow(new ArrowWidget(lapScene, driveAnchor, expandedActionEnvelope.getWidget().getAnchor()));
addCollapseAction(driveWidget, expandedActionEnvelope);
return driveContainer;
}
示例14: createChoiceEnvelope
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
/**
* Create envelope with fully expanded choice along with all inside widgets
* and presenters. The presenters are already registered.
*
* @param choicePath Path to the @choice
* @param choice {@link CompetenceElement} used to create the expanded
* envelope
* @param sourceAnchor Source anchor for {@link ArrowWidget} between the
* expanded choice widget and its parent.
* @return Created visual representation.
*/
public ShedCreationContainer<SlotEnvelope> createChoiceEnvelope(LapPath choicePath, CompetenceElement choice, Anchor sourceAnchor) {
ShedCollapseWidget choiceWidget = createChoiceWidget(choicePath, choice);
Anchor choiceAnchor = new LeveledHorizontalAnchor(choiceWidget);//new FixedWidgetAnchor(choiceWidget, new Point(ShedWidget.width, ShedWidget.height / 2), Anchor.Direction.RIGHT);
ShedCreationContainer<ShedTriggerEnvelope> choiceTriggerContainer = createTriggerEnvelope(choicePath, choice, choiceAnchor, choice.getTrigger());
LapPath choiceActionPath = choicePath.concat(LapType.ACTION, 0);
ShedCreationContainer<ExpandedActionEnvelope> expandedActionEnvelope = createdExpandedActionEnvelope(choiceActionPath);
SlotEnvelope choiceEnvelope = new SlotEnvelope(lapScene, choiceWidget, choiceTriggerContainer.getWidget(), expandedActionEnvelope.getWidget());
ShedCreationContainer<SlotEnvelope> choiceContainer = new ShedCreationContainer<SlotEnvelope>(choiceEnvelope);
Anchor leftChoiceAnchor = new FixedWidgetAnchor(choiceWidget, new Point(0, ShedWidget.height / 2), Anchor.Direction.LEFT);
ArrowWidget arrowToSource = new ArrowWidget(lapScene, sourceAnchor, leftChoiceAnchor);
choiceContainer.addArrow(arrowToSource);
choiceContainer.addArrows(choiceTriggerContainer.getArrows());
choiceContainer.addArrows(expandedActionEnvelope.getArrows());
choiceContainer.addArrow(new ArrowWidget(lapScene, choiceAnchor, expandedActionEnvelope.getWidget().getAnchor()));
addCollapseAction(choiceWidget, expandedActionEnvelope);
return choiceContainer;
}
示例15: collectObstacles
import org.netbeans.api.visual.anchor.Anchor; //导入依赖的package包/类
private int collectObstacles(List<Rectangle> colrects, List<Widget> colwidgets , ConnectionWidget cw){
int count=0;
Anchor sourceAnchor = cw.getSourceAnchor();
Anchor targetAnchor = cw.getTargetAnchor();
Widget sourceWidget = sourceAnchor.getRelatedWidget();
Widget targetWidget = targetAnchor.getRelatedWidget();
Point start = sourceAnchor.compute(cw.getSourceAnchorEntry()).getAnchorSceneLocation();
Point end = targetAnchor.compute(cw.getTargetAnchorEntry()).getAnchorSceneLocation();
for(Widget w : colwidgets){
if(w==sourceWidget || w == targetWidget) continue;
Rectangle r = w.convertLocalToScene(w.getBounds());
r.grow(HEXPAND, VEXPAND);
if(r.intersectsLine(start.x,start.y,end.x,end.y))
count++;
colrects.add(r);
}
return count;
}