Пример #1
0
 /**
  * Write the given text string in the current font, centered on (x, y) and rotated by the
  * specified number of degrees
  *
  * @param x the center x-coordinate of the text
  * @param y the center y-coordinate of the text
  * @param s the text
  * @param degrees is the number of degrees to rotate counterclockwise
  */
 public static void text(double x, double y, String s, double degrees) {
   double xs = scaleX(x);
   double ys = scaleY(y);
   offscreen.rotate(Math.toRadians(-degrees), xs, ys);
   text(x, y, s);
   offscreen.rotate(Math.toRadians(+degrees), xs, ys);
 }
Пример #2
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees
   *
   * @param x the center x-coordinate of the image
   * @param y the center y-coordinate of the image
   * @param s the name of the image/picture, e.g., "ball.gif"
   * @param degrees is the number of degrees to rotate counterclockwise
   * @throws RuntimeException if the image is corrupt
   */
  public static void picture(double x, double y, String s, double degrees) {
    Image image = getImage(s);
    double xs = scaleX(x);
    double ys = scaleY(y);
    int ws = image.getWidth(null);
    int hs = image.getHeight(null);
    if (ws < 0 || hs < 0) throw new RuntimeException("image " + s + " is corrupt");

    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(
        image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0), null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);

    draw();
  }
Пример #3
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y), rotated given number of degrees, rescaled
   * to w-by-h.
   *
   * @param x the center x-coordinate of the image
   * @param y the center y-coordinate of the image
   * @param s the name of the image/picture, e.g., "ball.gif"
   * @param w the width of the image
   * @param h the height of the image
   * @param degrees is the number of degrees to rotate counterclockwise
   * @throws RuntimeException if the image is corrupt
   */
  public static void picture(double x, double y, String s, double w, double h, double degrees) {
    Image image = getImage(s);
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(w);
    double hs = factorY(h);
    if (ws < 0 || hs < 0) throw new RuntimeException("image " + s + " is corrupt");
    if (ws <= 1 && hs <= 1) pixel(x, y);

    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(
        image,
        (int) Math.round(xs - ws / 2.0),
        (int) Math.round(ys - hs / 2.0),
        (int) Math.round(ws),
        (int) Math.round(hs),
        null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);

    draw();
  }
Пример #4
0
 /**
  * Returns the text rotation in radians : subclassers that don't support rotating text may return
  * 0 here. Used by TextLayout only.
  */
 protected double getRotation() {
   //			debug(set.getAttribute(TEXT_ROTATION).toString());
   return Math.toRadians(element.getAttribute(TEXT_ROTATION).doubleValue());
 }