Class ViewManager

java.lang.Object
com.kheops.jmap.client.views.ViewManager
All Implemented Interfaces:
JMapEventDispatcher, ViewEventListener, MouseListener, MouseMotionListener, EventListener

public class ViewManager extends Object implements JMapEventDispatcher, ViewEventListener, MouseListener, MouseMotionListener
The ViewManager class is responsible for managing View objects by keeping the list of views, by broadcasting the events to the views and by providing general services about the views such as determining which view is the currently active view. In an application, there is generally only one ViewManager instance.
  • Field Details

  • Constructor Details

    • ViewManager

      public ViewManager()
      Constructs a new ViewManager object
  • Method Details

    • dispatchEvent

      public void dispatchEvent(JMapEvent event)
      The dispatchEvent method is used to dispatch synchronously JMap events to all registered listeners. The main use of the JMapEventDispatcher interface is to dispatch events that were previously added to the JMap event queue.
      Note: only ViewEvent and ViewManagerEvent will be accepted by this method. Any other JMap event types will cause the view manager to throw an exception.
      Specified by:
      dispatchEvent in interface JMapEventDispatcher
      Parameters:
      event - the event to be dispatched.
      Throws:
      IllegalArgumentException - will be thrown if the JMapEvent instance is no an instance of the ViewEvent class.
      See Also:
    • addView

      public void addView(View view)
      Adds a new view to the list of views managed by this ViewManager object.
      Parameters:
      view - the view to be added
    • getView

      public View getView(String viewName)
    • removeView

      public void removeView(View view)
      Removes the specified view of the list managed by this ViewManager object.
      Parameters:
      view - the View object to remove from the list.
    • removeAllViews

      public void removeAllViews()
      Removes all views managed by this ViewManager object.
    • addViewEventListener

      public void addViewEventListener(ViewEventListener listener)
      Adds a new listener for view events.
      Parameters:
      listener - the corresponding ViewEventListener
    • removeViewEventListener

      public void removeViewEventListener(ViewEventListener listener)
      Removes a listener for view events.
      Parameters:
      listener - the corresponding ViewEventListener
    • addMouseListener

      public void addMouseListener(MouseListener listener)
      Adds a new listener for mouse events.
      Parameters:
      listener - the corresponding MouseListener
    • removeMouseListener

      public void removeMouseListener(MouseListener listener)
      Removes a listener for mouse events.
      Parameters:
      listener - the corresponding MouseListener
    • addMouseMotionListener

      public void addMouseMotionListener(MouseMotionListener listener)
      Adds a new listener for mouse motion events.
      Parameters:
      listener - the corresponding MouseMotionListener
    • removeMouseMotionListener

      public void removeMouseMotionListener(MouseMotionListener listener)
      Removes a listener for mouse motion events.
      Parameters:
      listener - the corresponding MouseMotionListener
    • getViewCount

      public int getViewCount()
      Returns the number of views managed by the view manager.
      Returns:
      the number of views managed by the view manager.
    • getViews

      public View[] getViews()
      Returns an array of views managed by this ViewManager object.
      Returns:
      an array of views
    • getActiveView

      public View getActiveView()
      Returns the current active view. May return null if there's no views in this view manager.
      Returns:
      the active view
    • refresh

      public void refresh()
      Refreshes all views managed by this ViewManager object.
    • redraw

      public void redraw(OrientedRectangle wcRegion, int drawOptions)
      Redraws all views. If clear is true, the view is erased first. Layers are drawn from lower position to higher position starting from fromLayer. WCRegion specifies the region to draw in WC coordinates. If drawing is already occurring, it will be stopped first.
      Parameters:
      wcRegion - the region to redraw.
      drawOptions - a bit field value that specified parts to be drawn.
    • close

      public void close()
      Closes all views managed by this ViewManager object.
    • setCurrentTool

      public void setCurrentTool(Tool currentTool)
      Sets the current tool to be used by all registered View objects.
      Parameters:
      currentTool - the tool to be used.
    • viewChangedOccurred

      public void viewChangedOccurred(ViewChangedEvent event)
      Description copied from interface: ViewEventListener
      This method handles ViewChangedEvent
      Specified by:
      viewChangedOccurred in interface ViewEventListener
      Parameters:
      event - the corresponding ViewChangedEvent object
    • viewToolChangedOccurred

      public void viewToolChangedOccurred(ViewToolChangedEvent event)
      Description copied from interface: ViewEventListener
      This method handles ViewToolChangedEvent
      Specified by:
      viewToolChangedOccurred in interface ViewEventListener
      Parameters:
      event - the corresponding ViewToolChangedEvent object
    • viewPopupMenuShowing

      public void viewPopupMenuShowing(ViewPopupMenuShowingEvent event)
      Description copied from interface: ViewEventListener
      This method handles ViewPopupMenuShowing
      Specified by:
      viewPopupMenuShowing in interface ViewEventListener
      Parameters:
      event - the corresponding ViewPopupMenuShowingEvent object
    • viewRedrawOccurred

      public void viewRedrawOccurred(ViewRedrawEvent event)
      Description copied from interface: ViewEventListener
      This method handles viewRedrawOccurred
      Specified by:
      viewRedrawOccurred in interface ViewEventListener
      Parameters:
      event - the corresponding ViewRedrawEvent object
    • viewRepaintOccurred

      public void viewRepaintOccurred(ViewRepaintEvent event)
      Description copied from interface: ViewEventListener
      This method handles viewRepaintOccurred
      Specified by:
      viewRepaintOccurred in interface ViewEventListener
      Parameters:
      event - the corresponding ViewRepaintEvent object
    • viewStaticElementChanged

      public void viewStaticElementChanged(ViewStaticElementEvent event)
      Description copied from interface: ViewEventListener
      This method handles viewStaticElementChanged
      Specified by:
      viewStaticElementChanged in interface ViewEventListener
      Parameters:
      event - the corresponding ViewStaticElementEvent object
    • viewReadyOccurred

      public void viewReadyOccurred(ViewReadyEvent event)
      Description copied from interface: ViewEventListener
      This method handles ViewReadyOccurred
      Specified by:
      viewReadyOccurred in interface ViewEventListener
      Parameters:
      event - the corresponding ViewReadyEvent object
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • getLayerManager

      public LayerManager getLayerManager()
      Returns the layer manager of the active view. May return null if there's no view in this view manager.
      Returns:
      layerMgr
    • addViewManagerEventListener

      public void addViewManagerEventListener(ViewManagerEventListener viewManagerEventListener)
      Adds a new ViewManager listener.
      Parameters:
      viewManagerEventListener - the view manager listener to add
      See Also:
    • removeViewManagerEventListener

      public void removeViewManagerEventListener(ViewManagerEventListener viewManagerEventListener)
      Removes a ViewManager listener.
      Parameters:
      viewManagerEventListener -
      See Also:
    • fireViewActivated

      public void fireViewActivated(View view)
      Fires a new viewActivated event using this ViewManager as the source of the event
      Parameters:
      view - activated view
    • fireViewActivated

      public void fireViewActivated(View view, Object src)
      Fires a new viewActivated event
      Parameters:
      view - activated view
      src - the source of the event
    • fireViewDeactivated

      public void fireViewDeactivated(View view)