public static class Tableau.Element extends Object implements Paintable, Serializable
Paintable
-) class is here to be a parent class for
paintable tableau elements. Nevertheless this class isn't abstract.paint()
, paintBg()
or
paintString()
.Tableau
,
paint(java.awt.Graphics, int, int, int, int)
,
paintBg(java.awt.Graphics, int, int, int, int)
,
paintString(java.awt.Graphics, int, int, int, int)
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Color |
bgColor
The element's background colour.
|
protected Color |
fgColor
The element's foreground colour.
|
protected Font |
font
The element's font.
|
protected Font |
oldFont
Previous Font (for paintString only).
|
protected int |
oldHeight
Previous height (for paintString only).
|
protected String |
oldText
Previous Text (for paintString only).
|
protected int |
oldWidth
Previous width (for paintString only).
|
protected IntPairFix |
relPos
Relative text position measured (for paintString only).
|
protected String |
text
The element's font.
|
Constructor and Description |
---|
Element(Color bgColor,
Color fgColor,
Font font,
String text)
Constructor with full setting.
|
Element(Color bgColor,
Color fgColor,
Font font,
String text,
int x,
int y,
int width,
int height)
Constructor with full setting and mooring (anchorage).
|
Modifier and Type | Method and Description |
---|---|
Color |
getFgColor()
The element's foreground colour.
|
Font |
getFont()
The element's font.
|
String |
getText()
The element's text.
|
void |
paint(Graphics g,
int x,
int y,
int width,
int height)
The one method to paint the element within the Tableau.
|
void |
paintBg(Graphics g,
int x,
int y,
int width,
int height)
Paint the background.
|
void |
paintString(Graphics g,
int x,
int y,
int width,
int height)
Paint the centred text.
|
void |
setBgColor(Color bgColor)
The element's background colour.
|
void |
setFgColor(Color fgColor)
Set the element's foreground colour.
|
void |
setFont(Font font)
Set the element's font.
|
void |
setText(String text)
Set the element's text.
|
protected String text
protected transient Color bgColor
protected Color fgColor
protected Font oldFont
protected String oldText
protected int oldHeight
protected int oldWidth
protected IntPairFix relPos
public Element(Color bgColor, Color fgColor, Font font, String text)
paint
methods. It can be changed any time by
setText(String)
.bgColor
- background colourfgColor
- foreground colourfont
- null will get GrafVal.STD_FONT
text
- first text
(may be null or empty)public Element(Color bgColor, Color fgColor, Font font, String text, int x, int y, int width, int height)
bgColor
- background colourfgColor
- foreground colourfont
- null will get GrafVal.STD_FONT
text
- first text
(may be changed) and also final
configuration name (must not be empty)x
- mooring place, left upper corner, x-coordinatey
- mooring place, left upper corner, y-coordinatewidth
- Anchor's widthheight
- Anchor's heightNoSuchElementException
- if no Tableau has been made yetTableau.lastTableau
public Font getFont()
public void setFont(Font font)
public void setBgColor(Color bgColor)
public final Color getFgColor()
public void setFgColor(Color fgColor)
public String getText()
paint
methods. It can be changed any time by
setText(String)
.public void paint(Graphics g, int x, int y, int width, int height)
paintBg()
) in background colour and sets the foreground
colour afterwards. If there is a non empty text
set it will be
output centrified using the method
paintString()
).paint
in interface Paintable
g
- The notorious Graphics
object (that can
nowadays be expected to be a Graphics2D
).x
- y are the left upper corner of where to paint;
y grows downwards [sic!]width
- height are the size of an surrounding rectangle
to paint within; if null (0, 0) either this object's
"natural" size (if there is such thing) shall be used
or nothing is to be donepublic void paintBg(Graphics g, int x, int y, int width, int height)
bgColor
when this method
returns.public void paintString(Graphics g, int x, int y, int width, int height)
fgColor
(in g).text
is not or empty a font
will be set (if given).
The text
's dimensions will be evaluated and it will be
output centred with respect to in d.relPos
) together with
the parameters (oldFont
, oldText
etc.), lest to repeat
the same calculations over again. Inheritors are recommended to keep
this procedere.GrafHelper
.paintString()
.