crw.framework
Class GraphicComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--crw.framework.GraphicComponent
All Implemented Interfaces:
javax.accessibility.Accessible, IGraphicComponent, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
GraphicComposite

public abstract class GraphicComponent
extends javax.swing.JPanel
implements IGraphicComponent

The top most super class of the visual component hierachy.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.Image bufferImg
          The offscreen buffer, for double buffering
protected  boolean changed
          for event handling.
protected  boolean changing
          for double buffering, if this component is continuously changing -- we need to repaint this component every time.
protected  int deltaX
          the translated x coordinate
protected  int deltaY
          the translated y coordinate
protected  boolean firstTime
          for the first time drawing.
protected  java.awt.Image fixedImg
          The offscreen buffer, for fixed image to improve the efficiency of the screen redering
protected  java.awt.Graphics gBuffer
          The graphic context of bufferImg
protected  java.awt.Graphics gFixed
          The graphic context of gFixed
protected  java.awt.Dimension imgSize
          the image size of this visual component.
protected  GraphicComponent parent
          the parent container (GraphicComposite) for this GraphicComponent
protected  boolean translated
          iff true, this component has been translated otherwise, no translation to this component
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
GraphicComponent()
          the abstract super class defualt constructor.
GraphicComponent(java.awt.Dimension imgSize)
          the constructor
 
Method Summary
 void addGraphicComponent(GraphicComponent gc)
          add a graphic component to be overrided by the GraphicComposite class.
 void draw(java.awt.Graphics g)
          draw method.
 void drawThisCompFixedImg()
          draw this component's fixed image.
 void drawThisComponent(java.awt.Graphics g)
          abstract method to draw this component.
 java.awt.Dimension getImageSize()
          get the image size of this component
 java.awt.Point getNewPosition()
          get this component's new position after the translation return the new original coordinates of this component after it is translated.
 java.awt.Point getThisComponentActualPosition()
          get the actual position of this GraphicComponent after all the translations of its parent's and grandparant's transaltions
 boolean isThisComponentAlwaysChanging()
          get the state if this graphicComponent is continuously changed
 boolean isThisComponentChanged()
          get the state if this graphicComponent is changed by a user event
 boolean isTranslated()
          test if this GraphicComponent has been translated
 void paintComponent(java.awt.Graphics g)
          to be able to compatible with java2 naming convention
 void removeGraphicComponent(GraphicComponent gc)
          to remove a GraphicComponent object to be overrided by the GraphicComposite class.
 void setBufferImg(java.awt.Image bufferImg)
          set the bufferImg for this component to be set by the top-level GraphicComposite
 void setBufGraphics(java.awt.Graphics gBuffer)
          set the gBuffer for this visual component to be set by the top-level GraphicComposite
 void setFixedImg(java.awt.Image fixedImg)
          set the fixedImg for this component to be set by the top-level GraphicComposite
 void setFxdGraphics(java.awt.Graphics gFixed)
          set the gFixed for this visual component to be set by the top-level GraphicComposite
 void setImageSize(java.awt.Dimension imgSize)
          set the image size of this component.
 void setParent(GraphicComponent gc)
          set the parent GraphicComposite for this GraphicComponent
 void setThisComponentAlwaysChanging(boolean changing)
          set the state, iff this component is continuously changed
 void setThisComponentChanged(boolean changed)
          set the state, iff this GraphicComponent is changed by a user event
 void translate(int deltaX, int deltaY)
          set up the traslation.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bufferImg

protected java.awt.Image bufferImg
The offscreen buffer, for double buffering

gBuffer

protected java.awt.Graphics gBuffer
The graphic context of bufferImg

fixedImg

protected java.awt.Image fixedImg
The offscreen buffer, for fixed image to improve the efficiency of the screen redering

gFixed

protected java.awt.Graphics gFixed
The graphic context of gFixed

translated

protected boolean translated
iff true, this component has been translated otherwise, no translation to this component

deltaX

protected int deltaX
the translated x coordinate

deltaY

protected int deltaY
the translated y coordinate

imgSize

protected java.awt.Dimension imgSize
the image size of this visual component.

changing

protected boolean changing
for double buffering, if this component is continuously changing -- we need to repaint this component every time.

changed

protected boolean changed
for event handling. if this component is changed caused by a user event -- repaint this component.

firstTime

protected boolean firstTime
for the first time drawing.

parent

protected GraphicComponent parent
the parent container (GraphicComposite) for this GraphicComponent
Constructor Detail

GraphicComponent

public GraphicComponent()
the abstract super class defualt constructor.

GraphicComponent

public GraphicComponent(java.awt.Dimension imgSize)
the constructor
Parameters:
imgSize - the image size of this visual component
Method Detail

draw

public void draw(java.awt.Graphics g)
draw method. to be called by the parent GraphicComposite usually the user shouldn't call this method directly

drawThisCompFixedImg

public void drawThisCompFixedImg()
draw this component's fixed image.

drawThisComponent

public void drawThisComponent(java.awt.Graphics g)
abstract method to draw this component. subclass must override this method to provide the actual draw operation in this GraphicComponent
Parameters:
g - the graphic context, provided by the parent composite

paintComponent

public void paintComponent(java.awt.Graphics g)
to be able to compatible with java2 naming convention
Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphic context, provided by the parent composite

addGraphicComponent

public void addGraphicComponent(GraphicComponent gc)
add a graphic component to be overrided by the GraphicComposite class.
Parameters:
gc - the GraphicComponent object

removeGraphicComponent

public void removeGraphicComponent(GraphicComponent gc)
to remove a GraphicComponent object to be overrided by the GraphicComposite class.
Parameters:
gc - the GraphicComponent object

translate

public void translate(int deltaX,
                      int deltaY)
set up the traslation.
Parameters:
deltaX - the translated x coordinate
deltaY - the translated y coordinate

isTranslated

public boolean isTranslated()
test if this GraphicComponent has been translated
Returns:
true iff this component has been translated.

getNewPosition

public java.awt.Point getNewPosition()
get this component's new position after the translation return the new original coordinates of this component after it is translated.

setImageSize

public void setImageSize(java.awt.Dimension imgSize)
set the image size of this component.
Parameters:
imgSize - the image size of this visual component

getImageSize

public java.awt.Dimension getImageSize()
get the image size of this component
Returns:
the image size of this GraphicComponent

setBufferImg

public void setBufferImg(java.awt.Image bufferImg)
set the bufferImg for this component to be set by the top-level GraphicComposite

setFixedImg

public void setFixedImg(java.awt.Image fixedImg)
set the fixedImg for this component to be set by the top-level GraphicComposite

setBufGraphics

public void setBufGraphics(java.awt.Graphics gBuffer)
set the gBuffer for this visual component to be set by the top-level GraphicComposite

setFxdGraphics

public void setFxdGraphics(java.awt.Graphics gFixed)
set the gFixed for this visual component to be set by the top-level GraphicComposite

setThisComponentChanged

public void setThisComponentChanged(boolean changed)
set the state, iff this GraphicComponent is changed by a user event
Parameters:
changed - iff true, this component is changed and need to be updated next time of rederring the screen

isThisComponentChanged

public boolean isThisComponentChanged()
get the state if this graphicComponent is changed by a user event

setThisComponentAlwaysChanging

public void setThisComponentAlwaysChanging(boolean changing)
set the state, iff this component is continuously changed
Parameters:
changed - iff tru, this component is constantly changed, and need to be updated every time rederring the screen

isThisComponentAlwaysChanging

public boolean isThisComponentAlwaysChanging()
get the state if this graphicComponent is continuously changed

setParent

public void setParent(GraphicComponent gc)
set the parent GraphicComposite for this GraphicComponent

getThisComponentActualPosition

public java.awt.Point getThisComponentActualPosition()
get the actual position of this GraphicComponent after all the translations of its parent's and grandparant's transaltions