Package eu.bandm.tools.d2d2.base
Class SyntaxGraph
java.lang.Object
eu.bandm.tools.d2d2.base.SyntaxGraph
Calculates and paints an extended regex as graphic.
Usage is a little bit redundant, see Def2Doc(3):
s = new SyntaxGraph(Graphics gr);
SizeInfo = s.new Layouter().layout(def);
Image = create writeable image
gri = image, get drawing Graphics
s.setGraphic(gri);
SyntaxGraph.Painter pa = s.new Painter();
SyntaxGraph.RectMap rectMap = pa.paintIt(def, myRefPainter)
The symbols follow the "Wirth"-tradition, and additionally render
the permutation "a & b" like "(a|b)", but with
special triangular symbols as border lines.
Insertions on complex expressions and substitutions are rendered as dashed-line boxes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassFirst phase which calculates the sizes of all sub-terms and their positions relative to the containing term.static classIntended to be overwritten in anonymous subclasses.classClass which does the painting and creates the data structures for the "clickable" image.static classMaps exprssion objects to graphic araes.static interfaceAn instance of this must be plugged into aSyntaxGraph.Painterfor customized representation of references.classDefault implementation which drawas a "3DRect" and the text.static classRepresents the result of a layout sub-process as a TeX-like box model with three length values. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StrokeLine type used to represent "insertion operator" areasprotected Graphics2DNeeded in the layout phase for string size calculation, in the paint phase for drawing.protected Map<Expression, Integer> All positions (inX, outX, y, and more) of each expression are RELATIVE to the enclosing construct.protected final SyntaxGraph.LayoutParametersThe parameters for layout calculaton and drawing.protected final Fontprotected Map<Expression, Integer> protected final Fontprotected final Fontprotected Map<Expression, Integer> protected Map<Expression, Integer> Auxiliary ypos which cannot be easily calculated from contents, e.g.protected Map<Expression, Integer> Auxiliary ypos which cannot be easily calculated from contents, e.g. -
Constructor Summary
ConstructorsConstructorDescriptionSyntaxGraph(Graphics2D graphics2D) Create a processor with the default layout parameters.SyntaxGraph(Graphics2D graphics2D, SyntaxGraph.LayoutParameters layoutParameters) Create a processor with the explicitly given layout parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected intcalcTextWidth(String s, Font f) protected StringvoidsetGraphics(Graphics2D graphics2D) Necessary when the graphics for layouting is different that that for drawing.
-
Field Details
-
layoutParameters
The parameters for layout calculaton and drawing. -
graphics2D
Needed in the layout phase for string size calculation, in the paint phase for drawing. -
inX
All positions (inX, outX, y, and more) of each expression are RELATIVE to the enclosing construct. Therefore, when calculating, the graph data for every expression starts at (0,0) = the upper left edge. When painting, every Expression (before descending into a sub-expression) opens a further AffineTransform, which maps the sub-expression's origin=(0,0) to the coordinates relative to its own origin=(0,0), where the sub-expression shall be positioned. These are the co-ordinates stored here:(0.0) = start of containing expression +...................... | ---------------------------- | \___XXXXXX_____/ _______y | XXXXXX ^ ^ positions of sub-expression XXXXXX inX outX XXXXXX -
outX
- See Also:
-
y
- See Also:
-
y2
Auxiliary ypos which cannot be easily calculated from contents, e.g. for "plus operator" the y pos of the backline; for the "subst operator" the total height of the drawn box. -
y3
Auxiliary ypos which cannot be easily calculated from contents, e.g. for the "subst operator" the upper height of the drawn box. -
mainFont
-
smallFont
-
ttFont
-
dotDashStroke
Line type used to represent "insertion operator" areas
-
-
Constructor Details
-
SyntaxGraph
Create a processor with the explicitly given layout parameters. These can be constructed by selectively overwriting as innew SyntaxGraph (gr, new LayoutParameters(){ { main_font_size = 14 ; } });- Parameters:
graphics2D- can be provisonary, and is used only for text size calculation. Can be replaced by the real painting target for the later painting phase.
-
SyntaxGraph
Create a processor with the default layout parameters.
-
-
Method Details
-
setGraphics
Necessary when the graphics for layouting is different that that for drawing. This is the case when the bounding box of the generated graphics is needed before creating an "Image" object (or sim.) to do the real painting. -
calcTextWidth
-
getTag
-