sim.display
Class Display2D

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by sim.display.Display2D
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, Manipulating2D, Steppable

public class Display2D
extends javax.swing.JComponent
implements Steppable, Manipulating2D

Display2D holds, displays, and manipulates 2D Portrayal objects, allowing the user to scale them, scroll them, change how often they're updated, take snapshots, and generate Quicktime movies. Display2D is Steppable, and each time it is stepped it redraws itself. Display2D also handles double-click events, routing them to the underlying portrayals as inspector requests.

In addition to various GUI widgets, Display2D holds a JScrollView which in turn holds a Display2D.InnerDisplay2D (a JComponent responsible for doing the actual drawing). Display2D can be placed in a JFrame; indeed it provides a convenience function to sprout its own JFrame with the method createFrame(). You can put Display2D in your own JFrame if you like, but you should try to call Display2D.quit() when the frame is disposed.

Display2D's constructor takes a height and a width; this will be the "expected" height and width of the underlying portrayal region when the Display2D is scaled to 1.0 (the default). The portrayals will also have an origin at (0,0) -- the top left corner. Display2D will automatically clip the portrayals to the area (0,0) to (width * scale, height * scale).

Display2D's step() method is typically called from the underlying schedule thread; this means that it has to be careful about painting as Swing widgets expect to be painted in the event loop thread. Display2D handles this in two ways. First, on MacOS X, the step() method calls repaint(), which will in turn call paintComponent() from the event loop thread at a time when the underlying schedule thread is doing nothing -- see Console. Second, on Windows and XWindows, the step() method immediately calls paintComponent(). Different OSes do it differently because MacOS X is far more efficient using standard repaint() calls, which get routed through Quartz. The step() method also updates various widgets using SwingUtilities.invokeLater().

See Also:
Serialized Form

Nested Class Summary
 class Display2D.InnerDisplay2D
          The object which actually does all the drawing.
 class Display2D.OptionPane
          Option pane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static javax.swing.ImageIcon CAMERA_ICON
           
static javax.swing.ImageIcon CAMERA_ICON_P
           
 java.lang.String DEFAULT_PREFERENCES_KEY
           
 javax.swing.JScrollPane display
          The scroll view which holds the insideDisplay.
 javax.swing.Box header
          The component bar at the top of the Display2D.
 Display2D.InnerDisplay2D insideDisplay
          The 2D display inside the scroll view.
static boolean isMacOSX
          Set to true if we're running on a Mac
static boolean isWindows
          Set to true if we're running on Windows
static java.lang.String javaVersion
          Set to the version number
static javax.swing.ImageIcon LAYERS_ICON
           
static javax.swing.ImageIcon LAYERS_ICON_P
           
static javax.swing.ImageIcon MOVIE_OFF_ICON
           
static javax.swing.ImageIcon MOVIE_OFF_ICON_P
           
static javax.swing.ImageIcon MOVIE_ON_ICON
           
static javax.swing.ImageIcon MOVIE_ON_ICON_P
           
 javax.swing.JButton movieButton
          The button which starts or stops a movie
 MovieMaker movieMaker
          Our movie maker, if one is running, else null.
 javax.swing.JButton optionButton
          The button which pops up the option pane
 Display2D.OptionPane optionPane
          Our option pane
static javax.swing.ImageIcon OPTIONS_ICON
           
static javax.swing.ImageIcon OPTIONS_ICON_P
           
 javax.swing.JPopupMenu popup
          The popup layers menu
protected  boolean precise
           
static java.lang.Object[] REDRAW_OPTIONS
           
 NumberTextField scaleField
          The field for scaling values
 javax.swing.JComboBox skipBox
          The combo box for skipping frames
 NumberTextField skipField
          The field for skipping frames
 javax.swing.JButton snapshotButton
          The button which snaps a screenshot
 javax.swing.JToggleButton togglebutton
          The button which pops up the layers menu
static int TYPE_PDF
           
static int TYPE_PNG
           
static int UPDATE_RULE_ALWAYS
           
static int UPDATE_RULE_INTERNAL_TIME
           
static int UPDATE_RULE_NEVER
           
static int UPDATE_RULE_STEPS
           
static int UPDATE_RULE_WALLCLOCK_TIME
           
 boolean useTooltips
          Use tool tips?
 
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
Display2D(double width, double height, GUIState simulation, long interval)
          Creates a Display2D with the provided width and height for its portrayal region, attached to the provided simulation, and displaying itself with the given interval (which must be > 0).
 
Method Summary
 void attach(FieldPortrayal2D portrayal, java.lang.String name)
          Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal.
 void attach(FieldPortrayal2D portrayal, java.lang.String name, boolean visible)
          Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal.
 void attach(FieldPortrayal2D portrayal, java.lang.String name, double x, double y, boolean visible)
          Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal.
 void attach(FieldPortrayal2D portrayal, java.lang.String name, java.awt.geom.Rectangle2D.Double bounds)
          Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal.
 void attach(FieldPortrayal2D portrayal, java.lang.String name, java.awt.geom.Rectangle2D.Double bounds, boolean visible)
          Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal.
 void attach(Inspector inspector, java.lang.String name)
          A convenience function: creates a popup menu item of the given name which, when selected, will display the given inspector in the Console.
 void clearSelections()
           
 void createConsoleMenu()
           
 javax.swing.JFrame createFrame()
          Creates a frame holding the Display2D.
 void createInspectors(java.awt.geom.Rectangle2D.Double rect, GUIState simulation)
          Determines the inspectors appropriate for the given selection region (rect), and sends them on to the Controller.
 java.lang.String createToolTipText(java.awt.geom.Rectangle2D.Double rect, GUIState simulation)
           
 java.util.ArrayList detatchAll()
          Detatches all portrayals from the Display2D.
protected  void finalize()
          Quits the Display2D.
 java.awt.Paint getBackdrop()
          Returns the backdrop color or paint.
 DrawInfo2D getDrawInfo2D(FieldPortrayal2D portrayal, java.awt.geom.Point2D point)
          Constructs a DrawInfo2D for the given portrayal, or null if failed.
 DrawInfo2D getDrawInfo2D(FieldPortrayal2D portrayal, java.awt.geom.Rectangle2D clip)
          Constructs a DrawInfo2D for the given portrayal, or null if failed.
 java.awt.Frame getFrame()
          Returns the frame holding this Component.
 java.lang.String getPreferencesKey()
           
 double getScale()
          Returns the scale (the zoom value) of the Display2D
 boolean handleMouseEvent(java.awt.event.MouseEvent event)
           
 boolean isClipping()
          Returns true if the Display2D is clipping the drawing area to the user-specified height and width
 Bag[] objectsHitBy(java.awt.geom.Point2D point)
          Returns LocationWrappers for all the objects which overlap with the point specified by 'point'.
 Bag[] objectsHitBy(java.awt.geom.Rectangle2D.Double rect)
          Returns LocationWrappers for all the objects which fall within the coordinate rectangle specified by rect.
 void performSelection(Bag locationWrappers)
           
 void performSelection(LocationWrapper wrapper)
           
 void performSelection(java.awt.geom.Rectangle2D.Double rect)
           
 void quit()
          Quits the Display2D.
 void reset()
          Resets the Display2D so it reschedules itself and clears out all selections.
 void setBackdrop(java.awt.Paint c)
          Specify the backdrop color or other paint.
 void setClipping(boolean val)
          Sets the Display2D to clip or to not clip to the user-specified height and width when drawing
 void setPreferencesKey(java.lang.String s)
          If you have more than one Display2D in your simulation and you want them to have different preferences, set each to a different key value.
 void setScale(double val)
          Sets the scale (the zoom value) of the Display2D
 boolean shouldUpdate()
          Returns whether it's time to update.
 void startMovie()
          Starts a Quicktime movie on the given Display2D.
 void step(SimState state)
          Steps the Display2D in the GUIState schedule.
 void stopMovie()
          Stops a Quicktime movie and cleans up, flushing the remaining frames out to disk.
 void takeSnapshot()
           
 void takeSnapshot(java.io.File file, int type)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

precise

protected boolean precise

DEFAULT_PREFERENCES_KEY

public java.lang.String DEFAULT_PREFERENCES_KEY

isMacOSX

public static final boolean isMacOSX
Set to true if we're running on a Mac


isWindows

public static final boolean isWindows
Set to true if we're running on Windows


javaVersion

public static final java.lang.String javaVersion
Set to the version number


LAYERS_ICON

public static final javax.swing.ImageIcon LAYERS_ICON

LAYERS_ICON_P

public static final javax.swing.ImageIcon LAYERS_ICON_P

MOVIE_ON_ICON

public static final javax.swing.ImageIcon MOVIE_ON_ICON

MOVIE_ON_ICON_P

public static final javax.swing.ImageIcon MOVIE_ON_ICON_P

MOVIE_OFF_ICON

public static final javax.swing.ImageIcon MOVIE_OFF_ICON

MOVIE_OFF_ICON_P

public static final javax.swing.ImageIcon MOVIE_OFF_ICON_P

CAMERA_ICON

public static final javax.swing.ImageIcon CAMERA_ICON

CAMERA_ICON_P

public static final javax.swing.ImageIcon CAMERA_ICON_P

OPTIONS_ICON

public static final javax.swing.ImageIcon OPTIONS_ICON

OPTIONS_ICON_P

public static final javax.swing.ImageIcon OPTIONS_ICON_P

REDRAW_OPTIONS

public static final java.lang.Object[] REDRAW_OPTIONS

useTooltips

public boolean useTooltips
Use tool tips?


movieMaker

public MovieMaker movieMaker
Our movie maker, if one is running, else null.


insideDisplay

public Display2D.InnerDisplay2D insideDisplay
The 2D display inside the scroll view. Does the actual drawing of the simulation.


optionPane

public Display2D.OptionPane optionPane
Our option pane


display

public javax.swing.JScrollPane display
The scroll view which holds the insideDisplay.


header

public javax.swing.Box header
The component bar at the top of the Display2D.


popup

public javax.swing.JPopupMenu popup
The popup layers menu


togglebutton

public javax.swing.JToggleButton togglebutton
The button which pops up the layers menu


movieButton

public javax.swing.JButton movieButton
The button which starts or stops a movie


snapshotButton

public javax.swing.JButton snapshotButton
The button which snaps a screenshot


optionButton

public javax.swing.JButton optionButton
The button which pops up the option pane


scaleField

public NumberTextField scaleField
The field for scaling values


skipField

public NumberTextField skipField
The field for skipping frames


skipBox

public javax.swing.JComboBox skipBox
The combo box for skipping frames


TYPE_PDF

public static int TYPE_PDF

TYPE_PNG

public static int TYPE_PNG

UPDATE_RULE_STEPS

public static final int UPDATE_RULE_STEPS
See Also:
Constant Field Values

UPDATE_RULE_INTERNAL_TIME

public static final int UPDATE_RULE_INTERNAL_TIME
See Also:
Constant Field Values

UPDATE_RULE_WALLCLOCK_TIME

public static final int UPDATE_RULE_WALLCLOCK_TIME
See Also:
Constant Field Values

UPDATE_RULE_ALWAYS

public static final int UPDATE_RULE_ALWAYS
See Also:
Constant Field Values

UPDATE_RULE_NEVER

public static final int UPDATE_RULE_NEVER
See Also:
Constant Field Values
Constructor Detail

Display2D

public Display2D(double width,
                 double height,
                 GUIState simulation,
                 long interval)
Creates a Display2D with the provided width and height for its portrayal region, attached to the provided simulation, and displaying itself with the given interval (which must be > 0).

Method Detail

setPreferencesKey

public void setPreferencesKey(java.lang.String s)
If you have more than one Display2D in your simulation and you want them to have different preferences, set each to a different key value. The default value is DEFAULT_PREFERENCES_KEY. You may not have a key which ends in a forward slash (/) when trimmed Key may be set to null (the default).


getPreferencesKey

public java.lang.String getPreferencesKey()

setScale

public void setScale(double val)
Sets the scale (the zoom value) of the Display2D


getScale

public double getScale()
Returns the scale (the zoom value) of the Display2D


isClipping

public boolean isClipping()
Returns true if the Display2D is clipping the drawing area to the user-specified height and width


setClipping

public void setClipping(boolean val)
Sets the Display2D to clip or to not clip to the user-specified height and width when drawing


setBackdrop

public void setBackdrop(java.awt.Paint c)
Specify the backdrop color or other paint. The backdrop is the region behind where the simulation actually draws. If set to null, no color/paint is used -- and indeed the background you're drawing on is not defined. Only set to null if you know you're filling the entire background with something else anyway.


getBackdrop

public java.awt.Paint getBackdrop()
Returns the backdrop color or paint. The backdrop is the region behind where the simulation actually draws. If set to null, no color/paint is used.


finalize

protected void finalize()
                 throws java.lang.Throwable
Quits the Display2D. Okay, so finalize is evil and we're not supposed to rely on it. We're not. But it's an additional cargo-cult programming measure just in case.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

quit

public void quit()
Quits the Display2D. Called by the Display2D's frame if the Display2D made the frame itself. Also called by finalize(). Otherwise you should call this method before destroying the Display2D.


reset

public void reset()
Resets the Display2D so it reschedules itself and clears out all selections. This is useful when reusing the Display2D.


attach

public void attach(FieldPortrayal2D portrayal,
                   java.lang.String name)
Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal. The portrayal will be attached with an origin at (0,0) and a width and height equal to the Display2D's default width and height. Portrayals are drawn on-screen in the order that they are attached; thus the "top-most" portrayal will be the last one attached.


attach

public void attach(FieldPortrayal2D portrayal,
                   java.lang.String name,
                   java.awt.geom.Rectangle2D.Double bounds)
Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal. The portrayal's attached origin, width and height is given in the bounds rectangle. Portrayals are drawn on-screen in the order that they are attached; thus the "top-most" portrayal will be the last one attached.


attach

public void attach(FieldPortrayal2D portrayal,
                   java.lang.String name,
                   boolean visible)
Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal. The portrayal will be attached with an origin at (0,0) and a width and height equal to the Display2D's default width and height. The portrayal may be set to initially visible or not visible. Portrayals are drawn on-screen in the order that they are attached; thus the "top-most" portrayal will be the last one attached.


attach

public void attach(FieldPortrayal2D portrayal,
                   java.lang.String name,
                   double x,
                   double y,
                   boolean visible)
Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal. The portrayal's attached origin is given with the coordinates provided. The width and height will be equal to the Display2D's default width and height (display2D.insideDisplay.width and display2D.insideDisplay.height respectively). To put the origin at the center of the display, you can set the x and y coordinates to display2D.insideDisplay.width/2, display2D.insideDisplay.height/2). The portrayal may be set to initially visible or not visible. Portrayals are drawn on-screen in the order that they are attached; thus the "top-most" portrayal will be the last one attached.


attach

public void attach(FieldPortrayal2D portrayal,
                   java.lang.String name,
                   java.awt.geom.Rectangle2D.Double bounds,
                   boolean visible)
Attaches a portrayal to the Display2D, along with the provided human-readable name for the portrayal. The portrayal's attached origin, width and height is given in the bounds rectangle. The portrayal may be set to initially visible or not visible. Portrayals are drawn on-screen in the order that they are attached; thus the "top-most" portrayal will be the last one attached.


attach

public void attach(Inspector inspector,
                   java.lang.String name)
A convenience function: creates a popup menu item of the given name which, when selected, will display the given inspector in the Console. Used rarely, typically for per-field Inspectors.


createConsoleMenu

public void createConsoleMenu()

detatchAll

public java.util.ArrayList detatchAll()
Detatches all portrayals from the Display2D.


objectsHitBy

public Bag[] objectsHitBy(java.awt.geom.Rectangle2D.Double rect)
Returns LocationWrappers for all the objects which fall within the coordinate rectangle specified by rect. This rectangle is in the coordinate system of the (InnerDisplay2D) component inside the scroll view of the Display2D class. The return value is an array of Bags. For each FieldPortrayal attached to the Display2D, one Bag is returned holding all the LocationWrappers for objects falling within the rectangle which are associated with that FieldPortrayal's portrayed field. The order of the Bags in the array is the same as the order of the FieldPortrayals in the Display2D's portrayals list.


objectsHitBy

public Bag[] objectsHitBy(java.awt.geom.Point2D point)
Returns LocationWrappers for all the objects which overlap with the point specified by 'point'. This point is in the coordinate system of the (InnerDisplay2D) component inside the scroll view of the Display2D class. The return value is an array of Bags. For each FieldPortrayal attached to the Display2D, one Bag is returned holding all the LocationWrappers for objects overlapping with the point which are associated with that FieldPortrayal's portrayed field. The order of the Bags in the array is the same as the order of the FieldPortrayals in the Display2D's portrayals list.


getDrawInfo2D

public DrawInfo2D getDrawInfo2D(FieldPortrayal2D portrayal,
                                java.awt.geom.Point2D point)
Constructs a DrawInfo2D for the given portrayal, or null if failed. O(num portrayals). Uses the given point as a clip.


getDrawInfo2D

public DrawInfo2D getDrawInfo2D(FieldPortrayal2D portrayal,
                                java.awt.geom.Rectangle2D clip)
Constructs a DrawInfo2D for the given portrayal, or null if failed. O(num portrayals). Uses the given clip.


createToolTipText

public java.lang.String createToolTipText(java.awt.geom.Rectangle2D.Double rect,
                                          GUIState simulation)

performSelection

public void performSelection(LocationWrapper wrapper)
Specified by:
performSelection in interface Manipulating2D

clearSelections

public void clearSelections()

performSelection

public void performSelection(Bag locationWrappers)

performSelection

public void performSelection(java.awt.geom.Rectangle2D.Double rect)

createInspectors

public void createInspectors(java.awt.geom.Rectangle2D.Double rect,
                             GUIState simulation)
Determines the inspectors appropriate for the given selection region (rect), and sends them on to the Controller.


createFrame

public javax.swing.JFrame createFrame()
Creates a frame holding the Display2D. This is the best method to create the frame, rather than making a frame and putting the Display2D in it. If you prefer the latter, then you need to handle two things. First, when the frame is disposed, you need to call quit() on the Display2D. Second, if you care about distribution to MacOS X Java 1.3.1, you need to call Utilities.doEnsuredRepaint(header) whenever the window is resized.


getFrame

public java.awt.Frame getFrame()
Returns the frame holding this Component. If there is NO such frame, an error will be generated (probably a ClassCastException).


takeSnapshot

public void takeSnapshot(java.io.File file,
                         int type)
                  throws java.io.IOException
Throws:
java.io.IOException

takeSnapshot

public void takeSnapshot()

startMovie

public void startMovie()
Starts a Quicktime movie on the given Display2D. The size of the movie frame will be the size of the display at the time this method is called. This method ought to be called from the main event loop. Most of the default movie formats provided will result in a gigantic movie, which you can re-encode using something smarter (like the Animation or Sorenson codecs) to put to a reasonable size. On the Mac, Quicktime Pro will do this quite elegantly.


stopMovie

public void stopMovie()
Stops a Quicktime movie and cleans up, flushing the remaining frames out to disk. This method ought to be called from the main event loop.


shouldUpdate

public boolean shouldUpdate()
Returns whether it's time to update.


handleMouseEvent

public boolean handleMouseEvent(java.awt.event.MouseEvent event)

step

public void step(SimState state)
Steps the Display2D in the GUIState schedule. If we're in MacOS X, this results in a repaint() request generated. If we're in Windows or X Windows, this results in a direct call to paintComponent on the insideDisplay. It's OS-dependent because different operating systems draw faster in different ways.

Specified by:
step in interface Steppable