edu.brook.ascape.view
Class Scrolling1DView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--edu.brook.ascape.view.CanvasView
                    |
                    +--edu.brook.ascape.view.BaseCellView
                          |
                          +--edu.brook.ascape.view.Scrolling1DView

public class Scrolling1DView
extends BaseCellView

A view that provides a vertically scrolling view appropriate for dispalying a simple one-dimensional collection of agents; i.e. a 1DCA. To Do: Support color features ala Overhead2DView.

Since:
1.0
Version:
1.5
See Also:
Serialized Form

Field Summary
protected  int maxAgentWidth
           
 
Fields inherited from class edu.brook.ascape.view.BaseCellView
borderSize, cellColorFeature, cellCustomizer, cells_fill_draw_feature, cells_fill_draw_inset_feature, cellSize, drawSelection, updateAllRequested, viewCustomizer
 
Fields inherited from class edu.brook.ascape.view.CanvasView
awaitingUpdate, bufferedGraphics, bufferedImage, currentUpdate, drawEveryNUpdates, frame, name, recorder, recordNext, scape
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Scrolling1DView()
          Constructs a new scrolling view, setting its initial cell size to 2.
 
Method Summary
 void addScape(Scape scape)
          Add a scape to the view.
 Cell cellAtPixel(int x, int y)
           
protected  void drawSelectedCell(java.awt.Graphics g)
           
 java.awt.Dimension getPreferredSize()
          Retuns the preferred size, which is width of the number of agents, and height of 300.
 void onUpdate()
          On notification of a scape update, draws the next line of the view, and copies the buffer upwards to scroll the view.
 void paint(java.awt.Graphics g)
          Repaints the canvas, drawing the buffer into it.
 void setBounds(int x, int y, int width, int height)
          Sets the size of the view, rescaling and moving the buffer as neccesary.
 
Methods inherited from class edu.brook.ascape.view.BaseCellView
build, displayCellCustomizer, displayViewCustomizer, getBorderSize, getCellColorFeature, getCellSize, getCustomizeCell, getDrawSelection, hideCellCustomizer, requestUpdateAll, setBorderSize, setCellColorFeature, setCellSize, setCustomizeCell
 
Methods inherited from class edu.brook.ascape.view.CanvasView
addNotify, finalize, getDrawEveryNUpdates, getGraphicsRecorder, getName, getScape, getViewFrame, initializeBuffer, onIterate, onSetup, onStart, onStop, removeScape, scapeUpdated, setDrawEveryNUpdates, setGraphicsRecorder, setName, setViewFrame, toString, update, updated
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, 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, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, 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, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setSize, setSize, setVisible, show, show, size, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxAgentWidth

protected int maxAgentWidth
Constructor Detail

Scrolling1DView

public Scrolling1DView()
Constructs a new scrolling view, setting its initial cell size to 2.
Method Detail

addScape

public void addScape(Scape scape)
              throws java.util.TooManyListenersException
Add a scape to the view. A view can be assigned only one scape. Sets the maximum agent width.
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
Overrides:
addScape in class CanvasView

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Sets the size of the view, rescaling and moving the buffer as neccesary.
Overrides:
setBounds in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Retuns the preferred size, which is width of the number of agents, and height of 300.
Overrides:
getPreferredSize in class CanvasView

cellAtPixel

public Cell cellAtPixel(int x,
                        int y)
Overrides:
cellAtPixel in class BaseCellView

drawSelectedCell

protected void drawSelectedCell(java.awt.Graphics g)
Overrides:
drawSelectedCell in class BaseCellView

onUpdate

public void onUpdate()
On notification of a scape update, draws the next line of the view, and copies the buffer upwards to scroll the view.
Parameters:
scapeEvent - a scape event update, usually unspecified
Overrides:
onUpdate in class BaseCellView

paint

public void paint(java.awt.Graphics g)
Repaints the canvas, drawing the buffer into it. If the view is wider than the buffer (size of agents), copies the buffer alongside it, to provide a continuous view of a periodic scape. To do: override this behavior for aperiod scapes, and provide some means for scrolling the horizontal origin.
Parameters:
g - the graphics context.
Overrides:
paint in class CanvasView

(c) 1998-2000 The Brookings Insitution
Webpage