org.geotools.renderer.lite
Class LabelCacheDefault

Object
  extended by LabelCacheDefault
All Implemented Interfaces:
LabelCache

Deprecated. Use LabelCacheImpl instead

public final class LabelCacheDefault
extends Object
implements LabelCache

Default LabelCache Implementation DJB (major changes on May 11th, 2005): 1.The old version of the labeler, if given a *set* of points, lines, or polygons justed labels the first item in the set. The sets are formed when you want to only put a single "Main St" on the map even if you have a bunch of small "Main St" segments. I changed this to be much much wiser. Basically, the new way looks at the set of geometries that its going to put a label on and find the "best" one that represents it. That geometry is then labeled (see below for details on where that label is placed). 2. I changed the actual drawing routines; 1. get the "representative geometry" 2. for points, label as before 3. for lines, find the middle point on the line (old version just averaged start and end points) and centre label on that point (rotated) 4. for polygon, put the label in the middle 3. ie. for lines, try the label at the 1/3, 1/2, and 2/3 location. Metric is how close the label bounding box is to the line. ie. for polygons, bisect the polygon (about the centroid) in to North, South, East and West polygons. Use the location that has the label best inside the polygon. After this is done, you can start doing constraint relaxation... 4. TODO: deal with labels going off the edge of the screen (much reduced now). 5. TODO: add a "minimum quality" parameter (ie. if you're labeling a tiny polygon with a tiny label, dont bother). Metrics are descibed in #3. 6. TODO: add ability for SLD to tweak parameters (ie. "always label"). ------------------------------------------------------------------------------------------ I've added extra functionality; a) priority -- if you set the in a TextSymbolizer, then you can control the order of labelling ** see mailing list for more details b) no --- turns off grouping for this symbolizer c) 5 -- do not put labels within 5 pixels of this label.

Author:
jeichar, dblasby
Module:
modules/library/render (gt-render.jar)

Field Summary
 boolean DEFAULT_GROUP
          Deprecated.  
 double DEFAULT_PRIORITY
          Deprecated.  
 int DEFAULT_SPACEAROUND
          Deprecated.  
protected  Map<String,LabelCacheItem> labelCache
          Deprecated. Map the label cache
protected  ArrayList<LabelCacheItem> labelCacheNonGrouped
          Deprecated. non-grouped labels get thrown in here*
 double MIN_GOODNESS_FIT
          Deprecated. labels that arent this good will not be shown
protected  boolean outlineRenderingEnabled
          Deprecated. When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector.
protected  List<Rectangle2D> reserved
          Deprecated. List of screen areas that we should not place labels in
protected  SLDStyleFactory styleFactory
          Deprecated.  
 
Constructor Summary
LabelCacheDefault()
          Deprecated.  
 
Method Summary
 void clear()
          Deprecated. Clears the cache completely
 void clear(String layerId)
          Deprecated. Clears the cache of all information relating to the layer identified.
 MultiLineString clipLineString(LineString line, Polygon bbox, Envelope displayGeomEnv)
          Deprecated. try to be more robust dont bother returning points This will try to solve robustness problems, but read code as to what it does.
 MultiPolygon clipPolygon(Polygon poly, Polygon bbox, Envelope displayGeomEnv)
          Deprecated. try to do a more robust way of clipping a polygon to a bounding box.
 void disableLayer(String layerId)
          Deprecated. Leaves the label information in the cache but ignores it when calculating what labels are drawn.
 void enableLayer(String layerId)
          Deprecated. Enable a layer after being disabled.
 void end(Graphics2D graphics, Rectangle displayArea)
          Deprecated. Called to indicate that the map is done rendering.
 void endLayer(String layerId, Graphics2D graphics, Rectangle displayArea)
          Deprecated. Called to indicate that a layer is done rendering.
 LineString getLongest(ArrayList<LineString> al)
          Deprecated.  
 double getPriority(TextSymbolizer symbolizer, SimpleFeature feature)
          Deprecated. get the priority from the symbolizer its an expression, so it will try to evaluate it: 1. if its missing --> DEFAULT_PRIORITY 2. if its a number, return that number 3. if its not a number, convert to string and try to parse the number; return the number 4. otherwise, return DEFAULT_PRIORITY
 boolean isOutlineRenderingEnabled()
          Deprecated.  
 List<LabelCacheItem> orderedLabels()
          Deprecated. return a list with all the values in priority order.
 void processNodes(List<LineString> edges, Hashtable<Coordinate,ArrayList<LineString>> nodes, ArrayList<LineString> result)
          Deprecated. pull a line from the list, and: 1. if nothing connects to it (its issolated), add it to "result" 2. otherwise, merge it at the start/end with the LONGEST line there. 3. remove the original line, and the lines it merged with from the hashtables 4. go again, with the merged line
 void put(Rectangle2D area)
          Deprecated. Reserve the provided geometry prior to sorting out where labels can go.
 void put(String layerId, TextSymbolizer symbolizer, SimpleFeature feature, LiteShape2 shape, NumberRange<Double> scaleRange)
          Deprecated. Puts a Label in the cache.
 void putInNodeHash(LineString ls, Hashtable<Coordinate,ArrayList<LineString>> nodes)
          Deprecated.  
 void removeFromHash(Hashtable<Coordinate,ArrayList<LineString>> nodes, LineString ls)
          Deprecated.  
 void setOutlineRenderingEnabled(boolean outlineRenderingEnabled)
          Deprecated. Sets the text rendering mode.
 void start()
          Deprecated. Called by renderer to indicate that the rendering process is starting.
 void startLayer(String layerId)
          Deprecated. Called by renderer to indication the start of rendering a layer.
 void stop()
          Deprecated. Tells the cache to stop labelling.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_GOODNESS_FIT

public double MIN_GOODNESS_FIT
Deprecated. 
labels that arent this good will not be shown


DEFAULT_PRIORITY

public double DEFAULT_PRIORITY
Deprecated. 

reserved

protected List<Rectangle2D> reserved
Deprecated. 
List of screen areas that we should not place labels in


labelCache

protected Map<String,LabelCacheItem> labelCache
Deprecated. 
Map the label cache


labelCacheNonGrouped

protected ArrayList<LabelCacheItem> labelCacheNonGrouped
Deprecated. 
non-grouped labels get thrown in here*


DEFAULT_GROUP

public boolean DEFAULT_GROUP
Deprecated. 

DEFAULT_SPACEAROUND

public int DEFAULT_SPACEAROUND
Deprecated. 

outlineRenderingEnabled

protected boolean outlineRenderingEnabled
Deprecated. 
When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector. Pro: labels and halos are perfectly centered, some people prefer the extra antialiasing obtained. Cons: possibly slower, some people do not like the extra antialiasing :)


styleFactory

protected SLDStyleFactory styleFactory
Deprecated. 
Constructor Detail

LabelCacheDefault

public LabelCacheDefault()
Deprecated. 
Method Detail

stop

public void stop()
Deprecated. 
Description copied from interface: LabelCache
Tells the cache to stop labelling.

Specified by:
stop in interface LabelCache

start

public void start()
Deprecated. 
Description copied from interface: LabelCache
Called by renderer to indicate that the rendering process is starting.

Specified by:
start in interface LabelCache
See Also:
LabelCache.start()

clear

public void clear()
Deprecated. 
Description copied from interface: LabelCache
Clears the cache completely

Specified by:
clear in interface LabelCache

clear

public void clear(String layerId)
Deprecated. 
Description copied from interface: LabelCache
Clears the cache of all information relating to the layer identified.

Specified by:
clear in interface LabelCache
Parameters:
layerId - id of the layer

disableLayer

public void disableLayer(String layerId)
Deprecated. 
Description copied from interface: LabelCache
Leaves the label information in the cache but ignores it when calculating what labels are drawn.

Specified by:
disableLayer in interface LabelCache
Parameters:
layerId - id of the layer to disable.

startLayer

public void startLayer(String layerId)
Deprecated. 
Description copied from interface: LabelCache
Called by renderer to indication the start of rendering a layer. Will add the layer to the set of active layers.

Specified by:
startLayer in interface LabelCache
Parameters:
layerId - an id for the layer
See Also:
org.geotools.renderer.lite.LabelCache#startLayer()

getPriority

public double getPriority(TextSymbolizer symbolizer,
                          SimpleFeature feature)
Deprecated. 
get the priority from the symbolizer its an expression, so it will try to evaluate it: 1. if its missing --> DEFAULT_PRIORITY 2. if its a number, return that number 3. if its not a number, convert to string and try to parse the number; return the number 4. otherwise, return DEFAULT_PRIORITY

Parameters:
symbolizer -
feature -

put

public void put(Rectangle2D area)
Deprecated. 
Description copied from interface: LabelCache
Reserve the provided geometry prior to sorting out where labels can go.

This facility is used to reserve an area so that labels do not end up overlapping on screen constructs like scalebars or north arrows etc...

Specified by:
put in interface LabelCache

put

public void put(String layerId,
                TextSymbolizer symbolizer,
                SimpleFeature feature,
                LiteShape2 shape,
                NumberRange<Double> scaleRange)
Deprecated. 
Description copied from interface: LabelCache
Puts a Label in the cache.

Specified by:
put in interface LabelCache
Parameters:
layerId - id indicating the layer the feature is part of
symbolizer - The symbolizer containing the style information
feature - the feature that has the information required for the symbolizer to calculate the required render information.
shape - the shape to be labeled. This is in screen coordinates.
scaleRange - the scaleRange that the symbolizer is legal
See Also:
org.geotools.renderer.lite.LabelCache#put(org.geotools.renderer.style.TextStyle2D, org.geotools.renderer.lite.LiteShape)

endLayer

public void endLayer(String layerId,
                     Graphics2D graphics,
                     Rectangle displayArea)
Deprecated. 
Description copied from interface: LabelCache
Called to indicate that a layer is done rendering. The method may draw labels if appropriate for the labeling algorithm

Specified by:
endLayer in interface LabelCache
Parameters:
layerId - an id for the layer
graphics - the graphics to draw on.
displayArea - The size of the display area
See Also:
org.geotools.renderer.lite.LabelCache#endLayer(java.awt.Graphics2D, java.awt.Rectangle)

orderedLabels

public List<LabelCacheItem> orderedLabels()
Deprecated. 
return a list with all the values in priority order. Both grouped and non-grouped

Specified by:
orderedLabels in interface LabelCache
Returns:
list with all values in priority order

end

public void end(Graphics2D graphics,
                Rectangle displayArea)
Deprecated. 
Description copied from interface: LabelCache
Called to indicate that the map is done rendering. The method may draw labels if appropriate for the labeling algorithm

Specified by:
end in interface LabelCache
Parameters:
graphics - the graphics to draw on.
displayArea - The size of the display area.
See Also:
LabelCache.end(java.awt.Graphics2D, java.awt.Rectangle)

clipLineString

public MultiLineString clipLineString(LineString line,
                                      Polygon bbox,
                                      Envelope displayGeomEnv)
Deprecated. 
try to be more robust dont bother returning points This will try to solve robustness problems, but read code as to what it does. It might return the unclipped line if there's a problem!

Parameters:
line -
bbox - MUST BE A BOUNDING BOX

clipPolygon

public MultiPolygon clipPolygon(Polygon poly,
                                Polygon bbox,
                                Envelope displayGeomEnv)
Deprecated. 
try to do a more robust way of clipping a polygon to a bounding box. This might return the orginal polygon if it cannot clip TODO: this is a bit simplistic, there's lots more to do.

Parameters:
poly -
bbox -
displayGeomEnv -
Returns:
a MutliPolygon

processNodes

public void processNodes(List<LineString> edges,
                         Hashtable<Coordinate,ArrayList<LineString>> nodes,
                         ArrayList<LineString> result)
Deprecated. 
pull a line from the list, and: 1. if nothing connects to it (its issolated), add it to "result" 2. otherwise, merge it at the start/end with the LONGEST line there. 3. remove the original line, and the lines it merged with from the hashtables 4. go again, with the merged line

Parameters:
edges -
nodes -
result -

removeFromHash

public void removeFromHash(Hashtable<Coordinate,ArrayList<LineString>> nodes,
                           LineString ls)
Deprecated. 

getLongest

public LineString getLongest(ArrayList<LineString> al)
Deprecated. 

putInNodeHash

public void putInNodeHash(LineString ls,
                          Hashtable<Coordinate,ArrayList<LineString>> nodes)
Deprecated. 

enableLayer

public void enableLayer(String layerId)
Deprecated. 
Description copied from interface: LabelCache
Enable a layer after being disabled. If startLayer is called this does not need to be called as start layer implicitely activates the layer.

Specified by:
enableLayer in interface LabelCache
Parameters:
layerId - layer to activate.

isOutlineRenderingEnabled

public boolean isOutlineRenderingEnabled()
Deprecated. 

setOutlineRenderingEnabled

public void setOutlineRenderingEnabled(boolean outlineRenderingEnabled)
Deprecated. 
Sets the text rendering mode. When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector. Pro: labels and halos are perfectly centered, some people prefer the extra antialiasing obtained. Cons: possibly slower, some people do not like the extra antialiasing :)



Copyright © 1996-2009 Geotools. All Rights Reserved.