本文整理汇总了Java中org.netbeans.api.visual.widget.Widget.getScene方法的典型用法代码示例。如果您正苦于以下问题:Java Widget.getScene方法的具体用法?Java Widget.getScene怎么用?Java Widget.getScene使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.visual.widget.Widget
的用法示例。
在下文中一共展示了Widget.getScene方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMouseEvent
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
* Conditionally display a {@link JPopupMenu} for the given Widget if
* the WidgetMouseEvent is a popup trigger. This method is called
* by both {@link #mousePressed(Widget, WidgetMouseEvent)} and
* {@link #mouseReleased(Widget, WidgetMouseEvent)} methods to handle
* displaying a popup menu for the given widget and event. Uses
* {@link WidgetMouseEvent#isPopupTrigger() event.isPopupTrigger()} to
* determine whether or not a popup menu should be displayed.
* @param widget
* @param event
* @return {@link State#REJECTED} if no JPopupMenu is displayed,
* or {@link State#CONSUMED} if a JPopupMenu is displayed.
* @see #mousePressed(Widget, WidgetMouseEvent)
* @see #mouseReleased(Widget, WidgetMouseEvent)
*/
protected State handleMouseEvent (Widget widget, WidgetMouseEvent event) {
// Different OSes use different MouseEvents (Pressed/Released) to
// signal that an event is a PopupTrigger. So, the mousePressed(...)
// and mouseReleased(...) methods delegate to this method to
// handle the MouseEvent.
if (event.isPopupTrigger ()) {
JPopupMenu popupMenu = provider.getPopupMenu (widget, event.getPoint ());
if (popupMenu != null) {
Scene scene = widget.getScene ();
Point point = scene.convertSceneToView (widget.convertLocalToScene (event.getPoint ()));
popupMenu.show (scene.getView (), point.x, point.y);
}
return State.CONSUMED;
}
return State.REJECTED;
}
示例2: mousePressed
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked()) {
return State.createLocked(widget, this);
}
scene = widget.getScene();
if (event.getButton() == scene.getInputBindings().getPanActionButton()) {
scrollPane = findScrollPane (scene.getView ());
if (scrollPane != null) {
lastLocation = scene.convertSceneToView (widget.convertLocalToScene (event.getPoint ()));
SwingUtilities.convertPointToScreen (lastLocation, scene.getView ());
return State.createLocked (widget, this);
}
}
return State.REJECTED;
}
示例3: pan
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private boolean pan (Widget widget, Point newLocation) {
if (scrollPane == null || scene != widget.getScene ())
return false;
newLocation = scene.convertSceneToView (widget.convertLocalToScene (newLocation));
SwingUtilities.convertPointToScreen (newLocation, scene.getView ());
JComponent view = scene.getView ();
Rectangle rectangle = view.getVisibleRect ();
rectangle.x += lastLocation.x - newLocation.x;
rectangle.y += lastLocation.y - newLocation.y;
view.scrollRectToVisible (rectangle);
lastLocation = newLocation;
return true;
}
示例4: createEditorComponent
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public JTextField createEditorComponent (EditorController controller, Widget widget) {
if (! editor.isEnabled (widget))
return null;
JTextField field = new JTextField (editor.getText (widget));
field.selectAll ();
Scene scene = widget.getScene();
double zoomFactor = scene.getZoomFactor ();
if (zoomFactor > 1.0) {
Font font = scene.getDefaultFont();
font = font.deriveFont((float) (font.getSize2D() * zoomFactor));
field.setFont (font);
}
return field;
}
示例5: mousePressed
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
public State mousePressed (Widget widget, WidgetMouseEvent event) {
if (isLocked ())
return State.createLocked (widget, this);
if (enabled && (event.getModifiersEx() & modifiersExMask) == modifiersEx) {
scene = widget.getScene ();
scrollPane = findScrollPane (scene.getView ());
if (scrollPane != null) {
lastLocation = scene.convertSceneToView (widget.convertLocalToScene (event.getPoint ()));
SwingUtilities.convertPointToScreen (lastLocation, scene.getView ());
return State.createLocked (widget, this);
}
}
return State.REJECTED;
}
示例6: mouseWheelMoved
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) {
Scene scene = widget.getScene ();
int modifiers = scene.getInputBindings ().getZoomActionModifiers ();
if ((event.getModifiers () & modifiers) != modifiers)
return State.REJECTED;
int amount = event.getWheelRotation ();
double scale = 1.0;
while (amount > 0) {
scale /= zoomMultiplier;
amount --;
}
while (amount < 0) {
scale *= zoomMultiplier;
amount ++;
}
JComponent view = scene.getView ();
if (view != null) {
Rectangle viewBounds = view.getVisibleRect ();
Point center = widget.convertLocalToScene (event.getPoint ());
Point mouseLocation = scene.convertSceneToView (center);
scene.setZoomFactor (scale * scene.getZoomFactor ());
scene.validate (); // HINT - forcing to change preferred size of the JComponent view
center = scene.convertSceneToView (center);
view.scrollRectToVisible (new Rectangle (
center.x - (mouseLocation.x - viewBounds.x),
center.y - (mouseLocation.y - viewBounds.y),
viewBounds.width,
viewBounds.height
));
} else
scene.setZoomFactor (scale * scene.getZoomFactor ());
return State.CONSUMED;
}
示例7: switchPreviousFocus
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public boolean switchPreviousFocus (Widget widget) {
Scene scene = widget.getScene ();
return scene instanceof ObjectScene && switchFocus ((ObjectScene) scene, false);
}
示例8: switchNextFocus
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public boolean switchNextFocus (Widget widget) {
Scene scene = widget.getScene ();
return scene instanceof ObjectScene && switchFocus ((ObjectScene) scene, true);
}
示例9: mouseWheelMoved
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) {
Scene scene = widget.getScene ();
int modifiers = scene.getInputBindings ().getZoomActionModifiers ();
if ((event.getModifiers () & modifiers) != modifiers)
return State.REJECTED;
int amount = event.getWheelRotation ();
double scale = 1.0;
while (amount > 0) {
scale /= zoomMultiplier;
amount --;
}
while (amount < 0) {
scale *= zoomMultiplier;
amount ++;
}
JComponent view = scene.getView ();
if (view != null) {
Rectangle viewBounds = view.getVisibleRect ();
Point center = GeomUtil.center (viewBounds);
center = scene.convertViewToScene (center);
scene.setZoomFactor (scale * scene.getZoomFactor ());
scene.validate (); // HINT - forcing to change preferred size of the JComponent view
center = scene.convertSceneToView (center);
view.scrollRectToVisible (new Rectangle (
center.x - viewBounds.width / 2,
center.y - viewBounds.height / 2,
viewBounds.width,
viewBounds.height
));
} else
scene.setZoomFactor (scale * scene.getZoomFactor ());
return State.CONSUMED;
}
示例10: openEditor
import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private boolean openEditor (Widget widget, InplaceEditorProvider.EditorInvocationType invocationType) {
if (editor != null) {
return false;
}
Scene scene = widget.getScene();
JComponent component = scene.getView();
if (component == null) {
return false;
}
this.invocationType = invocationType;
editor = provider.createEditorComponent(this, widget);
if (editor == null) {
this.invocationType = null;
return false;
}
this.widget = widget;
component.add(editor);
provider.notifyOpened(this, widget, editor);
Rectangle rectangle = widget.getScene().convertSceneToView(widget.convertLocalToScene(widget.getBounds()));
Point center = GeomUtil.center(rectangle);
Dimension size = editor.getMinimumSize();
if (rectangle.width > size.width) {
size.width = rectangle.width;
}
if (rectangle.height > size.height) {
size.height = rectangle.height;
}
int x = center.x - size.width / 2;
int y = center.y - size.height / 2;
rectangle = new Rectangle(x, y, size.width, size.height);
updateRectangleToFitToView(rectangle);
Rectangle r = provider.getInitialEditorComponentBounds(this, widget, editor, rectangle);
this.rectangle = r != null ? r : rectangle;
editor.setBounds(x, y, size.width, size.height);
notifyEditorComponentBoundsChanged();
editor.requestFocusInWindow();
return true;
}