org.free.garminimg.swing
Class MapPanel<COORD>

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 org.free.garminimg.swing.MapPanel<COORD>
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class MapPanel<COORD>
extends javax.swing.JPanel

A swing panel displaying a map.

See Also:
MapControlPanel, 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
static java.awt.Color BG_COLOR
           
static java.awt.Color LABEL_BACKGROUND
           
static java.awt.Color LABEL_COLOR
           
 
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(ImgFilesBag map, MapTransformer<COORD> transformer)
          Create a dependent MapPanel, with its converter and maps provided from outside.
MapPanel(MapTransformer.Converter<COORD> converter, int margin)
          Create a stand-alone MapPanel, with its own converter and its own maps.
 
Method Summary
 void addMapLocation(java.io.File location)
           
 void clearMaps()
           
 void componentResized()
           
 TransformedMapListener createMapDrawer(MapConfig workConfig, java.awt.Graphics2D g2, float fontSize, MapTransformer<COORD> workTransformer)
          Create a map drawer.
 java.lang.String getInfo(int x, int y, int maxNbInfo)
           
 ImgFilesBag getMap()
           
 int getResolution(int minLon, int maxLon)
           
static int getResolution(int minLon, int maxLon, int width)
           
 int getResolution(MapTransformer<COORD> transformer)
           
 MapTransformer<COORD> getTransformer()
           
 void hideInfo()
           
 void movePosition(double deltaX, double deltaY)
           
 void paintComponent(java.awt.Graphics g)
           
 void saveMapAs(java.io.File selectedFile, FileExporter exporter, MapTransformer<COORD> transformer)
           
 void setDetailLevel(int detailLevel)
           
 void setPoiThreshold(int threshold)
           
 void setPosition(double minLon, double maxLon, double minLat, double maxLat)
           
 void setQuality(MapConfig.Quality quality)
          Does not trigger a repaint...
 void setShading(boolean enabled)
           
 void setShowLineLabel(boolean showLineLabel)
           
 void setShowPointLabel(boolean showPointLabel)
           
 void setShowPolygonLabel(boolean showPolygonLabel)
           
 void showAllMap()
          Zoom and position the map in order to see everything.
 void showInfo(int x, int y, int maxNbInfo)
           
protected  void showInfoPopup(java.lang.String info, int x, int y)
           
protected  void transformerChanged()
           
 void transformerChangedManually()
          If an external class changed manually the transformer, it must call this method to make the change effective.
 void zoom(double factor)
           
 void zoom(double factor, int x, int y)
          If factor>1 zoom in, otherwise zoom out.
 void zoomToGarminGeo(double factor, int longitude, int latitude)
           
 
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, 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

BG_COLOR

public static final java.awt.Color BG_COLOR

LABEL_COLOR

public static final java.awt.Color LABEL_COLOR

LABEL_BACKGROUND

public static final java.awt.Color LABEL_BACKGROUND
Constructor Detail

MapPanel

public MapPanel(MapTransformer.Converter<COORD> converter,
                int margin)
Create a stand-alone MapPanel, with its own converter and its own maps.


MapPanel

public MapPanel(ImgFilesBag map,
                MapTransformer<COORD> transformer)
Create a dependent MapPanel, with its converter and maps provided from outside.

Method Detail

componentResized

public void componentResized()

transformerChanged

protected void transformerChanged()

transformerChangedManually

public void transformerChangedManually()
If an external class changed manually the transformer, it must call this method to make the change effective.


addMapLocation

public void addMapLocation(java.io.File location)
                    throws java.io.IOException
Throws:
java.io.IOException

clearMaps

public void clearMaps()
               throws java.io.IOException
Throws:
java.io.IOException

setPosition

public void setPosition(double minLon,
                        double maxLon,
                        double minLat,
                        double maxLat)

movePosition

public void movePosition(double deltaX,
                         double deltaY)

zoom

public void zoom(double factor,
                 int x,
                 int y)
If factor>1 zoom in, otherwise zoom out.


zoom

public void zoom(double factor)

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

getInfo

public java.lang.String getInfo(int x,
                                int y,
                                int maxNbInfo)

getTransformer

public MapTransformer<COORD> getTransformer()

showAllMap

public void showAllMap()
Zoom and position the map in order to see everything.


setQuality

public void setQuality(MapConfig.Quality quality)
Does not trigger a repaint...


showInfo

public void showInfo(int x,
                     int y,
                     int maxNbInfo)

showInfoPopup

protected void showInfoPopup(java.lang.String info,
                             int x,
                             int y)

hideInfo

public void hideInfo()

zoomToGarminGeo

public void zoomToGarminGeo(double factor,
                            int longitude,
                            int latitude)

getMap

public ImgFilesBag getMap()

getResolution

public int getResolution(MapTransformer<COORD> transformer)

getResolution

public int getResolution(int minLon,
                         int maxLon)

getResolution

public static int getResolution(int minLon,
                                int maxLon,
                                int width)

createMapDrawer

public TransformedMapListener createMapDrawer(MapConfig workConfig,
                                              java.awt.Graphics2D g2,
                                              float fontSize,
                                              MapTransformer<COORD> workTransformer)
Create a map drawer. Called each time a new map view must be displayed.

Override this if you want a custom drawer.


saveMapAs

public void saveMapAs(java.io.File selectedFile,
                      FileExporter exporter,
                      MapTransformer<COORD> transformer)
               throws java.io.IOException
Throws:
java.io.IOException

setShowLineLabel

public void setShowLineLabel(boolean showLineLabel)

setShowPolygonLabel

public void setShowPolygonLabel(boolean showPolygonLabel)

setShowPointLabel

public void setShowPointLabel(boolean showPointLabel)

setPoiThreshold

public void setPoiThreshold(int threshold)

setDetailLevel

public void setDetailLevel(int detailLevel)

setShading

public void setShading(boolean enabled)


Copyright © 2008. All Rights Reserved.