Exemplo n.º 1
0
 public void paint(Graphics g) {
   if (g instanceof Graphics2D) {
     Graphics2D g2 = (Graphics2D) g;
     g2.setRenderingHint(
         RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   }
   super.paint(g);
 }
Exemplo n.º 2
0
 public void paint(Graphics g) {
   if (comp != null) {
     width = comp.getWidth() / 6;
     height = comp.getHeight() * 2 / 3;
   }
   g.setColor(bgColor);
   g.fillRect(x, y, width, height);
   g.setColor(fgColor);
   g.setFont(font);
   g.drawString(strTray, x / 2 + width / 2, y + height + 10);
   super.paint(g);
 }
Exemplo n.º 3
0
 /*
  *  Create a BufferedImage for Swing components.
  *  All or part of the component can be captured to an image.
  *
  *  @param	 component Swing component to create image from
  *  @param	 region The region of the component to be captured to an image
  *  @param	 fileName name of file to be created or null
  *  @return	image the image for the given region
  *  @exception IOException if an error occurs during writing
  */
 public static BufferedImage createImage(JComponent component, Rectangle region, String fileName)
     throws IOException {
   boolean opaqueValue = component.isOpaque();
   component.setOpaque(true);
   BufferedImage image =
       new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2d = image.createGraphics();
   g2d.setClip(region);
   component.paint(g2d);
   g2d.dispose();
   component.setOpaque(opaqueValue);
   ScreenCapture.writeImage(image, fileName);
   return image;
 }
Exemplo n.º 4
0
  public void paint(Graphics g) {
    super.paint(g);
    if (thumbnail != null) {
      int x = getWidth() / 2 - thumbnail.getIconWidth() / 2;
      int y = getHeight() / 2 - thumbnail.getIconHeight() / 2;
      if (y < 0) {
        y = 0;
      }

      if (x < 5) {
        x = 5;
      }
      thumbnail.paintIcon(this, g, x, y);
    }
  }
Exemplo n.º 5
0
  public void paint(Graphics g) {
    Graphics2D gr = (Graphics2D) g;
    super.paint(g);
    Rectangle bounds = scene.getBounds();
    Dimension size = getSize();

    double sx = bounds.width > 0 ? (double) size.width / bounds.width : 0.0;
    double sy = bounds.width > 0 ? (double) size.height / bounds.height : 0.0;
    double scale = Math.min(sx, sy);

    int vw = (int) (scale * bounds.width);
    int vh = (int) (scale * bounds.height);
    int vx = (size.width - vw) / 2;
    int vy = (size.height - vh) / 2;

    if (image == null || vw != imageWidth || vh != imageHeight) {

      imageWidth = vw;
      imageHeight = vh;
      image = this.createImage(imageWidth, imageHeight);
      Graphics2D ig = (Graphics2D) image.getGraphics();
      ig.scale(scale, scale);
      scene.setRealZoomFactor(scale);
      scene.paint(ig);
      scene.setRealZoomFactor(0.0);
    }

    gr.drawImage(image, vx, vy, this);

    JComponent component = scene.getView();
    double zoomFactor = scene.getZoomFactor();
    Rectangle viewRectangle = component != null ? component.getVisibleRect() : null;
    if (viewRectangle != null) {
      Rectangle window =
          new Rectangle(
              (int) ((double) viewRectangle.x * scale / zoomFactor),
              (int) ((double) viewRectangle.y * scale / zoomFactor),
              (int) ((double) viewRectangle.width * scale / zoomFactor),
              (int) ((double) viewRectangle.height * scale / zoomFactor));
      window.translate(vx, vy);
      gr.setColor(new Color(200, 200, 200, 128));
      gr.fill(window);
      gr.setColor(Color.BLACK);
      gr.drawRect(window.x, window.y, window.width - 1, window.height - 1);
    }
  }
Exemplo n.º 6
0
 @Override
 public void paint(Graphics g) {
   super.paint(g);
 }