lejos.robotics.mapping
Class MapPanel

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 lejos.robotics.mapping.MapPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class MapPanel
extends javax.swing.JPanel

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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 static float ARROW_LENGTH
           
protected  float arrowLength
           
protected static java.awt.Color BACKGROUND_COLOR
           
static int BACKGROUND_COLOR_INDEX
           
protected static java.awt.Color CLOSEST_COLOR
           
static int CLOSEST_COLOR_INDEX
           
 java.lang.String[] colorKeys
           
 java.awt.Color[] colors
           
protected static java.awt.Color ESTIMATE_COLOR
           
static int ESTIMATE_COLOR_INDEX
           
protected static java.awt.Color FEATURE_COLOR
           
static int FEATURE_COLOR_INDEX
           
protected static java.awt.Color GRID_COLOR
           
static int GRID_COLOR_INDEX
           
protected  int gridSize
           
protected  java.awt.Color[] INITIAL_COLORS
           
protected static java.awt.Color MAP_COLOR
           
static int MAP_COLOR_INDEX
           
protected static int MAX_CLUSTER_SIZE
           
protected static java.awt.Color MESH_COLOR
           
static int MESH_COLOR_INDEX
           
protected  PCNavigationModel model
           
protected static java.awt.Color MOVE_COLOR
           
static int MOVE_COLOR_INDEX
           
protected static java.awt.Color NEIGHBOR_COLOR
           
static int NEIGHBOR_COLOR_INDEX
           
protected  int NODE_CIRC
           
protected  NavigationPanel parent
           
protected static java.awt.Color PARTICLE_COLOR
           
static int PARTICLE_COLOR_INDEX
           
protected static java.awt.Color PATH_COLOR
           
static int PATH_COLOR_INDEX
           
protected static java.awt.Color ROBOT_COLOR
           
static int ROBOT_COLOR_INDEX
           
protected static int ROBOT_SIZE
           
protected  java.awt.Dimension size
           
protected static java.awt.Color TARGET_COLOR
           
static int TARGET_COLOR_INDEX
           
protected static int TARGET_SIZE
           
 java.awt.Point viewStart
           
protected static java.awt.Color WAYPOINT_COLOR
           
static int WAYPOINT_COLOR_INDEX
           
 
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
MapPanel(PCNavigationModel model, java.awt.Dimension size, NavigationPanel parent)
          Create the panel, set its size, and associated it with the navigation model and navigation panel.
 
Method Summary
protected  Line getArrowLine(Pose pose)
          Create a Line that represents the direction of the pose
 void getColors(java.util.Properties props)
           
protected  float getDistance(float distance)
          Convert a distance in map coordinates to a screen distance
 java.lang.String getToolTipText(java.awt.event.MouseEvent e)
          Get tooltips for individual features - currently just particles
protected  float getX(float x)
          Get the screen X coordinate for a given map coordinate
protected  float getY(float y)
          Get the screen Y coordinate for a given map coordinate
 void paintComponent(java.awt.Graphics g)
          Overrides JPanel paintComponent to paint all the navigation data
protected  void paintFeatures(java.awt.Graphics2D g2d)
          Paint features detected
 void paintGrid(java.awt.Graphics2D g2d)
          Paint the grid
 void paintMap(java.awt.Graphics2D g2d)
          Draw the map using Line2D objects
protected  void paintMesh(java.awt.Graphics2D g2d)
          Paint the navigation mesh
protected  void paintMoves(java.awt.Graphics2D g2d)
          Paint the moves made
 void paintParticles(java.awt.Graphics2D g2d)
          Paint the particles
protected  void paintPath(java.awt.Graphics2D g2d)
          Paint the path
 void paintPose(java.awt.Graphics2D g2d, Pose pose)
          Paint the pose using Ellipse2D
protected  void paintRobot(java.awt.Graphics2D g2d)
          If we are down to one small cluster show the location of the robot.
protected  void paintTarget(java.awt.Graphics2D g2d)
          Paint the target
protected  void paintWaypoints(java.awt.Graphics2D g2d)
           
 void saveColors(java.util.Properties props)
           
 void setDefaults()
           
 void showColors()
           
 
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, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAP_COLOR

protected static final java.awt.Color MAP_COLOR

PARTICLE_COLOR

protected static final java.awt.Color PARTICLE_COLOR

BACKGROUND_COLOR

protected static final java.awt.Color BACKGROUND_COLOR

GRID_COLOR

protected static final java.awt.Color GRID_COLOR

ESTIMATE_COLOR

protected static final java.awt.Color ESTIMATE_COLOR

CLOSEST_COLOR

protected static final java.awt.Color CLOSEST_COLOR

MESH_COLOR

protected static final java.awt.Color MESH_COLOR

NEIGHBOR_COLOR

protected static final java.awt.Color NEIGHBOR_COLOR

TARGET_COLOR

protected static final java.awt.Color TARGET_COLOR

PATH_COLOR

protected static final java.awt.Color PATH_COLOR

MOVE_COLOR

protected static final java.awt.Color MOVE_COLOR

FEATURE_COLOR

protected static final java.awt.Color FEATURE_COLOR

WAYPOINT_COLOR

protected static final java.awt.Color WAYPOINT_COLOR

ROBOT_COLOR

protected static final java.awt.Color ROBOT_COLOR

ARROW_LENGTH

protected static final float ARROW_LENGTH
See Also:
Constant Field Values

ROBOT_SIZE

protected static final int ROBOT_SIZE
See Also:
Constant Field Values

TARGET_SIZE

protected static final int TARGET_SIZE
See Also:
Constant Field Values

NODE_CIRC

protected final int NODE_CIRC
See Also:
Constant Field Values

model

protected PCNavigationModel model

parent

protected NavigationPanel parent

size

protected java.awt.Dimension size

arrowLength

protected float arrowLength

gridSize

protected int gridSize

colors

public java.awt.Color[] colors

colorKeys

public java.lang.String[] colorKeys

MAP_COLOR_INDEX

public static final int MAP_COLOR_INDEX
See Also:
Constant Field Values

PARTICLE_COLOR_INDEX

public static final int PARTICLE_COLOR_INDEX
See Also:
Constant Field Values

BACKGROUND_COLOR_INDEX

public static final int BACKGROUND_COLOR_INDEX
See Also:
Constant Field Values

GRID_COLOR_INDEX

public static final int GRID_COLOR_INDEX
See Also:
Constant Field Values

ESTIMATE_COLOR_INDEX

public static final int ESTIMATE_COLOR_INDEX
See Also:
Constant Field Values

CLOSEST_COLOR_INDEX

public static final int CLOSEST_COLOR_INDEX
See Also:
Constant Field Values

MESH_COLOR_INDEX

public static final int MESH_COLOR_INDEX
See Also:
Constant Field Values

NEIGHBOR_COLOR_INDEX

public static final int NEIGHBOR_COLOR_INDEX
See Also:
Constant Field Values

TARGET_COLOR_INDEX

public static final int TARGET_COLOR_INDEX
See Also:
Constant Field Values

PATH_COLOR_INDEX

public static final int PATH_COLOR_INDEX
See Also:
Constant Field Values

MOVE_COLOR_INDEX

public static final int MOVE_COLOR_INDEX
See Also:
Constant Field Values

FEATURE_COLOR_INDEX

public static final int FEATURE_COLOR_INDEX
See Also:
Constant Field Values

WAYPOINT_COLOR_INDEX

public static final int WAYPOINT_COLOR_INDEX
See Also:
Constant Field Values

ROBOT_COLOR_INDEX

public static final int ROBOT_COLOR_INDEX
See Also:
Constant Field Values

MAX_CLUSTER_SIZE

protected static final int MAX_CLUSTER_SIZE
See Also:
Constant Field Values

INITIAL_COLORS

protected final java.awt.Color[] INITIAL_COLORS

viewStart

public java.awt.Point viewStart
Constructor Detail

MapPanel

public MapPanel(PCNavigationModel model,
                java.awt.Dimension size,
                NavigationPanel parent)
Create the panel, set its size, and associated it with the navigation model and navigation panel.

Parameters:
model - the navigation model
size - the map panel size
parent - the navigation panel
Method Detail

paintMap

public void paintMap(java.awt.Graphics2D g2d)
Draw the map using Line2D objects

Parameters:
g2d - the Graphics2D object

paintMesh

protected void paintMesh(java.awt.Graphics2D g2d)
Paint the navigation mesh

Parameters:
g2d - the Graphics2D object

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides JPanel paintComponent to paint all the navigation data

Overrides:
paintComponent in class javax.swing.JComponent

paintRobot

protected void paintRobot(java.awt.Graphics2D g2d)
If we are down to one small cluster show the location of the robot.

Parameters:
g2d - the Graphics2D object

paintPose

public void paintPose(java.awt.Graphics2D g2d,
                      Pose pose)
Paint the pose using Ellipse2D

Parameters:
g2d - the Graphics2D object

paintGrid

public void paintGrid(java.awt.Graphics2D g2d)
Paint the grid

Parameters:
g2d - the Graphics2D object

paintParticles

public void paintParticles(java.awt.Graphics2D g2d)
Paint the particles

Parameters:
g2d - the Graphics2D object

paintTarget

protected void paintTarget(java.awt.Graphics2D g2d)
Paint the target

Parameters:
g2d - the Graphics2D object

paintFeatures

protected void paintFeatures(java.awt.Graphics2D g2d)
Paint features detected

Parameters:
g2d - the Graphics2D object

paintWaypoints

protected void paintWaypoints(java.awt.Graphics2D g2d)

paintMoves

protected void paintMoves(java.awt.Graphics2D g2d)
Paint the moves made

Parameters:
g2d - the Graphics2D object

getArrowLine

protected Line getArrowLine(Pose pose)
Create a Line that represents the direction of the pose

Parameters:
pose - the pose
Returns:
the arrow line

paintPath

protected void paintPath(java.awt.Graphics2D g2d)
Paint the path

Parameters:
g2d - the Graphics2d object

getX

protected float getX(float x)
Get the screen X coordinate for a given map coordinate


getY

protected float getY(float y)
Get the screen Y coordinate for a given map coordinate


getDistance

protected float getDistance(float distance)
Convert a distance in map coordinates to a screen distance


getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
Get tooltips for individual features - currently just particles

Overrides:
getToolTipText in class javax.swing.JComponent

showColors

public void showColors()

getColors

public void getColors(java.util.Properties props)

saveColors

public void saveColors(java.util.Properties props)

setDefaults

public void setDefaults()