org.scilab.forge.jlatexmath
Class Box
- java.lang.Object
-
- org.scilab.forge.jlatexmath.Box
-
- Direct Known Subclasses:
- CharBox, FcscoreBox, FramedBox, GeoGebraLogoBox, GlueBox, GraphicsBox, HorizontalBox, HorizontalRule, JavaFontRenderingBox, OverBar, OverUnderBox, ReflectBox, RotateBox, ScaleBox, StrutBox
public abstract class Box extends java.lang.ObjectAn 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 methodstartDraw(Graphics2D, float, float)and end with calling the methodendDraw(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 abstractgetLastFontId()method (the last font that will be used when this box will be painted).
-
-
Field Summary
Fields Modifier and Type Field and Description static booleanDEBUG
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidadd(Box b)Inserts the given box at the end of the list of child boxes.voidadd(int pos, Box b)Inserts the given box at the given position in the list of child boxes.abstract voiddraw(java.awt.Graphics2D g2, float x, float y)Paints this box at the given coordinates using the given graphics context.floatgetDepth()Get the depth of this box.BoxgetElderParent()floatgetHeight()Get the height of this box.abstract intgetLastFontId()Get the id of the font that will be used the last when this box will be painted.BoxgetParent()floatgetShift()Get the shift amount for this box.floatgetWidth()Get the width of this box.voidnegWidth()voidsetDepth(float d)Set the depth for this box.voidsetElderParent(Box elderParent)voidsetHeight(float h)Set the height for this box.voidsetParent(Box parent)voidsetShift(float s)Set the shift amount for this box.voidsetWidth(float w)Set the width for this box.
-
-
-
Method Detail
-
add
public void add(Box b)
Inserts the given box at the end of the list of child boxes.- Parameters:
b- the box to be inserted
-
add
public void add(int pos, Box b)Inserts the given box at the given position in the list of child boxes.- Parameters:
pos- the position at which to insert the given boxb- the box to be inserted
-
setParent
public void setParent(Box parent)
-
getParent
public Box getParent()
-
setElderParent
public void setElderParent(Box elderParent)
-
getElderParent
public Box getElderParent()
-
getWidth
public float getWidth()
Get the width of this box.- Returns:
- the width of this box
-
negWidth
public void negWidth()
-
getHeight
public float getHeight()
Get the height of this box.- Returns:
- the height of this box
-
getDepth
public float getDepth()
Get the depth of this box.- Returns:
- the depth of this box
-
getShift
public float getShift()
Get the shift amount for this box.- Returns:
- the shift amount
-
setWidth
public void setWidth(float w)
Set the width for this box.- Parameters:
w- the width
-
setDepth
public void setDepth(float d)
Set the depth for this box.- Parameters:
d- the depth
-
setHeight
public void setHeight(float h)
Set the height for this box.- Parameters:
h- the height
-
setShift
public void setShift(float s)
Set the shift amount for this box.- Parameters:
s- the shift amount
-
draw
public abstract void draw(java.awt.Graphics2D g2, float x, float y)Paints this box at the given coordinates using the given graphics context.- Parameters:
g2- the graphics (2D) context to use for paintingx- the x-coordinatey- the y-coordinate
-
getLastFontId
public abstract int getLastFontId()
Get the id of the font that will be used the last when this box will be painted.- Returns:
- the id of the last font that will be used.
-
-
DMelt 3.0 © DataMelt by jWork.ORG