|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectLabelCacheImpl
public final class LabelCacheImpl
Default LabelCache Implementation.
The label cache sports a number of features that are enabled depending on the programmatic configuration and the TextSymbolizer options.
The basic functionalitty of the label cache consist in finding the
best label position for each Feature according to the TextSymbolizer
specifications, and drawing it, provided it does not overlap with other labels.
This basic behaviour can be customized in a number of ways.
TextSymbolizer.getPriority()
OGC Expression controls a label priority.
A label with high priority will be drawn before others, increasing its likeliness to appear on the screen
Nested Class Summary | |
---|---|
static class |
LabelCacheImpl.LabelRenderingMode
|
Field Summary | |
---|---|
double |
DEFAULT_PRIORITY
|
protected Map<LabelCacheItem,LabelCacheItem> |
groupedLabelsLookup
Used to locate grouped labels quickly |
protected ArrayList<LabelCacheItem> |
labelCache
labels get thrown in here, in insertion order |
protected LabelCacheImpl.LabelRenderingMode |
labelRenderingMode
|
static double |
MIN_CURVED_DELTA
The angle delta at which we switch from curved rendering to straight rendering |
protected SLDStyleFactory |
styleFactory
|
Constructor Summary | |
---|---|
LabelCacheImpl()
|
Method Summary | |
---|---|
void |
clear()
Clears the cache completely |
void |
clear(String layerId)
Clears the cache of all information relating to the layer identified. |
MultiLineString |
clipLineString(LineString line)
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)
try to do a more robust way of clipping a polygon to a bounding box. |
void |
disableLayer(String layerId)
Leaves the label information in the cache but ignores it when calculating what labels are drawn. |
void |
enableLayer(String layerId)
Enable a layer after being disabled. |
void |
end(Graphics2D graphics,
Rectangle displayArea)
Called to indicate that the map is done rendering. |
void |
endLayer(String layerId,
Graphics2D graphics,
Rectangle displayArea)
Called to indicate that a layer is done rendering. |
List<LabelCacheItem> |
getActiveLabels()
Returns a list of all active labels |
LabelCacheImpl.LabelRenderingMode |
getLabelRenderingMode()
|
double |
getPriority(TextSymbolizer symbolizer,
Feature feature)
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 |
List<LabelCacheItem> |
orderedLabels()
Return a list with all the values in priority order. |
List<LineString> |
processNodes(List<LineString> edges,
Map<Coordinate,List<LineString>> nodes)
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)
Reserve the provided geometry prior to sorting out where labels can go. |
void |
put(String layerId,
TextSymbolizer symbolizer,
Feature feature,
LiteShape2 shape,
NumberRange scaleRange)
Puts a Label in the cache. |
void |
removeFromHash(Map<Coordinate,List<LineString>> nodes,
LineString ls)
|
void |
setLabelRenderingMode(LabelCacheImpl.LabelRenderingMode mode)
Sets the text rendering mode. |
void |
start()
Called by renderer to indicate that the rendering process is starting. |
void |
startLayer(String layerId)
Called by renderer to indication the start of rendering a layer. |
void |
stop()
Tells the cache to stop labelling. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public double DEFAULT_PRIORITY
public static double MIN_CURVED_DELTA
protected Map<LabelCacheItem,LabelCacheItem> groupedLabelsLookup
protected ArrayList<LabelCacheItem> labelCache
protected LabelCacheImpl.LabelRenderingMode labelRenderingMode
protected SLDStyleFactory styleFactory
Constructor Detail |
---|
public LabelCacheImpl()
Method Detail |
---|
public void enableLayer(String layerId)
LabelCache
enableLayer
in interface LabelCache
layerId
- layer to activate.public LabelCacheImpl.LabelRenderingMode getLabelRenderingMode()
public void setLabelRenderingMode(LabelCacheImpl.LabelRenderingMode mode)
public void stop()
LabelCache
stop
in interface LabelCache
public void start()
LabelCache
start
in interface LabelCache
LabelCache.start()
public void clear()
LabelCache
clear
in interface LabelCache
public void clear(String layerId)
LabelCache
clear
in interface LabelCache
layerId
- id of the layerpublic void disableLayer(String layerId)
LabelCache
disableLayer
in interface LabelCache
layerId
- id of the layer to disable.public void startLayer(String layerId)
LabelCache
startLayer
in interface LabelCache
layerId
- an id for the layerorg.geotools.renderer.lite.LabelCache#startLayer()
public double getPriority(TextSymbolizer symbolizer, Feature feature)
symbolizer
- feature
- public void put(String layerId, TextSymbolizer symbolizer, Feature feature, LiteShape2 shape, NumberRange scaleRange)
LabelCache
put
in interface LabelCache
layerId
- id indicating the layer the feature is part ofsymbolizer
- The symbolizer containing the style informationfeature
- 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 legalorg.geotools.renderer.lite.LabelCache#put(org.geotools.renderer.style.TextStyle2D,
org.geotools.renderer.lite.LiteShape)
public void put(Rectangle2D area)
LabelCache
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...
put
in interface LabelCache
public void endLayer(String layerId, Graphics2D graphics, Rectangle displayArea)
LabelCache
endLayer
in interface LabelCache
layerId
- an id for the layergraphics
- the graphics to draw on.displayArea
- The size of the display areaorg.geotools.renderer.lite.LabelCache#endLayer(java.awt.Graphics2D,
java.awt.Rectangle)
public List<LabelCacheItem> orderedLabels()
orderedLabels
in interface LabelCache
public List<LabelCacheItem> getActiveLabels()
public void end(Graphics2D graphics, Rectangle displayArea)
LabelCache
end
in interface LabelCache
graphics
- the graphics to draw on.displayArea
- The size of the display area.LabelCache.end(java.awt.Graphics2D,
java.awt.Rectangle)
public MultiLineString clipLineString(LineString line)
line
- bbox
- MUST BE A BOUNDING BOXpublic MultiPolygon clipPolygon(Polygon poly, Polygon bbox, Envelope displayGeomEnv)
poly
- bbox
- displayGeomEnv
-
public List<LineString> processNodes(List<LineString> edges, Map<Coordinate,List<LineString>> nodes)
edges
- nodes
- result
- public void removeFromHash(Map<Coordinate,List<LineString>> nodes, LineString ls)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |