CharBox
, FcscoreBox
, FramedBox
, GeoGebraLogoBox
, GlueBox
, GraphicsBox
, HorizontalBox
, HorizontalRule
, JavaFontRenderingBox
, OverBar
, OverUnderBox
, ReflectBox
, RotateBox
, ScaleBox
, StrutBox
public abstract class Box
extends java.lang.Object
Subclasses must implement the abstract draw(Graphics2D, float, float)
method
(that paints the box). This implementation must start with calling the method
startDraw(Graphics2D, float, float)
and end with calling the method
endDraw(Graphics2D)
to set and restore the color's that must be used for
painting the box and to draw the background! They must also implement the abstract
getLastFontId()
method (the last font
that will be used when this box will be painted).
Modifier and Type | Field | Description |
---|---|---|
protected java.awt.Color |
background |
The background color of the whole box.
|
protected java.util.LinkedList<Box> |
children |
List of child boxes
|
static boolean |
DEBUG |
|
protected float |
depth |
The depth of this box, i.e.
|
protected Box |
elderParent |
|
protected java.awt.Color |
foreground |
The foreground color of the whole box.
|
protected float |
height |
The height of this box, i.e.
|
protected java.awt.Color |
markForDEBUG |
|
protected Box |
parent |
|
protected float |
shift |
The shift amount: the meaning depends on the particular kind of box
(up, down, left, right)
|
protected int |
type |
|
protected float |
width |
The width of this box, i.e.
|
Modifier | Constructor | Description |
---|---|---|
protected |
Box() |
Creates an empty box (no children) with all dimensions set to 0 and no
foreground and background color set (default values will be used: null)
|
protected |
Box(java.awt.Color fg,
java.awt.Color bg) |
Creates an empty box (no children) with all dimensions set to 0 and sets
the foreground and background color of the box.
|
Modifier and Type | Method | Description |
---|---|---|
void |
add(int pos,
Box b) |
Inserts the given box at the given position in the list of child boxes.
|
void |
add(Box b) |
Inserts the given box at the end of the list of child boxes.
|
abstract void |
draw(java.awt.Graphics2D g2,
float x,
float y) |
Paints this box at the given coordinates using the given graphics context.
|
protected void |
drawDebug(java.awt.Graphics2D g2,
float x,
float y) |
|
protected void |
drawDebug(java.awt.Graphics2D g2,
float x,
float y,
boolean showDepth) |
|
protected void |
endDraw(java.awt.Graphics2D g2) |
Restores the previous color setting.
|
float |
getDepth() |
Get the depth of this box.
|
Box |
getElderParent() |
|
float |
getHeight() |
Get the height of this box.
|
abstract int |
getLastFontId() |
Get the id of the font that will be used the last when this box will be painted.
|
Box |
getParent() |
|
float |
getShift() |
Get the shift amount for this box.
|
float |
getWidth() |
Get the width of this box.
|
void |
negWidth() |
|
void |
setDepth(float d) |
Set the depth for this box.
|
void |
setElderParent(Box elderParent) |
|
void |
setHeight(float h) |
Set the height for this box.
|
void |
setParent(Box parent) |
|
void |
setShift(float s) |
Set the shift amount for this box.
|
void |
setWidth(float w) |
Set the width for this box.
|
protected void |
startDraw(java.awt.Graphics2D g2,
float x,
float y) |
Stores the old color setting, draws the background of the box (if not null)
and sets the foreground color (if not null).
|
public static boolean DEBUG
protected java.awt.Color foreground
protected java.awt.Color background
protected float width
protected float height
protected float depth
protected float shift
protected int type
protected java.util.LinkedList<Box> children
protected Box parent
protected Box elderParent
protected java.awt.Color markForDEBUG
protected Box()
protected Box(java.awt.Color fg, java.awt.Color bg)
fg
- the foreground colorbg
- the background colorpublic void add(Box b)
b
- the box to be insertedpublic void add(int pos, Box b)
pos
- the position at which to insert the given boxb
- the box to be insertedpublic void setParent(Box parent)
public Box getParent()
public void setElderParent(Box elderParent)
public Box getElderParent()
public float getWidth()
public void negWidth()
public float getHeight()
public float getDepth()
public float getShift()
public void setWidth(float w)
w
- the widthpublic void setDepth(float d)
d
- the depthpublic void setHeight(float h)
h
- the heightpublic void setShift(float s)
s
- the shift amountpublic abstract void draw(java.awt.Graphics2D g2, float x, float y)
g2
- the graphics (2D) context to use for paintingx
- the x-coordinatey
- the y-coordinatepublic abstract int getLastFontId()
protected void startDraw(java.awt.Graphics2D g2, float x, float y)
g2
- the graphics (2D) contextx
- the x-coordinatey
- the y-coordinateprotected void drawDebug(java.awt.Graphics2D g2, float x, float y, boolean showDepth)
protected void drawDebug(java.awt.Graphics2D g2, float x, float y)
protected void endDraw(java.awt.Graphics2D g2)
g2
- the graphics (2D) context