org.geotools.renderer.label
Class LabelPainter

Object
  extended by LabelPainter

public class LabelPainter
extends Object

This class performs the layouting and painting of the single label (leaving the label cache the task to sort labels and locate the best label points)

Author:
Andrea Aime
Module:
modules/library/render (gt-render.jar)

Constructor Summary
LabelPainter(Graphics2D graphics, boolean outlineRenderingEnabled)
          Builds a new painter
 
Method Summary
 double getAscent()
          The full size above the baseline
 Rectangle2D getFullLabelBounds()
          Get the straight label bounds, taking into account halo, shield and line wrapping
 LabelCacheItem getLabel()
          Returns the current label item
 Rectangle2D getLabelBounds()
          Get the straight label bounds, without taking into account halo and shield
 int getLineCount()
          Number of lines for this label (more than 1 if the label has embedded newlines or if we're auto-wrapping it)
 double getLineHeight()
          Returns the line height for this label in pixels (for multiline labels, it's the height of the first line)
 double getLinePlacementYAnchor()
          Vertical centering is not trivial, because visually we want centering on characters such as a,m,e, and not centering on d,g whose center is affected by the full ascent or the full descent.
 int getStraightLabelWidth()
          Returns the width of the label, as painted in straight form (
 void paintCurvedLabel(LineStringCursor cursor)
          Paints a label that follows the line, centered in the current cursor position
 void paintStraightLabel(AffineTransform transform)
          Paints the label as a non curved one.
 void setLabel(LabelCacheItem labelItem)
          Sets the current label.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelPainter

public LabelPainter(Graphics2D graphics,
                    boolean outlineRenderingEnabled)
Builds a new painter

Parameters:
graphics -
outlineRenderingEnabled -
Method Detail

setLabel

public void setLabel(LabelCacheItem labelItem)
Sets the current label. The label will be laid out according to the label item settings (curved lines, auto wrapping, curved line usage) and the painter will be ready to draw it.

Parameters:
labelItem -

getLabel

public LabelCacheItem getLabel()
Returns the current label item

Returns:

getLineHeight

public double getLineHeight()
Returns the line height for this label in pixels (for multiline labels, it's the height of the first line)

Returns:

getAscent

public double getAscent()
The full size above the baseline

Returns:

getStraightLabelWidth

public int getStraightLabelWidth()
Returns the width of the label, as painted in straight form (

Returns:

getLineCount

public int getLineCount()
Number of lines for this label (more than 1 if the label has embedded newlines or if we're auto-wrapping it)

Returns:

getFullLabelBounds

public Rectangle2D getFullLabelBounds()
Get the straight label bounds, taking into account halo, shield and line wrapping

Returns:

getLabelBounds

public Rectangle2D getLabelBounds()
Get the straight label bounds, without taking into account halo and shield

Returns:

paintStraightLabel

public void paintStraightLabel(AffineTransform transform)
                        throws Exception
Paints the label as a non curved one. The positioning and rotation are provided by the transformation

Parameters:
transform -
Throws:
Exception

paintCurvedLabel

public void paintCurvedLabel(LineStringCursor cursor)
Paints a label that follows the line, centered in the current cursor position

Parameters:
cursor -

getLinePlacementYAnchor

public double getLinePlacementYAnchor()
Vertical centering is not trivial, because visually we want centering on characters such as a,m,e, and not centering on d,g whose center is affected by the full ascent or the full descent. This method tries to computes the y anchor taking into account those.



Copyright © 1996-2009 Geotools. All Rights Reserved.