com.bbn.openmap.omGraphics.awt
Class TextShapeDecoration

java.lang.Object
  extended by com.bbn.openmap.omGraphics.awt.AbstractShapeDecoration
      extended by com.bbn.openmap.omGraphics.awt.TextShapeDecoration
All Implemented Interfaces:
Revertable, ShapeDecoration

public class TextShapeDecoration
extends AbstractShapeDecoration

A ShapeDecoration that draws a text along a path

Version:
16 aot 2002
Author:
Eric LEPICIER

Field Summary
static int BACKWARD
          Orientation for the shape text decoration: use reverse poly direction
static int BASELINE
          Baseline vertical alignment
static int BOTTOM
          Bottom vertical alignment
static int BOTTOM_TO_TOP
          Orientation for the shape text decoration: force bottom to top
static int CENTER
          Center vertical alignment
static int FOLLOW_POLY
          Text will follow the poly instead of being written on the segment from begin to end of the poly, also allow text to be uncomplete.
static int FORWARD
          Orientation for the shape text decoration: use poly direction
static int LEFT_TO_RIGHT
          Orientation for the shape text decoration: force left to right
static int MOST_READABLE
          Orientation for the shape text decoration: occidental reading use
static int RIGHT_TO_LEFT
          Orientation for the shape text decoration: force right to left
static int TOP
          Top vertical alignment
static int TOP_TO_BOTTOM
          Orientation for the shape text decoration: force top to bottom
 
Fields inherited from interface com.bbn.openmap.omGraphics.awt.ShapeDecoration
LEFT, RIGHT
 
Constructor Summary
TextShapeDecoration(java.lang.String text)
          Constructor.
TextShapeDecoration(java.lang.String text, java.awt.Font font, int orientation, int verticalAlignment)
          Constructor.
 
Method Summary
 void draw(java.awt.Graphics g, java.awt.geom.Point2D[] points, boolean complete)
          Draws the text along the polyline
static void drawAngledString(java.awt.Graphics g, java.lang.String text, int x, int y, double angle)
          Draws the text from a starting point with an angle
protected  void drawFollow(java.awt.Graphics g, java.awt.geom.Point2D[] pts, boolean reverse)
          Draws the text character per character to follow the polyline
 java.awt.Font getFont()
          Returns the font.
 java.lang.String getText()
          Returns the text.
 int getVerticalAlignment()
          Returns the verticalAlignment.
protected  boolean needToReverse(int x1, int y1, int x2, int y2)
          Returns true if the polyline need to be reverted for the text to be drawn with the specified orientation.
 void setFont(java.awt.Font font)
          Sets the font.
 void setText(java.lang.String text)
          Sets the text.
 void setVerticalAlignment(int verticalAlignment)
          Sets the verticalAlignment.
 
Methods inherited from class com.bbn.openmap.omGraphics.awt.AbstractShapeDecoration
getLength, getOrientation, getPaint, getStroke, getWidth, restoreGraphics, revert, setGraphics, setLength, setOrientation, setPaint, setStroke, setWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASELINE

public static final int BASELINE
Baseline vertical alignment

See Also:
Constant Field Values

CENTER

public static final int CENTER
Center vertical alignment

See Also:
Constant Field Values

TOP

public static final int TOP
Top vertical alignment

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Bottom vertical alignment

See Also:
Constant Field Values

FORWARD

public static final int FORWARD
Orientation for the shape text decoration: use poly direction

See Also:
Constant Field Values

BACKWARD

public static final int BACKWARD
Orientation for the shape text decoration: use reverse poly direction

See Also:
Constant Field Values

LEFT_TO_RIGHT

public static final int LEFT_TO_RIGHT
Orientation for the shape text decoration: force left to right

See Also:
Constant Field Values

RIGHT_TO_LEFT

public static final int RIGHT_TO_LEFT
Orientation for the shape text decoration: force right to left

See Also:
Constant Field Values

TOP_TO_BOTTOM

public static final int TOP_TO_BOTTOM
Orientation for the shape text decoration: force top to bottom

See Also:
Constant Field Values

BOTTOM_TO_TOP

public static final int BOTTOM_TO_TOP
Orientation for the shape text decoration: force bottom to top

See Also:
Constant Field Values

MOST_READABLE

public static final int MOST_READABLE
Orientation for the shape text decoration: occidental reading use

See Also:
Constant Field Values

FOLLOW_POLY

public static final int FOLLOW_POLY
Text will follow the poly instead of being written on the segment from begin to end of the poly, also allow text to be uncomplete. You may add this one to the other constants

See Also:
Constant Field Values
Constructor Detail

TextShapeDecoration

public TextShapeDecoration(java.lang.String text,
                           java.awt.Font font,
                           int orientation,
                           int verticalAlignment)
Constructor.

Parameters:
text -
font -
orientation -
verticalAlignment -

TextShapeDecoration

public TextShapeDecoration(java.lang.String text)
Constructor.

Parameters:
text -
Method Detail

draw

public void draw(java.awt.Graphics g,
                 java.awt.geom.Point2D[] points,
                 boolean complete)
Draws the text along the polyline

points - the polyline
complete - true if the polyline length equals the decoration length
See Also:
ShapeDecoration.draw(Graphics, Point2D[], boolean)

needToReverse

protected boolean needToReverse(int x1,
                                int y1,
                                int x2,
                                int y2)
Returns true if the polyline need to be reverted for the text to be drawn with the specified orientation.

Parameters:
x1 - starting point x coordinate
y1 - starting point y coordinate
x2 - ending point x coordinate
y2 - ending point y coordinate
Returns:
boolean

drawFollow

protected void drawFollow(java.awt.Graphics g,
                          java.awt.geom.Point2D[] pts,
                          boolean reverse)
Draws the text character per character to follow the polyline

Parameters:
g -
pts -
reverse -

drawAngledString

public static void drawAngledString(java.awt.Graphics g,
                                    java.lang.String text,
                                    int x,
                                    int y,
                                    double angle)
Draws the text from a starting point with an angle

Parameters:
g -
text -
x -
y -
angle -

getFont

public java.awt.Font getFont()
Returns the font.

Returns:
Font

getText

public java.lang.String getText()
Returns the text.

Returns:
String

setFont

public void setFont(java.awt.Font font)
Sets the font.

Parameters:
font - The font to set

setText

public void setText(java.lang.String text)
Sets the text.

Parameters:
text - The text to set

getVerticalAlignment

public int getVerticalAlignment()
Returns the verticalAlignment.

Returns:
int

setVerticalAlignment

public void setVerticalAlignment(int verticalAlignment)
Sets the verticalAlignment.

Parameters:
verticalAlignment - The verticalAlignment to set (TOP, CENTER, BASELINE, BOTTOM)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details