nl.tudelft.simulation.dsol.gui.animation2D
Class GridPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by nl.tudelft.simulation.dsol.gui.animation2D.GridPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
AnimationPanel

public class GridPanel
extends JPanel

The GridPanel introduces the gridPanel
(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Version:
$Revision: 1.1 $ $Date: 2007/01/06 13:23:34 $
Author:
Niels Lang , Peter Jacobs
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DOWN
          the DOWN directions for moving/zooming
protected  Rectangle2D extent
          the extent of this panel
protected  NumberFormat formatter
          the formatter to use
protected static Color GRIDCOLOR
          gridColor
protected  double gridSize
          the gridSize in world Units
protected  Rectangle2D homeExtent
          the extent of this panel
static int IN
          the ZOOM_IN directions for moving/zooming
protected  Dimension lastDimension
          the last computed Dimension
static int LEFT
          the LEFT directions for moving/zooming
static int OUT
          the ZOOM_OUT directions for moving/zooming
static int RIGHT
          the RIGHT directions for moving/zooming
protected  boolean showGrid
          show the grid
static int UP
          the UP directions for moving/zooming
 
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
GridPanel(Rectangle2D extent)
          constructs a new GridPanel
GridPanel(Rectangle2D extent, Dimension size)
          constructs a new GridPanel
 
Method Summary
protected  void drawGrid(Graphics g)
          Added to make sure the recursive render-call calls THIS render method instead of a potential super-class defined 'paintComponent' render method.
 Rectangle2D getExtent()
          returns the extent of this panel
 void home()
          resets the panel to its original extent
 boolean isShowGrid()
           
 void paintComponent(Graphics g)
           
 void pan(int direction, double percentage)
          pans the panel in a specified direction
 void setShowGrid(boolean showGrid)
           
 void showGrid(boolean bool)
          show the grid?
 void zoom(int direction, double factor)
          zooms in/out
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, update
 
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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UP

public static final int UP
the UP directions for moving/zooming

See Also:
Constant Field Values

DOWN

public static final int DOWN
the DOWN directions for moving/zooming

See Also:
Constant Field Values

LEFT

public static final int LEFT
the LEFT directions for moving/zooming

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
the RIGHT directions for moving/zooming

See Also:
Constant Field Values

IN

public static final int IN
the ZOOM_IN directions for moving/zooming

See Also:
Constant Field Values

OUT

public static final int OUT
the ZOOM_OUT directions for moving/zooming

See Also:
Constant Field Values

GRIDCOLOR

protected static final Color GRIDCOLOR
gridColor


extent

protected Rectangle2D extent
the extent of this panel


homeExtent

protected Rectangle2D homeExtent
the extent of this panel


showGrid

protected boolean showGrid
show the grid


gridSize

protected double gridSize
the gridSize in world Units


formatter

protected NumberFormat formatter
the formatter to use


lastDimension

protected Dimension lastDimension
the last computed Dimension

Constructor Detail

GridPanel

public GridPanel(Rectangle2D extent)
constructs a new GridPanel

Parameters:
extent - the extent to show.

GridPanel

public GridPanel(Rectangle2D extent,
                 Dimension size)
constructs a new GridPanel

Parameters:
extent - the initial extent
size - the size of the panel in pixels.
Method Detail

getExtent

public Rectangle2D getExtent()
returns the extent of this panel

Returns:
Rectangle2D

paintComponent

public void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent
See Also:
#paintComponent(java.awt.Graphics)

showGrid

public void showGrid(boolean bool)
show the grid?

Parameters:
bool - true/false

pan

public void pan(int direction,
                double percentage)
pans the panel in a specified direction

Parameters:
direction - the direction
percentage - the percentage

home

public void home()
resets the panel to its original extent


isShowGrid

public boolean isShowGrid()
Returns:
Returns the showGrid.

setShowGrid

public void setShowGrid(boolean showGrid)
Parameters:
showGrid - The showGrid to set.

zoom

public void zoom(int direction,
                 double factor)
zooms in/out

Parameters:
direction - the zoom direction
factor - The Factor

drawGrid

protected void drawGrid(Graphics g)
Added to make sure the recursive render-call calls THIS render method instead of a potential super-class defined 'paintComponent' render method.

Parameters:
g - the graphics object


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.