Example #1
0
 public void tree(Graphics2D g2d, double size, int phase) {
   g2d.setColor(colors[phase % 3]);
   new TextLayout(theT.toString(), theFont, g2d.getFontRenderContext()).draw(g2d, 0.0f, 0.0f);
   if (size > 10.0) {
     AffineTransform at = new AffineTransform();
     at.setToTranslation(Twidth, -0.1);
     at.scale(0.6, 0.6);
     g2d.transform(at);
     size *= 0.6;
     new TextLayout(theR.toString(), theFont, g2d.getFontRenderContext()).draw(g2d, 0.0f, 0.0f);
     at.setToTranslation(Rwidth + 0.75, 0);
     g2d.transform(at);
     Graphics2D g2dt = (Graphics2D) g2d.create();
     at.setToRotation(-Math.PI / 2.0);
     g2dt.transform(at);
     tree(g2dt, size, phase + 1);
     g2dt.dispose();
     at.setToTranslation(.75, 0);
     at.rotate(-Math.PI / 2.0);
     at.scale(-1.0, 1.0);
     at.translate(-Twidth, 0);
     g2d.transform(at);
     tree(g2d, size, phase);
   }
   g2d.setTransform(new AffineTransform());
 }
Example #2
0
  /**
   * Paints the transcoded SVG image on the specified graphics context.
   *
   * @param g Graphics context.
   */
  private void paint(Graphics2D g) {
    Shape shape = null;

    float origAlpha = 1.0f;

    java.util.LinkedList<AffineTransform> transformations =
        new java.util.LinkedList<AffineTransform>();

    //
    transformations.offer(g.getTransform());
    g.transform(new AffineTransform(1.0666667f, 0, 0, 1.0666667f, 0, 0));

    // _0

    // _0_0

    // _0_0_0
    shape = new GeneralPath();
    ((GeneralPath) shape).moveTo(44.85476, 13.658783);
    ((GeneralPath) shape).lineTo(39.8797, 18.833183);
    ((GeneralPath) shape).lineTo(62.034473, 24.087093);
    ((GeneralPath) shape).lineTo(56.182423, 2.2196937);
    ((GeneralPath) shape).lineTo(51.25553, 7.156234);
    ((GeneralPath) shape).curveTo(23.11004, -15.968987, -18.852411, 21.698124, 9.346271, 53.566833);
    ((GeneralPath) shape).curveTo(34.37855, 75.45358, 62.938217, 55.468464, 62.84925, 31.573273);
    ((GeneralPath) shape).lineTo(53.94392, 31.646673);
    ((GeneralPath) shape).curveTo(53.04116, 50.485714, 32.096634, 60.792103, 16.790325, 48.184963);
    ((GeneralPath) shape)
        .curveTo(-3.4530144, 28.782303, 21.423546, -2.7391064, 44.85476, 13.658743);
    ((GeneralPath) shape).closePath();

    g.setPaint(color);
    g.fill(shape);

    g.setTransform(transformations.poll()); // _0
  }