本文整理汇总了Java中org.netbeans.api.visual.widget.Widget.setPreferredLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Widget.setPreferredLocation方法的具体用法?Java Widget.setPreferredLocation怎么用?Java Widget.setPreferredLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.widget.Widget
的用法示例。
在下文中一共展示了Widget.setPreferredLocation方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResolvedNodeLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
* 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);
}
示例2: TestScene
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public TestScene() {
addChild(mainLayer);
addChild(connectionLayer);
addChild(interractionLayer);
getActions().addAction(createAction);
//mainLayer.addChild(new LabelWidget(this, "Click on background to create a node. Drag a node to create a connection."));
// do not change label nor location because it is hard coded in test cases
//addNode("Label 0").setPreferredLocation(new Point(100, 100));
Widget label0Widget = addNode("Label 0");
label0Widget.setPreferredLocation(new Point(100, 100));
label0Widget.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProvider()));
label0Widget.getActions().addAction(new LabelAction());
Widget label1Widget = addNode("Label 1");
label1Widget.setPreferredLocation(new Point(300, 100));
LabelWidget movableWidget = new LabelWidget(this, "Movable Widget");
movableWidget.setPreferredLocation(new Point(100, 150));
movableWidget.getActions().addAction(moveAction);
addChild(movableWidget);
}
示例3: finish
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private void finish() {
for (GraphNode n : scene.getNodes()) {
NodeWidget w = getWidget(n);
Widget wid = scene.findWidget(n);
Point point = new Point();
point.setLocation(w.locX, w.locY);
if (scene.isAnimated()) {
scene.getSceneAnimator().animatePreferredLocation(wid, point);
} else {
wid.setPreferredLocation(point);
}
}
}
示例4: 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 ();
}
}
示例5: performLayout
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
protected void performLayout () {
devolveLayout.layout (widget);
for (Widget child : widget.getChildren ()) {
if (animate)
widget.getScene ().getSceneAnimator ().animatePreferredLocation (child, child.getLocation ());
else
child.setPreferredLocation (child.getLocation ());
child.revalidate ();
}
}
示例6: testShow
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public void testShow () {
Scene scene = new Scene ();
LayerWidget mainLayer = new LayerWidget (scene);
scene.addChild(mainLayer);
Widget w1 = new Widget (scene);
w1.setBorder (BorderFactory.createLineBorder ());
w1.setPreferredLocation (new Point (100, 100));
w1.setPreferredSize (new Dimension (40, 20));
mainLayer.addChild(w1);
Widget w2 = new Widget (scene);
w2.setBorder (BorderFactory.createLineBorder ());
w2.setPreferredLocation (new Point (200, 100));
w2.setPreferredSize (new Dimension (40, 20));
mainLayer.addChild(w2);
LayerWidget connLayer = new LayerWidget (scene);
scene.addChild(connLayer);
ConnectionWidget conn = new ConnectionWidget(scene);
conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(w1));
conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(w2));
connLayer.addChild(conn);
Color color = (Color) (new DefaultLookFeel()).getBackground();
assertScene (scene, color,
new Rectangle (99, 99, 42, 22),
new Rectangle (199, 99, 42, 22),
new Rectangle (138, 108, 64, 4)
);
}
示例7: setNewLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
*
* @param widget
* @param location location returned by MoveStrategy
*/
@Override
public void setNewLocation(Widget widget, Point location) {
System.out.println("Set location " + location);
widget.setPreferredLocation(new Point(originalLocation.x + location.x, originalLocation.y + location.y));
}
示例8: setNewLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public void setNewLocation(Widget widget, Point location) {
if (selection.contains(widget)) {
// move entire selection
Point originalLocation = getOriginalLocation(widget);
int xOffset = location.x - originalLocation.x;
int yOffset = location.y - originalLocation.y;
for (Widget w : selection) {
Point p = new Point(w.getPreferredLocation());
p.translate(xOffset, yOffset);
w.setPreferredLocation(p);
}
} else {
widget.setPreferredLocation(location);
}
}
示例9: setNewLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override public void setNewLocation(Widget widget, Point location) {
widget.setPreferredLocation (location);
}
示例10: setNewLocation
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public void setNewLocation (Widget widget, Point location) {
widget.setPreferredLocation (location);
}
示例11: DiagramScene
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public DiagramScene(Action[] actions, DiagramViewModel model) {
this.actions = actions;
content = new InstanceContent();
lookup = new AbstractLookup(content);
this.setCheckClipping(true);
scrollPane = createScrollPane();
hoverAction = createObjectHoverAction();
// This panAction handles the event only when the left mouse button is
// pressed without any modifier keys, otherwise it will not consume it
// and the selection action (below) will handle the event
panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK);
this.getActions().addAction(panAction);
selectAction = createSelectAction();
this.getActions().addAction(selectAction);
blockLayer = new LayerWidget(this);
this.addChild(blockLayer);
mainLayer = new LayerWidget(this);
this.addChild(mainLayer);
topLeft = new Widget(this);
topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(topLeft);
bottomRight = new Widget(this);
bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(bottomRight);
connectionLayer = new LayerWidget(this);
this.addChild(connectionLayer);
LayerWidget selectionLayer = new LayerWidget(this);
this.addChild(selectionLayer);
this.setLayout(LayoutFactory.createAbsoluteLayout());
this.getInputBindings().setZoomActionModifiers(KeyEvent.CTRL_MASK);
zoomAction = ActionFactory.createMouseCenteredZoomAction(1.2);
this.getActions().addAction(zoomAction);
this.getView().addMouseWheelListener(mouseWheelListener);
this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));
this.getActions().addAction(ActionFactory.createWheelPanAction());
LayerWidget selectLayer = new LayerWidget(this);
this.addChild(selectLayer);
this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));
boolean b = this.getUndoRedoEnabled();
this.setUndoRedoEnabled(false);
this.setNewModel(model);
this.setUndoRedoEnabled(b);
this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED);
}
示例12: DiagramScene
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public DiagramScene(DiagramViewModel model) {
this.model = model;
content = new InstanceContent();
lookup = new AbstractLookup(content);
content.add(this);
this.setCheckClipping(true);
scrollPane = createScrollPane();
hoverAction = createObjectHoverAction();
// This panAction handles the event only when the left mouse button is
// pressed without any modifier keys, otherwise it will not consume it
// and the selection action (below) will handle the event
panAction = new CustomizablePanWidgetAction(~0, MouseEvent.BUTTON1_DOWN_MASK);
this.getActions().addAction(panAction);
selectAction = createSelectAction();
this.getActions().addAction(selectAction);
blockLayer = new LayerWidget(this);
this.addChild(blockLayer);
mainLayer = new LayerWidget(this);
this.addChild(mainLayer);
topLeft = new Widget(this);
topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(topLeft);
bottomRight = new Widget(this);
bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(bottomRight);
connectionLayer = new LayerWidget(this);
this.addChild(connectionLayer);
LayerWidget selectionLayer = new LayerWidget(this);
this.addChild(selectionLayer);
this.setLayout(LayoutFactory.createAbsoluteLayout());
this.getInputBindings().setZoomActionModifiers(KeyEvent.CTRL_MASK);
zoomAction = ActionFactory.createMouseCenteredZoomAction(1.2);
this.getActions().addAction(zoomAction);
this.getView().addMouseWheelListener(mouseWheelListener);
this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));
this.getActions().addAction(ActionFactory.createWheelPanAction());
LayerWidget selectLayer = new LayerWidget(this);
this.addChild(selectLayer);
this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));
this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED);
update();
}
示例13: DiagramScene
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public DiagramScene(Action[] actions, Action[] actionsWithSelection, DiagramViewModel model) {
this.actions = actions;
this.actionsWithSelection = actionsWithSelection;
content = new InstanceContent();
lookup = new AbstractLookup(content);
this.setCheckClipping(true);
scrollPane = createScrollPane();
hoverAction = createObjectHoverAction();
// This panAction handles the event only when the left mouse button is
// pressed without any modifier keys, otherwise it will not consume it
// and the selection action (below) will handle the event
panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK);
this.getActions().addAction(panAction);
selectAction = createSelectAction();
this.getActions().addAction(selectAction);
blockLayer = new LayerWidget(this);
this.addChild(blockLayer);
connectionLayer = new LayerWidget(this);
this.addChild(connectionLayer);
mainLayer = new LayerWidget(this);
this.addChild(mainLayer);
topLeft = new Widget(this);
topLeft.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(topLeft);
bottomRight = new Widget(this);
bottomRight.setPreferredLocation(new Point(-BORDER_SIZE, -BORDER_SIZE));
this.addChild(bottomRight);
LayerWidget selectionLayer = new LayerWidget(this);
this.addChild(selectionLayer);
this.setLayout(LayoutFactory.createAbsoluteLayout());
this.getInputBindings().setZoomActionModifiers(KeyEvent.CTRL_MASK);
zoomAction = ActionFactory.createMouseCenteredZoomAction(1.2);
this.getActions().addAction(zoomAction);
this.getView().addMouseWheelListener(mouseWheelListener);
this.getActions().addAction(ActionFactory.createPopupMenuAction(popupMenuProvider));
this.getActions().addAction(ActionFactory.createWheelPanAction());
LayerWidget selectLayer = new LayerWidget(this);
this.addChild(selectLayer);
this.getActions().addAction(ActionFactory.createRectangularSelectAction(rectangularSelectDecorator, selectLayer, rectangularSelectProvider));
boolean b = this.getUndoRedoEnabled();
this.setUndoRedoEnabled(false);
this.setNewModel(model);
this.setUndoRedoEnabled(b);
this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED);
}