|
||||||||||
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
TextSymbolizer.getOptions()
contains a map of vendor specific options
other than priority which are not part of the SLD specification. Here is a list
of their names, default values, and meaning:
spaceAround
(0): the minimum distance between two labels, in pixelsgroup
(false): if true, geometries with the same labels are grouped and
considered a single entity to be labeled. This allows to avoid or control repeated labelslabelAllGroup
(false): when false, in a group only the biggest geometry is labelled
(the biggest is obtained by merging, when possible, the original geometries). When true, also the
smaller items in the group are labelled. Works only on lines at the momentmaxDisplacement
(50): the distance, in pixel, a label can be displaced
from its natural position in an attempt to find a position that does not conflict with
already drawn labels. At the moment this works only on linesrepeat
(0): when positive it's the desired distance between two subsequent labels
on a "big" geometry. Works only on lines atm, if zero only one label is drawn no matter how big
the geometry isminGroupDistance
(0): minimum distance between two labels in the same label group.
To be used when both displacement and repeat are used to avoid having two labels too close to
each otherallowOvveruns
(true): when false does not allow labels on lines to get beyond the
beginning/end of the line. By default a partial overrun is tolerated, set to false to disallow it.followLine
(false): when true activates curved labels on linear geometries. The label
will follow the shape of the current line, as opposed to being drawn a tangent straight linemaxAngleDelta
(22.5): when drawing curved labels, max allowed angle between
two subsequent characters. Higher angles may cause disconnected words or overlapping charactersautoWrap
(false): number of pixels are which a long label should be split into
multiple lines. Works on all geometries, on lines it is mutually exclusive with the
followLine option.
Field Summary | |
---|---|
boolean |
DEFAULT_ALLOW_OVERRUNS
|
boolean |
DEFAULT_FOLLOW_LINE
|
boolean |
DEFAULT_GROUP
|
boolean |
DEFAULT_LABEL_ALL_GROUP
|
int |
DEFAULT_LABEL_REPEAT
|
double |
DEFAULT_MAX_ANGLE_DELTA
|
int |
DEFAULT_MAX_DISPLACEMENT
|
int |
DEFAULT_MIN_GROUP_DISTANCE
|
double |
DEFAULT_PRIORITY
|
boolean |
DEFAULT_REMOVE_OVERLAPS
|
int |
DEFAULT_SPACE_AROUND
|
protected Map<String,LabelCacheItem> |
labelCache
Map |
protected ArrayList<LabelCacheItem> |
labelCacheNonGrouped
non-grouped labels get thrown in here* |
protected boolean |
outlineRenderingEnabled
When true, the text is rendered as its GlyphVector outline (as a geometry) instead of using drawGlypVector. |
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,
Polygon bbox,
Envelope displayGeomEnv)
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. |
double |
getPriority(TextSymbolizer symbolizer,
SimpleFeature 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 |
boolean |
isOutlineRenderingEnabled()
|
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(String layerId,
TextSymbolizer symbolizer,
SimpleFeature feature,
LiteShape2 shape,
NumberRange scaleRange)
Puts a Label in the cache. |
void |
removeFromHash(Map<Coordinate,List<LineString>> nodes,
LineString ls)
|
void |
setOutlineRenderingEnabled(boolean outlineRenderingEnabled)
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
protected Map<String,LabelCacheItem> labelCache
protected ArrayList<LabelCacheItem> labelCacheNonGrouped
public boolean DEFAULT_GROUP
public int DEFAULT_SPACE_AROUND
public int DEFAULT_MAX_DISPLACEMENT
public int DEFAULT_MIN_GROUP_DISTANCE
public int DEFAULT_LABEL_REPEAT
public boolean DEFAULT_LABEL_ALL_GROUP
public boolean DEFAULT_ALLOW_OVERRUNS
public boolean DEFAULT_REMOVE_OVERLAPS
public boolean DEFAULT_FOLLOW_LINE
public double DEFAULT_MAX_ANGLE_DELTA
protected boolean outlineRenderingEnabled
protected SLDStyleFactory styleFactory
Constructor Detail |
---|
public LabelCacheImpl()
Method Detail |
---|
public void enableLayer(String layerId)
LabelCache
enableLayer
in interface LabelCache
layerId
- layer to activate.public boolean isOutlineRenderingEnabled()
public void setOutlineRenderingEnabled(boolean outlineRenderingEnabled)
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, SimpleFeature feature)
symbolizer
- feature
- public void put(String layerId, TextSymbolizer symbolizer, SimpleFeature 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 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 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, Polygon bbox, Envelope displayGeomEnv)
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 |