Class SyntaxGraph.Painter

Enclosing class:
SyntaxGraph

public class SyntaxGraph.Painter extends SinglePhase
Class which does the painting and creates the data structures for the "clickable" image.
  • Field Details

    • backgroundColor

      protected Color backgroundColor
      Stored costructor parameter
    • rectMap

      protected SyntaxGraph.RectMap rectMap
      Visitor result register: the map from areas to Strings, for clickability.
    • refPainter

      protected SyntaxGraph.RefPainter refPainter
      The object used to paint references.
    • normalStroke

      protected final Stroke normalStroke
      Line type for all normal lines and boxes.
    • tightStroke

      protected final Stroke tightStroke
      Line type for operators without any intervening whitespace, like "~+" and "~". Is broader than the normal line.
  • Constructor Details

    • Painter

      public Painter()
  • Method Details

    • paintIt

      public SyntaxGraph.RectMap paintIt(Expression expr, @Opt @Opt SyntaxGraph.RefPainter refPainter, Color backgroundColor)
      Central Service Access: Paint the complete expression tree. Initial coordinate system is the image to create.
      All compound expressions update the affine transform state according to their own SyntaxGraph.y and SyntaxGraph.inX positions, then draw their (more or less complex) line systems and descend into the sub-expressions.
      All simple expressions do not change the affine transform state, but use their stored coordinate to paramtrize draw commands. (But they could do it also via the transform state.)
      Parameters:
      expr - expression which shall be printed
      refPainter - used to paint the references. If ==null, a default will be used.
      Returns:
      the map of areas for to be clickable
    • drawArc

      void drawArc(int xc, int yc, int quad, boolean isTight)
      Draw a quarter of a circle.
      Parameters:
      xc - x coordinate of center
      yc - y coordinate of center
      quad - quadrant to paint, in mathematical numbering
      isTight - whether to draw with a bold line
    • drawLine

      void drawLine(int x0, int y0, int x1, int y1, boolean isTight)
      Draw a straight line.
      Parameters:
      x0 - x coordinate of start
      y0 - y coordinate of start
      x1 - x coordinate of end
      y1 - y coordinate of end
      isTight - whether to draw with a bold line
    • shiftCoordinates

      AffineTransform shiftCoordinates(int x, int y)
      Add a new transformation to the transformation pipeline and return its former state.
    • action

      public void action(Pcdata ref)
      Paint the graphic representation of pc-data content.
      Overrides:
      action in class SinglePhase
    • paintMetaBox

      void paintMetaBox(Expression exp, Expression sub, String text)
      Paint a dashed box for insertion/substitution/greediness.
      Parameters:
      exp - the higher expression
      sub - the contained expression
      text - to print
    • action

      public void action(Insertion ins)
      Render an insertion. Either as a dashed box araound an expression, or simply containing the name of a reference.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Greedy greedy)
      Render a greedy operator as a dashed and decorated box around the contained expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Subst subst)
      Render a substituion operator as a dashed and decorated box around the contained expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Reference ref)
      Render a reference. Calls processReferring(Expression,String,boolean,boolean)
      Overrides:
      action in class SinglePhase
    • paintPassline

      void paintPassline(int xw, int y_inout, boolean hasBackline, boolean istight)
      Draws a pass-line (for creating epsilon) and additionally a back-line beneath, iff selected. Assumes that this fact has already been respected when calculating the y_in and y_out coordinates and the y-coordinates of the sub-object !
    • paintOptOrStar

      void paintOptOrStar(GrUnary x, boolean isStar, boolean istight)
      Paint an option- or star-expresion.
    • action

      public void action(Opt opt)
      Paint an option-expresion.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Star star)
      Paint a star-expresion.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Plus plus)
      Paint an plus-expresion.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Alt alt)
      Paint an alt-expresion. Assumes that alt.on is not a singleton, not "deprivated".
      Overrides:
      action in class SinglePhase
    • drawtriangle

      protected void drawtriangle(int x0, int x1, int x2, int y0, int y1, int y2)
      Draw a triangle which frames the Perm-expression.
    • action

      public void action(Perm perm)
      Overrides:
      action in class SinglePhase
    • action

      public void action(Seq seq)
      Paint a seq-expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharSetConst cs)
      Paint a character set constant.
      Overrides:
      action in class SinglePhase
    • paintCharBin

      protected void paintCharBin(CharBinary bin, String operator)
      Paint a character set binaryoperator.
    • action

      public void action(CharMinus exp)
      Paint a character set binaryoperator.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharJoin exp)
      Paint a character set binaryoperator.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharCut exp)
      Paint a character set binaryoperator.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharRange exp)
      Paint a character set binaryoperator.
      Overrides:
      action in class SinglePhase
    • action

      public void action(ParseParticle pp)
      Paint the graphical representation of a tag-generating parse particle in a character parser.
      Overrides:
      action in class SinglePhase
    • action

      public void action(StringConst sc)
      Paint the graphical representation of a String constant.
      Overrides:
      action in class SinglePhase