Пример #1
0
 public void paint(Graphics g, Shape a) {
   Graphics2D g2 = (Graphics2D) g;
   Rectangle2D abounds = a.getBounds2D();
   AffineTransform saveTransform = g2.getTransform();
   Paint savePaint = g2.getPaint();
   try {
     g2.translate(abounds.getX() - bounds.getX(), abounds.getY() - bounds.getY());
     g2.setPaint(Color.BLACK); // FIXME
     p.paint(g2);
   } finally {
     g2.setTransform(saveTransform);
     g2.setPaint(savePaint);
   }
 }
Пример #2
0
  private JPopupTrayIcon createTrayIcon(Dimension size) {
    ImageIcon icon;
    if (size.height < 24) icon = Images.loadIcon("tray16_invert.png");
    else icon = Images.loadIcon("tray24_invert.png");
    BufferedImage img = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D d = img.createGraphics();

    Color color1 = config.getColor("tray.bgColor1", null);
    if (color1 != null) {
      Color color2 = config.getColor("tray.bgColor2", null);

      if (color2 == null) color2 = color1;
      Paint old = d.getPaint();
      d.setPaint(new GradientPaint(0, 0, color1, 0, size.height, color2));
      d.fillRect(0, 0, size.width, size.height);
      d.setPaint(old);
    }

    d.drawImage(icon.getImage(), 0, 0, size.width, size.height, icon.getImageObserver());
    return new JPopupTrayIcon(img);
  }