コード例 #1
0
 public PaintContext createContext(
     ColorModel cm,
     Rectangle deviceBounds,
     Rectangle2D userBounds,
     AffineTransform xform,
     RenderingHints hints) {
   Point2D transformedPoint = xform.transform(point, null);
   Point2D transformedRadius = xform.deltaTransform(mRadius, null);
   return new RoundGradientContext(
       transformedPoint, mPointColor, transformedRadius, mBackgroundColor);
 }
コード例 #2
0
  /**
   * Method to get the coordinates of the enclosing rectangle after this transformation is applied
   * to the current picture
   *
   * @return the enclosing rectangle
   */
  public Rectangle2D getTransformEnclosingRect(AffineTransform trans) {
    int width = getWidth();
    int height = getHeight();
    double maxX = width - 1;
    double maxY = height - 1;
    double minX, minY;
    Point2D.Double p1 = new Point2D.Double(0, 0);
    Point2D.Double p2 = new Point2D.Double(maxX, 0);
    Point2D.Double p3 = new Point2D.Double(maxX, maxY);
    Point2D.Double p4 = new Point2D.Double(0, maxY);
    Point2D.Double result = new Point2D.Double(0, 0);
    Rectangle2D.Double rect = null;

    // get the new points and min x and y and max x and y
    trans.deltaTransform(p1, result);
    minX = result.getX();
    maxX = result.getX();
    minY = result.getY();
    maxY = result.getY();
    trans.deltaTransform(p2, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());
    trans.deltaTransform(p3, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());
    trans.deltaTransform(p4, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());

    // create the bounding rectangle to return
    rect = new Rectangle2D.Double(minX, minY, maxX - minX + 1, maxY - minY + 1);
    return rect;
  }
コード例 #3
0
ファイル: CSCharacterParser.java プロジェクト: scireum/jpod
 @Override
 protected void basicTextShowGlyphs(PDGlyphs glyphs, float advance) {
   AffineTransform tx;
   tx = (AffineTransform) getDeviceTransform().clone();
   tx.concatenate(textState.globalTransform);
   lastStartX = tx.getTranslateX();
   lastStartY = tx.getTranslateY();
   // get the transformed character bounding box
   double glyphAscent = glyphs.getAscent();
   double glyphDescent = glyphs.getDescent();
   double ascent = (textState.fontSize * glyphAscent) / THOUSAND;
   double descent = (textState.fontSize * glyphDescent) / THOUSAND;
   if (descent > 0) {
     descent = -descent;
   }
   double[] pts = {0, descent, advance, ascent};
   tx.deltaTransform(pts, 0, pts, 0, 2);
   //
   float x = (float) lastStartX;
   float y = (float) (lastStartY + pts[1]);
   float width = (float) pts[2];
   float height = (float) (pts[3] - pts[1]);
   if (width < 0) {
     x += width;
     width = -width;
   }
   if (height < 0) {
     y += height;
     height = -height;
   }
   Rectangle2D charRect = new Rectangle2D.Float(x, y, width, height);
   if (getBounds() == null || getBounds().intersects(charRect)) {
     onCharacterFound(glyphs, charRect);
   }
   // advance text matrix and store position for reference
   super.basicTextShowGlyphs(glyphs, advance);
   tx = (AffineTransform) getDeviceTransform().clone();
   tx.concatenate(textState.globalTransform);
   lastStopX = tx.getTranslateX();
   lastStopY = tx.getTranslateY();
 }