Exemplo n.º 1
0
  static void drawPathIterator(EpsGraphics eps, double x, double y, PathIterator path) {

    eps.newpath();
    final double coord[] = new double[6];
    while (path.isDone() == false) {
      final int code = path.currentSegment(coord);
      if (code == PathIterator.SEG_MOVETO) {
        eps.moveto(coord[0] + x, coord[1] + y);
      } else if (code == PathIterator.SEG_LINETO) {
        eps.lineto(coord[0] + x, coord[1] + y);
      } else if (code == PathIterator.SEG_CLOSE) {
        eps.closepath();
      } else if (code == PathIterator.SEG_CUBICTO) {
        eps.curveto(
            coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
      } else if (code == PathIterator.SEG_QUADTO) {
        eps.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
      } else {
        throw new UnsupportedOperationException("code=" + code);
      }

      path.next();
    }

    eps.fill(path.getWindingRule());
  }
Exemplo n.º 2
0
  private void drawAsText(
      UText shape, double x, double y, UParam param, EpsGraphics eps, ColorMapper mapper) {
    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    // final FontMetrics fm = g2dummy.getFontMetrics(fontConfiguration.getFont().getFont());
    // final double ypos = y - fm.getDescent() + 0.5;
    final double ypos = y - 1;

    eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
    ((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
  }
Exemplo n.º 3
0
 public void draw(EpsGraphics eps, double x, double y) {
   final boolean dashed = false;
   eps.newpathDot();
   boolean first = true;
   for (CubicCurve2D.Double bez : beziers) {
     bez =
         new CubicCurve2D.Double(
             x + bez.x1,
             y + bez.y1,
             x + bez.ctrlx1,
             y + bez.ctrly1,
             x + bez.ctrlx2,
             y + bez.ctrly2,
             x + bez.x2,
             y + bez.y2);
     if (first) {
       eps.movetoNoMacro(bez.x1, bez.y1);
       first = dashed;
     }
     eps.curvetoNoMacro(bez.ctrlx1, bez.ctrly1, bez.ctrlx2, bez.ctrly2, bez.x2, bez.y2);
   }
   eps.closepathDot();
 }
Exemplo n.º 4
0
 public void drawOk(EpsGraphics eps, double x, double y) {
   boolean first = true;
   for (CubicCurve2D.Double bez : beziers) {
     bez =
         new CubicCurve2D.Double(
             x + bez.x1,
             y + bez.y1,
             x + bez.ctrlx1,
             y + bez.ctrly1,
             x + bez.ctrlx2,
             y + bez.ctrly2,
             x + bez.x2,
             y + bez.y2);
     eps.epsLine(bez.x1, bez.y1, bez.x2, bez.y2);
   }
 }
Exemplo n.º 5
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {

    final UClip clip = clipContainer.getClip();
    if (clip != null && clip.isInside(x, y) == false) {
      return;
    }

    final UText shape = (UText) ushape;

    if (strategy == EpsStrategy.WITH_MACRO_AND_TEXT) {
      drawAsText(shape, x, y, param, eps, mapper);
      return;
    }

    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    final UFont font = fontConfiguration.getFont();

    final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
    eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
    drawPathIterator(eps, x, y, t.getOutline(null).getPathIterator(null));

    if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      eps.setStrokeWidth("1.1", 0, 0);
      eps.epsLine(x, y + 1.5, x + dim.getWidth(), y + 1.5);
      eps.setStrokeWidth("1", 0, 0);
    }
    if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      final int ypos = (int) (y + 2.5) - 1;
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      eps.setStrokeWidth("1.1", 0, 0);
      for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
        eps.epsLine(i, ypos - 0, i + 3, ypos + 1);
        eps.epsLine(i + 3, ypos + 1, i + 6, ypos - 0);
      }
      eps.setStrokeWidth("1", 0, 0);
    }
    if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
      final HtmlColor extended = fontConfiguration.getExtendedColor();
      if (extended != null) {
        eps.setStrokeColor(mapper.getMappedColor(extended));
      }
      final Dimension2D dim =
          DriverTextG2d.calculateDimension(stringBounder, font, shape.getText());
      final FontMetrics fm = g2dummy.getFontMetrics(font.getFont());
      final int ypos = (int) (y - fm.getDescent() - 0.5);
      eps.setStrokeWidth("1.3", 0, 0);
      eps.epsLine(x, ypos, x + dim.getWidth(), ypos);
      eps.setStrokeWidth("1", 0, 0);
    }
  }
Exemplo n.º 6
0
 private static String format(double x) {
   return EpsGraphics.format(x);
 }