本文整理了Java中org.netbeans.api.visual.widget.Widget.getPreferredLocation()
方法的一些代码示例,展示了Widget.getPreferredLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Widget.getPreferredLocation()
方法的具体详情如下:
包路径:org.netbeans.api.visual.widget.Widget
类名称:Widget
方法名:getPreferredLocation
[英]Returns a preferred location of the widget.
[中]返回小部件的首选位置。
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
public Point getOriginalLocation (Widget widget) {
return widget.getPreferredLocation ();
}
public void setNewLocation (Widget widget, Point location) {
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
public Point getOriginalLocation (Widget widget) {
return widget.getPreferredLocation ();
}
public void setNewLocation (Widget widget, Point location) {
代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-visual
@Override
public Point getOriginalLocation (final @Nonnull Widget widget)
{
return widget.getPreferredLocation();
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
Point sourceLocation = sourceLocations.get (widget);
if (sourceLocation == null) {
sourceLocation = widget.getPreferredLocation ();
if (sourceLocation == null) {
sourceLocation = widget.getLocation ();
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
Point sourceLocation = sourceLocations.get (widget);
if (sourceLocation == null) {
sourceLocation = widget.getPreferredLocation ();
if (sourceLocation == null) {
sourceLocation = widget.getLocation ();
代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-visual
@Override
public void movementStarted (final @Nonnull Widget widget)
{
logger.fine("movementStarted(%s)", widget);
originalLocation = widget.getPreferredLocation();
dragBehaviour.nodeDragStarted(new DragEvent(node, widget, originalLocation));
}
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
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);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
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);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
public void layout (Widget widget) {
Collection<Widget> children = widget.getChildren ();
for (Widget child : children) {
if (child.isVisible ())
child.resolveBounds (child.getPreferredLocation (), null);
else
child.resolveBounds (null, new Rectangle ());
}
}
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
public void layout (Widget widget) {
Collection<Widget> children = widget.getChildren ();
for (Widget child : children) {
if (child.isVisible ())
child.resolveBounds (child.getPreferredLocation (), null);
else
child.resolveBounds (null, new Rectangle ());
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf-navigation
public void layoutNodesLocations( PageFlowScene scene, Collection<Page> nodes) {
final Collection<Page> allNodes = scene.getNodes();
for( Page node : nodes ) {
final Widget nodeWidget = scene.findWidget(node);
if( nodeWidget == null ) {
return;
}
if ( nodeWidget.getPreferredLocation() != null ) {
/* If the getPreferredLocation has already been set by something else. */
/* The unique ID for a node is it's display name defined by: node.getDisplayName() */
positions.put(node.getDisplayName(), nodeWidget.getPreferredLocation());
} else {
Point point = positions.get(node.getDisplayName());
if ( point == null ) {
point = getNewComponentLocation(scene, positions, allNodes);
}
positions.put(node.getDisplayName(), point);
nodeWidget.setPreferredLocation(point);
}
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
for (Widget childWidget : children) {
Rectangle preferredBounds = childWidget.getPreferredBounds ();
Point location = childWidget.getPreferredLocation ();
int x = areaX - preferredBounds.x;
int y = areaY + yCursor - preferredBounds.y;
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
for (Widget childWidget : children) {
Rectangle preferredBounds = childWidget.getPreferredBounds ();
Point location = childWidget.getPreferredLocation ();
int x = areaX - preferredBounds.x;
int y = areaY + yCursor - preferredBounds.y;
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
public void layout (Widget widget) {
assert widget == cardLayoutWidget;
Point preferredLocation = null;
Rectangle preferredBounds = null;
if (activeChildWidget != null && activeChildWidget.isVisible ())
for (Widget child : cardLayoutWidget.getChildren ())
if (child == activeChildWidget) {
preferredLocation = child.getPreferredLocation ();
preferredBounds = child.getPreferredBounds ();
break;
}
if (preferredLocation == null)
preferredLocation = POINT_EMPTY;
if (preferredBounds == null)
preferredBounds = RECTANGLE_EMPTY;
Rectangle otherBounds = new Rectangle (preferredBounds.x, preferredBounds.y, 0, 0);
for (Widget child : cardLayoutWidget.getChildren ())
child.resolveBounds (preferredLocation, child == activeChildWidget ? preferredBounds : otherBounds);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
public void layout (Widget widget) {
assert widget == cardLayoutWidget;
Point preferredLocation = null;
Rectangle preferredBounds = null;
if (activeChildWidget != null && activeChildWidget.isVisible ())
for (Widget child : cardLayoutWidget.getChildren ())
if (child == activeChildWidget) {
preferredLocation = child.getPreferredLocation ();
preferredBounds = child.getPreferredBounds ();
break;
}
if (preferredLocation == null)
preferredLocation = POINT_EMPTY;
if (preferredBounds == null)
preferredBounds = RECTANGLE_EMPTY;
Rectangle otherBounds = new Rectangle (preferredBounds.x, preferredBounds.y, 0, 0);
for (Widget child : cardLayoutWidget.getChildren ())
child.resolveBounds (preferredLocation, child == activeChildWidget ? preferredBounds : otherBounds);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
Widget view = getView ();
if (view != null && slider.getPartHitAt (event.getPoint ()) == SliderWidget.Part.SLIDER) {
movingWidget = widget;
originalSceneLocation = view.getPreferredLocation ();
if (originalSceneLocation == null)
originalSceneLocation = new Point ();
dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
return State.createLocked (widget, this);
}
}
return State.REJECTED;
}
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (event.getButton () == MouseEvent.BUTTON1 && event.getClickCount () == 1) {
Widget view = getView ();
if (view != null && slider.getPartHitAt (event.getPoint ()) == SliderWidget.Part.SLIDER) {
movingWidget = widget;
originalSceneLocation = view.getPreferredLocation ();
if (originalSceneLocation == null)
originalSceneLocation = new Point ();
dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
return State.createLocked (widget, this);
}
}
return State.REJECTED;
}
代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-visual
@Override
public void movementFinished (final @Nonnull Widget widget)
{
logger.fine("movementFinished(%s)", widget);
final Point newLocation = widget.getPreferredLocation();
logger.finer(">>>> original location: %s, new location: %s", originalLocation, newLocation);
final DragEvent dragEvent = new DragEvent(node, widget, newLocation);
if (newLocation.equals(originalLocation))
{
dragBehaviour.nodeDragFinished(dragEvent, CANCELLED);
}
else if (dragBehaviour.confirmDrag(dragEvent) == CONFIRMED)
{
dragBehaviour.nodeDragFinished(dragEvent, CONFIRMED);
}
else // roll back to original location
{
// TODO use an animation - the SceneAnimator is not good, since we aren't notified when the animation
// has been completed. We need to know as the nodeDragFinished() call must be performed at that time,
// otherwise the LocationProvider kicks in and sticks the widget to its coordinates.
widget.setPreferredLocation(originalLocation);
dragBehaviour.nodeDragFinished(dragEvent, CANCELLED);
}
originalLocation = null;
}
代码示例来源:origin: in.jlibs/org-netbeans-api-visual
/**
* Should be called to set a new resolved preferred location of a node.
* @param graph the universal graph
* @param node the node with resolved location
* @param newPreferredLocation the new resolved location
*/
protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) {
ObjectScene scene = graph.getScene ();
Widget widget = scene.findWidget (node);
if (widget == null)
return;
Point previousPreferredLocation = widget.getPreferredLocation ();
if (animated)
scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation);
else
widget.setPreferredLocation (newPreferredLocation);
GraphLayoutListener<N,E>[] listeners = createListenersCopy ();
for (GraphLayoutListener<N,E> listener : listeners)
listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual
/**
* Should be called to set a new resolved preferred location of a node.
* @param graph the universal graph
* @param node the node with resolved location
* @param newPreferredLocation the new resolved location
*/
protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) {
ObjectScene scene = graph.getScene ();
Widget widget = scene.findWidget (node);
if (widget == null)
return;
Point previousPreferredLocation = widget.getPreferredLocation ();
if (animated)
scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation);
else
widget.setPreferredLocation (newPreferredLocation);
GraphLayoutListener<N,E>[] listeners = createListenersCopy ();
for (GraphLayoutListener<N,E> listener : listeners)
listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation);
}
内容来源于网络,如有侵权,请联系作者删除!