org.geotools.renderer.j2d
Class RenderedMapScale

java.lang.Object
  extended byorg.geotools.renderer.j2d.RenderedLayer
      extended byorg.geotools.renderer.j2d.RenderedLegend
          extended byorg.geotools.renderer.j2d.RenderedMapScale

public class RenderedMapScale
extends RenderedLegend

A map scale in linear units (for example kilometres) to be painted over others layers. The map scale can be draw on top of projected or geographic coordinate system. Note that because of deformations related to the projection of a curved surface on a flat screen, the map scale is not valid everywhere in the widget area. More specifically:

Version:
$Id: RenderedMapScale.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class org.geotools.renderer.j2d.RenderedLayer
listeners
 
Constructor Summary
RenderedMapScale()
          Construct a new map scale located in the lower left corner.
 
Method Summary
 java.awt.Paint getBackground()
          Gets the background color.
 boolean getForceGeodesic()
          Tells if the map scale should use orthodromic distance computation even for projected coordinate system.
 java.awt.Paint getForeground()
          Gets the foreground color.
 int getMaximumLength()
          Returns the maximum length of map scale in pixels.
 java.lang.String getName(java.util.Locale locale)
          Returns this layer's name.
 int getThickness()
          Returns the map scale thickness.
protected  java.lang.String getTitle(CoordinateSystem cs)
          Returns the title to paint with the map scale.
protected  java.lang.String getToolTipText(GeoMouseEvent event)
          Returns the map scale as a tool tip text.
 Unit getUnits()
          Returns the map scale units.
protected  void paint(RenderingContext context)
          Draw the map scale.
 void setBackground(java.awt.Paint background)
          Sets the background color.
 void setForceGeodesic(boolean forceGeodesic)
          Tells if the map scale should use orthodromic distance computation even for projected coordinate system.
 void setForeground(java.awt.Paint foreground)
          Sets the foreground color.
 void setMaximumLength(int maximumLength)
          Set the maximum length of map scale in pixels.
 void setThickness(int thickness)
          Sets the map scale thickness.
 void setUnits(Unit units)
          Set the map scale units.
 
Methods inherited from class org.geotools.renderer.j2d.RenderedLegend
getInsets, getMargin, getPosition, getText, setInsets, setMargin, setPosition, setText
 
Methods inherited from class org.geotools.renderer.j2d.RenderedLayer
addPropertyChangeListener, addPropertyChangeListener, dispose, getAction, getCoordinateSystem, getLocale, getPreferredArea, getPreferredPixelSize, getRenderer, getTreeLock, getZOrder, isVisible, prefetch, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, setCoordinateSystem, setPreferredArea, setPreferredPixelSize, setVisible, setZOrder, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenderedMapScale

public RenderedMapScale()
Construct a new map scale located in the lower left corner. The scale position can be changed with RenderedLegend.setPosition(org.geotools.renderer.j2d.LegendPosition) and RenderedLegend.setMargin(java.awt.Insets).

Method Detail

getName

public java.lang.String getName(java.util.Locale locale)
Returns this layer's name. The default implementation returns the scale factor.

Overrides:
getName in class RenderedLayer
Parameters:
locale - The desired locale, or null for a default locale.
Returns:
This layer's name.
See Also:
RenderedLayer.getLocale(), Renderer.getName(java.util.Locale)

getForceGeodesic

public boolean getForceGeodesic()
Tells if the map scale should use orthodromic distance computation even for projected coordinate system. Default value is false.


setForceGeodesic

public void setForceGeodesic(boolean forceGeodesic)
Tells if the map scale should use orthodromic distance computation even for projected coordinate system. This method has no effect if the rendering coordinate system is geographic.


getUnits

public Unit getUnits()
Returns the map scale units. This is the units to be used for displaying numbers on the map scale. The conversion from rendering units is automatically performed at rendering time. Default map scale units are kilometres.

Returns:
The map scale units (default to kilometres).

setUnits

public void setUnits(Unit units)
              throws UnitException
Set the map scale units. This unit must be linear, even if the rendering coordinate system is geographic. Conversion from angular to linear unit will be performed at rendering time through orthodromic distance computation.

Parameters:
units - New map scale units. Must not be null.
Throws:
UnitException - if units is not compatible with the map scale.

getMaximumLength

public int getMaximumLength()
Returns the maximum length of map scale in pixels. The actual length may be smaller, since RenderedMapScale will try to round the logical length (e.g. in order to format round labels in kilometres). The logical length is zoom dependent and will be computed at rendering time from the length in pixels.

Returns:
The maximum length for the map scale, in pixels (or dots).

setMaximumLength

public void setMaximumLength(int maximumLength)
Set the maximum length of map scale in pixels.

Parameters:
maximumLength - The maximum length for the map scale, in pixels (or dots).

getThickness

public int getThickness()
Returns the map scale thickness. This is the height of rectangles making horizontal map scale. This thickness do not depends on the scale value.

Returns:
The map scale thickness, in dots.

setThickness

public void setThickness(int thickness)
Sets the map scale thickness. This is the height of rectangles making horizontal map scale. This thickness do not depends on the scale value.

Parameters:
thickness - The new map scale thickness, in dots.

getBackground

public java.awt.Paint getBackground()
Gets the background color.

Returns:
The background color, or null for a completly transparent background.

setBackground

public void setBackground(java.awt.Paint background)
Sets the background color.

Parameters:
background - The new background color, or null for a completly transparent background.

getForeground

public java.awt.Paint getForeground()
Gets the foreground color.

Returns:
The foreground color.

setForeground

public void setForeground(java.awt.Paint foreground)
Sets the foreground color.

Parameters:
foreground - The new foreground color.

getTitle

protected java.lang.String getTitle(CoordinateSystem cs)
Returns the title to paint with the map scale. Default implementation returns the name of the supplied coordinate system.

Parameters:
cs - The rendering coordinate system, or null.
Returns:
The title for the map scale, or null if none.

paint

protected void paint(RenderingContext context)
              throws org.opengis.referencing.operation.TransformException
Draw the map scale. This map scale is build from some amount of rectangle drawn side by side vertically or horizontally. Each rectangle is for a distance like 100 meters or 1 kilometer, depending the current map scale (from the zoom).

Overrides:
paint in class RenderedLegend
Parameters:
context - Information relatives to the rendering context.
Throws:
org.opengis.referencing.operation.TransformException - If a coordinate transformation failed during the rendering process.

getToolTipText

protected java.lang.String getToolTipText(GeoMouseEvent event)
Returns the map scale as a tool tip text.

Overrides:
getToolTipText in class RenderedLayer
Parameters:
event - Coordonn?es du curseur de la souris.
Returns:
Le texte ? afficher lorsque la souris tra?ne sur la couche. Ce texte peut ?tre nul pour signifier qu'il ne faut rien ?crire.
See Also:
Renderer.getToolTipText(org.geotools.renderer.j2d.GeoMouseEvent)


Copyright © GeoTools. All Rights Reserved.