Beispiel #1
0
  // draw method
  public synchronized void draw(Graphics2D g) {
    int w = s.getWidth();
    int h = s.getHeight();

    image.x %= w;
    image.y %= h;

    if (image.x < 0) {
      image.x += w;
    } else {
    }

    if (image.y < 0) {
      image.y += h;
    } else {
    }

    int x = image.x;
    int y = image.y;

    g.drawImage(bg, x, y, null);
    g.drawImage(bg, x - w, y, null);
    g.drawImage(bg, x, y - h, null);
    g.drawImage(bg, x - w, y - h, null);
  }
Beispiel #2
0
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = ((Graphics2D) g);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
    g2d.setRenderingHint(
        RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
    g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
    g2d.setColor(Color.BLACK);
    g2d.fillRect(0, 0, getWidth(), getHeight());

    if (bufferedImage != null) {
      synchronized (LOCKER) {
        g2d.drawImage(bufferedImage, transformCells, null);
      }
    }
    // draw struct preview
    if (structurePreview != null) {
      Composite composite = g2d.getComposite();
      g2d.setComposite(compositeStructPreview);
      g2d.drawImage(structurePreview, previewTransform, null);
      g2d.setComposite(composite);
    }
    // draw grid
    if (transformCells.getScaleX() > SHOW_GRID_MIN_SCALE) {
      Composite composite = g2d.getComposite();
      g2d.setComposite(compositeGrid);
      g2d.drawImage(bufferedImageGrid, transformGrid, null);
      g2d.setComposite(composite);
    }
    // draw border for preview
    if (structurePreview != null && Math.abs(transformCells.getScaleX()) >= 0.95) {
      Shape shape = new Rectangle(0, 0, structurePreview.getWidth(), structurePreview.getHeight());
      shape = previewTransform.createTransformedShape(shape);
      g2d.setColor(Color.RED);
      g2d.draw(shape);
    }

    // draw border
    double x = transformCells.getTranslateX();
    double y = transformCells.getTranslateY();

    g2d.setColor(BORDER_COLOR);
    g2d.setStroke(new BasicStroke(BORDER_WIDTH));
    g2d.drawRect(
        round(x - BORDER_WIDTH),
        round(y - BORDER_WIDTH),
        round(getAutomatonWidth() * transformCells.getScaleX() + 2 * BORDER_WIDTH),
        round(getAutomatonHeight() * transformCells.getScaleY() + 2 * BORDER_WIDTH));
  }
Beispiel #3
0
  // =========================================================== paintComponent
  @Override
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g; // Downcast to Graphics2D

    // ... One time initialization of in-memory, saved image.
    if (_bufImage == null) {
      // ... This is the first time, initialize _bufImage
      int w = this.getWidth();
      int h = this.getHeight();
      _bufImage = (BufferedImage) this.createImage(w, h);
      Graphics2D gc = _bufImage.createGraphics();
      gc.setColor(COLOR_BACKGROUND);
      gc.fillRect(0, 0, w, h); // fill in background
    }

    // ... Display the saved image.
    g2.drawImage(_bufImage, null, 0, 0);

    // ... Overwrite the screen display with currently dragged image.
    if (_state == State.DRAGGING) {
      // ... Write shape that is being dragged over the screen image,
      //    but not into the saved buffered image.  It will be written
      //    on the saved image when the mouse is released.
      drawCurrentShape(g2);
    }
  }
  public static void saveJPG(Image img, String s) {
    BufferedImage bi =
        new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(img, null, null);

    FileOutputStream out = null;
    try {
      out = new FileOutputStream(s);
    } catch (java.io.FileNotFoundException io) {
      System.out.println("File Not Found");
    }

    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(0.5f, false);
    encoder.setJPEGEncodeParam(param);

    try {
      encoder.encode(bi);
      out.close();
    } catch (java.io.IOException io) {
      System.out.println("IOException");
    }
  }
 public void render(int w, int h, Graphics2D g2) {
   int iw = img[imgIndex].getWidth(null);
   int ih = img[imgIndex].getHeight(null);
   BufferedImage bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
   biop[opsIndex].filter(img[imgIndex], bi);
   g2.drawImage(bi, 0, 0, w, h, null);
 }
  private void drawSelection(Graphics2D g2d) {
    if (srcx != destx || srcy != desty) {
      int x1 = (srcx < destx) ? srcx : destx;
      int y1 = (srcy < desty) ? srcy : desty;
      int x2 = (srcx > destx) ? srcx : destx;
      int y2 = (srcy > desty) ? srcy : desty;

      rectSelection.x = x1;
      rectSelection.y = y1;
      rectSelection.width = (x2 - x1) + 1;
      rectSelection.height = (y2 - y1) + 1;
      if (rectSelection.width > 0 && rectSelection.height > 0) {
        g2d.drawImage(scr_img.getSubimage(x1, y1, x2 - x1 + 1, y2 - y1 + 1), null, x1, y1);
      }

      g2d.setColor(selFrameColor);
      g2d.setStroke(bs);
      g2d.draw(rectSelection);
      int cx = (x1 + x2) / 2;
      int cy = (y1 + y2) / 2;
      g2d.setColor(selCrossColor);
      g2d.setStroke(_StrokeCross);
      g2d.drawLine(cx, y1, cx, y2);
      g2d.drawLine(x1, cy, x2, cy);

      if (Screen.getNumberScreens() > 1) {
        drawScreenFrame(g2d, srcScreenId);
      }
    }
  }
Beispiel #7
0
  public void drawScreen() {
    Graphics2D g = (Graphics2D) this.getGraphics();

    g.drawImage(buffer, 0, 0, this);
    Toolkit.getDefaultToolkit().sync();
    g.dispose();
  }
 protected void drawImageMosaic(Graphics2D g2) {
   // Break the image up into tiles. Draw each
   //   tile with its own transparency, allowing
   //   the background to show through to varying
   //   degrees.
   int side = 36;
   int width = mImage.getWidth();
   int height = mImage.getHeight();
   for (int y = 0; y < height; y += side) {
     for (int x = 0; x < width; x += side) {
       // Calculate an appropriate transparency value.
       float xBias = (float) x / (float) width;
       float yBias = (float) y / (float) height;
       float alpha = 1.0f - Math.abs(xBias - yBias);
       g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
       // Draw the subimage.
       int w = Math.min(side, width - x);
       int h = Math.min(side, height - y);
       BufferedImage tile = mImage.getSubimage(x, y, w, h);
       g2.drawImage(tile, x, y, null);
     }
   }
   // Reset the composite.
   g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
 }
Beispiel #9
0
 public static BufferedImage convertToARGB(BufferedImage image) {
   BufferedImage newImage =
       new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
   Graphics2D g = newImage.createGraphics();
   g.drawImage(image, 0, 0, null);
   g.dispose();
   return newImage;
 }
 @Override
 public void paint(Graphics g) {
   if (scr_img != null) {
     Graphics2D g2dWin = (Graphics2D) g;
     if (bi == null) {
       bi = new BufferedImage(scrOCP.getW(), scrOCP.getH(), BufferedImage.TYPE_INT_RGB);
     }
     Graphics2D bfG2 = bi.createGraphics();
     bfG2.drawImage(scr_img_darker, 0, 0, this);
     drawMessage(bfG2);
     drawSelection(bfG2);
     g2dWin.drawImage(bi, 0, 0, this);
     setVisible(true);
   } else {
     setVisible(false);
   }
 }
 ////////////////////////////////////////////////////////////////////////////
 // Paint
 //
 public synchronized void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   // Graphics2D buffGraphics2 = (Graphics2D) buffGraphics;
   //    g2.drawImage(bImage, 3, 3, getWidth() - 3, getHeight() - 3,
   //        0, 0, iWidth, iHeight, null);
   g2.drawImage(bImage, 0, 0, iWidth, iHeight, null);
   g2.drawString(String.valueOf(System.currentTimeMillis()), 10, 10);
 }
  public Image cutMeeple() {
    _meeple = new ImageIcon("meeple.gif").getImage();
    BufferedImage blankCanvas = new BufferedImage(80, 80, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) blankCanvas.getGraphics();

    g2.drawImage(_meeple, 0, 0, 80, 80, 130, 5, 174, 52, this);
    return blankCanvas;
  }
Beispiel #13
0
  public void paint(Graphics gOld) {
    if (image == null || xsize != getSize().width || ysize != getSize().height) {
      xsize = getSize().width;
      ysize = getSize().height;
      image = createImage(xsize, ysize);
      g = (Graphics2D) image.getGraphics();
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    // fill background
    g.setColor(Color.cyan);
    g.fillRect(0, 0, xsize, ysize);

    int x[] = {getX(0), getX(getWidth2()), getX(getWidth2()), getX(0), getX(0)};
    int y[] = {getY(0), getY(0), getY(getHeight2()), getY(getHeight2()), getY(0)};
    // fill border
    g.setColor(Color.black);
    g.fillPolygon(x, y, 4);
    // draw border
    g.setColor(Color.red);
    g.drawPolyline(x, y, 5);
    if (animateFirstTime) {
      gOld.drawImage(image, 0, 0, null);
      return;
    }
    if (gameOver) return;
    g.drawImage(outerSpaceImage, getX(0), getY(0), getWidth2(), getHeight2(), this);
    for (int index = 0; index < missile.length; index++) {
      if (missile[index].active) {
        g.setColor(Color.red);
        drawCircle(getX(missile[index].xPos), getYNormal(missile[index].yPos), 90, .3, 1.5);
      }
    }
    if (rocketRight) {
      drawRocket(rocketImage, getX(rocketXPos), getYNormal(rocketYPos), 0.0, 2.0, 2.0);
    } else {
      drawRocket(rocketImage, getX(rocketXPos), getYNormal(rocketYPos), 0.0, -2.0, 2.0);
    }
    for (int index = 0; index < numStars; index++) {
      g.setColor(Color.yellow);
      if (starActive[index])
        drawCircle(getX(starXPos[index]), getYNormal(starYPos[index]), 0, 1.5, 1.5);
    }
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("Score: " + score, 10, 45);
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("HighScore: " + highScore, 300, 45);
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("Lives: " + rocketLife, 150, 45);
    if (rocketLife == 0) {
      g.setColor(Color.red);
      g.setFont(new Font("Impact", Font.BOLD, 60));
      g.drawString("GAME OVER", getX(getWidth2() / 6), getYNormal(getHeight2() / 2));
    }
    gOld.drawImage(image, 0, 0, null);
  }
 public static BufferedImage resize(BufferedImage image, int width, int height) {
   BufferedImage bi = new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
   Graphics2D g2d = (Graphics2D) bi.createGraphics();
   g2d.addRenderingHints(
       new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
   g2d.drawImage(image, 0, 0, width, height, null);
   g2d.dispose();
   return bi;
 }
Beispiel #15
0
  public void paint(Graphics g) {
    super.paint(g);

    Graphics2D g2 = (Graphics2D) g;
    int size =
        Math.min(
            MAX_SIZE,
            Math.min(
                getWidth() - imagePadding.left - imagePadding.right,
                getHeight() - imagePadding.top - imagePadding.bottom));

    g2.translate(getWidth() / 2 - size / 2, getHeight() / 2 - size / 2);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    Shape shape;

    if (mode == ColorPicker.SAT || mode == ColorPicker.BRI) {
      shape = new Ellipse2D.Float(0, 0, size, size);
    } else {
      Rectangle r = new Rectangle(0, 0, size, size);
      shape = r;
    }

    if (hasFocus()) {
      PaintUtils.paintFocus(g2, shape, 5);
    }

    if (!(shape instanceof Rectangle)) {
      // paint a circular shadow
      g2.translate(2, 2);
      g2.setColor(new Color(0, 0, 0, 20));
      g2.fill(new Ellipse2D.Float(-2, -2, size + 4, size + 4));
      g2.setColor(new Color(0, 0, 0, 40));
      g2.fill(new Ellipse2D.Float(-1, -1, size + 2, size + 2));
      g2.setColor(new Color(0, 0, 0, 80));
      g2.fill(new Ellipse2D.Float(0, 0, size, size));
      g2.translate(-2, -2);
    }

    g2.drawImage(image, 0, 0, size, size, 0, 0, size, size, null);

    if (shape instanceof Rectangle) {
      Rectangle r = (Rectangle) shape;
      PaintUtils.drawBevel(g2, r);
    } else {
      g2.setColor(new Color(0, 0, 0, 120));
      g2.draw(shape);
    }

    g2.setColor(Color.white);
    g2.setStroke(new BasicStroke(1));
    g2.draw(new Ellipse2D.Float(point.x - 3, point.y - 3, 6, 6));
    g2.setColor(Color.black);
    g2.draw(new Ellipse2D.Float(point.x - 4, point.y - 4, 8, 8));

    g.translate(-imagePadding.left, -imagePadding.top);
  }
  public Image rotateImage(Image tilePiece, int degree) {

    ImageIcon icon = new ImageIcon(tilePiece);
    BufferedImage blankCanvas = new BufferedImage(80, 80, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) blankCanvas.getGraphics();
    g2.rotate(Math.toRadians(degree), 40, 40);
    g2.drawImage(tilePiece, 0, 0, this);
    return blankCanvas;
  }
 private void paintItems(Graphics2D g2d) {
   for (Item item : c.getAllStuff()) {
     if (item != null) {
       if (item.flicker()) {
         g2d.drawImage(
             item.getImage(), item.getPosition().getX(), item.getPosition().getY(), this);
       }
     }
   }
 }
  // Takes resource name and returns button
  public JButton createButton(String name, String toolTip) {

    // load the image
    String imagePath = "./resources/" + name + ".png";
    ImageIcon iconRollover = new ImageIcon(imagePath);
    int w = iconRollover.getIconWidth();
    int h = iconRollover.getIconHeight();

    // get the cursor for this button
    Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);

    // make translucent default image
    Image image = createCompatibleImage(w, h, Transparency.TRANSLUCENT);
    Graphics2D g = (Graphics2D) image.getGraphics();
    Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f);
    g.setComposite(alpha);
    g.drawImage(iconRollover.getImage(), 0, 0, null);
    g.dispose();
    ImageIcon iconDefault = new ImageIcon(image);

    // make a pressed image
    image = createCompatibleImage(w, h, Transparency.TRANSLUCENT);
    g = (Graphics2D) image.getGraphics();
    g.drawImage(iconRollover.getImage(), 2, 2, null);
    g.dispose();
    ImageIcon iconPressed = new ImageIcon(image);

    // create the button
    JButton button = new JButton();
    button.addActionListener(this);
    button.setIgnoreRepaint(true);
    button.setFocusable(false);
    button.setToolTipText(toolTip);
    button.setBorder(null);
    button.setContentAreaFilled(false);
    button.setCursor(cursor);
    button.setIcon(iconDefault);
    button.setRolloverIcon(iconRollover);
    button.setPressedIcon(iconPressed);

    return button;
  }
 public void paint(Graphics g) {
   synchronized (this) {
     Graphics2D g2d = (Graphics2D) g;
     if (img != null) {
       int imgw = img.getWidth();
       int imgh = img.getHeight();
       g2d.setComposite(AlphaComposite.Src);
       g2d.drawImage(img, null, 0, 0);
     }
   }
 }
Beispiel #20
0
 public static BufferedImage cropImage(BufferedImage bi, int x, int y, int w, int h) {
   BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2 = image.createGraphics();
   g2.setRenderingHint(
       RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
   g2.setPaint(Color.white);
   g2.fillRect(0, 0, w, h);
   g2.drawImage(bi, -x, -y, null); // this);
   g2.dispose();
   return image;
 }
Beispiel #21
0
  /**
   * Draw picture (gif, jpg, or png) centered on (x, y).
   *
   * @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"
   * @throws RuntimeException if the image is corrupt
   */
  public static void picture(double x, double y, String s) {
    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.drawImage(
        image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0), null);
    draw();
  }
Beispiel #22
0
 protected void drawImage(
     Graphics2D g,
     BufferedImage image,
     int dx1,
     int dy1,
     int dx2,
     int dy2,
     int sx1,
     int sy1,
     int sx2,
     int sy2) {
   g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
 }
  public void drawImageCentred(Graphics g, Image image) {
    if (element != null) {
      Graphics2D g2 = (Graphics2D) g;
      Rectangle r = element.jGetBounds();

      int mitteX = r.width / 2;
      int mitteY = r.height / 2;
      int imageMitteX = image.getWidth(null) / 2;
      int imageMitteY = image.getHeight(null) / 2;

      g2.drawImage(image, r.x + mitteX - imageMitteX, r.y + mitteY - imageMitteY, null);
    }
  }
Beispiel #24
0
 public static BufferedImage scaleImage(BufferedImage bi, double scale) {
   int w1 = (int) (Math.round(scale * bi.getWidth()));
   int h1 = (int) (Math.round(scale * bi.getHeight()));
   BufferedImage image = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2 = image.createGraphics();
   g2.setRenderingHint(
       RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
   g2.setPaint(Color.white);
   g2.fillRect(0, 0, w1, h1);
   g2.drawImage(bi, 0, 0, w1, h1, null); // this);
   g2.dispose();
   return image;
 }
    private void updatePipette() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog != null && pickerDialog.isShowing()) {
        Point mouseLoc = updateLocation();
        if (mouseLoc == null) return;
        final Color c = getPixelColor(mouseLoc);
        if (!c.equals(getColor()) || !mouseLoc.equals(myPreviousLocation)) {
          setColor(c);
          myPreviousLocation.setLocation(mouseLoc);
          myCaptureRect.setBounds(
              mouseLoc.x - HOT_SPOT.x + SIZE / 2 - 2, mouseLoc.y - HOT_SPOT.y + SIZE / 2 - 2, 5, 5);

          BufferedImage capture = myRobot.createScreenCapture(myCaptureRect);

          // Clear the cursor graphics
          myGraphics.setComposite(AlphaComposite.Src);
          myGraphics.setColor(UIUtil.TRANSPARENT_COLOR);
          myGraphics.fillRect(0, 0, myImage.getWidth(), myImage.getHeight());

          myGraphics.drawImage(
              capture, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // cropping round image
          myGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));
          myGraphics.drawImage(
              myMaskImage, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // paint magnifier
          myGraphics.setComposite(AlphaComposite.SrcOver);

          UIUtil.drawImage(
              myGraphics, myPipetteImage, SIZE - AllIcons.Ide.Pipette.getIconWidth(), 0, this);

          pickerDialog.setCursor(
              myParent.getToolkit().createCustomCursor(myImage, HOT_SPOT, "ColorPicker"));
          notifyListener(c, 300);
        }
      }
    }
      public Example(BufferedImage image) {
        // copy image
        int width = image.getWidth();
        int height = image.getHeight();
        this.image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = this.image.createGraphics();
        g2.drawImage(image, 0, 0, null);
        g2.dispose();

        // create icon
        if (Math.max(width, height) > ICON_SIZE) {
          double scale = Math.min((double) ICON_SIZE / width, (double) ICON_SIZE / height);
          width *= scale;
          height *= scale;
        }
        BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        g2 = buf.createGraphics();
        g2.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g2.drawImage(image, 0, 0, width, height, null);
        g2.dispose();
        this.icon = new ImageIcon(buf);
      }
 private void paintLifes(Graphics2D g2d) {
   int lifes = c.getLifes();
   for (int i = 0; i < lifes; i++) {
     ImageIcon imageIcon =
         new ImageIcon(
             ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife()));
     Life life =
         ItemFactory.createLife(
             Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(),
             0,
             imageIcon);
     g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this);
   }
 }
Beispiel #28
0
 public static BufferedImage rotateImage(BufferedImage bi) {
   int w = bi.getWidth();
   int h = bi.getHeight();
   BufferedImage image = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2 = image.createGraphics();
   g2.setRenderingHint(
       RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
   g2.setPaint(Color.white); // getBackground());
   g2.fillRect(0, 0, h, w);
   g2.rotate(90 * Math.PI / 180);
   g2.drawImage(bi, 0, -h, w, h, null); // this);
   g2.dispose();
   return image;
 }
    @Override
    protected void paintComponent(Graphics g) {
      super.paintComponent(g);

      g = g.create();
      try {
        AntialiasingManager.activateAntialiasing(g);

        Graphics2D g2 = (Graphics2D) g;

        if (bgImage != null) g2.drawImage(bgImage.getImage(), 30, 30, null);

        g2.drawImage(
            ImageLoader.getImage(ImageLoader.AUTH_WINDOW_BACKGROUND),
            0,
            0,
            this.getWidth(),
            this.getHeight(),
            null);
      } finally {
        g.dispose();
      }
    }
Beispiel #30
0
  public void drawRocket(
      Image image, int xpos, int ypos, double rot, double xscale, double yscale) {
    int width = rocketImage.getWidth(this);
    int height = rocketImage.getHeight(this);
    g.translate(xpos, ypos);
    g.rotate(rot * Math.PI / 180.0);
    g.scale(xscale, yscale);

    g.drawImage(image, -width / 2, -height / 2, width, height, this);

    g.scale(1.0 / xscale, 1.0 / yscale);
    g.rotate(-rot * Math.PI / 180.0);
    g.translate(-xpos, -ypos);
  }