org.deegree_impl.graphics.displayelements
Class LabelFactory

java.lang.Object
  extended byorg.deegree_impl.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: 1.8 $ $Date: 2004/05/11 13:10:46 $
Author:
Markus Schneider

Constructor Summary
LabelFactory()
           
 
Method Summary
static double[] calcDeviation(int[] start, int[] end, java.util.List 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, GM_Curve curve)
          Calculates the screen coordinates of the given GM_Curve.
static int[] calcScreenCoordinates(GeoTransform projection, GM_Object 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)
           
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)
           
static java.util.ArrayList createLabels(GM_Curve curve, LabelDisplayElement element, java.awt.Graphics2D g, GeoTransform projection)
          Determines positions on the given GM_Curve where a caption could be drawn.
static java.util.List createLabels(GM_MultiCurve multiCurve, LabelDisplayElement element, java.awt.Graphics2D g, GeoTransform projection)
          Determines positions on the given GM_MultiCurve 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 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

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)

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)

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:
Throws:
java.lang.Exception

createLabels

public static java.util.List createLabels(GM_MultiCurve multiCurve,
                                          LabelDisplayElement element,
                                          java.awt.Graphics2D g,
                                          GeoTransform projection)
                                   throws FilterEvaluationException
Determines positions on the given GM_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 createLabels(GM_Curve curve,
                                               LabelDisplayElement element,
                                               java.awt.Graphics2D g,
                                               GeoTransform projection)
                                        throws FilterEvaluationException
Determines positions on the given GM_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 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:

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:

getRotation

public static double getRotation(double x1,
                                 double y1,
                                 double x2,
                                 double y2)

getDistance

public static double getDistance(int[] p1,
                                 int[] p2)

getDistance

public static double getDistance(double x1,
                                 double y1,
                                 double x2,
                                 double y2)

calcScreenCoordinates

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


calcScreenCoordinates

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