本文整理汇总了Java中org.netbeans.api.visual.widget.Widget类的典型用法代码示例。如果您正苦于以下问题:Java Widget类的具体用法?Java Widget怎么用?Java Widget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Widget类属于org.netbeans.api.visual.widget包,在下文中一共展示了Widget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handleKeyEvent
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
private State handleKeyEvent (Widget widget, WidgetKeyEvent event, KeyStroke keyStroke) {
if (keyStroke == null)
return State.REJECTED;
ActionListener action;
if (actionMap != null && inputMap != null) {
Object o = inputMap.get (keyStroke);
action = o != null ? actionMap.get (o) : null;
} else {
JComponent view = widget.getScene ().getView ();
action = view != null ? view.getActionForKeyStroke (keyStroke) : null;
}
if (action != null) {
action.actionPerformed (new ActionEvent (widget, (int) event.getEventID (), null, event.getWhen (), event.getModifiers ())); // TODO - action-event command
return State.CONSUMED;
}
return State.REJECTED;
}
示例3: 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);
}
示例4: setText
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
@Override
public void setText(Widget widget, String string) {
String apName = ap.getName();
String actionName = action.getName();
try {
ap.setName(string);
action.setActionName(string);
} catch (Exception ex) {
try {
action.setActionName(actionName);
ap.setName(apName);
} catch (Exception ex1) {
// Shouldn't happen, but if it doesn, show exception
Exceptions.printStackTrace(ex1);
}
}
}
示例5: process
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
private boolean process (Widget widget, Point localLocation, int modifiers) {
boolean ctrl = (modifiers & MouseEvent.CTRL_DOWN_MASK) != 0;
boolean shift = (modifiers & MouseEvent.SHIFT_DOWN_MASK) != 0;
ContiguousSelectEvent.SelectionType type = ctrl
? (shift ? ContiguousSelectEvent.SelectionType.ADDITIVE_CONTIGUOUS : ContiguousSelectEvent.SelectionType.ADDITIVE_NON_CONTIGUOUS)
: (shift ? ContiguousSelectEvent.SelectionType.REPLACE_CONTIGUOUS : ContiguousSelectEvent.SelectionType.REPLACE_NON_CONTIGUOUS);
ContiguousSelectEvent providerEvent = ContiguousSelectEvent.create (previousWidget, previousLocalLocation, widget, localLocation, type);
if (provider.isSelectionAllowed (providerEvent)) {
provider.select(providerEvent);
if (! shift) {
previousWidget = widget;
previousLocalLocation = localLocation;
}
return true;
}
return false;
}
示例6: select
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
public void select(Widget widget, Point point, boolean change) {
if (widget == this) {
clearSelection();
} else {
assert widget instanceof BlockWidget;
BlockWidget bw = (BlockWidget) widget;
if (change) {
if (selection.contains(bw)) {
removeFromSelection(bw);
} else {
addToSelection(bw);
}
} else {
if (!selection.contains(bw)) {
clearSelection();
addToSelection(bw);
}
}
}
}
示例7: 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);
}
}
}
示例8: mouseReleased
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
@Override
public State mouseReleased (Widget widget, WidgetMouseEvent event) {
boolean state = pan (widget, event.getPoint ());
if (state)
scrollPane = null;
return state ? State.createLocked (widget, this) : State.REJECTED;
}
示例9: mouseReleased
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
@Override
public State mouseReleased(Widget widget, WidgetAction.WidgetMouseEvent event) {
// if (editor != null)
// closeEditor (true);
// return State.REJECTED;
if (editor != null) {
Container parent = editor.getParent();
if (parent != null) {
parent.requestFocusInWindow();
}
closeEditor(true);
}
return State.REJECTED;
}
示例10: ContiguousSelectEvent
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
private ContiguousSelectEvent (Widget previouslyChoosenWidget, Point previouslyChoosenLocalLocation, Widget choosenWidget, Point choosenLocalLocation, SelectionType selectionType) {
this.previouslyChoosenWidget = previouslyChoosenWidget;
this.previouslyChoosenLocalLocation = previouslyChoosenLocalLocation;
this.choosenWidget = choosenWidget;
this.choosenLocalLocation = choosenLocalLocation;
this.selectionType = selectionType;
}
示例11: mousePressed
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
// if (editor != null)
// closeEditor (true);
// return State.REJECTED;
if (editor != null) {
Container parent = editor.getParent();
if (parent != null) {
parent.requestFocusInWindow();
}
closeEditor(true);
}
return State.REJECTED;
}
示例12: getPopupMenu
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
@Override
public JPopupMenu getPopupMenu(Widget widget, Point point) {
JPopupMenu menu = diagramScene.createPopupMenu();
menu.addSeparator();
JMenu predecessors = new JMenu("Nodes Above");
predecessors.addMenuListener(new NeighborMenuListener(predecessors, getFigure(), false));
menu.add(predecessors);
JMenu successors = new JMenu("Nodes Below");
successors.addMenuListener(new NeighborMenuListener(successors, getFigure(), true));
menu.add(successors);
return menu;
}
示例13: testLabelOrientations
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
public void testLabelOrientations () {
Scene scene = new Scene ();
LayerWidget layer = new LayerWidget (scene);
scene.addChild(layer);
layer.addChild (new Widget (scene));
createLabel (layer, "N O R M A L", 100, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null);
createLabel (layer, "R O T A T E 9 0", 100, 100, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.BASELINE).setPreferredBounds (null);
createLabel (layer, "NORMAL BASELINE", 200, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE);
createLabel (layer, "ROTATE90 BASELINE", 200, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.BASELINE, LabelWidget.VerticalAlignment.BASELINE);
createLabel (layer, "NORMAL LEFT,TOP", 400, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP);
createLabel (layer, "ROTATE90 LEFT,TOP", 400, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.LEFT, LabelWidget.VerticalAlignment.TOP);
createLabel (layer, "NORMAL CENTER", 600, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER);
createLabel (layer, "ROTATE90 CENTER", 600, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.CENTER, LabelWidget.VerticalAlignment.CENTER);
createLabel (layer, "NORMAL RIGHT,BOTTOM", 800, 100, LabelWidget.Orientation.NORMAL, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM);
createLabel (layer, "ROTATE90 RIGHT,BOTTOM", 800, 300, LabelWidget.Orientation.ROTATE_90, LabelWidget.Alignment.RIGHT, LabelWidget.VerticalAlignment.BOTTOM);
BufferedImage snapshot = takeOneTimeSnapshot (scene);
BufferedImage clean = clearRegions (snapshot, Color.RED,
new Rectangle (100, 80, 100, 30),
new Rectangle (80, 0, 30, 110),
new Rectangle (190, 90, 130, 30),
new Rectangle (380, 70, 110, 30),
new Rectangle (610, 150, 120, 30),
new Rectangle (810, 230, 150, 30),
new Rectangle (180, 270, 30, 130),
new Rectangle (380, 270, 30, 160),
new Rectangle (650, 290, 30, 150),
new Rectangle (945, 275, 30, 190)
);
Color color = (Color) (new DefaultLookFeel()).getBackground();
assertCleaness (testCleaness (clean, color, Color.YELLOW, Color.RED), snapshot, clean);
}
示例14: installUI
import org.netbeans.api.visual.widget.Widget; //导入依赖的package包/类
public void installUI (VMDNodeWidget widget) {
widget.setBorder (BORDER60);
Widget header = widget.getHeader ();
header.setBackground (COLOR60_HOVER_BACKGROUND);
header.setBorder (VMDOriginalColorScheme.BORDER_PIN);
Widget pinsSeparator = widget.getPinsSeparator ();
pinsSeparator.setForeground (VMDOriginalColorScheme.BORDER_CATEGORY_BACKGROUND);
}
示例15: 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 ();
}
}