Example #1
0
 public void drawImage(FSImage image, int x, int y) {
   Image img = ((SWTFSImage) image).getImage();
   if (img == null) {
     int width = image.getWidth();
     int height = image.getHeight();
     Color oldBG = _gc.getBackground();
     Color oldFG = _gc.getForeground();
     _gc.setBackground(_gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
     _gc.setForeground(_gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
     _gc.fillRectangle(x, y, width, height);
     _gc.drawRectangle(x, y, width, height);
     _gc.drawLine(x, y, x + width - 1, y + height - 1);
     _gc.drawLine(x, y + height - 1, x + width - 1, y);
     _gc.setBackground(oldBG);
     _gc.setForeground(oldFG);
   } else {
     Rectangle bounds = img.getBounds();
     _gc.drawImage(
         img, 0, 0, bounds.width, bounds.height, x, y, image.getWidth(), image.getHeight());
   }
 }
Example #2
0
  public void setColor(java.awt.Color color) {
    if (color.equals(_awt_color)) {
      return;
    }

    Color col = new Color(_gc.getDevice(), color.getRed(), color.getGreen(), color.getBlue());
    _gc.setForeground(col);
    _gc.setBackground(col);
    _gc.setAlpha(color.getAlpha());
    if (_color != null) {
      _color.dispose();
    }
    _color = col;
    _awt_color = color;
  }