gishur.gui2
Class DisplayManager

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--gishur.gui2.DisplayManager
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable, ToolTip

public class DisplayManager
extends java.awt.Canvas
implements java.lang.Runnable, ToolTip

The drawing surface for DrawManagers.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static byte PAINT_ALL
          Repaint all objects
static byte PAINT_DIRTY
          Repaint all dirty objects
static byte PAINT_NOTHING
          Just draw the buffered image
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DisplayManager(java.lang.String name, DrawManager manager)
          Constructs a new DisplayManager with the specified DrawManager.
 
Method Summary
 void addGeneralAWTEventListener(GeneralAWTEventListener listener)
          Adds the specified GeneralAWTEventListener to receive all AWTEvents from this DisplayManager.
 void addModifyListener(ModifyListener listener)
          Adds the specified ModifyListener to receive ModifyEvents from this DisplayManager.
 boolean containsGeneralAWTEventListener(GeneralAWTEventListener listener)
          Checks, if the given event listener is already connected to this component.
 boolean containsModifyListener(ModifyListener listener)
          Checks, if the given event listener is already connected to this component.
 int getPaintInterval()
          Returns the repaint interval.
 RenderContext getRenderContext()
          Returns the RenderContext used.
 java.lang.String getStatusTip(int x, int y)
          Returns the StatusTip-text.
 java.lang.String getToolTip(int x, int y)
          Returns the ToolTip-text for this component.
 java.awt.Rectangle getViewPort()
          Returns the view port size.
 boolean hasStatusTips()
          Returns true if StatusTips are enabled.
 boolean hasToolTips()
          Returns true if ToolTips are enabled.
 void invalidate()
          Invalidates this component.
 boolean isValid()
          Determines whether this component is valid.
 java.awt.Point lastMousePosition()
          Returns the last mouse position.
 DrawManager manager()
          Returns the DrawManager for this DisplayManager.
 void paint(java.awt.Graphics g)
          Paints this component.
protected  void processEvent(java.awt.AWTEvent e)
          Processes events occurring on this component.
protected  void processModifyEvent(ModifyEvent e)
          Processes ModifyEvents occured at this DisplayManager.
 void removeCursor(DrawAtom owner)
          Removes the mouse cursor set by the given owner.
 void removeGeneralAWTEventListener(GeneralAWTEventListener listener)
          Removes the specified GeneralAWTEventListener so that it no longer receives all AWTEvents from this DisplayManager.
 void removeModifyListener(ModifyListener listener)
          Removes the specified ModifyListener so that it no longer receives ModifyEvents from this DisplayManager.
 void repaint()
          Requests the DisplayManager to repaint its objects.
 void repaint(byte mode)
          Requests the DisplayManager to repaint its objects with the specified repaint mode.
 void run()
          The run-method for the repaint-thread.
 void setCursor(java.awt.Cursor cursor, DrawAtom owner)
          Sets the mouse cursor to the given cursor.
 void setPaintInterval(int time)
          Sets the repaint interval for this DisplayManager.
 void setPaintPriority(int priority)
          Sets the priority of the thread that repaints the elements.
 void setRenderContext(RenderContext context)
          Sets the RenderContext to use.
 boolean setStatusTips(boolean tip)
          Enables / disables ToolTips
 boolean setToolTips(boolean tip)
          Enables / disables ToolTips
 void update(byte mode)
          Updates the screen dirtectly with the specified repaint mode.
 void update(java.awt.Graphics g)
          Updates this component.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAINT_NOTHING

public static final byte PAINT_NOTHING
Just draw the buffered image

PAINT_DIRTY

public static final byte PAINT_DIRTY
Repaint all dirty objects

PAINT_ALL

public static final byte PAINT_ALL
Repaint all objects
Constructor Detail

DisplayManager

public DisplayManager(java.lang.String name,
                      DrawManager manager)
Constructs a new DisplayManager with the specified DrawManager.
Parameters:
name - the name of the DisplayManager
manager - DrawManager to use
Method Detail

manager

public DrawManager manager()
Returns the DrawManager for this DisplayManager.

setPaintInterval

public void setPaintInterval(int time)
Sets the repaint interval for this DisplayManager. The parameter time specifies the duration of a paint interval. The value 0 means paint on demand (objects are repainted as soon as they have changed). The repaint with a non negative paint interval works via an extra paint thread. The value -1 means paint on demand via the java awt paint thread. A negative value less than -1 means repaint by the user (through update(byte)).
Parameters:
time - repaint interval in milliseconds

setRenderContext

public void setRenderContext(RenderContext context)
Sets the RenderContext to use.
Parameters:
context - the new RenderContext to use.

getRenderContext

public RenderContext getRenderContext()
Returns the RenderContext used.
Returns:
the RenderContext used.

getPaintInterval

public int getPaintInterval()
Returns the repaint interval. The value 0 means repaint on demand, a negative value means repaint by the user.
Returns:
repaint interval.

setPaintPriority

public void setPaintPriority(int priority)
Sets the priority of the thread that repaints the elements. The priority must be in the range Thread.MIN_PRIORITY to Thread.MAX_PRIORITY. The setting takes only affect until a call to setPaintInterval(int) and if the paint interval was set to a value at least 0.
Parameters:
priority - the new priority for the repaint thread

getViewPort

public java.awt.Rectangle getViewPort()
Returns the view port size.

run

public void run()
The run-method for the repaint-thread. This method will be used if the repaint interval is set to a value greater than 0.
Specified by:
run in interface java.lang.Runnable

repaint

public void repaint()
Requests the DisplayManager to repaint its objects.
Overrides:
repaint in class java.awt.Component

repaint

public void repaint(byte mode)
Requests the DisplayManager to repaint its objects with the specified repaint mode.
Parameters:
mode - repaint mode (a constant of {PAINT_NOTHING, PAINT_DIRTY,PAINT_ALL})

update

public void update(byte mode)
Updates the screen dirtectly with the specified repaint mode. This method works only if the repaint interval is set on a value smaller than 0 (setPaintInterval(int)). This method can be used for own repaint modes.
Parameters:
mode - repaint mode (on constant of {PAINT_NOTHING, PAINT_DIRTY,PAINT_ALL})

update

public void update(java.awt.Graphics g)
Updates this component. The AWT calls the update method in response to a call to Component.repaint().
Overrides:
update in class java.awt.Component
Parameters:
g - the specified context to use for updating.

paint

public void paint(java.awt.Graphics g)
Paints this component. This method is called when the contents of the component should be painted in response to the component first being shown or damage needing repair. The clip rectangle in the Graphics parameter will be set to the area which needs to be painted.
Overrides:
paint in class java.awt.Canvas
Parameters:
g - The graphics context to use for painting.

invalidate

public void invalidate()
Invalidates this component. This component and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.
Overrides:
invalidate in class java.awt.Component

isValid

public boolean isValid()
Determines whether this component is valid. Components are invalidated when they are first shown on the screen.
Overrides:
isValid in class java.awt.Component
Returns:
true if the component is valid; false otherwise.

hasToolTips

public boolean hasToolTips()
Returns true if ToolTips are enabled.
Returns:
true if ToolTips are enabled.

hasStatusTips

public boolean hasStatusTips()
Returns true if StatusTips are enabled.
Returns:
true if StatusTips are enabled.

setToolTips

public boolean setToolTips(boolean tip)
Enables / disables ToolTips
Parameters:
tip - if true, ToolTips were enabled, otherwise disabled
Returns:
old ToolTip status

setStatusTips

public boolean setStatusTips(boolean tip)
Enables / disables ToolTips
Parameters:
tip - if true, ToolTips were enabled, otherwise disabled
Returns:
old ToolTip status

getToolTip

public java.lang.String getToolTip(int x,
                                   int y)
Returns the ToolTip-text for this component. The ToolTip-text will be shown (using a ToolTipper) if the mouse rests over the object.
Specified by:
getToolTip in interface ToolTip
Parameters:
x,y - the position of the mouse in component coordinates
Returns:
ToolTip

getStatusTip

public java.lang.String getStatusTip(int x,
                                     int y)
Returns the StatusTip-text. This text will be shown in the applets (or browsers) statusbar.
Specified by:
getStatusTip in interface ToolTip
Parameters:
x,y - the position of the mouse in component coordinates
Returns:
StatusTip

setCursor

public void setCursor(java.awt.Cursor cursor,
                      DrawAtom owner)
Sets the mouse cursor to the given cursor. The cursor must be removed by the same owner.
Parameters:
cursor - the java.awt.Cursor to set
owner - the owner of the mouse curosor.

removeCursor

public void removeCursor(DrawAtom owner)
Removes the mouse cursor set by the given owner.
Parameters:
owner - the owner of the mouse curosor.

addGeneralAWTEventListener

public void addGeneralAWTEventListener(GeneralAWTEventListener listener)
Adds the specified GeneralAWTEventListener to receive all AWTEvents from this DisplayManager.
Parameters:
listener - the GeneralAWTEventListener

removeGeneralAWTEventListener

public void removeGeneralAWTEventListener(GeneralAWTEventListener listener)
Removes the specified GeneralAWTEventListener so that it no longer receives all AWTEvents from this DisplayManager.
Parameters:
listener - the GeneralAWTEventListener

containsGeneralAWTEventListener

public boolean containsGeneralAWTEventListener(GeneralAWTEventListener listener)
Checks, if the given event listener is already connected to this component.
Parameters:
listener - the event listener to check

addModifyListener

public void addModifyListener(ModifyListener listener)
Adds the specified ModifyListener to receive ModifyEvents from this DisplayManager.
Parameters:
listener - the ModifyListener

removeModifyListener

public void removeModifyListener(ModifyListener listener)
Removes the specified ModifyListener so that it no longer receives ModifyEvents from this DisplayManager.
Parameters:
listener - the ModifyListener

containsModifyListener

public boolean containsModifyListener(ModifyListener listener)
Checks, if the given event listener is already connected to this component.
Parameters:
listener - the event listener to check

processEvent

protected void processEvent(java.awt.AWTEvent e)
Processes events occurring on this component. By default this method calls first the event method of the connected GeneralAWTEventListeners and then the the appropriate process<event type>Event method for the given class of event.
Overrides:
processEvent in class java.awt.Component
Parameters:
e - the event.
See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent), Component.processFocusEvent(java.awt.event.FocusEvent), Component.processKeyEvent(java.awt.event.KeyEvent), Component.processMouseEvent(java.awt.event.MouseEvent), Component.processMouseMotionEvent(java.awt.event.MouseEvent), Component.processInputMethodEvent(java.awt.event.InputMethodEvent), processModifyEvent(gishur.core.event.ModifyEvent)

processModifyEvent

protected void processModifyEvent(ModifyEvent e)
Processes ModifyEvents occured at this DisplayManager.
Parameters:
e - the ModifyEvent

lastMousePosition

public java.awt.Point lastMousePosition()
Returns the last mouse position.
Returns:
the last mouse position.