public class MapPanel
extends javax.swing.JPanel
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
private java.util.List<MapComponent> |
drawingOrder
The order in which the components are drawn.
|
private int |
fps
FPS
|
private Map |
map |
private java.util.concurrent.ConcurrentHashMap<MapComponent,MapComponentView> |
mapComponents
The
MapComponents that are visible on the Map. |
private int |
maxX
The maximum width.
|
private int |
maxY
The maximum height.
|
private int |
numberOfCalls
FPS notification
|
private int |
offsetX
The offset in the x direction.
|
private int |
offsetY
The offset in the y direction.
|
private double |
pixelRatio
The pixel ratio.
|
private long |
previousTime
Previous time
|
private java.util.List<java.lang.Class<? extends MapComponentView>> |
views
The user created views.
|
private int[] |
zoomCoordinates
Zoom coordinates indicate the coordinates needed to draw the zoom-in
rectangle.
|
private java.awt.Image |
zoomImage
The image used to visualize a zoomed in map.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
MapPanel(Map map,
double pixelRatio)
Creates the map panel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMapComponent(MapComponent component)
Adds a
MapComponent to the map. |
private void |
addMapComponent(MapComponent component,
int superClasses)
Adds a
MapComponent to the map. |
void |
addMapComponentView(java.lang.Class<? extends MapComponentView> view)
Adds a map component view.
|
void |
clicked(int x,
int y)
Method called when the user clicks the mouse.
|
void |
doZoomRectangle(int xStart,
int yStart,
int xEnd,
int yEnd)
Indicates the coordinates that are needed for the zoom in rectangle.
|
void |
paint(java.awt.Graphics g) |
void |
remove(MapComponent mapComponent)
Removes a
MapComponent from the map panel. |
void |
setPixelRatio(double pixelRatio)
Sets the pixel ratio.
|
void |
update(int timeStep,
double time)
Update the map panel.
|
void |
zoom(int xStart,
int yStart,
int xEnd,
int yEnd,
double mapWidth)
Calculates the parameters needed for the user specified zoom.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, updateadd, 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, transferFocusDownCycle, validate, validateTreeaction, 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, 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, transferFocusBackward, transferFocusUpCycleprivate java.util.List<MapComponent> drawingOrder
private int fps
private java.util.concurrent.ConcurrentHashMap<MapComponent,MapComponentView> mapComponents
MapComponents that are visible on the Map.private int maxX
private int maxY
private int numberOfCalls
private int offsetX
private int offsetY
private double pixelRatio
private long previousTime
private int[] zoomCoordinates
private java.awt.Image zoomImage
private java.util.List<java.lang.Class<? extends MapComponentView>> views
private Map map
public MapPanel(Map map, double pixelRatio)
map - The map.pixelRatio - The pixel ratio.public void addMapComponent(MapComponent component)
MapComponent to the map. It is assumed that a
MapComponent has a MapComponentView that visualizes the
MapComponent. The naming convention for a
MapComponentView is: "MapComponentName"+"View". For instance, the
MapComponent HumanAgent has a MapComponentView
called HumanAgentView.component - The component.private void addMapComponent(MapComponent component, int superClasses)
MapComponent to the map. It is a recursive method that at
takes a component and a value as an input. The value represents the
number of super classes above the component we want to add a
visualization of. This is used, because some map components do not have a
specific visualization. For instance, the Passenger does not have
a view corresponding to it, but the HumanAgent (the superclass of
Passenger) does have a corresponding view.component - The component.superClasses - The number of super classes above.public void addMapComponentView(java.lang.Class<? extends MapComponentView> view)
view - The view.public void clicked(int x,
int y)
x - The x coordinate.y - The y coordinate.public void doZoomRectangle(int xStart,
int yStart,
int xEnd,
int yEnd)
xStart - Top left x coordinate.yStart - Top left y coordinate.xEnd - Bottom right x coordinate.yEnd - Bottom right y coordinate.public void paint(java.awt.Graphics g)
paint in class javax.swing.JComponentpublic void remove(MapComponent mapComponent)
MapComponent from the map panel.mapComponent - The map component.public void setPixelRatio(double pixelRatio)
pixelRatio - The pixel ratio.public void update(int timeStep,
double time)
timeStep - The time step.time - The time.public void zoom(int xStart,
int yStart,
int xEnd,
int yEnd,
double mapWidth)
xStart - Top left x coordinate.yStart - Top left y coordinate.xEnd - Bottom right x coordinate.yEnd - Bottom right y coordinate.mapWidth - The width of the map.