org.freehep.graphics2d
Class GenericTagHandler

java.lang.Object
  extended by org.freehep.graphics2d.TagHandler
      extended by org.freehep.graphics2d.GenericTagHandler

public class GenericTagHandler
extends TagHandler

The class converts HTML tags like in instances of TextAttribute.

Version:
$Id: GenericTagHandler.java 12753 2007-06-12 22:32:31Z duns $
Author:
Mark Donszelmann, Steffen Greiffenberg

Field Summary
static java.lang.Integer UNDERLINE_OVERLINE
          TextAttribute for overline, not a standard
 
Constructor Summary
GenericTagHandler(java.awt.Graphics2D graphics)
          creates a tag handler for printing text and calculating its size
 
Method Summary
protected  java.lang.String closeTag(java.lang.String tag)
          closes the given html tag.
 java.awt.font.TextLayout createTextLayout(TagString s, double superscriptCorrection)
          calculates the string bounds using the current font of graphics.
protected  java.lang.String openTag(java.lang.String tag)
          handles bold , italic , superscript , subscript , vertical , overline , underline , strikethrough , underline dashed , underline dotted and typewriter
 void print(TagString s, double x, double y, double superscriptCorrection)
          prints the tagged string at x:y
protected  java.lang.String text(java.lang.String text)
          calculates miny und maxy for createTextLayout(TagString, double).
 
Methods inherited from class org.freehep.graphics2d.TagHandler
defaultEntity, entity, main, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDERLINE_OVERLINE

public static java.lang.Integer UNDERLINE_OVERLINE
TextAttribute for overline, not a standard

Constructor Detail

GenericTagHandler

public GenericTagHandler(java.awt.Graphics2D graphics)
creates a tag handler for printing text and calculating its size

Parameters:
graphics - stores the font for calculations
Method Detail

print

public void print(TagString s,
                  double x,
                  double y,
                  double superscriptCorrection)
prints the tagged string at x:y

Parameters:
s - string to print using the stored graphics
x - coordinate for drawing
y - coordinate for drawing
superscriptCorrection - correction for to high / to low text

createTextLayout

public java.awt.font.TextLayout createTextLayout(TagString s,
                                                 double superscriptCorrection)
calculates the string bounds using the current font of graphics.

Parameters:
s - string to calculate
Returns:
bouding box after parsing s

openTag

protected java.lang.String openTag(java.lang.String tag)
handles bold , italic , superscript , subscript , vertical , overline , underline , strikethrough , underline dashed , underline dotted and typewriter

Overrides:
openTag in class TagHandler
Parameters:
tag - one of the known tags, otherwise the overloaded methode is called
Returns:
empty string or the result of the overloaded method

closeTag

protected java.lang.String closeTag(java.lang.String tag)
closes the given html tag. It doesn't matter, if that one was opened, so closes a too, because the use the same TextAttribute.UNDERLINE.

Overrides:
closeTag in class TagHandler
Parameters:
tag - to close
Returns:
empty string or the result of the overloaded method

text

protected java.lang.String text(java.lang.String text)
calculates miny und maxy for createTextLayout(TagString, double). If print(org.freehep.graphics2d.TagString, double, double, double) is set, text is drawed using Graphics2D.drawString(String, float, float) of graphics

Overrides:
text in class TagHandler
Parameters:
text - text to draw
Returns:
unmodified text parameter


Copyright © 2000-2007 FreeHEP. All Rights Reserved.