|
ReportCat 1.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectli.netcat.print.util.StringDrawDevice
The StringDrawDevice is a pluggable strategy to draw Strings. All string printing use the installed device.
The exact determination of the width of a String (used for right alignment) seems to be a non trivial problem. The various solutions
(e.g. TextLayout) have all advantages and disadvantages. Override the various methods to implement your needs.
Default fonts can also be retrieved and defined with static metods of the StringDrawDevice.
| Constructor Summary | |
StringDrawDevice()
|
|
| Method Summary | |
int |
charsWidth(java.awt.Graphics g,
java.awt.Font font,
char[] text,
int offset,
int length)
Returns the width of a String. |
void |
drawChars(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y,
int align)
Draws a String at the specified position with the specified horizontal alignment. |
protected void |
drawCharsCenter(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
Callback to be overridden. |
protected void |
drawCharsLeft(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
Callback to be overridden. |
protected void |
drawCharsRight(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
Callback to be overridden. |
void |
drawString(java.awt.Graphics g,
java.lang.String s,
int x,
int y,
int align)
Draws a String at the specified position with the specified horizontal alignment. |
protected void |
drawStringCenter(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
Callback to be overridden. |
protected void |
drawStringLeft(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
Callback to be overridden. |
protected void |
drawStringRigth(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
Callback to be overridden. |
static java.awt.Font |
getDefaultBoldFont()
Returns the default bold font. |
static java.awt.Font |
getDefaultPlainFont()
Returns the default plain font. |
static StringDrawDevice |
getDevice()
Returns the current installed device. |
static void |
setDefaultBoldFont(java.awt.Font font)
Sets the default bold font. |
static void |
setDefaultPlainFont(java.awt.Font font)
Sets the default plain font. |
static void |
setDevice(StringDrawDevice device)
Sets a new implementation of the device. |
int |
stringWidth(java.awt.Graphics g,
java.awt.Font font,
java.lang.String s)
Returns the width of a String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public StringDrawDevice()
| Method Detail |
public static StringDrawDevice getDevice()
public static void setDevice(StringDrawDevice device)
device - A new implementation of the device, not null.public static java.awt.Font getDefaultPlainFont()
public static void setDefaultPlainFont(java.awt.Font font)
font - The default plain font.public static java.awt.Font getDefaultBoldFont()
public static void setDefaultBoldFont(java.awt.Font font)
font - The default bold font.
public void drawString(java.awt.Graphics g,
java.lang.String s,
int x,
int y,
int align)
String at the specified position with the specified horizontal alignment.
g - The Graphics to draw on.s - The text as String.x - The left, center or right x coordinate of the baseline.y - The y coordinate of the baseline.align - The horizontal alignment, LEFT, CENTER or RIGHT.
public void drawChars(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y,
int align)
String at the specified position with the specified horizontal alignment.
g - The Graphics to draw on.text - The text as char[].offset - The first character to be printed.length - The number of characters to print.x - The x coordinate of the left, center or right of the baseline.y - The y coordinate of the baseline.align - The horizontal alignment, LEFT, CENTER or RIGHT.
public int stringWidth(java.awt.Graphics g,
java.awt.Font font,
java.lang.String s)
String. It is implemented as g.getFontMetrics(font).stringWidth(s).
Override this method for an other implementation.
g - The relevant Graphics object.font - The font to be used.s - The text as String.
public int charsWidth(java.awt.Graphics g,
java.awt.Font font,
char[] text,
int offset,
int length)
String. It is implemented as g.getFontMetrics(font).charsWidth(text, offset, length).
Override this method for an other implementation.
g - The relevant Graphics object.font - The font to be used.text - The text as char[].offset - The first character to be printed.length - The number of characters to print.
protected void drawStringLeft(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
g - The Graphics to draw on.s - The text as String.x - The left x coordinate of the baseline.y - The y coordinate of the baseline.
protected void drawCharsLeft(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
g - The Graphics to draw on.text - The text as char[].offset - The first character to be printed.length - The number of characters to print.x - The left x coordinate of the baseline.y - The y coordinate of the baseline.
protected void drawStringCenter(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
g - The Graphics to draw on.s - The text as String.x - The centered x coordinate of the baseline.y - The y coordinate of the baseline.
protected void drawCharsCenter(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
g - The Graphics to draw on.text - The text as char[].offset - The first character to be printed.length - The number of characters to print.x - The centered x coordinate of the baseline.y - The y coordinate of the baseline.
protected void drawStringRigth(java.awt.Graphics g,
java.lang.String s,
int x,
int y)
g - The Graphics to draw on.s - The text as String.x - The right x coordinate of the baseline.y - The y coordinate of the baseline.
protected void drawCharsRight(java.awt.Graphics g,
char[] text,
int offset,
int length,
int x,
int y)
g - The Graphics to draw on.text - The text as char[].offset - The first character to be printed.length - The number of characters to print.x - The right x coordinate of the baseline.y - The y coordinate of the baseline.
|
ReportCat 1.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||