edu.brook.ascape.view
Class PanelView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.brook.ascape.view.PanelImp
                                |
                                +--edu.brook.ascape.view.PanelView
Direct Known Subclasses:
BaseCustomizer, BatchView, ControlBarView, SimpleControlView

public class PanelView
extends PanelImp
implements ComponentView

A base class for a panel that acts as an observer of scapes. Provides notification of scape updates.

Since:
1.0
Version:
1.2.6
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
 
Field Summary
protected  boolean awaitingUpdate
          Has the buffer been modified? Are we waiting for the paint method to update it to the onscreen image?
protected  ViewFrameBridge frame
          The frame this view is displayed in.
protected  java.lang.String name
          The name of the view.
protected  GraphicsRecorder recorder
          A recorder for the graphic of this view.
protected  boolean recordNext
          Are we waiting for a record to occur?
protected  Scape scape
          The scape being viewed.
 
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
 
Constructor Summary
PanelView()
          Constructs a panel view.
PanelView(java.lang.String name)
          Constructs a panel view.
 
Method Summary
 void addScape(Scape scape)
          Add a scape to the view.
 void build()
          Called to create and layout the components of the component view, once the view's scape has been created.
 GraphicsRecorder getGraphicsRecorder()
          Returns a recorder that can be used to record the graphics of this view.
 java.lang.String getName()
          Returns a name for the view as defined by set name.
 Scape getScape()
          Returns the scape this canvas views.
 ViewFrameBridge getViewFrame()
          Returns the frame this view occupies, null if none.
 void onIterate()
          Called when scape is iterated.
 void onSetup()
          Method called when the scape is ready for setup.
 void onStart()
          Method called when the scape is started.
 void onStop()
          Method called when the scape is stopped.
 void onUpdate()
          Called when scape reports an update event.
 void paint(java.awt.Graphics g)
          Paints the panel.
 void removeScape(Scape scape)
          Removes the scape from this listener.
 void scapeUpdated(ScapeEvent scapeEvent)
          Notifies this view that its scape has been updated.
 void setGraphicsRecorder(GraphicsRecorder recorder)
          Sets the recorder that can be used to record the graphics of this view.
 void setName(java.lang.String name)
          Sets the name of this view.
 void setViewFrame(ViewFrameBridge frame)
          Sets the frame this view appears in.
 java.lang.String toString()
          Returns a short description of this view.
 void updated()
          Called (automatically from paint) when this view has been updated.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, 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, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, 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, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scape

protected Scape scape
The scape being viewed.

frame

protected ViewFrameBridge frame
The frame this view is displayed in. Null if this view isn't in a frame.

recorder

protected GraphicsRecorder recorder
A recorder for the graphic of this view. Usually null, unless this view is being recorded.

awaitingUpdate

protected boolean awaitingUpdate
Has the buffer been modified? Are we waiting for the paint method to update it to the onscreen image?

name

protected java.lang.String name
The name of the view.

recordNext

protected boolean recordNext
Are we waiting for a record to occur?
Constructor Detail

PanelView

public PanelView()
Constructs a panel view.

PanelView

public PanelView(java.lang.String name)
Constructs a panel view.
Parameters:
name - a user relevant name for this view
Method Detail

getScape

public Scape getScape()
Returns the scape this canvas views.
Specified by:
getScape in interface ComponentView

addScape

public void addScape(Scape scape)
              throws java.util.TooManyListenersException
Add a scape to the view. A view can be assigned only one scape.
Parameters:
scape - the scape to make this canvas the observer of
Throws:
java.util.TooManyListenersException - on attempt to add a scape when one is allready added

removeScape

public void removeScape(Scape scape)
Removes the scape from this listener. Null expected.
Parameters:
scape - the scape to remove

getViewFrame

public ViewFrameBridge getViewFrame()
Returns the frame this view occupies, null if none.
Specified by:
getViewFrame in interface ComponentView

setViewFrame

public void setViewFrame(ViewFrameBridge frame)
Sets the frame this view appears in.
Specified by:
setViewFrame in interface ComponentView

build

public void build()
Called to create and layout the components of the component view, once the view's scape has been created.
Specified by:
build in interface ComponentView

onIterate

public void onIterate()
Called when scape is iterated.

onSetup

public void onSetup()
Method called when the scape is ready for setup.

onUpdate

public void onUpdate()
Called when scape reports an update event. (No need to call this method after updating panel.)

onStart

public void onStart()
Method called when the scape is started.

onStop

public void onStop()
Method called when the scape is stopped.

scapeUpdated

public void scapeUpdated(ScapeEvent scapeEvent)
Notifies this view that its scape has been updated. View sets awaiting update state to true, and requests a repaint. Subclasses should update their component states at this point.
Parameters:
scapeEvent - a scape event update, usually unspecified

updated

public void updated()
Called (automatically from paint) when this view has been updated. The view calls its observed scape and notifies it that the view has finished updating its state.

getName

public java.lang.String getName()
Returns a name for the view as defined by set name.
Overrides:
getName in class java.awt.Component

setName

public void setName(java.lang.String name)
Sets the name of this view.
Parameters:
name - a user relevant name for this view
Overrides:
setName in class java.awt.Component

getGraphicsRecorder

public GraphicsRecorder getGraphicsRecorder()
Returns a recorder that can be used to record the graphics of this view. If null (default, and typical), there is no recorder for this view.
Specified by:
getGraphicsRecorder in interface ComponentView

setGraphicsRecorder

public void setGraphicsRecorder(GraphicsRecorder recorder)
Sets the recorder that can be used to record the graphics of this view. If null, do not record.
Specified by:
setGraphicsRecorder in interface ComponentView

toString

public java.lang.String toString()
Returns a short description of this view. Sames as name unless overridden.
Overrides:
toString in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paints the panel. If view is awaiting update, paint calls updated so that the scape will be notified when we are done painting. This method should rarely need to be overridden; use scapeUpdated to update component state.
Specified by:
paint in interface ComponentView
Parameters:
g - the graphics context.
Overrides:
paint in class javax.swing.JComponent

(c) 1998-2000 The Brookings Insitution
Webpage