irc.style
Class FormattedStringDrawer

java.lang.Object
  |
  +--irc.style.FormattedStringDrawer

public class FormattedStringDrawer
extends java.lang.Object

The formatted string drawer.


Field Summary
static int BOTTOM
           
static int LEFT
           
static int RIGHT
           
static int TOP
           
 
Constructor Summary
FormattedStringDrawer(java.awt.Font fnt, IRCConfiguration config, ColorContext context)
          Create a new FormattedStringDrawer.
 
Method Summary
 DecodedLine decodeLine(java.lang.String str)
          Prepare a line for display.
 void draw(DecodedLine str, java.awt.Graphics g, int left, int right, int y, int clipxl, int clipxr, boolean analyse, boolean wrap, DrawResult res)
          Draw the given prepared line.
 java.awt.Color getColor(int i)
          Get the current color at index i.
 java.awt.Font getFont()
          Get the used font.
 int getHeight(DecodedLine str, java.awt.FontMetrics fm)
          Get the given string width, in pixel.
 int getHeight(DecodedLine str, java.awt.Graphics g, int x, int wmax, boolean wrap)
           
 int getHorizontalDirection()
           
 java.lang.String getStripped(java.lang.String str)
          Strip a line from all its color and special codes.
 int getVerticalDirection()
           
 int getWidth(DecodedLine str, java.awt.FontMetrics fm)
          Get the given string height, in pixel.
 void setColorContext(ColorContext context)
          Set the color context to use.
 void setColors(java.awt.Color[] cols)
          Set the colors to use, overriding current colors from color context.
 void setFont(java.awt.Font fnt)
          Set the font to use.
 void setHorizontalDirection(int dir)
           
 void setVerticalDirection(int dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values
Constructor Detail

FormattedStringDrawer

public FormattedStringDrawer(java.awt.Font fnt,
                             IRCConfiguration config,
                             ColorContext context)
Create a new FormattedStringDrawer.

Parameters:
fnt - fonts to use.
config - the global configuration.
context - the color context to use.
Method Detail

setVerticalDirection

public void setVerticalDirection(int dir)

getVerticalDirection

public int getVerticalDirection()

setHorizontalDirection

public void setHorizontalDirection(int dir)

getHorizontalDirection

public int getHorizontalDirection()

setColorContext

public void setColorContext(ColorContext context)
Set the color context to use.

Parameters:
context - new color context.

decodeLine

public DecodedLine decodeLine(java.lang.String str)
Prepare a line for display.

Parameters:
str - line to prepare.
Returns:
prepared line, ready for display.

getHeight

public int getHeight(DecodedLine str,
                     java.awt.FontMetrics fm)
Get the given string width, in pixel.

Parameters:
str - the prepared line.
fm - the FontMetrics that will be used on display.
Returns:
the string width, in pixel.

getWidth

public int getWidth(DecodedLine str,
                    java.awt.FontMetrics fm)
Get the given string height, in pixel.

Parameters:
str - the prepared line.
fm - the FontMetrics that will be used on display.
Returns:
the string height, in pixel.

setColors

public void setColors(java.awt.Color[] cols)
Set the colors to use, overriding current colors from color context.

Parameters:
cols - colors to use.

getColor

public java.awt.Color getColor(int i)
Get the current color at index i.

Parameters:
i - color index.
Returns:
the color at index i.

setFont

public void setFont(java.awt.Font fnt)
Set the font to use.

Parameters:
fnt - the font to be used.

getFont

public java.awt.Font getFont()
Get the used font.

Returns:
the used font.

getStripped

public java.lang.String getStripped(java.lang.String str)
Strip a line from all its color and special codes.

Parameters:
str - string to strip.
Returns:
stripped line.

getHeight

public int getHeight(DecodedLine str,
                     java.awt.Graphics g,
                     int x,
                     int wmax,
                     boolean wrap)

draw

public void draw(DecodedLine str,
                 java.awt.Graphics g,
                 int left,
                 int right,
                 int y,
                 int clipxl,
                 int clipxr,
                 boolean analyse,
                 boolean wrap,
                 DrawResult res)
Draw the given prepared line.

Parameters:
str - the prepared line to draw.
g - the graphics where to draw.
left - left margin.
right - right margin.
y - y position.
clipxl - left clip position : drawing doesn't have to be complete left to this position.
clipxr - right clip position : drawing doens't have to be complete right to this position.
analyse - true if word per word analyse must be performed, false otherwise. If not analyse is requested, the DrawResultItem array in res will be zero-sized.
wrap - true is wrapping must be done, false otherwise.
res - analyse report destination for the drawed line.