本文整理汇总了Java中org.netbeans.api.visual.widget.Widget.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Widget.getLocation方法的具体用法?Java Widget.getLocation怎么用?Java Widget.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.widget.Widget
的用法示例。
在下文中一共展示了Widget.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveReplacementWidgetCoreDive
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private boolean resolveReplacementWidgetCoreDive (Widget[] result, Widget widget, Point parentLocation) {
if (widget == connectionWidget)
return false;
Point widgetLocation = widget.getLocation ();
Point location = new Point (parentLocation.x - widgetLocation.x, parentLocation.y - widgetLocation.y);
if (! widget.getBounds ().contains (location))
return false;
java.util.List<Widget> children = widget.getChildren ();
for (int i = children.size () - 1; i >= 0; i --) {
if (resolveReplacementWidgetCoreDive (result, children.get (i), location))
return true;
}
if (! widget.isHitAt (location))
return false;
ConnectorState state = provider.isReplacementWidget (connectionWidget, widget, reconnectingSource);
if (state == ConnectorState.REJECT)
return false;
if (state == ConnectorState.ACCEPT)
result[0] = widget;
return true;
}
示例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: resolveTargetWidgetCoreDive
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private boolean resolveTargetWidgetCoreDive (Widget[] result, Widget widget, Point parentLocation) {
if (interractionLayer.equals (widget))
return false;
Point widgetLocation = widget.getLocation ();
Point location = new Point (parentLocation.x - widgetLocation.x, parentLocation.y - widgetLocation.y);
if (! widget.getBounds ().contains (location))
return false;
java.util.List<Widget> children = widget.getChildren ();
for (int i = children.size () - 1; i >= 0; i --) {
if (resolveTargetWidgetCoreDive (result, children.get (i), location))
return true;
}
if (! widget.isHitAt (location))
return false;
ConnectorState state = provider.isTargetWidget (sourceWidget, widget);
if (state == ConnectorState.REJECT)
return false;
if (state == ConnectorState.ACCEPT)
result[0] = widget;
return true;
}
示例4: computateAnchorPosition
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
* Computates the Anchorposition like the Rectangular anchor for a
* given widget as source/target and a controlpoint as opposit anchorposition
*/
private Point computateAnchorPosition(Widget relatedWidget, Point controlPoint) {
Rectangle bounds = relatedWidget.getBounds();
//todo: fix, center of widget must be cacluated trough the bounds
//since there are some wheird widgets where the location is not the center of the widget
Point relatedLocation = relatedWidget.getLocation();//center of the widget
if (bounds.isEmpty () || relatedLocation.equals (controlPoint))
return relatedLocation;
float dx = controlPoint.x - relatedLocation.x;
float dy = controlPoint.y - relatedLocation.y;
float ddx = Math.abs (dx) / (float) bounds.width;
float ddy = Math.abs (dy) / (float) bounds.height;
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 point;
}
示例5: computateAnchorPosition
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
* Computates the Anchorposition like the Rectangular anchor for a
* given widget as source/target and a controlpoint as opposit anchorposition
*/
private Point computateAnchorPosition(Widget relatedWidget, Point controlPoint) {
Rectangle bounds = relatedWidget.getBounds();
Point relatedLocation = relatedWidget.getLocation();//center of the widget
if (bounds.isEmpty () || relatedLocation.equals (controlPoint))
return relatedLocation;
float dx = controlPoint.x - relatedLocation.x;
float dy = controlPoint.y - relatedLocation.y;
float ddx = Math.abs (dx) / (float) bounds.width;
float ddy = Math.abs (dy) / (float) bounds.height;
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 point;
}
示例6: movementFinished
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override public void movementFinished(Widget widget) {
// little hack to call highlightRelated on mouse click while leaving
// normal move behaviour on real dragging
Point moveEnd = widget.getLocation();
if (moveStart.distance(moveEnd) < 5) {
Object obj = DependencyGraphScene.this.findObject(widget);
if (obj instanceof GraphNode) {
DependencyGraphScene.this.highlightRelated((GraphNode)obj);
}
}
}
示例7: tick
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
protected void tick (double progress) {
for (Map.Entry<Widget, Point> entry : targetLocations.entrySet ()) {
Widget widget = entry.getKey ();
Point sourceLocation = sourceLocations.get (widget);
if (sourceLocation == null) {
sourceLocation = widget.getPreferredLocation ();
if (sourceLocation == null) {
sourceLocation = widget.getLocation ();
if (sourceLocation == null) {
sourceLocation = new Point ();
}
}
sourceLocations.put (widget, sourceLocation);
}
Point targetLocation = entry.getValue ();
if (targetLocation == null)
continue;
Point point;
if (progress >= 1.0)
point = targetLocation;
else
point = new Point (
(int) (sourceLocation.x + progress * (targetLocation.x - sourceLocation.x)),
(int) (sourceLocation.y + progress * (targetLocation.y - sourceLocation.y)));
widget.setPreferredLocation (point);
}
if (progress >= 1.0) {
sourceLocations.clear ();
targetLocations.clear ();
}
}
示例8: getSourceBounds
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private Rectangle getSourceBounds()
{
Widget source = connection.getSourceAnchor().getRelatedWidget();
if(source != null)
{
Point sourceLocation = source.getLocation();
Rectangle clientArea = source.getClientArea();
return new Rectangle(sourceLocation, clientArea.getSize());
}
return null;
}
示例9: getTargetBounds
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private Rectangle getTargetBounds()
{
Widget target = connection.getTargetAnchor().getRelatedWidget();
if(target != null)
{
Point targetLocation = target.getLocation();
Rectangle targetArea = target.getClientArea();
return new Rectangle(targetLocation, targetArea.getSize());
}
return null;
}
示例10: getSourceBounds
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
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());
}
示例11: getTargetBounds
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
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());
}
示例12: edgeBalance
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private int edgeBalance(Widget nodeWidget) {
if(scene == null)
return 1;
Point nodeLocation = nodeWidget.getLocation();
int left = 0, right = 0;
Object node = scene.findObject(nodeWidget);
for(Object e : scene.findNodeEdges(node, true, true)) {//inputedges
ConnectionWidget cw = (ConnectionWidget) scene.findWidget(e);
if(cw != this) {
Widget targetNodeWidget = cw.getTargetAnchor().getRelatedWidget();
Point location;
if(targetNodeWidget == nodeWidget) {
Widget sourceNodeWidget = cw.getSourceAnchor().getRelatedWidget();
location = sourceNodeWidget.getLocation();
} else {
location = targetNodeWidget.getLocation();
}
if(location.x < nodeLocation.x)
left++;
else
right++;
}
}
if(left < right)
return -1;
else
return 1;
}
示例13: movementStarted
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override public void movementStarted(Widget widget) {
widget.bringToFront();
moveStart = widget.getLocation();
}
示例14: movementStarted
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public void movementStarted(Widget widget) {
originalLocation = widget.getLocation();
System.out.println("Original location " + originalLocation);
}
示例15: getOriginalLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public Point getOriginalLocation(Widget widget) {
return widget.getLocation();
}