deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.graphics.displayelements
Class LabelFactory

java.lang.Object
  extended by org.deegree.graphics.displayelements.LabelFactory

public class LabelFactory
extends java.lang.Object

Does the labeling, i.e. creates (screen) Label representations from LabelDisplayElements.

Different geometry-types (of the LabelDisplayElement) imply different strategies concerning the way the Labels are generated.

Version:
$Revision: 27114 $ $Date: 2010-09-30 16:04:40 +0200 (Do, 30 Sep 2010) $
Author:
Markus Schneider

Constructor Summary
LabelFactory()
           
 
Method Summary
static double[] calcDeviation(int[] start, int[] end, java.util.List<int[]> points)
          Calculates the maximum deviation that points on a linestring have to the ideal line between the starting point and the end point.
static int[][] calcScreenCoordinates(GeoTransform projection, Curve curve)
          Calculates the screen coordinates of the given Curve. physical screen coordinates
static int[] calcScreenCoordinates(GeoTransform projection, Geometry geometry)
          Returns the physical (screen) coordinates.
static Label createLabel(java.lang.String caption, java.awt.Font font, java.awt.Color color, java.awt.font.LineMetrics metrics, Feature feature, Halo halo, int x, int y, int w, int h, double rotation, double[] anchorPoint, double[] displacement)
          Deprecated. use the one with opacity instead
static Label createLabel(java.lang.String caption, java.awt.Font font, java.awt.Color color, java.awt.font.LineMetrics metrics, Feature feature, Halo halo, int x, int y, int w, int h, double rotation, double[] anchorPoint, double[] displacement, double opacity)
           
static Label createLabel(java.lang.String caption, java.awt.Font font, java.awt.Color color, java.awt.font.LineMetrics metrics, Feature feature, Halo halo, int x, int y, int w, int h, double rotation, double anchorPointX, double anchorPointY, double displacementX, double displacementY)
          Deprecated. use the one with opacity instead
static Label createLabel(java.lang.String caption, java.awt.Font font, java.awt.Color color, java.awt.font.LineMetrics metrics, Feature feature, Halo halo, int x, int y, int w, int h, double rotation, double anchorPointX, double anchorPointY, double displacementX, double displacementY, double opacity)
           
static HorizontalLabel createLabelInABox(java.lang.String text, java.awt.Font font, java.awt.Color color, Halo halo, double x, double y, double w, double h, Feature feature, GeoTransform projection)
          Deprecated. use the one with opacity instead
static HorizontalLabel createLabelInABox(java.lang.String text, java.awt.Font font, java.awt.Color color, Halo halo, double x, double y, double w, double h, Feature feature, GeoTransform projection, double opacity)
           
static java.util.ArrayList<Label> createLabels(Curve curve, LabelDisplayElement element, java.awt.Graphics2D g, GeoTransform projection)
          Determines positions on the given Curve where a caption could be drawn.
static Label[] createLabels(LabelDisplayElement element, GeoTransform projection, java.awt.Graphics2D g)
          Generates label-representations for a given LabelDisplayElement.
static java.util.List<Label> createLabels(MultiCurve multiCurve, LabelDisplayElement element, java.awt.Graphics2D g, GeoTransform projection)
          Determines positions on the given MultiCurve where a caption could be drawn.
static int[] findPointWithDistance(int[] p0, int[] p1, int[] p2, int d)
          Finds a point on the line between p1 and p2 that has a certain distance from point p0 (provided that there is such a point).
static double getDistance(double x1, double y1, double x2, double y2)
           
static double getDistance(int[] p1, int[] p2)
           
static double getRotation(double x1, double y1, double x2, double y2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelFactory

public LabelFactory()
Method Detail

createLabel

@Deprecated
public static Label createLabel(java.lang.String caption,
                                           java.awt.Font font,
                                           java.awt.Color color,
                                           java.awt.font.LineMetrics metrics,
                                           Feature feature,
                                           Halo halo,
                                           int x,
                                           int y,
                                           int w,
                                           int h,
                                           double rotation,
                                           double anchorPointX,
                                           double anchorPointY,
                                           double displacementX,
                                           double displacementY)
Deprecated. use the one with opacity instead

Parameters:
caption -
font -
color -
metrics -
feature -
halo -
x -
y -
w -
h -
rotation -
anchorPointX -
anchorPointY -
displacementX -
displacementY -
Returns:
label-representations

createLabel

public static Label createLabel(java.lang.String caption,
                                java.awt.Font font,
                                java.awt.Color color,
                                java.awt.font.LineMetrics metrics,
                                Feature feature,
                                Halo halo,
                                int x,
                                int y,
                                int w,
                                int h,
                                double rotation,
                                double anchorPointX,
                                double anchorPointY,
                                double displacementX,
                                double displacementY,
                                double opacity)
Parameters:
caption -
font -
color -
metrics -
feature -
halo -
x -
y -
w -
h -
rotation -
anchorPointX -
anchorPointY -
displacementX -
displacementY -
opacity -
Returns:
label representations

createLabel

public static Label createLabel(java.lang.String caption,
                                java.awt.Font font,
                                java.awt.Color color,
                                java.awt.font.LineMetrics metrics,
                                Feature feature,
                                Halo halo,
                                int x,
                                int y,
                                int w,
                                int h,
                                double rotation,
                                double[] anchorPoint,
                                double[] displacement,
                                double opacity)
Parameters:
caption -
font -
color -
metrics -
feature -
halo -
x -
y -
w -
h -
rotation -
anchorPoint -
displacement -
opacity -
Returns:
the label

createLabel

@Deprecated
public static Label createLabel(java.lang.String caption,
                                           java.awt.Font font,
                                           java.awt.Color color,
                                           java.awt.font.LineMetrics metrics,
                                           Feature feature,
                                           Halo halo,
                                           int x,
                                           int y,
                                           int w,
                                           int h,
                                           double rotation,
                                           double[] anchorPoint,
                                           double[] displacement)
Deprecated. use the one with opacity instead

Parameters:
caption -
font -
color -
metrics -
feature -
halo -
x -
y -
w -
h -
rotation -
anchorPoint -
displacement -
Returns:
label-representations

createLabels

public static Label[] createLabels(LabelDisplayElement element,
                                   GeoTransform projection,
                                   java.awt.Graphics2D g)
                            throws java.lang.Exception
Generates label-representations for a given LabelDisplayElement.

Parameters:
element -
projection -
g -
Returns:
label-representations
Throws:
java.lang.Exception

createLabels

public static java.util.List<Label> createLabels(MultiCurve multiCurve,
                                                 LabelDisplayElement element,
                                                 java.awt.Graphics2D g,
                                                 GeoTransform projection)
                                          throws FilterEvaluationException
Determines positions on the given MultiCurve where a caption could be drawn. For each of this positons, three candidates are produced; one on the line, one above of it and one below.

Parameters:
multiCurve -
element -
g -
projection -
Returns:
ArrayList containing Arrays of Label-objects
Throws:
FilterEvaluationException

createLabels

public static java.util.ArrayList<Label> createLabels(Curve curve,
                                                      LabelDisplayElement element,
                                                      java.awt.Graphics2D g,
                                                      GeoTransform projection)
                                               throws FilterEvaluationException
Determines positions on the given Curve where a caption could be drawn. For each of this positons, three candidates are produced; one on the line, one above of it and one below.

Parameters:
curve -
element -
g -
projection -
Returns:
ArrayList containing Arrays of Label-objects
Throws:
FilterEvaluationException

calcDeviation

public static double[] calcDeviation(int[] start,
                                     int[] end,
                                     java.util.List<int[]> points)
Calculates the maximum deviation that points on a linestring have to the ideal line between the starting point and the end point.

The ideal line is thought to be running from left to right, the left deviation value generally is above the line, the right value is below.

Parameters:
start - starting point of the linestring
end - end point of the linestring
points - points in between
Returns:
maximum deviation

findPointWithDistance

public static int[] findPointWithDistance(int[] p0,
                                          int[] p1,
                                          int[] p2,
                                          int d)
Finds a point on the line between p1 and p2 that has a certain distance from point p0 (provided that there is such a point).

Parameters:
p0 - point that is used as reference point for the distance
p1 - starting point of the line
p2 - end point of the line
d - distance
Returns:
point on the line between p1 and p2 that has a certain distance from point p0

createLabelInABox

@Deprecated
public static HorizontalLabel createLabelInABox(java.lang.String text,
                                                           java.awt.Font font,
                                                           java.awt.Color color,
                                                           Halo halo,
                                                           double x,
                                                           double y,
                                                           double w,
                                                           double h,
                                                           Feature feature,
                                                           GeoTransform projection)
Deprecated. use the one with opacity instead

Creates a label that fits in the specified box.

Parameters:
text -
font -
color -
halo -
x -
y -
w -
h -
feature -
projection -
Returns:
the label

createLabelInABox

public static HorizontalLabel createLabelInABox(java.lang.String text,
                                                java.awt.Font font,
                                                java.awt.Color color,
                                                Halo halo,
                                                double x,
                                                double y,
                                                double w,
                                                double h,
                                                Feature feature,
                                                GeoTransform projection,
                                                double opacity)
Parameters:
text -
font -
color -
halo -
x -
y -
w -
h -
feature -
projection -
opacity -
Returns:
the label

getRotation

public static double getRotation(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Parameters:
x1 -
y1 -
x2 -
y2 -
Returns:
rotation (degree) of the line between two passed coordinates

getDistance

public static double getDistance(int[] p1,
                                 int[] p2)
Parameters:
p1 -
p2 -
Returns:
distance between two passed coordinates

getDistance

public static double getDistance(double x1,
                                 double y1,
                                 double x2,
                                 double y2)
Parameters:
x1 -
y1 -
x2 -
y2 -
Returns:
distance between two passed coordinates

calcScreenCoordinates

public static int[][] calcScreenCoordinates(GeoTransform projection,
                                            Curve curve)
Calculates the screen coordinates of the given Curve. physical screen coordinates

Parameters:
projection -
curve -
Returns:
the coordinates

calcScreenCoordinates

public static int[] calcScreenCoordinates(GeoTransform projection,
                                          Geometry geometry)
Returns the physical (screen) coordinates.

Parameters:
projection -
geometry -
Returns:
physical screen coordinates

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org