Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Color


    }

    public Color getBackground(Object node) {
        if (node instanceof String) {
            return new Color(Display.getCurrent(), 200,200,200);
        }
        return null;
    }
View Full Code Here


  private ColorManager() {   
  }
 
  public Color getColor(RGB rgb) {
    Color color = (Color) _colorTable.get(rgb);
    if (color == null) {
      color = new Color(Display.getCurrent(), rgb);
      _colorTable.put(rgb, color);
    }
    return color;
  }
View Full Code Here

    gcImage.dispose();
    return image;
  }
 
  public static void drawPie(GC gc,int x, int y,int width,int height,int percent) {
    Color background = gc.getBackground();
    gc.setForeground(Colors.blue);
    int angle = (percent * 360) / 100;
    if(angle<4)
      angle = 0; // workaround fillArc rendering bug
    gc.setBackground(Colors.white);
View Full Code Here

                }
               
                log.append( str + "\n" );
              }

              Color   color;

              if ( f_log_type == LOG_NORMAL ){

                color = Colors.black;
View Full Code Here

                start = log.getText().length();
               
                log.append( str );
              }
             
              Color   color;
             
              if ( f_log_type == LOG_NORMAL ){
               
                color = Colors.black;
               
View Full Code Here

      cell.setGraphic(null);
      return;
    }
    Image image = new Image(SWTThread.getInstance().getDisplay(), newWidth,
        newHeight);
    Color color;
    GC gcImage = new GC(image);
    gcImage.setForeground(Colors.grey);
    gcImage.drawRectangle(0, 0, x1 + 1, y1 + 1);
    int blocksPerPixel = 0;
    int iPixelsPerBlock = 0;
View Full Code Here

     
      if(bounds.width > 10000 || bounds.height > 10000) return;
     
      bufferBackground = new Image(drawCanvas.getDisplay(),bounds);
     
      Color colors[] = new Color[4];
      colors[0] = colorWhite;
      colors[1] = lightGrey;
      colors[2] = lightGrey2;
      colors[3] = lightGrey;
      GC gcBuffer = new GC(bufferBackground);
View Full Code Here

      int r = config.getIntParameter(keys[i] + ".red", -1);
      if (r >= 0) {
        int g = config.getIntParameter(keys[i] + ".green");
        int b = config.getIntParameter(keys[i] + ".blue");
       
        Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
        blockColors[i] = color;
      }

      Composite colorSet = new Composite(legend, SWT.NONE);

      colorSet.setLayout(new RowLayout(SWT.HORIZONTAL));

      final Canvas cColor = new Canvas(colorSet, SWT.BORDER);
      cColor.setData("Index", new Integer(i));
      // XXX Use paint instead of setBackgrond, because OSX does translucent
      // crap
      cColor.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
          int i = ((Integer)cColor.getData("Index")).intValue();
          e.gc.setBackground(blockColors[i]);
          e.gc.fillRectangle(e.x, e.y, e.width, e.height);
        }
      });

      cColor.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
          Integer iIndex = (Integer)cColor.getData("Index");
          if (iIndex == null)
            return;
          int index = iIndex.intValue();

          if (e.button == 1) {
            ColorDialog cd = new ColorDialog(panel.getShell());
            cd.setRGB(blockColors[index].getRGB());
           
            RGB rgb = cd.open();
            if (rgb != null)
              config.setRGBParameter(keys[index], rgb.red, rgb.green, rgb.blue);
          } else {
            config.removeRGBParameter(keys[index]);
          }
        }
      });

      Label lblDesc = new Label(colorSet, SWT.NULL);
      Messages.setLanguageText(lblDesc, keys[i]);

      data = new RowData();
      data.width = 20;
      data.height = lblDesc.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 3;
      cColor.setLayoutData(data);
     
      // If color changes, update our legend
      config.addParameterListener(keys[i],paramListeners[i] = new ParameterListener() {
        public void parameterChanged(String parameterName) {
          for (int j = 0; j < keys.length; j++) {
            if (keys[j].equals(parameterName)) {
              final int index = j;

              final int r = config.getIntParameter(keys[j] + ".red", -1);
              if (r >= 0) {
                final int g = config.getIntParameter(keys[j] + ".green");
                final int b = config.getIntParameter(keys[j] + ".blue");
               
                final RGB rgb = new RGB(r, g, b);
                if (blockColors[j].isDisposed()
                    || !rgb.equals(blockColors[j].getRGB())) {

                  Utils.execSWTThread(new AERunnable() {
                    public void runSupport() {
                      if (panel == null || panel.isDisposed())
                        return;
                      Color color = ColorCache.getColor(panel.getDisplay(), r, g, b);
                      blockColors[index] = color;
                      cColor.redraw();
                    }
                  });
                }
View Full Code Here

   
  }
 
  private void updateButtonColor(final Display display, final int rV, final int gV, final int bV) {
    Image oldImg = img;
    Color color = ColorCache.getColor(display, rV, gV, bV);
    img = new Image(display,25,10);
    GC gc = new GC(img);
    gc.setBackground(color);
    gc.fillRectangle(0,0,25,10);
    gc.dispose();
View Full Code Here

     
      hsl.setHue( hue );
     
      hue -= step;
     
      colours[i] = new Color( device, hsl.getRed(), hsl.getGreen(), hsl.getBlue());
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.Color

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.