org.geotools.gui.swing.map.map2d.stream.strategy
Class AbstractRenderingStrategy

Object
  extended by AbstractRenderingStrategy
All Implemented Interfaces:
EventListener, StreamingStrategy, MapLayerListListener
Direct Known Subclasses:
MergeBufferedImageStrategy, SingleBufferedImageStrategy, SingleVolatileImageStrategy

public abstract class AbstractRenderingStrategy
extends Object
implements StreamingStrategy, MapLayerListListener

Abstract rendering strategy

Author:
Johann Sorel

Field Summary
protected  AffineTransform affineTransform
           
protected  MapContext context
           
protected  Envelope mapArea
           
 
Constructor Summary
AbstractRenderingStrategy()
          create a default AbstractStrategy
 
Method Summary
 void addStrategyListener(StrategyListener listener)
          add a StrategyListener
protected  boolean checkAspect()
           
abstract  BufferedImage createBufferImage(MapContext context)
           
abstract  BufferedImage createBufferImage(MapLayer layer)
           
 void dispose()
          must be call to remove all reference on the renderingstrategy.
protected  void fireMapAreaChanged(Envelope oldone, Envelope newone)
           
protected  void fireMapContextChanged(MapContext oldcontext, MapContext newContext)
           
protected  void fit()
           
protected  Envelope fixAspectRatio(Rectangle rect, Envelope area)
           
 AffineTransform getAffineTransform()
          get the actual affinetransfrom
 JComponent getComponent()
          get the visual component
 MapContext getContext()
          get the MapContext
 Envelope getMapArea()
          get the maparea to look at
abstract  BufferedImage getSnapShot()
          create a bufferedImage of what is actually visible on the map widget
 StrategyListener[] getStrategyListeners()
          get an array of StrategyListener
protected abstract  JComponent init()
           
 boolean isAutoRefresh()
          to see if the strategy is in auto refresh mode
 boolean isPainting()
          true if the strategy is currently painting
protected  boolean isValidEnvelope(Envelope env)
           
abstract  void layerAdded(MapLayerListEvent event)
          Triggered when a new layer is added to the MapContext
abstract  void layerChanged(MapLayerListEvent event)
          Triggered when something in a layer changed (data, style, title)
abstract  void layerMoved(MapLayerListEvent event)
          Triggered when a group of layers chenges position in the layer list
abstract  void layerRemoved(MapLayerListEvent event)
          Triggered when a layer is removed from the MapContext
abstract  void refresh()
          use for a complete reset of the strategy
 void removeStrategyListener(StrategyListener listener)
          remove a StrategyListener
 void setAffineTransform(AffineTransform affineTransform)
          set affinetransform
 void setAutoRefreshEnabled(boolean ref)
          to enable automatic refreshing of the map, if not you must call manualy the refresh method
 void setContext(MapContext newContext)
          set the MapContext
 void setMapArea(Envelope area)
          set the maparea to look at
protected  void setPainting(boolean b)
           
protected  void testRefresh()
           
 Point toComponentCoord(Coordinate coord)
          transform a JTS Coordinate in an pixel x/y coordinate
 Coordinate toMapCoord(int mx, int my)
          transform a mouse coordinate in JTS Coordinate using the CRS of the mapcontext
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected MapContext context

mapArea

protected Envelope mapArea

affineTransform

protected AffineTransform affineTransform
Constructor Detail

AbstractRenderingStrategy

public AbstractRenderingStrategy()
create a default AbstractStrategy

Method Detail

init

protected abstract JComponent init()

fixAspectRatio

protected Envelope fixAspectRatio(Rectangle rect,
                                  Envelope area)

fit

protected void fit()

testRefresh

protected void testRefresh()

checkAspect

protected boolean checkAspect()

isValidEnvelope

protected boolean isValidEnvelope(Envelope env)

setPainting

protected void setPainting(boolean b)

fireMapAreaChanged

protected void fireMapAreaChanged(Envelope oldone,
                                  Envelope newone)

fireMapContextChanged

protected void fireMapContextChanged(MapContext oldcontext,
                                     MapContext newContext)

toMapCoord

public Coordinate toMapCoord(int mx,
                             int my)
Description copied from interface: StreamingStrategy
transform a mouse coordinate in JTS Coordinate using the CRS of the mapcontext

Specified by:
toMapCoord in interface StreamingStrategy
Parameters:
mx - : x coordinate of the mouse on the map (in pixel)
my - : y coordinate of the mouse on the map (in pixel)
Returns:
JTS Coordinate

toComponentCoord

public Point toComponentCoord(Coordinate coord)
Description copied from interface: StreamingStrategy
transform a JTS Coordinate in an pixel x/y coordinate

Specified by:
toComponentCoord in interface StreamingStrategy
Returns:
Java2D Point

createBufferImage

public abstract BufferedImage createBufferImage(MapLayer layer)

createBufferImage

public abstract BufferedImage createBufferImage(MapContext context)

getSnapShot

public abstract BufferedImage getSnapShot()
Description copied from interface: StreamingStrategy
create a bufferedImage of what is actually visible on the map widget

Specified by:
getSnapShot in interface StreamingStrategy
Returns:
BufferedImage

refresh

public abstract void refresh()
Description copied from interface: StreamingStrategy
use for a complete reset of the strategy

Specified by:
refresh in interface StreamingStrategy

getComponent

public final JComponent getComponent()
Description copied from interface: StreamingStrategy
get the visual component

Specified by:
getComponent in interface StreamingStrategy
Returns:
Component

setContext

public final void setContext(MapContext newContext)
Description copied from interface: StreamingStrategy
set the MapContext

Specified by:
setContext in interface StreamingStrategy
Parameters:
newContext - : can not be null

getContext

public final MapContext getContext()
Description copied from interface: StreamingStrategy
get the MapContext

Specified by:
getContext in interface StreamingStrategy
Returns:
MapContext or null if no mapContext

setMapArea

public final void setMapArea(Envelope area)
Description copied from interface: StreamingStrategy
set the maparea to look at

Specified by:
setMapArea in interface StreamingStrategy
Parameters:
area - : can not be null

getMapArea

public final Envelope getMapArea()
Description copied from interface: StreamingStrategy
get the maparea to look at

Specified by:
getMapArea in interface StreamingStrategy
Returns:
Envelope or null if no MapArea

addStrategyListener

public final void addStrategyListener(StrategyListener listener)
Description copied from interface: StreamingStrategy
add a StrategyListener

Specified by:
addStrategyListener in interface StreamingStrategy
Parameters:
listener - : StrategyListener to add

removeStrategyListener

public final void removeStrategyListener(StrategyListener listener)
Description copied from interface: StreamingStrategy
remove a StrategyListener

Specified by:
removeStrategyListener in interface StreamingStrategy
Parameters:
listener - : StrategyListener to remove

getStrategyListeners

public final StrategyListener[] getStrategyListeners()
Description copied from interface: StreamingStrategy
get an array of StrategyListener

Specified by:
getStrategyListeners in interface StreamingStrategy
Returns:
array of StrategyListener

setAutoRefreshEnabled

public final void setAutoRefreshEnabled(boolean ref)
Description copied from interface: StreamingStrategy
to enable automatic refreshing of the map, if not you must call manualy the refresh method

Specified by:
setAutoRefreshEnabled in interface StreamingStrategy

isAutoRefresh

public final boolean isAutoRefresh()
Description copied from interface: StreamingStrategy
to see if the strategy is in auto refresh mode

Specified by:
isAutoRefresh in interface StreamingStrategy
Returns:
boolean

isPainting

public final boolean isPainting()
Description copied from interface: StreamingStrategy
true if the strategy is currently painting

Specified by:
isPainting in interface StreamingStrategy
Returns:
boolean

dispose

public void dispose()
Description copied from interface: StreamingStrategy
must be call to remove all reference on the renderingstrategy. to avoid memory leack.

Specified by:
dispose in interface StreamingStrategy

layerAdded

public abstract void layerAdded(MapLayerListEvent event)
Description copied from interface: MapLayerListListener
Triggered when a new layer is added to the MapContext

Specified by:
layerAdded in interface MapLayerListListener
Parameters:
event - encapsulating the event information

layerRemoved

public abstract void layerRemoved(MapLayerListEvent event)
Description copied from interface: MapLayerListListener
Triggered when a layer is removed from the MapContext

Specified by:
layerRemoved in interface MapLayerListListener
Parameters:
event - encapsulating the event information

layerChanged

public abstract void layerChanged(MapLayerListEvent event)
Description copied from interface: MapLayerListListener
Triggered when something in a layer changed (data, style, title)

Specified by:
layerChanged in interface MapLayerListListener
Parameters:
event - encapsulating the event information

layerMoved

public abstract void layerMoved(MapLayerListEvent event)
Description copied from interface: MapLayerListListener
Triggered when a group of layers chenges position in the layer list

Specified by:
layerMoved in interface MapLayerListListener
Parameters:
event - encapsulating the event information

getAffineTransform

public AffineTransform getAffineTransform()
Description copied from interface: StreamingStrategy
get the actual affinetransfrom

Specified by:
getAffineTransform in interface StreamingStrategy
Returns:
AffineTransform

setAffineTransform

public void setAffineTransform(AffineTransform affineTransform)
Description copied from interface: StreamingStrategy
set affinetransform

Specified by:
setAffineTransform in interface StreamingStrategy


Copyright © 1996-2009 Geotools. All Rights Reserved.