Extension SDK 10.1.2

oracle.javatools.editor.underline
Class SimpleLinePainter

java.lang.Object
  extended byoracle.javatools.editor.underline.SimpleLinePainter
All Implemented Interfaces:
UnderlinePainter
Direct Known Subclasses:
DottedLinePainter, ZigZagLinePainter

public class SimpleLinePainter
extends java.lang.Object
implements UnderlinePainter

The SimpleLinePainter is an implementation of the UnderlinePainter which paints a straight underline of a given thickness.


Field Summary
protected  boolean fromBaseline
          Whether the line is painted from the baseline (extending downwards for thickness) or from the descent below the baseline (extending upwards for thickness.)
static int MAX_THICKNESS
          The maximum thickness that can be specified to the line painter.
protected  int thickness
          The thickness of the line to paint.
 
Constructor Summary
SimpleLinePainter(int thickness, boolean fromBaseline)
          Constructs a new SimpleLinePainter of the specified thickness.
 
Method Summary
protected  int getYPos(int yBaseline, int descent)
          Utility routine to calculate the appropriate y position to start painting downwards from, based on the requested paint position (from baseline or from bottom), and the yBaseline coordinate and the descent.)
 void paintUnderline(java.awt.Graphics graphics, java.awt.Color color, int xPos, int width, int yBaseline, int descent)
          Paints the underline using this implementation of the UnderlinePainter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_THICKNESS

public static final int MAX_THICKNESS
The maximum thickness that can be specified to the line painter.

See Also:
Constant Field Values

thickness

protected final int thickness
The thickness of the line to paint.


fromBaseline

protected final boolean fromBaseline
Whether the line is painted from the baseline (extending downwards for thickness) or from the descent below the baseline (extending upwards for thickness.)

Constructor Detail

SimpleLinePainter

public SimpleLinePainter(int thickness,
                         boolean fromBaseline)
Constructs a new SimpleLinePainter of the specified thickness. Any thickness greater than MAX_THICKNESS will be automatically reduced. If fromBaseline is true, the line is painted from the baseline (downwards for thickness) or from the descent below the baseline (extending upwards for thickness.)

Parameters:
thickness - the thickness of the line to paint
fromBaseline - true if the underline extends from the baseline
Method Detail

getYPos

protected int getYPos(int yBaseline,
                      int descent)
Utility routine to calculate the appropriate y position to start painting downwards from, based on the requested paint position (from baseline or from bottom), and the yBaseline coordinate and the descent.)

Parameters:
yBaseline - the y position of the baseline
descent - the descent of the text below the baseline

paintUnderline

public void paintUnderline(java.awt.Graphics graphics,
                           java.awt.Color color,
                           int xPos,
                           int width,
                           int yBaseline,
                           int descent)
Paints the underline using this implementation of the UnderlinePainter.

Specified by:
paintUnderline in interface UnderlinePainter
Parameters:
graphics - the graphics context to paint into
color - the color to use for painting the underline
xPos - the x position to start painting from
width - the width of the underline to paint
yBaseline - the y position of the baseline of the text we are drawing an underline for
descent - the descent of the font the text was drawn with

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.