|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--com.bbn.openmap.MapBean
The MapBean is the main component of the OpenMap Development Kit. It is a Java Bean that manages and displays a map. A map is comprised of a projection and a list of layers, and this class has methods that allow you to control the projection parameters and to add and remove layers. Layers that are part of the map receive dynamic notifications of changes to the underlying view and projection.
Most of the methods in the MapBean are called from the Java AWT and Swing code. These methods make the MapBean a good "Swing citizen" to its parent components, and you should not need to invoke them. In general there are only two reasons to call MapBean methods: controlling the projection, and adding or removing layers.
When controlling the MapBean projection, simply call the method that applies - setCenter, pan, zoom, etc. NOTE: If you are setting more than one parameter of the projection, it's more efficient to getProjection(), directly set the parameters of the projection object, and then call setProjection() with the modified projection. That way, each ProjectionListener of the MapBean (each layer) will only receive one projectionChanged() method call, as opposed to receiving one for each projection adjustment.
To add or remove layers, use the add() and remove() methods that the MapBean inherits from java.awt.Container. The add() method can be called with an integer that indicates its desired position in the layer list.
Changing the default clipping area may cause some Layers to not be drawn completely, depending on what the clipping area is set to and when the layer is trying to get itself painted. When manually adjusting clipping area, make sure that when restricted clipping is over that a full repaint occurs if there is a chance that another layer may be trying to paint itself.
Layer
,
Serialized FormField Summary | |
protected java.util.Vector |
addedLayers
This vector is to let the layers know when they have been added to the map. |
protected java.awt.Paint |
background
The background color for this particular MapBean. |
static java.lang.String |
BackgroundProperty
|
protected Layer[] |
currentLayers
|
static java.lang.String |
CursorProperty
|
static java.awt.Color |
DEFAULT_BACKGROUND_COLOR
|
static float |
DEFAULT_CENTER_LAT
|
static float |
DEFAULT_CENTER_LON
|
static int |
DEFAULT_HEIGHT
|
static float |
DEFAULT_SCALE
|
static int |
DEFAULT_WIDTH
|
protected boolean |
doContainerChange
|
protected boolean |
layerRemovalDelayed
Some users may want the layers deleted immediately when they are removed from the map. |
static java.lang.String |
LayersProperty
|
protected int |
minHeight
|
protected int |
minWidth
|
protected PaintListenerSupport |
painters
The PaintListeners want to know when the map has been repainted. |
protected Proj |
projection
|
static java.lang.String |
ProjectionProperty
|
protected ProjectionSupport |
projectionSupport
|
protected java.util.Vector |
removedLayers
Layers that are removed from the MapBean are held until the next projection change. |
protected MapBeanRepaintPolicy |
repaintPolicy
The MapBeanRepaintPolicy to use to handler/filter/pace layer repaint() requests. |
static boolean |
suppressCopyright
Suppress the copyright message on initialization. |
static java.lang.String |
title
OpenMap title. |
static java.lang.String |
version
OpenMap version. |
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 | |
MapBean()
Construct a MapBean. |
Method Summary | |
protected void |
addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
Adds additional constraints on possible children components. |
void |
addPaintListener(PaintListener l)
Add a PaintListener. |
void |
addProjectionListener(ProjectionListener l)
Add a ProjectionListener to the MapBean. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
In addition to adding the PropertyChangeListener as the JComponent method does, this method also provides the listener with the initial version of the Layer and Cursor properties. |
void |
center(CenterEvent evt)
Handles incoming CenterEvents . |
protected void |
changeLayers(java.awt.event.ContainerEvent e)
ContainerListener Interface method. |
void |
componentAdded(java.awt.event.ContainerEvent e)
ContainerListener Interface method. |
void |
componentHidden(java.awt.event.ComponentEvent e)
ComponentListener interface method. |
void |
componentMoved(java.awt.event.ComponentEvent e)
ComponentListener interface method. |
void |
componentRemoved(java.awt.event.ContainerEvent e)
ContainerListener Interface method. |
void |
componentResized(java.awt.event.ComponentEvent e)
ComponentListener interface method. |
void |
componentShown(java.awt.event.ComponentEvent e)
ComponentListener interface method. |
protected void |
debugmsg(java.lang.String msg)
|
protected void |
drawProjectionBackground(java.awt.Graphics g)
Convenience method to test if Graphics is Graphics2D object, and to try to do the right thing. |
protected void |
fireProjectionChanged()
Called from within the MapBean when its projection listeners need to know about a projection change. |
java.awt.Color |
getBackground()
Get the background color of the map. |
java.awt.Paint |
getBckgrnd()
Get the background of the map. |
LatLonPoint |
getCenter()
Gets the center of the map in the form of a LatLonPoint. |
LatLonPoint |
getCoordinates(java.awt.event.MouseEvent event)
Convenience function to get the LatLonPoint representing a screen location from a MouseEvent. |
LatLonPoint |
getCoordinates(java.awt.event.MouseEvent event,
LatLonPoint llp)
Convenience function to get the LatLonPoint representing a screen location from a MouseEvent. |
static java.lang.String |
getCopyrightMessage()
Return the OpenMap Copyright message. |
boolean |
getDoContainerChange()
ContainerListener Interface method. |
java.awt.Insets |
getInsets()
Get the Insets of the MapBean. |
MapBeanRepaintPolicy |
getMapBeanRepaintPolicy()
Get the MapBeanRepaintPolicy used by the MapBean. |
java.awt.Dimension |
getMinimumSize()
Return the minimum size of the MapBean window. |
Projection |
getProjection()
Get the projection property. |
int |
getProjectionType()
Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there. |
float |
getScale()
Gets the scale of the map. |
void |
hideLayerPalettes()
Turn off all layer palettes. |
boolean |
isBufferDirty()
Checks whether the image buffer should be repainted. |
boolean |
isBuffered()
Interface-like method to query if the MapBean is buffered, so you can control behavior better. |
boolean |
isLayerRemovalDelayed()
Return the flag for delayed layer removal. |
void |
paint(java.awt.Graphics g)
Same as JComponent.paint(), except if there are no children (Layers), the projection still paints the background and the border is painted. |
void |
paintChildren(java.awt.Graphics g)
Same as JComponent.paintChildren() except any PaintListeners are notified and the border is painted over the children. |
void |
paintChildren(java.awt.Graphics g,
java.awt.Rectangle clip)
Same as paintChildren, but allows you to set a clipping area to paint. |
void |
paintChildrenWithBorder(java.awt.Graphics g,
boolean drawBorder)
Method that provides an option of whether or not to draw the border when painting. |
void |
pan(PanEvent evt)
Handles incoming PanEvents . |
void |
projectionChanged(ProjectionEvent e)
ProjectionListener interface method. |
void |
purgeAndNotifyRemovedLayers()
Clear the vector containing all of the removed layers, and let those layers know they have been removed from the map. |
void |
removePaintListener(PaintListener l)
Remove a PaintListener. |
void |
removeProjectionListener(ProjectionListener l)
Remove a ProjectionListener from the MapBean. |
void |
repaint(Layer layer)
A call to try and get the MapBean to reduce flashing by controlling when repaints happen, waiting for lower layers to call for a repaint(), too. |
void |
setBackground(java.awt.Color color)
|
void |
setBackgroundColor(java.awt.Color color)
Set the background color of the map. |
void |
setBckgrnd(java.awt.Paint paint)
Set the background of the map. |
void |
setBufferDirty(boolean value)
Interface-like method to set a buffer dirty, if there is one. |
void |
setCenter(float lat,
float lon)
Sets the center of the map. |
void |
setCenter(LatLonPoint newCenter)
Sets the center of the map. |
void |
setCursor(java.awt.Cursor newCursor)
Set the Mouse cursor over the MapBean component. |
void |
setDoContainerChange(boolean value)
ContainerListener Interface method. |
void |
setLayerRemovalDelayed(boolean set)
If true (default) layers are held when they are removed, and then released and notified of removal when the projection changes. |
void |
setLayers(LayerEvent evt)
LayerListener interface method. |
void |
setLayout(java.awt.LayoutManager mgr)
Prevents changing the LayoutManager. |
void |
setMapBeanRepaintPolicy(MapBeanRepaintPolicy mbrp)
Set the MapBeanRepaintPolicy used by the MapBean. |
void |
setMinimumSize(java.awt.Dimension dim)
Set the minimum size of the MapBean window. |
void |
setProjection(Projection aProjection)
Set the projection. |
void |
setProjectionType(int newType)
Deprecated. Projection Type integers are no longer really used. The ProjectionFactory should be consulted for which type are available, and the projection should be created there. |
void |
setScale(float newScale)
Sets the scale of the map. |
void |
showLayerPalettes()
Go through the layers, and for all of them that have the autoPalette variable turned on, show their palettes. |
java.lang.String |
toString()
Return a stringified representation of the MapBean. |
void |
zoom(ZoomEvent evt)
Zoom the Map. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String LayersProperty
public static final java.lang.String CursorProperty
public static final java.lang.String BackgroundProperty
public static final java.lang.String ProjectionProperty
public static final java.lang.String title
public static final java.lang.String version
public static boolean suppressCopyright
public static final float DEFAULT_CENTER_LAT
public static final float DEFAULT_CENTER_LON
public static final float DEFAULT_SCALE
public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
protected int minHeight
protected int minWidth
protected Proj projection
protected ProjectionSupport projectionSupport
protected java.util.Vector removedLayers
protected boolean layerRemovalDelayed
protected java.util.Vector addedLayers
protected PaintListenerSupport painters
protected java.awt.Paint background
protected MapBeanRepaintPolicy repaintPolicy
public static final java.awt.Color DEFAULT_BACKGROUND_COLOR
protected transient Layer[] currentLayers
protected transient boolean doContainerChange
Constructor Detail |
public MapBean()
Method Detail |
public static java.lang.String getCopyrightMessage()
public java.lang.String toString()
toString
in class java.awt.Component
protected final void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
addImpl
in class java.awt.Container
comp
- Componentconstraints
- Objectindex
- int locationpublic final void setLayout(java.awt.LayoutManager mgr)
setLayout
in class java.awt.Container
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public void setMinimumSize(java.awt.Dimension dim)
setMinimumSize
in class javax.swing.JComponent
public final java.awt.Insets getInsets()
This makes sure that there will be no +x,+y offset when drawing graphics. This is ok since any borders around the MapBean will get drawn afterwards on top.
getInsets
in class javax.swing.JComponent
public void componentResized(java.awt.event.ComponentEvent e)
componentResized
in interface java.awt.event.ComponentListener
e
- ComponentEventpublic void componentMoved(java.awt.event.ComponentEvent e)
componentMoved
in interface java.awt.event.ComponentListener
e
- ComponentEventpublic void componentShown(java.awt.event.ComponentEvent e)
componentShown
in interface java.awt.event.ComponentListener
e
- ComponentEventpublic void componentHidden(java.awt.event.ComponentEvent e)
componentHidden
in interface java.awt.event.ComponentListener
e
- ComponentEventpublic void addProjectionListener(ProjectionListener l)
l
- ProjectionListenerpublic void removeProjectionListener(ProjectionListener l)
l
- ProjectionListenerprotected void fireProjectionChanged()
public void purgeAndNotifyRemovedLayers()
public float getScale()
Projection.getScale()
public void setScale(float newScale)
newScale
- the new scaleProj.setScale(float)
public LatLonPoint getCenter()
Projection.getCenter()
public void setCenter(LatLonPoint newCenter)
newCenter
- the center point of the mapProj.setCenter(LatLonPoint)
public void setCenter(float lat, float lon)
lat
- the latitude of center point of the map in decimal
degreeslon
- the longitude of center point of the map in decimal
degreesProj.setCenter(float, float)
public int getProjectionType()
Projection.getProjectionType()
public void setProjectionType(int newType)
newType
- the new projection typepublic void setBackgroundColor(java.awt.Color color)
color
- java.awt.Color.public void setBackground(java.awt.Color color)
setBackground
in class javax.swing.JComponent
public void setBckgrnd(java.awt.Paint paint)
paint
- java.awt.Paint.public java.awt.Color getBackground()
getBackground
in class java.awt.Component
public java.awt.Paint getBckgrnd()
public Projection getProjection()
public void setProjection(Projection aProjection)
aProjection
- Projectionpublic void center(CenterEvent evt)
CenterEvents
.
center
in interface CenterListener
evt
- the incoming center eventpublic void pan(PanEvent evt)
PanEvents
.
pan
in interface PanListener
evt
- the incoming pan eventpublic void zoom(ZoomEvent evt)
zoom
in interface ZoomListener
evt
- the ZoomEvent describing the new scale.public void setDoContainerChange(boolean value)
value
- booleanpublic boolean getDoContainerChange()
public void componentAdded(java.awt.event.ContainerEvent e)
componentAdded
in interface java.awt.event.ContainerListener
e
- ContainerEventpublic void componentRemoved(java.awt.event.ContainerEvent e)
componentRemoved
in interface java.awt.event.ContainerListener
e
- ContainerEventpurgeAndNotifyRemovedLayers()
protected void changeLayers(java.awt.event.ContainerEvent e)
e
- ContainerEventpublic void projectionChanged(ProjectionEvent e)
projectionChanged
in interface ProjectionListener
e
- ProjectionEventpublic void setCursor(java.awt.Cursor newCursor)
setCursor
in class java.awt.Component
newCursor
- Cursorpublic void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
addPropertyChangeListener
in class javax.swing.JComponent
protected final void debugmsg(java.lang.String msg)
public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
protected void drawProjectionBackground(java.awt.Graphics g)
public void paintChildren(java.awt.Graphics g)
paintChildren
in class javax.swing.JComponent
public void paintChildren(java.awt.Graphics g, java.awt.Rectangle clip)
public void paintChildrenWithBorder(java.awt.Graphics g, boolean drawBorder)
public void addPaintListener(PaintListener l)
l
- PaintListenerpublic void removePaintListener(PaintListener l)
l
- PaintListenerpublic void setLayers(LayerEvent evt)
setLayers
in interface LayerListener
evt
- a LayerEventpublic void repaint(Layer layer)
public void setMapBeanRepaintPolicy(MapBeanRepaintPolicy mbrp)
public MapBeanRepaintPolicy getMapBeanRepaintPolicy()
public LatLonPoint getCoordinates(java.awt.event.MouseEvent event)
public LatLonPoint getCoordinates(java.awt.event.MouseEvent event, LatLonPoint llp)
public boolean isBuffered()
public void setBufferDirty(boolean value)
value
- booleanpublic boolean isBufferDirty()
public void setLayerRemovalDelayed(boolean set)
public boolean isLayerRemovalDelayed()
public void showLayerPalettes()
public void hideLayerPalettes()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |