org.geotools.gui.swing
Class JMapPane

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.geotools.gui.swing.JMapPane
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible
Direct Known Subclasses:
JMapPane

public class JMapPane
extends JPanel
implements MouseListener, MouseMotionListener, PropertyChangeListener

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
protected  BufferedImage baseImage
          the base image of the map
protected  Envelope mapArea
          the area of the map to draw
protected  Envelope oldMapArea
          the last map area drawn.
protected  Rectangle oldRect
          the size of the pane last time we drew
static int Pan
           
protected  BufferedImage panningImage
          the base image of the map
protected  boolean reset
           
static int Reset
           
static int Select
           
static int ZoomIn
           
static int ZoomOut
           
 
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
JMapPane()
           
JMapPane(GTRenderer render, MapContext context)
          create a basic JMapPane
JMapPane(LayoutManager layout, boolean isDoubleBuffered, GTRenderer render, MapContext context)
          full constructor extending JPanel
 
Method Summary
 Envelope bestAllowedMapArea(Envelope env)
          Korrigiert den Envelope aka mapArea auf die beste erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.
 void doSelection(double x, double y, MapLayer layer)
           
protected  void drawRectangle(Graphics graphics)
           
 MapContext getContext()
           
 MapLayer getHighlightLayer()
           
 HighlightManager getHighlightManager()
           
 Style getLineHighlightStyle()
           
 Style getLineSelectionStyle()
           
 Envelope getMapArea()
           
 Double getMaxZoomScale()
          Retuns the maximum allowed zoom scale.
 Double getMinZoomScale()
          Retuns the minimum allowed zoom scale.
 Style getPointHighlightStyle()
           
 Style getPointSelectionStyle()
           
 Style getPolygonHighlightStyle()
           
 Style getPolygonSelectionStyle()
           
 GTRenderer getRenderer()
          get the renderer
 FeatureCollection getSelection()
           
 MapLayer getSelectionLayer()
           
 SelectionManager getSelectionManager()
           
 int getState()
           
 double getZoomFactor()
           
 void highlightChanged(HighlightChangedEvent e)
           
 boolean isHighlight()
           
 boolean isReset()
           
 void layerAdded(MapLayerListEvent event)
           
 void layerChanged(MapLayerListEvent event)
           
 void layerMoved(MapLayerListEvent event)
           
 void layerRemoved(MapLayerListEvent event)
           
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void paintComponent(Graphics g)
           
protected  void processDrag(int x1, int y1, int x2, int y2, MouseEvent e)
           
 void propertyChange(PropertyChangeEvent evt)
           
 void selectionChanged(SelectionChangedEvent e)
           
 void setClickable(boolean clickable)
          if clickable is set to true then a single click on the map pane will zoom or pan the map.
 void setContext(MapContext context)
           
 void setHighlight(boolean highlight)
           
 void setHighlightLayer(MapLayer highlightLayer)
           
 void setHighlightManager(HighlightManager highlightManager)
           
 void setLineHighlightStyle(Style lineHighlightStyle)
           
 void setLineSelectionStyle(Style lineSelectionStyle)
           
 void setMapArea(Envelope mapArea)
           
 void setMaxZoomScale(Double maxZoomScale)
          Set the maximum allowed zoom scale.
 void setMinZoomScale(Double minZoomScale)
          Set the minimum (nearest) allowed zoom scale.
 void setPointHighlightStyle(Style pointHighlightStyle)
           
 void setPointSelectionStyle(Style pointSelectionStyle)
           
 void setPolygonHighlightStyle(Style polygonHighlightStyle)
           
 void setPolygonSelectionStyle(Style polygonSelectionStyle)
           
 void setRenderer(GTRenderer renderer)
           
 void setReset(boolean reset)
           
 void setSelection(FeatureCollection selection)
           
 void setSelectionLayer(MapLayer selectionLayer)
           
 void setSelectionManager(SelectionManager selectionManager)
           
 void setState(int state)
           
 void setZoomFactor(double zoomFactor)
           
 
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, 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

Reset

public static final int Reset
See Also:
Constant Field Values

ZoomIn

public static final int ZoomIn
See Also:
Constant Field Values

ZoomOut

public static final int ZoomOut
See Also:
Constant Field Values

Pan

public static final int Pan
See Also:
Constant Field Values

Select

public static final int Select
See Also:
Constant Field Values

mapArea

protected Envelope mapArea
the area of the map to draw


oldRect

protected Rectangle oldRect
the size of the pane last time we drew


oldMapArea

protected Envelope oldMapArea
the last map area drawn.


baseImage

protected BufferedImage baseImage
the base image of the map


panningImage

protected BufferedImage panningImage
the base image of the map


reset

protected boolean reset
Constructor Detail

JMapPane

public JMapPane()

JMapPane

public JMapPane(GTRenderer render,
                MapContext context)
create a basic JMapPane

Parameters:
render - - how to draw the map
context - - the map context to display

JMapPane

public JMapPane(LayoutManager layout,
                boolean isDoubleBuffered,
                GTRenderer render,
                MapContext context)
full constructor extending JPanel

Parameters:
layout - - layout (probably shouldn't be set)
isDoubleBuffered - - a Swing thing I don't really understand
render - - what to draw the map with
context - - what to draw
Method Detail

getRenderer

public GTRenderer getRenderer()
get the renderer


setRenderer

public void setRenderer(GTRenderer renderer)

getContext

public MapContext getContext()

setContext

public void setContext(MapContext context)

getMapArea

public Envelope getMapArea()

setMapArea

public void setMapArea(Envelope mapArea)

getState

public int getState()

setState

public void setState(int state)

getZoomFactor

public double getZoomFactor()

setZoomFactor

public void setZoomFactor(double zoomFactor)

getSelectionLayer

public MapLayer getSelectionLayer()

setSelectionLayer

public void setSelectionLayer(MapLayer selectionLayer)

isHighlight

public boolean isHighlight()

setHighlight

public void setHighlight(boolean highlight)

getHighlightLayer

public MapLayer getHighlightLayer()

setHighlightLayer

public void setHighlightLayer(MapLayer highlightLayer)

getHighlightManager

public HighlightManager getHighlightManager()

setHighlightManager

public void setHighlightManager(HighlightManager highlightManager)

getLineHighlightStyle

public Style getLineHighlightStyle()

setLineHighlightStyle

public void setLineHighlightStyle(Style lineHighlightStyle)

getLineSelectionStyle

public Style getLineSelectionStyle()

setLineSelectionStyle

public void setLineSelectionStyle(Style lineSelectionStyle)

getPointHighlightStyle

public Style getPointHighlightStyle()

setPointHighlightStyle

public void setPointHighlightStyle(Style pointHighlightStyle)

getPointSelectionStyle

public Style getPointSelectionStyle()

setPointSelectionStyle

public void setPointSelectionStyle(Style pointSelectionStyle)

getPolygonHighlightStyle

public Style getPolygonHighlightStyle()

setPolygonHighlightStyle

public void setPolygonHighlightStyle(Style polygonHighlightStyle)

getPolygonSelectionStyle

public Style getPolygonSelectionStyle()

setPolygonSelectionStyle

public void setPolygonSelectionStyle(Style polygonSelectionStyle)

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

doSelection

public void doSelection(double x,
                        double y,
                        MapLayer layer)

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

processDrag

protected void processDrag(int x1,
                           int y1,
                           int x2,
                           int y2,
                           MouseEvent e)

highlightChanged

public void highlightChanged(HighlightChangedEvent e)

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

isReset

public boolean isReset()

setReset

public void setReset(boolean reset)

layerAdded

public void layerAdded(MapLayerListEvent event)

layerRemoved

public void layerRemoved(MapLayerListEvent event)

layerChanged

public void layerChanged(MapLayerListEvent event)

layerMoved

public void layerMoved(MapLayerListEvent event)

drawRectangle

protected void drawRectangle(Graphics graphics)

setClickable

public void setClickable(boolean clickable)
if clickable is set to true then a single click on the map pane will zoom or pan the map.

Parameters:
clickable -

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

getSelection

public FeatureCollection getSelection()

setSelection

public void setSelection(FeatureCollection selection)

selectionChanged

public void selectionChanged(SelectionChangedEvent e)

getSelectionManager

public SelectionManager getSelectionManager()

setSelectionManager

public void setSelectionManager(SelectionManager selectionManager)

bestAllowedMapArea

public Envelope bestAllowedMapArea(Envelope env)
Korrigiert den Envelope aka mapArea auf die beste erlaubte Flaeche damit die Massstabsbeschaenkungen noch eingehalten werden, FALLS der uebergeben Envelope nicht schon gueltig sein sollte.
Since 21. April 09: Before thecalculation starts, the aspect ratio is corrected. This change implies, that setMapArea() will most of the time not allow setting to a wrong aspectRatio.


getMinZoomScale

public Double getMinZoomScale()
Retuns the minimum allowed zoom scale. This is the bigger number value of the two. Defaults to Double.MAX_VALUE


getMaxZoomScale

public Double getMaxZoomScale()
Retuns the maximum allowed zoom scale. This is the smaller number value of the two. Defaults to Double.MIN_VALUE


setMaxZoomScale

public void setMaxZoomScale(Double maxZoomScale)
Set the maximum allowed zoom scale. This is the smaller number value of the two.


setMinZoomScale

public void setMinZoomScale(Double minZoomScale)
Set the minimum (nearest) allowed zoom scale. This is the bigger number value of the two.