Java Code Examples for org.netbeans.api.visual.widget.Widget#getScene()
The following examples show how to use
org.netbeans.api.visual.widget.Widget#getScene() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupMenuAction.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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; }
Example 2
Source File: ExtendedPanAction.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 3
Source File: ExtendedPanAction.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 4
Source File: PanAction.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: PanAction.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: ExtendedPanAction.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 7
Source File: TextFieldInplaceEditorProvider.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 8
Source File: ExtendedPanAction.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 9
Source File: ExtendedPanAction.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 10
Source File: ExtendedPanAction.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 11
Source File: CustomizablePanAction.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example 12
Source File: CustomizablePanAction.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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; }
Example 13
Source File: ExtendedPanAction.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public State mousePressed(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) { scene = widget.getScene(); scrollPane = findScrollPane(scene.getView()); if (scrollPane != null) { lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint())); SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView()); return State.createLocked(widget, this); } } return State.REJECTED; }
Example 14
Source File: Highlighter.java From jlibs with Apache License 2.0 | 4 votes |
private Widget resolve(Widget widget){ ObjectScene scene = (ObjectScene)widget.getScene(); return scene.findWidget(scene.findObject(widget)); }
Example 15
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 4 votes |
public void edit(Widget widget) { PageFlowScene scene = (PageFlowScene) widget.getScene(); PageFlowSceneElement element = (PageFlowSceneElement) scene.findObject(widget); MapActionUtility.openPageFlowSceneElement(element); }
Example 16
Source File: InplaceEditorAction.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 17
Source File: CenteredZoomAction.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 18
Source File: CycleObjectSceneFocusProvider.java From netbeans with Apache License 2.0 | 4 votes |
public boolean switchNextFocus (Widget widget) { Scene scene = widget.getScene (); return scene instanceof ObjectScene && switchFocus ((ObjectScene) scene, true); }
Example 19
Source File: CycleObjectSceneFocusProvider.java From netbeans with Apache License 2.0 | 4 votes |
public boolean switchPreviousFocus (Widget widget) { Scene scene = widget.getScene (); return scene instanceof ObjectScene && switchFocus ((ObjectScene) scene, false); }
Example 20
Source File: MouseCenteredZoomAction.java From netbeans with Apache License 2.0 | 4 votes |
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; }