|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
uchicago.src.sim.gui.DisplaySurface
public class DisplaySurface
Handles the drawing of Displayables and the probing of probeables. Displayables are added to a DisplaySurface which is then responsible for drawing them, and handling probing (single left-click) of them. Displayables are drawn in the order they are added to the DisplaySurface. Typically, a DisplaySurface is created by the model and has displayables added to it. DisplaySurface also handles the creation of movies from and snapshots of displays.
When drawing discrete (cell-based displays) the actual drawing surface divided up into a number of cells equal to the DisplaySurface's width * the DisplaySuface's height (and in the future, the DisplaySurface's depth). Drawing at x, y coordinates via
SimGraphics draws in the cell with these coordinates.When drawing non-discrete displays(e.g Network2DDisplay), drawing is done to actual screen coordinates, where x and y refer to a screen coordinate.
Displayable,
Probeable,
Serialized Form| Nested Class Summary | |
|---|---|
class |
DisplaySurface.DisplayableOrder
|
| 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 | |
|---|---|
protected javax.swing.JMenuBar |
bar
The menu bar for the DisplaySurface JFrame |
protected java.awt.Dimension |
defaultSize
|
protected java.util.Hashtable |
displays
Dictionary of the Displays contained by this DisplaySurface. |
protected javax.swing.event.MouseInputAdapter |
dsMouseAdapter
|
protected java.awt.event.WindowAdapter |
dsWindowAdapter
|
protected javax.swing.JFrame |
frame
The JFrame in which this DisplaySurface is displayed. |
protected java.util.ArrayList |
keyListeners
List of keyListeners for this DisplaySurface. |
protected Legend |
legend
|
protected java.awt.Point |
location
|
protected javax.swing.JMenu |
menu
The option menu. |
protected SimModel |
model
The model associated with this display surface. |
protected boolean |
mousePressed
This is set to true via a mouse motion listener on the frame. |
protected MovieMaker |
movieMaker
|
protected java.lang.String |
name
The name of this display. |
protected boolean |
needsUpdate
Whether or not this DisplaySurface needs to be updated. |
protected Painter |
painter
The Painter used by this DisplaySurface to do the actual drawing. |
protected java.util.ArrayList |
probeables
List of probeable displays. |
protected java.awt.Dimension |
size
|
protected java.lang.String |
snapshotFile
Filename for snapshots taken of this display surface. |
protected java.util.ArrayList |
zoomables
|
protected uchicago.src.sim.gui.DisplaySurface.Rect |
zoomRect
|
| 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 uchicago.src.sim.gui.MediaProducer |
|---|
MPEG, QUICK_TIME |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
DisplaySurface(java.awt.Dimension size,
SimModel model,
java.lang.String name)
Creates a DisplaySurface of the specified size and with the specified model and the specified name. |
|
DisplaySurface(SimModel model,
java.lang.String name)
Creates a DisplaySurface for the specified model and with the specified name. |
|
DisplaySurface(SimModel model,
java.lang.String name,
Painter painter)
Creates a DisplaySurface for the specified model, with the specified name and using the specified Painter. |
|
| Method Summary | |
|---|---|
void |
addDisplayable(Displayable display,
java.lang.String name)
Adds a Displayable to the list of displayables that are displayed when updateDisplay is called. |
void |
addDisplayable(Displayable display,
java.lang.String name,
int order)
Adds a Displayable to the list of displayables that are displayed when updateDisplay is called. |
void |
addDisplayableProbeable(Displayable display,
java.lang.String name)
Adds the specified Displayable to the displayables list and the probeables list. |
void |
addKeyListener(java.awt.event.KeyListener listener)
|
void |
addLegendLabel(java.lang.String label,
int iconType,
java.awt.Color color,
boolean hollow)
|
void |
addLegendLabel(java.lang.String label,
int iconType,
java.awt.Color color,
boolean hollow,
int iconWidth,
int iconHeight)
|
void |
addMovieFrame()
Adds the currently displayed image as frame to a movie. setMovieName must be called before this method is called. |
void |
addProbeable(Probeable probeable)
Adds the specified Probeable to the list of probeables. |
void |
addZoomable(Zoomable zoomable)
|
void |
closeMovie()
Closes the movie, writing any remaining frames to the file. |
void |
componentHidden(java.awt.event.ComponentEvent e)
|
void |
componentMoved(java.awt.event.ComponentEvent e)
|
void |
componentResized(java.awt.event.ComponentEvent e)
|
void |
componentShown(java.awt.event.ComponentEvent e)
|
void |
createLegend(java.lang.String title)
|
void |
display()
Displays this DisplaySurface, that is, makes it visible on the screen in a JFrame etc. |
void |
dispose()
Dispose this DisplaySurface |
java.awt.Dimension |
getDefaultSize()
Returns the default dimension of this DisplaySurface. |
javax.swing.JFrame |
getFrame()
Returns the JFrame for this DisplaySurface. |
javax.swing.JMenu |
getOptionsMenu()
Returns the options menu for this DisplaySurface. |
java.awt.Dimension |
getPreferredSize()
Gets the preferred size of this DisplaySurface. |
boolean |
isFrameVisible()
|
void |
paint(java.awt.Graphics g)
Paints this surface. |
void |
paintAll(java.awt.Graphics g)
|
void |
paintComponents(java.awt.Graphics g)
|
void |
removeDisplayable(Displayable display)
Removes the specified Displayable from the list of displayables to display |
void |
removeKeyListener(java.awt.event.KeyListener listener)
|
void |
removeProbeable(Probeable probeable)
Removes the specified Probeable from the list of probeables. |
void |
removeProbeableDisplayable(Displayable display)
Removes the specified Displayable from the ist of displayables to display. |
void |
setBackground(java.awt.Color c)
Sets the background color for this display |
void |
setLocation(int x,
int y)
Sets the screen location for this OpenGraph. |
void |
setMovieName(java.lang.String fileName,
java.lang.String movieType)
Sets the name and type of a movie. |
void |
setSnapshotFileName(java.lang.String fileName)
Sets the snapshot file name. |
void |
simEventPerformed(SimEvent evt)
Repaints the display on a pause or a stop event. |
void |
takeSnapshot()
Takes a snapshot of the current displayed image and writes it to the file specified by setSnapshotFileName(String fileName). |
void |
update(java.awt.Graphics g)
|
void |
updateDisplay()
Updates the display. |
void |
updateDisplayDirect()
Updates the display. |
| 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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, 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, 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, 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, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Painter painter
protected java.util.ArrayList probeables
protected javax.swing.JFrame frame
protected boolean needsUpdate
protected java.lang.String snapshotFile
protected SimModel model
protected java.util.Hashtable displays
protected javax.swing.JMenu menu
protected javax.swing.JMenuBar bar
protected java.lang.String name
protected MovieMaker movieMaker
protected Legend legend
protected java.util.ArrayList keyListeners
protected java.util.ArrayList zoomables
protected java.awt.Point location
protected java.awt.Dimension size
protected java.awt.Dimension defaultSize
protected boolean mousePressed
protected uchicago.src.sim.gui.DisplaySurface.Rect zoomRect
protected java.awt.event.WindowAdapter dsWindowAdapter
protected javax.swing.event.MouseInputAdapter dsMouseAdapter
| Constructor Detail |
|---|
public DisplaySurface(java.awt.Dimension size,
SimModel model,
java.lang.String name)
Object2DDisplay display = new Object2DDisplay(someGrid);
DisplaySurface ds = new DisplaySurface(display.getSize(), someModel,
"Display");
. The name appears in the title bar of the
actual screen window that contains the display.
size - the size of the DisplaySurfacemodel - the model associated with this display surfacename - the name that appears in the title bar of the physical
display
public DisplaySurface(SimModel model,
java.lang.String name,
Painter painter)
Note that specifying your own Painter is an advanced feature and shouldn't be done unless you know what you are doing. Of course, if you've written your own Painter then you probably do.
model - the model associated with this display surfacename - the name that appears in the title bar of the physical
displaypainter - the Painter object used to do the actual painting of
the Displayables contained by this DisplaySurface.
public DisplaySurface(SimModel model,
java.lang.String name)
model - the model associated with this display surfacename - the name that appears in the title bar of the physical
display| Method Detail |
|---|
public void setBackground(java.awt.Color c)
setBackground in class javax.swing.JComponentc - the background color
public void addDisplayable(Displayable display,
java.lang.String name)
updateDisplay is called.
display - the displayable to addname - the name of the displayable (is shown under the view menu)
public void addDisplayable(Displayable display,
java.lang.String name,
int order)
updateDisplay is called.
display - the displayable to addname - the name of the displayable (is shown under the view menu)order - the integer specifying the display order of the displayablepublic void removeDisplayable(Displayable display)
display - the displayable to removepublic void addProbeable(Probeable probeable)
probeable - the probeable to addpublic void removeProbeable(Probeable probeable)
probeable - the probeable to removepublic void removeProbeableDisplayable(Displayable display)
display - the Displayable to removepublic void addZoomable(Zoomable zoomable)
public java.awt.Dimension getDefaultSize()
public void addDisplayableProbeable(Displayable display,
java.lang.String name)
display - the Displayable to add to this to DisplaySurface.name - the name of the displayable to add. Name will be shown
on the view menu
java.lang.IllegalArgumentException - if the specified object
is not a probable and a displayablepublic void updateDisplay()
public void updateDisplayDirect()
public void paint(java.awt.Graphics g)
paint in class javax.swing.JComponentpublic void paintComponents(java.awt.Graphics g)
paintComponents in class java.awt.Containerpublic void paintAll(java.awt.Graphics g)
paintAll in class java.awt.Componentpublic void update(java.awt.Graphics g)
update in class javax.swing.JComponentpublic boolean isFrameVisible()
public void setLocation(int x,
int y)
setLocation in class java.awt.Componentx - the x screen coordinatey - the y screen coordinatepublic void display()
public void dispose()
public void createLegend(java.lang.String title)
public void addLegendLabel(java.lang.String label,
int iconType,
java.awt.Color color,
boolean hollow)
public void addLegendLabel(java.lang.String label,
int iconType,
java.awt.Color color,
boolean hollow,
int iconWidth,
int iconHeight)
public void setMovieName(java.lang.String fileName,
java.lang.String movieType)
setMovieName in interface MediaProducerfileName - the name of the moviemovieType - the type of movie (e.g. DisplaySurface.QUICK_TIME)public void addMovieFrame()
addMovieFrame in interface MediaProducerpublic void closeMovie()
closeMovie in interface MediaProducerpublic javax.swing.JMenu getOptionsMenu()
public javax.swing.JFrame getFrame()
public void setSnapshotFileName(java.lang.String fileName)
setSnapshotFileName in interface MediaProducerfileName - then file name to record to image to.public void takeSnapshot()
takeSnapshot in interface MediaProducerpublic java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JComponentpublic void addKeyListener(java.awt.event.KeyListener listener)
addKeyListener in class java.awt.Componentpublic void removeKeyListener(java.awt.event.KeyListener listener)
removeKeyListener in class java.awt.Componentpublic void simEventPerformed(SimEvent evt)
simEventPerformed in interface SimEventListenerpublic void componentShown(java.awt.event.ComponentEvent e)
componentShown in interface java.awt.event.ComponentListenerpublic void componentHidden(java.awt.event.ComponentEvent e)
componentHidden in interface java.awt.event.ComponentListenerpublic void componentMoved(java.awt.event.ComponentEvent e)
componentMoved in interface java.awt.event.ComponentListenerpublic void componentResized(java.awt.event.ComponentEvent e)
componentResized in interface java.awt.event.ComponentListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||