|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.scilab.forge.jlatexmath.Box
public abstract class Box
An abstract graphical representation of a formula, that can be painted. All characters, font sizes, positions are fixed. Only special Glue boxes could possibly stretch or shrink. A box has 3 dimensions (width, height and depth), can be composed of other child boxes that can possibly be shifted (up, down, left or right). Child boxes can also be positioned outside their parent's box (defined by it's dimensions).
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).
Field Summary | |
---|---|
protected java.awt.Color |
background
The background color of the whole box. |
protected java.util.LinkedList<Box> |
children
List of child boxes |
protected float |
depth
The depth of this box, i.e. |
protected java.awt.Color |
foreground
The foreground color of the whole box. |
protected float |
height
The height of this box, i.e. |
protected float |
shift
The shift amount: the meaning depends on the particular kind of box (up, down, left, right) |
protected float |
width
The width of this box, i.e. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
void |
add(Box b)
Inserts the given box at the end of the list of child boxes. |
void |
add(int pos,
Box b)
Inserts the given box at the given position in 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 |
endDraw(java.awt.Graphics2D g2)
Restores the previous color setting. |
float |
getDepth()
Get the depth of this box. |
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. |
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 |
setHeight(float h)
Set the height for this box. |
void |
setShift(float s)
Set the shift amount 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). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.Color foreground
protected java.awt.Color background
protected float width
protected float height
protected float depth
protected float shift
protected java.util.LinkedList<Box> children
Constructor Detail |
---|
protected Box()
protected Box(java.awt.Color fg, java.awt.Color bg)
fg
- the foreground colorbg
- the background colorMethod Detail |
---|
public 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 float getWidth()
public void negWidth()
public float getHeight()
public float getDepth()
public float getShift()
public 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 endDraw(java.awt.Graphics2D g2)
g2
- the graphics (2D) context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |