コード例 #1
0
ファイル: Labeller.java プロジェクト: jdeolive/jeo-android
  void render(LineLabel label) {
    tx.reset(canvas);

    String txt = label.getText();

    Paint p = label.get(Paint.class, Paint.class);

    List<LineSegment> path = label.getPath();
    for (int i = 0; i < txt.length(); i++) {
      LineSegment line = path.get(i);

      PointF p0 = tx.getWorldToCanvas().map(line.p0);
      PointF p1 = tx.getWorldToCanvas().map(line.p1);

      double theta = Math.atan((p1.y - p0.y) / (p1.x - p0.x));

      Matrix m = canvas.getMatrix();
      Matrix n = new Matrix(canvas.getMatrix());
      n.preRotate((float) Math.toDegrees(theta), p0.x, p0.y);

      // Paint debug = new Paint();
      // debug.setColor(Color.RED);
      // canvas.drawLine(p0.x, p0.y, p1.x, p1.y, debug);

      canvas.setMatrix(n);
      canvas.drawText(txt, i, i + 1, p0.x, p0.y, p);
      canvas.setMatrix(m);
    }

    tx.apply(canvas);
    // canvas.drawTextOnPath(l.text, l.getPath(), 0, 0, l.get(Paint.class,Paint.class));
  }
コード例 #2
0
ファイル: Labeller.java プロジェクト: jdeolive/jeo-android
  void render(PointLabel label) {
    tx.reset(canvas);

    Paint p = label.get(Paint.class, Paint.class);

    Coordinate a = label.getAnchor();
    PointF f = tx.getWorldToCanvas().map(a);

    canvas.drawText(label.getText(), f.x, f.y, p);

    tx.apply(canvas);
  }