org.mbari.siam.moos.utils.chart.graph
Class RTextLine

java.lang.Object
  extended by org.mbari.siam.moos.utils.chart.graph.TextLine
      extended by org.mbari.siam.moos.utils.chart.graph.RTextLine

public class RTextLine
extends TextLine

This class is an extension of the TextLine Class that allows text to be rotated. To rotate the text the Component.createImage method is used. This means that this class needs to know the component that will receive the text. If the component is not known the text cannot be rotated and the class will fall back to the TextLine.draw method.

The text is rotated by running the image through an ImageFilter. This filter can easily be modified to rotate text through an arbitrary angle but unless the text is large the integer mapping will blur the text. Also positioning of arbitrarily rotated text becomes problematic.

Version:
$Revision: 1.1 $, $Date: 2008/11/04 22:17:54 $
Author:
Leigh Brookshaw

Field Summary
protected  int angle
          Rotation Angle of text in degrees
 
Fields inherited from class org.mbari.siam.moos.utils.chart.graph.TextLine
ALGEBRAIC, ascent, background, CENTER, color, descent, font, fontname, fontsize, fontstyle, height, justification, leading, LEFT, lg, list, maxAscent, maxDescent, parse, RIGHT, SCIENTIFIC, script_fraction, sub_offset, sup_offset, text, width
 
Constructor Summary
RTextLine()
          Instantiate the class
RTextLine(java.awt.Component c)
          Instantiate the class.
RTextLine(java.awt.Font f, java.awt.Color c, int j)
          Instantiate the class
RTextLine(java.awt.Font f, java.awt.Color c, int j, int a)
          Instantiate the class
RTextLine(java.lang.String s)
          Instantiate the class.
RTextLine(java.lang.String s, java.awt.Color c)
          Instantiate the class
RTextLine(java.lang.String s, java.awt.Font f)
          Instantiate the class
RTextLine(java.lang.String s, java.awt.Font f, java.awt.Color c, int j)
          Instantiate the class
 
Method Summary
 void copyState(RTextLine t)
          Copy the state of the parsed Textline into the existing object.
 void draw(java.awt.Component comp, java.awt.Graphics g, int x, int y)
          Parse the text, rotate it then draw it to the screen.
 void draw(java.awt.Graphics g, int x, int y)
          Parse the text then draw it.
 void draw(java.awt.Graphics g, int x, int y, int j)
          Parse the text then draw it.
 int getBottomEdge(java.awt.Graphics g)
          Return the bottom edge of the rotated text.
 int getBottomEdge(java.awt.Graphics g, int j)
          Return the bottom edge of the rotated text.
 java.awt.Component getComponent()
           
 int getLeftEdge(java.awt.Graphics g)
          Return the left edge of the rotated text.
 int getLeftEdge(java.awt.Graphics g, int j)
          Return the left edge of the rotated text.
 int getRHeight(java.awt.Graphics g)
          The height of the text after it has been rotated.
 int getRightEdge(java.awt.Graphics g)
          Return the right edge of the rotated text.
 int getRightEdge(java.awt.Graphics g, int j)
          Return the right edge of the rotated text.
 int getRotation()
           
 int getRWidth(java.awt.Graphics g)
          The width of the text after it has been rotated.
 int getTopEdge(java.awt.Graphics g)
          Return the top edge of the rotated text.
 int getTopEdge(java.awt.Graphics g, int j)
          Return the top edge of the rotated text.
 void setDrawingComponent(java.awt.Component c)
          Set the Component the text will be drawn into.
 void setRotation(int angle)
          Set the text rotation angle.
 void setRotation(int angle, java.awt.Component c)
          Set the Rotation and the Component that will be drawn into
 
Methods inherited from class org.mbari.siam.moos.utils.chart.graph.TextLine
charWidth, copyState, copyState, getAscent, getBackground, getColor, getDescent, getFM, getFont, getFontName, getFontSize, getFontStyle, getHeight, getJustification, getLeading, getMaxAscent, getMaxDescent, getScriptFont, getText, getWidth, isNull, parseDouble, parseDouble, parseDouble, parseText, setBackground, setColor, setFont, setFontName, setFontSize, setFontStyle, setJustification, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

angle

protected int angle
Rotation Angle of text in degrees

Constructor Detail

RTextLine

public RTextLine()
Instantiate the class


RTextLine

public RTextLine(java.lang.String s)
Instantiate the class.

Parameters:
s - String to parse.

RTextLine

public RTextLine(java.awt.Component c)
Instantiate the class.

Parameters:
c - the Component the text will be drawn into.

RTextLine

public RTextLine(java.lang.String s,
                 java.awt.Font f)
Instantiate the class

Parameters:
s - String to parse.
f - Font to use.

RTextLine

public RTextLine(java.lang.String s,
                 java.awt.Font f,
                 java.awt.Color c,
                 int j)
Instantiate the class

Parameters:
s - String to parse.
f - Font to use.
c - Color to use
j - Justification

RTextLine

public RTextLine(java.lang.String s,
                 java.awt.Color c)
Instantiate the class

Parameters:
s - String to parse.
c - Color to use

RTextLine

public RTextLine(java.awt.Font f,
                 java.awt.Color c,
                 int j,
                 int a)
Instantiate the class

Parameters:
f - Font to use.
c - Color to use
j - Justification
a - Rotation angle in degrees

RTextLine

public RTextLine(java.awt.Font f,
                 java.awt.Color c,
                 int j)
Instantiate the class

Parameters:
f - Font to use.
c - Color to use
j - Justification
Method Detail

copyState

public void copyState(RTextLine t)
Copy the state of the parsed Textline into the existing object.

Parameters:
t - The TextLine to get the state information from.

setRotation

public void setRotation(int angle)
Set the text rotation angle. Only multiples of 90 degrees are accepted

Parameters:
angle - The angle to rotate the text

setDrawingComponent

public void setDrawingComponent(java.awt.Component c)
Set the Component the text will be drawn into. This is required to rotate the text. if it is not set the text will not be rotated.

Parameters:
c - The drawing component

setRotation

public void setRotation(int angle,
                        java.awt.Component c)
Set the Rotation and the Component that will be drawn into

Parameters:
angle - The angle to rotate the text
c - The drawing component

getRotation

public int getRotation()
Returns:
the Rotation angle in degrees.

getComponent

public java.awt.Component getComponent()
Returns:
the Component that will receive the text.

getRWidth

public int getRWidth(java.awt.Graphics g)
The width of the text after it has been rotated.

Parameters:
g - Graphics context.
Returns:
the width of the parsed text after it has been rotated.

getRHeight

public int getRHeight(java.awt.Graphics g)
The height of the text after it has been rotated.

Parameters:
g - Graphics context.
Returns:
the height of the parsed text after it has been rotated.

getLeftEdge

public int getLeftEdge(java.awt.Graphics g)
Return the left edge of the rotated text. This is dependent on the justification of the text.

Parameters:
g - Graphics context.
Returns:
the Left edge of the rotated text

getRightEdge

public int getRightEdge(java.awt.Graphics g)
Return the right edge of the rotated text. This is dependent on the justification of the text.

Parameters:
g - Graphics context.
Returns:
the Right edge of the rotated text

getTopEdge

public int getTopEdge(java.awt.Graphics g)
Return the top edge of the rotated text. This is dependent on the justification of the text.

Parameters:
g - Graphics context.
Returns:
the Top edge of the rotated text

getBottomEdge

public int getBottomEdge(java.awt.Graphics g)
Return the bottom edge of the rotated text. This is dependent on the justification of the text.

Parameters:
g - Graphics context.
Returns:
the Bottom edge of the rotated text

getLeftEdge

public int getLeftEdge(java.awt.Graphics g,
                       int j)
Return the left edge of the rotated text.

Parameters:
g - Graphics context.
j - Text justification
Returns:
the Left edge of the rotated text

getRightEdge

public int getRightEdge(java.awt.Graphics g,
                        int j)
Return the right edge of the rotated text.

Parameters:
g - Graphics context.
j - Text justification
Returns:
the Right edge of the rotated text

getTopEdge

public int getTopEdge(java.awt.Graphics g,
                      int j)
Return the top edge of the rotated text.

Parameters:
g - Graphics context.
j - Text justification
Returns:
the Top edge of the rotated text

getBottomEdge

public int getBottomEdge(java.awt.Graphics g,
                         int j)
Return the bottom edge of the rotated text.

Parameters:
g - Graphics context.
j - Text justification
Returns:
the Bottom edge of the rotated text

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y)
Parse the text then draw it.

Overrides:
draw in class TextLine
Parameters:
g - Graphics context
x - pixel position of the text
y - pixel position of the text

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y,
                 int j)
Parse the text then draw it.

Overrides:
draw in class TextLine
Parameters:
g - Graphics context
x - pixel position of the text
y - pixel position of the text
j - justification of the text

draw

public void draw(java.awt.Component comp,
                 java.awt.Graphics g,
                 int x,
                 int y)
Parse the text, rotate it then draw it to the screen.

Parameters:
g - Graphics context
x - pixel position of the text
y - pixel position of the text


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.