Beispiel #1
0
    public PlainPDFLine(BasePDFGraphicsContext context) {
      this.context = context;
      lineEmitter.addTrackedProperty(
          iLinearGraphicsContext.strokeColor_v,
          new iMetric<Vector4, Vector4>() {
            public float distance(Vector4 from, Vector4 to) {
              if (from == null || to == null) return 0;
              float d = from.distanceFrom(to);
              return d;
            }
          });

      lineEmitter.setCanEmitCubic(false);
    }
Beispiel #2
0
  public void drawInto(
      CachedLine line,
      Dict properties,
      iDynamicMesh outputLine,
      iLinearGraphicsContext context,
      SmallLineEmitter lineEmitter) {

    CachedLineCursor cursor = new CachedLineCursor(line);

    line.finish();

    if (outputLine != null) outputLine.open();
    Vector2 a = new Vector2();
    Vector2 b = new Vector2();
    Vector2 c1 = new Vector2();
    Vector2 c2 = new Vector2();
    lineEmitter.begin();
    while (cursor.hasNextSegment()) {
      if (outputLine instanceof DynamicLine) ((DynamicLine) outputLine).startLine();
      if (outputLine instanceof SubLine) ((SubLine) outputLine).getLine().startLine();
      lineEmitter.beginContour();
      while (cursor.hasNextInSpline()) {

        if (cursor.nextIsCubic()) {
          if (cursor.nextCubicFrame(a, c1, c2, b)) {
            lineEmitter.flattenCubicFrame(
                a,
                c1,
                c2,
                b,
                lineEmitter.packet(cursor.getCurrent()),
                lineEmitter.packet(cursor.getAfter()),
                properties,
                context,
                0);
          }
        } else {

          if (cursor.nextLinearFrame(a, b)) {
            lineEmitter.flattenLinearFrame(
                a,
                b,
                lineEmitter.packet(cursor.getCurrent()),
                lineEmitter.packet(cursor.getAfter()),
                properties,
                context,
                0);
          }
        }

        cursor.next();
      }
      if (outputLine instanceof DynamicLine) ((DynamicLine) outputLine).endLine();
      if (outputLine instanceof SubLine) ((SubLine) outputLine).getLine().endLine();
      lineEmitter.endContour();

      if (cursor.hasNextSegment()) cursor.next();
    }
    lineEmitter.end();
    if (outputLine != null) outputLine.close();
  }