本文整理汇总了Java中org.netbeans.api.visual.widget.Widget.convertLocalToScene方法的典型用法代码示例。如果您正苦于以下问题:Java Widget.convertLocalToScene方法的具体用法?Java Widget.convertLocalToScene怎么用?Java Widget.convertLocalToScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.widget.Widget
的用法示例。
在下文中一共展示了Widget.convertLocalToScene方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mousePressed
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
insets = widget.getBorder ().getInsets ();
controlPoint = resolver.resolveControlPoint (widget, event.getPoint ());
if (controlPoint != null) {
resizingWidget = widget;
originalSceneRectangle = null;
if (widget.isPreferredBoundsSet ())
originalSceneRectangle = widget.getPreferredBounds ();
if (originalSceneRectangle == null)
originalSceneRectangle = widget.getBounds ();
if (originalSceneRectangle == null)
originalSceneRectangle = widget.getPreferredBounds ();
dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
provider.resizingStarted (widget);
return State.createLocked (widget, this);
}
}
return State.REJECTED;
}
示例2: locationSuggested
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public Point locationSuggested (Widget widget, Point originalLocation, Point suggestedLocation) {
Point widgetLocation = widget.getLocation ();
Rectangle widgetBounds = outerBounds ? widget.getBounds () : widget.getClientArea ();
Rectangle bounds = widget.convertLocalToScene (widgetBounds);
bounds.translate (suggestedLocation.x - widgetLocation.x, suggestedLocation.y - widgetLocation.y);
Insets insets = widget.getBorder ().getInsets ();
if (! outerBounds) {
suggestedLocation.x += insets.left;
suggestedLocation.y += insets.top;
}
Point point = super.locationSuggested (widget, bounds, widget.getParentWidget().convertLocalToScene(suggestedLocation), true, true, true, true);
if (! outerBounds) {
point.x -= insets.left;
point.y -= insets.top;
}
return widget.getParentWidget ().convertSceneToLocal (point);
}
示例3: keyPressed
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State keyPressed (Widget widget, WidgetKeyEvent event) {
if (event.getKeyCode () == KeyEvent.VK_CONTEXT_MENU || ((event.getModifiers () & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK && event.getKeyCode () == KeyEvent.VK_F10)) {
JPopupMenu popupMenu = provider.getPopupMenu (widget, null);
if (popupMenu != null) {
JComponent view = widget.getScene ().getView ();
if (view != null) {
// Rectangle visibleRect = view.getVisibleRect ();
// popupMenu.show (view, visibleRect.x + 10, visibleRect.y + 10);
Rectangle bounds = widget.getBounds ();
Point location = new Point (bounds.x + 5, bounds.y + 5);
location = widget.convertLocalToScene (location);
location = widget.getScene ().convertSceneToView (location);
popupMenu.show (view, location.x, location.y);
}
}
return State.CONSUMED;
}
return State.REJECTED;
}
示例4: collectObstacles
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的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;
}
示例5: compute
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的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: findShedWidget
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private ShedWidget findShedWidget(Widget searchedEnvelope, Point scenePoint) {
for (Widget searchedEnvelopeChild : searchedEnvelope.getChildren()) {
ShedWidget foundWidget = findShedWidget(searchedEnvelopeChild, scenePoint);
if (foundWidget != null) {
return foundWidget;
}
}
Rectangle localSearchedBounds = searchedEnvelope.getBounds();
Rectangle sceneSearchedBounds = searchedEnvelope.convertLocalToScene(localSearchedBounds);
if (sceneSearchedBounds.contains(scenePoint) && (searchedEnvelope instanceof ShedWidget)) {
return (ShedWidget) searchedEnvelope;
}
return null;
}
示例7: performLayout
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
protected void performLayout() {
Rectangle rectangle = null;
List<? extends Widget> toFit = widgets != null ? widgets : depScene.getChildren();
if (toFit == null) {
return;
}
for (Widget widget : toFit) {
Rectangle bounds = widget.getBounds();
if (bounds == null) {
continue;
}
if (rectangle == null) {
rectangle = widget.convertLocalToScene(bounds);
} else {
rectangle = rectangle.union(widget.convertLocalToScene(bounds));
}
}
// margin around
if (widgets == null) {
rectangle.grow(5, 5);
} else {
rectangle.grow(25, 25);
}
Dimension dim = rectangle.getSize();
Dimension viewDim = parentScrollPane.getViewportBorderBounds().getSize ();
double zf = Math.min ((double) viewDim.width / dim.width, (double) viewDim.height / dim.height);
if (depScene.isAnimated()) {
if (widgets == null) {
depScene.getSceneAnimator().animateZoomFactor(zf);
} else {
CenteredZoomAnimator cza = new CenteredZoomAnimator(depScene.getSceneAnimator());
cza.setZoomFactor(zf,
new Point((int)rectangle.getCenterX(), (int)rectangle.getCenterY()));
}
} else {
depScene.setMyZoomFactor (zf);
}
}
示例8: mousePressed
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
movingWidget = widget;
initialMouseLocation = event.getPoint ();
originalSceneLocation = provider.getOriginalLocation (widget);
if (originalSceneLocation == null)
originalSceneLocation = new Point ();
dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
provider.movementStarted (widget);
return State.createLocked (widget, this);
}
return State.REJECTED;
}
示例9: gotoSelection
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public void gotoSelection(Set<Object> ids) {
Rectangle overall = null;
Set<Integer> hiddenNodes = new HashSet<>(this.getModel().getHiddenNodes());
hiddenNodes.removeAll(ids);
this.getModel().showNot(hiddenNodes);
Set<Object> objects = idSetToObjectSet(ids);
for (Object o : objects) {
Widget w = getWidget(o);
if (w != null) {
Rectangle r = w.getBounds();
Point p = w.convertLocalToScene(new Point(0, 0));
Rectangle r2 = new Rectangle(p.x, p.y, r.width, r.height);
if (overall == null) {
overall = r2;
} else {
overall = overall.union(r2);
}
}
}
if (overall != null) {
centerRectangle(overall);
}
setSelectedObjects(objects);
}
示例10: move
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
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;
}
示例11: compute
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public List<Point> compute(List<Point> points) {
ArrayList<Point> bestPoints = new ArrayList<Point> (points) ;
Point relatedLocation = getRelatedSceneLocation();
int direction = 1 ;
int index = 0 ;
//the related location is the center of this anchor. It is possible that
//the list of points started at the opposite anchor (other end of connection).
Point endPoint = bestPoints.get(index);
if (!endPoint.equals(relatedLocation)) {
index = bestPoints.size() - 1 ;
endPoint = bestPoints.get(index);
direction = -1 ;
}
Widget widget = getRelatedWidget();
Rectangle bounds = widget.getBounds();
bounds = widget.convertLocalToScene(bounds);
Point neighbor = bestPoints.get (index+direction) ;
//moving the end point to the end of the anchor from the interior
while (bounds.contains(neighbor)) {
bestPoints.remove(index) ;
endPoint = bestPoints.get (index);
neighbor = bestPoints.get (index+direction);
}
Result intersection = this.computeBoundaryIntersectionPoint(endPoint, neighbor);
bestPoints.remove(index) ;
bestPoints.add(index, intersection.getAnchorSceneLocation());
return bestPoints ;
}
示例12: countNodeIntersections
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private int countNodeIntersections(Collection<Widget> nodeWidgets, Line2D... lines){
int count=0;
for(Widget nw : nodeWidgets){
if(nw.isVisible()) {
Rectangle bounds = nw.convertLocalToScene(nw.getBounds());
for( Line2D line : lines){
if(line.intersects(bounds))
count++;
}
}
}
return count;
}
示例13: compute
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
Point relatedLocation = getRelatedSceneLocation();
Point oppositeLocation = getOppositeSceneLocation(entry);
Widget widget = getRelatedWidget();
Rectangle bounds = widget.convertLocalToScene(widget.getBounds());
if (relatedLocation.x >= oppositeLocation.x) {
return new Anchor.Result(new Point(bounds.x, bounds.y + ShedWidget.height / 2), Direction.LEFT);
} else {
return new Anchor.Result(new Point(bounds.x + bounds.width, bounds.y + ShedWidget.height / 2), Direction.RIGHT);
}
}
示例14: compute
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
Widget widget = getRelatedWidget();
Point sceneLocation = widget.convertLocalToScene(localLocation);
return new Anchor.Result(new Point(sceneLocation), direction);
}
示例15: intersects
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private boolean intersects(Widget w, List<Point> list) {
Rectangle r = w.convertLocalToScene(w.getBounds());
r.grow(HEXPAND, VEXPAND);
return intersects(list, r);
}