Class SyntaxGraph

java.lang.Object
eu.bandm.tools.d2d2.base.SyntaxGraph

public class SyntaxGraph extends Object
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.

  • Field Details

    • layoutParameters

      protected final SyntaxGraph.LayoutParameters layoutParameters
      The parameters for layout calculaton and drawing.
    • graphics2D

      protected Graphics2D graphics2D
      Needed in the layout phase for string size calculation, in the paint phase for drawing.
    • inX

      protected Map<Expression,Integer> 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

      protected Map<Expression,Integer> outX
      See Also:
    • y

      protected Map<Expression,Integer> y
      See Also:
    • y2

      protected Map<Expression,Integer> 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

      protected Map<Expression,Integer> y3
      Auxiliary ypos which cannot be easily calculated from contents, e.g. for the "subst operator" the upper height of the drawn box.
    • mainFont

      protected final Font mainFont
    • smallFont

      protected final Font smallFont
    • ttFont

      protected final Font ttFont
    • dotDashStroke

      public static final Stroke dotDashStroke
      Line type used to represent "insertion operator" areas
  • Constructor Details

    • SyntaxGraph

      public SyntaxGraph(Graphics2D graphics2D, SyntaxGraph.LayoutParameters layoutParameters)
      Create a processor with the explicitly given layout parameters. These can be constructed by selectively overwriting as in
       new 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

      public SyntaxGraph(Graphics2D graphics2D)
      Create a processor with the default layout parameters.
  • Method Details

    • setGraphics

      public void setGraphics(Graphics2D graphics2D)
      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

      protected int calcTextWidth(String s, Font f)
    • getTag

      protected String getTag(Reference ref)