public abstract class ViewNode
extends java.lang.Object
implements java.lang.Cloneable
Operation Node
and are also organized as nodes forming a tree.Modifier and Type | Field and Description |
---|---|
protected ViewNode[] |
m_children
The child nodes of this view node.
|
protected java.text.DecimalFormat |
m_format |
protected OpNode |
m_master
The master node, the model of this view
|
protected java.awt.Graphics2D |
OFFLINEGRAPHICS
Used for temporary offline-rendering (e.g. determining the size of the panel)
|
Constructor and Description |
---|
ViewNode() |
Modifier and Type | Method and Description |
---|---|
protected static java.awt.geom.Rectangle2D |
centerHorizontally(java.awt.geom.Rectangle2D frame,
double left,
double right,
double y)
A utility method that returns a rectangle that is horizontally centered
betwwen
left and right and has y
as upper boundary. |
java.lang.Object |
clone()
Create a "deep copy" of the subtree rooted by this node.
|
ViewNodeMetrics |
draw(java.awt.Graphics2D g2,
double xPos,
double yPos,
int printFlags)
Draws the expression represented by this node onto
g2 using
position (xPos, yPos) as lower left corner. |
protected abstract ViewNodeMetrics |
drawExpression(java.awt.Graphics2D g2,
double xPos,
double yPos,
int printFlags)
Draws the actual expression without parentheses, factor and exponent
|
protected ViewNodeMetrics |
drawFactor(java.awt.Graphics2D g2,
double xPos,
double yPos,
int printFlags)
Draws the factor of the expression represented by this node.
|
protected static ViewNodeMetrics |
drawParenShape(java.awt.Graphics2D g2,
double xPos,
double yPos,
java.lang.String glyph,
ViewNodeMetrics expressionMetrics)
Draws the parenthesis specified by
glyph onto g2 , using
(xPos,yPos) as lower left corner. |
protected static java.awt.geom.Rectangle2D |
drawText(java.awt.Graphics2D g2,
double xPos,
double yPos,
java.lang.String text)
Draws
text onto g2 beginning using position (xPos, yPos)
as lower left corner. |
double |
getBaseline()
Returns the baseline for the expression represented by this node.
|
java.awt.geom.Rectangle2D |
getBounds()
Returns the overall bounds of the expression represented by this node.
|
java.text.DecimalFormat |
getDecimalFormat()
Returns the display format for decimal (i.e.
|
protected OpNode |
getMaster()
Return the
net.mumie.mathletfactory.algebra.op.node.OpNode , that
is the model for this view node. |
ViewNodeMetrics |
getMetrics()
Returns the bounds covering the rendered text of this node
|
protected static double |
getSpacer(java.awt.Graphics2D g2)
this method is used for creating a small "dotwide" space depending on
the current font.
|
void |
setChildren(ViewNode[] children)
Inserts the argument as children for this node.
|
void |
setDecimalFormat(java.text.DecimalFormat format)
Sets the given display format for decimal (i.e.
|
void |
setMaster(OpNode node)
Sets the
OpNode that this node is the view for. |
java.lang.String |
toString()
Returns {@link net.mumie.mathletfactory.algebra.op.node.OpNode#toString master.toString()}.
|
protected OpNode m_master
protected ViewNode[] m_children
protected java.text.DecimalFormat m_format
protected final java.awt.Graphics2D OFFLINEGRAPHICS
public ViewNodeMetrics getMetrics()
public void setMaster(OpNode node)
OpNode
that this node is the view for.public void setChildren(ViewNode[] children)
protected abstract ViewNodeMetrics drawExpression(java.awt.Graphics2D g2, double xPos, double yPos, int printFlags)
protected ViewNodeMetrics drawFactor(java.awt.Graphics2D g2, double xPos, double yPos, int printFlags)
draw(java.awt.Graphics2D, double, double, int)
before the actual expression is drawn.public ViewNodeMetrics draw(java.awt.Graphics2D g2, double xPos, double yPos, int printFlags)
g2
using
position (xPos, yPos) as lower left corner.protected static ViewNodeMetrics drawParenShape(java.awt.Graphics2D g2, double xPos, double yPos, java.lang.String glyph, ViewNodeMetrics expressionMetrics)
glyph
onto g2
, using
(xPos,yPos) as lower left corner. expressionMetrics
is used for the
height of the parenthesis.protected OpNode getMaster()
net.mumie.mathletfactory.algebra.op.node.OpNode
, that
is the model for this view node.public double getBaseline()
public java.awt.geom.Rectangle2D getBounds()
protected static java.awt.geom.Rectangle2D drawText(java.awt.Graphics2D g2, double xPos, double yPos, java.lang.String text)
text
onto g2
beginning using position (xPos, yPos)
as lower left corner.protected static java.awt.geom.Rectangle2D centerHorizontally(java.awt.geom.Rectangle2D frame, double left, double right, double y)
left
and right
and has y
as upper boundary.public java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
protected static double getSpacer(java.awt.Graphics2D g2)
public java.lang.String toString()
toString
in class java.lang.Object
public void setDecimalFormat(java.text.DecimalFormat format)
NumberView.DEFAULT_PATTERN
is used.public java.text.DecimalFormat getDecimalFormat()
Further documentation and examples can be found under www.mathletfactory.de.