Package com.kheops.jmap.client.views
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Tool
protected View
protected LayerRefreshManager
protected final Vector
<MouseListener> protected final Vector
<MouseMotionListener> protected final ViewManagerEventDispatcher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMouseListener
(MouseListener listener) Adds a new listener for mouse events.void
addMouseMotionListener
(MouseMotionListener listener) Adds a new listener for mouse motion events.void
Adds a new view to the list of views managed by this ViewManager object.void
addViewEventListener
(ViewEventListener listener) Adds a new listener for view events.void
addViewManagerEventListener
(ViewManagerEventListener viewManagerEventListener) Adds a new ViewManager listener.void
close()
Closes all views managed by this ViewManager object.void
dispatchEvent
(JMapEvent event) ThedispatchEvent
method is used to dispatch synchronously JMap events to all registered listeners.void
fireViewActivated
(View view) Fires a new viewActivated event using this ViewManager as the source of the eventvoid
fireViewActivated
(View view, Object src) Fires a new viewActivated eventvoid
fireViewDeactivated
(View view) Returns the current active view.Returns the layer manager of the active view.int
Returns the number of views managed by the view manager.View[]
getViews()
Returns an array of views managed by this ViewManager object.void
void
void
void
void
void
void
void
redraw
(OrientedRectangle wcRegion, int drawOptions) Redraws all views.void
refresh()
Refreshes all views managed by this ViewManager object.void
Removes all views managed by this ViewManager object.void
removeMouseListener
(MouseListener listener) Removes a listener for mouse events.void
removeMouseMotionListener
(MouseMotionListener listener) Removes a listener for mouse motion events.void
removeView
(View view) Removes the specified view of the list managed by this ViewManager object.void
removeViewEventListener
(ViewEventListener listener) Removes a listener for view events.void
removeViewManagerEventListener
(ViewManagerEventListener viewManagerEventListener) Removes a ViewManager listener.void
setCurrentTool
(Tool currentTool) Sets the current tool to be used by all registered View objects.void
This method handles ViewChangedEventvoid
This method handles ViewPopupMenuShowingvoid
viewReadyOccurred
(ViewReadyEvent event) This method handles ViewReadyOccurredvoid
This method handles viewRedrawOccurredvoid
This method handles viewRepaintOccurredvoid
This method handles viewStaticElementChangedvoid
This method handles ViewToolChangedEvent
-
Field Details
-
currentTool
-
viewEventDispatcher
-
mouseListeners
-
mouseMotionListeners
-
views
-
currentView
-
layerRefreshManager
-
-
Constructor Details
-
ViewManager
public ViewManager()Constructs a new ViewManager object
-
-
Method Details
-
dispatchEvent
ThedispatchEvent
method is used to dispatch synchronously JMap events to all registered listeners. The main use of theJMapEventDispatcher
interface is to dispatch events that were previously added to the JMap event queue.
Note: onlyViewEvent
andViewManagerEvent
will be accepted by this method. Any other JMap event types will cause the view manager to throw an exception.- Specified by:
dispatchEvent
in interfaceJMapEventDispatcher
- Parameters:
event
- the event to be dispatched.- Throws:
IllegalArgumentException
- will be thrown if theJMapEvent
instance is no an instance of theViewEvent
class.- See Also:
-
addView
Adds a new view to the list of views managed by this ViewManager object.- Parameters:
view
- the view to be added
-
getView
-
removeView
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
Adds a new listener for view events.- Parameters:
listener
- the corresponding ViewEventListener
-
removeViewEventListener
Removes a listener for view events.- Parameters:
listener
- the corresponding ViewEventListener
-
addMouseListener
Adds a new listener for mouse events.- Parameters:
listener
- the corresponding MouseListener
-
removeMouseListener
Removes a listener for mouse events.- Parameters:
listener
- the corresponding MouseListener
-
addMouseMotionListener
Adds a new listener for mouse motion events.- Parameters:
listener
- the corresponding MouseMotionListener
-
removeMouseMotionListener
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
Returns an array of views managed by this ViewManager object.- Returns:
- an array of views
-
getActiveView
Returns the current active view. May returnnull
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
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
Sets the current tool to be used by all registered View objects.- Parameters:
currentTool
- the tool to be used.
-
viewChangedOccurred
Description copied from interface:ViewEventListener
This method handles ViewChangedEvent- Specified by:
viewChangedOccurred
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewChangedEvent object
-
viewToolChangedOccurred
Description copied from interface:ViewEventListener
This method handles ViewToolChangedEvent- Specified by:
viewToolChangedOccurred
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewToolChangedEvent object
-
viewPopupMenuShowing
Description copied from interface:ViewEventListener
This method handles ViewPopupMenuShowing- Specified by:
viewPopupMenuShowing
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewPopupMenuShowingEvent object
-
viewRedrawOccurred
Description copied from interface:ViewEventListener
This method handles viewRedrawOccurred- Specified by:
viewRedrawOccurred
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewRedrawEvent object
-
viewRepaintOccurred
Description copied from interface:ViewEventListener
This method handles viewRepaintOccurred- Specified by:
viewRepaintOccurred
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewRepaintEvent object
-
viewStaticElementChanged
Description copied from interface:ViewEventListener
This method handles viewStaticElementChanged- Specified by:
viewStaticElementChanged
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewStaticElementEvent object
-
viewReadyOccurred
Description copied from interface:ViewEventListener
This method handles ViewReadyOccurred- Specified by:
viewReadyOccurred
in interfaceViewEventListener
- Parameters:
event
- the corresponding ViewReadyEvent object
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
getLayerManager
Returns the layer manager of the active view. May returnnull
if there's no view in this view manager.- Returns:
- layerMgr
-
addViewManagerEventListener
Adds a new ViewManager listener.- Parameters:
viewManagerEventListener
- the view manager listener to add- See Also:
-
removeViewManagerEventListener
Removes a ViewManager listener.- Parameters:
viewManagerEventListener
-- See Also:
-
fireViewActivated
Fires a new viewActivated event using this ViewManager as the source of the event- Parameters:
view
- activated view
-
fireViewActivated
Fires a new viewActivated event- Parameters:
view
- activated viewsrc
- the source of the event
-
fireViewDeactivated
-