java.lang.Object
Layer
org.dinopolis.gpstool.gui.util.BasicLayer
- public abstract class BasicLayer
- extends Layer
BasicLayer provide a layer in the application to display
geographical data. This means they are informed about any changes
of the projection (zoom in, out, move, etc.) and have to react
accordingly. Usually this reaction is to recalculate the data
(calculate the screen coordinates from the geographical (WGS84)
coordinates). This task is done by using the
forward(...) methods of the projection passed in the
projectionChanged() method. This calculation should be
done in a separate task, so the JComponent.paintComponent(java.awt.Graphics)>JComponent.paintComponent(java.awt.Graphics) 55 method
terminates as fast as possible. Use a org.dinopolis.util.gui.SwingWorker for this purpose.
This
abstract layer helps any extending classes with the handling of the
background thread. The programmer needs only to implement the
doCalculation() 55 method and to paint the calculated objects
in the JComponent.paintComponent(java.awt.Graphics)>JComponent.paintComponent(java.awt.Graphics) 55 method.
- Version:
- $Revision: 1.3 $
|
Method Summary |
protected abstract void |
doCalculation()
This method is called from a background thread to recalulate the
screen coordinates of any geographical objects. |
boolean |
isActive()
Returns if the layer is active or not. |
void |
paintComponent(java.awt.Graphics g)
Paints the objects for this layer. |
void |
projectionChanged(ProjectionEvent event)
Handler for ProjectionEvents. |
protected void |
recalculateCoordinates()
This method is called whenever the projection changed or the layer
was activated. |
void |
setActive(boolean active)
Called by the application to switch the layer on or off. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
swing_worker_
protected org.dinopolis.util.gui.SwingWorker swing_worker_
layer_active_
protected boolean layer_active_
BasicLayer
public BasicLayer()
doCalculation
protected abstract void doCalculation()
- This method is called from a background thread to recalulate the
screen coordinates of any geographical objects. This method must
store its objects and paint them in the paintComponent() method.
recalculateCoordinates
protected void recalculateCoordinates()
- This method is called whenever the projection changed or the layer
was activated. It starts a SwingWorker and calls the
doCalculation() 55 method in another thread. After this method
finished, a repaint() is initiated.
paintComponent
public void paintComponent(java.awt.Graphics g)
- Paints the objects for this layer.
setActive
public void setActive(boolean active)
- Called by the application to switch the layer on or off. If the
layer is switched off, it must not paint anything and should not
consume any calculational power.
isActive
public boolean isActive()
- Returns if the layer is active or not.
projectionChanged
public void projectionChanged(ProjectionEvent event)
- Handler for
ProjectionEvents. This function is
invoked when the MapBean projection changes. The
graphics are reprojected and then the Layer is repainted.