Class AreaSelectionTool

  • All Implemented Interfaces:
    MenuContributor

    public class AreaSelectionTool
    extends Tool
    This tool can be used to select an area in the page view.

    Actions can be registered via addRegisteredActions(RegisteredAction...). If an area is selected, a toolbar will pop up to execute one of the registered actions. If no toolbar is desired, a default action can be set via setDefaultAction(RegisteredAction).

    If a default action is set, it will be executed immediately and no toolbar will be shown. This default action will be removed after the area selection and has to be set before each selection, if desired.

    • Field Detail

      • startPointDocument

        protected Point2D startPointDocument
      • endPointDocument

        protected Point2D endPointDocument
      • startPointScreen

        protected Point2D startPointScreen
      • endPointScreen

        protected Point2D endPointScreen
      • page

        protected Page page
    • Constructor Detail

      • AreaSelectionTool

        public AreaSelectionTool()
    • Method Detail

      • render

        protected void render​(RenderParameters parameters,
                              boolean isActive)
        Description copied from class: Tool
        Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.

        This render method is called within the context and during the rendering of a single page. The page being rendered is passed to implementors of this method in order to be able to control and influence the page rendering.

        Overrides:
        render in class Tool
        Parameters:
        parameters - the view component which is currently being rendered
        isActive - whether the called tool is currently active
      • handleMouseEntered

        protected void handleMouseEntered​(MouseEditEvent e,
                                          boolean isActive)
        Description copied from class: Tool
        Invoked when the mouse cursor enters the unobscured part of component's geometry.
        Overrides:
        handleMouseEntered in class Tool
        Parameters:
        e - the MouseEditEvent
        isActive - whether this tool is currently active
      • handleMousePressed

        protected void handleMousePressed​(MouseEditEvent e,
                                          boolean isActive)
        Description copied from class: Tool
        Invoked when a mouse button has been pressed on a component.
        Overrides:
        handleMousePressed in class Tool
        Parameters:
        e - the event
        isActive - whether this tool is currently active
      • handleMouseReleased

        protected void handleMouseReleased​(MouseEditEvent e,
                                           boolean isActive)
        Description copied from class: Tool
        Invoked when a mouse button has been released on a component.
        Overrides:
        handleMouseReleased in class Tool
        Parameters:
        e - the event
        isActive - whether this tool is currently active
      • handleKeyReleased

        protected void handleKeyReleased​(KeyEditEvent e,
                                         boolean isActive)
        Description copied from class: Tool
        Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.
        Overrides:
        handleKeyReleased in class Tool
        Parameters:
        e - the MouseEditEvent
        isActive - whether this tool is currently active
      • setEnabled

        protected void setEnabled​(boolean enabled)
        Description copied from class: Tool
        Receive notification from the tool manager about the tool's enabled state. In general, tools need not and should not try to implement different behaviour depending on the enabled state, as this is already covered by the ToolManager calling the Tool.handleEditEvent(boolean, EditEvent) and Tool.render(RenderParameters, boolean) in the appropriate state only. However, some tools may need to perform extended actions (for example, for resource management purposes) upon a change of the enabled state.
        Overrides:
        setEnabled in class Tool
        Parameters:
        enabled - controls whether to enable or disable this Tool
      • onAreaSelected

        protected void onAreaSelected​(PageView pageView,
                                      com.levigo.jadice.web.shared.model.internal.SelectedArea area)
        Called when the user selected an area. If a default action is registered, it will be executed. If there is no default action, the toolbar will be opened for the registered commands.
        Parameters:
        pageView - the page view
        area - the selected area
      • handleMouseDragged

        protected void handleMouseDragged​(MouseEditEvent e,
                                          boolean isActive)
        Description copied from class: Tool
        Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

        Due to platform-dependent DragDrop implementations, MouseDragEvent events may not be delivered during a native Drag&Drop operation.

        Overrides:
        handleMouseDragged in class Tool
        Parameters:
        e - the event
        isActive - whether this tool is currently active
      • addRegisteredActions

        public void addRegisteredActions​(RegisteredAction... registeredActions)
      • getDefaultAction

        public RegisteredAction getDefaultAction()
        Returns the current default action which is registered to be executed on the next selection.
        Returns:
        the default action
      • setDefaultAction

        public void setDefaultAction​(RegisteredAction defaultAction)
        Sets the default action to be executed on the next area selection. Please note that after a selection, the default action will be set to null and has to be set when starting the area selection with a command.
        Parameters:
        defaultAction - the default action to be executed on next selection
      • createToolbarActionContext

        public Context createToolbarActionContext()
      • getPageView

        public PageView getPageView()