Examples of GC


Examples of org.eclipse.swt.graphics.GC

        tableColumn = (TableColumnCore) row.getDataSource();

        if (event.image != null && !Constants.isLinux) {
          try {
            GC gc = new GC(event.image);
            try {
              Rectangle bounds = event.image.getBounds();
              gc.fillRectangle(bounds);
              String title = MessageText.getString(
                  tableColumn.getTitleLanguageKey(), tableColumn.getName());
              String s = title
                  + " Column will be placed at the location you drop it, shifting other columns down";
              GCStringPrinter sp = new GCStringPrinter(gc, s, bounds, false, false,
                  SWT.CENTER | SWT.WRAP);
              sp.calculateMetrics();
              if (sp.isCutoff()) {
                GCStringPrinter.printString(gc, title, bounds, false, false,
                    SWT.CENTER | SWT.WRAP);
              } else {
                sp.printString();
              }
            } finally {
              gc.dispose();
            }
          } catch (Throwable t) {
            //ignore
          }
        }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

 
  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();
    colorChooser.setImage(img);
    if(oldImg != null && ! oldImg.isDisposed())
      oldImg.dispose();
  }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

    if (internalLoop == 0 || sizeChanged ){
     
      drawPlot();
    }

    GC gc = new GC(canvas);
   
    gc.drawImage(bufferImage,bounds.x,bounds.y);
   
    gc.dispose();  
  }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

        bufferImage.dispose();
      }
     
      bufferImage = new Image( canvas.getDisplay(), bounds );

      GC image = new GC( bufferImage );

      int  max_x = 0;
      int  max_y = 0;
      int  max_z = 0;
     
      for (int i=0;i<values.length;i++){
       
        int[]  entry = (int[])values[i];
       
        if ( entry[0] > max_x ){
         
          max_x = entry[0];
        }
        if ( entry[1] > max_y ){
         
          max_y = entry[1];
        }
        if ( entry[2] > max_z ){
       
          max_z = entry[2];
        }
      }
     
     
      int usable_width   = bounds.width - PAD_LEFT - PAD_RIGHT;
      int usable_height  = bounds.height - PAD_TOP - PAD_BOTTOM;
     
      try {
        image.setAntialias( SWT.ON );
      } catch (Exception e) {
        // Ignore ERROR_NO_GRAPHICS_LIBRARY error or any others
      }
     
      double  x_ratio = ((float)usable_width-((usable_height/2)/ANGLE_TAN)) / max_x;
      double  y_ratio = ((float)usable_height/2) / max_y;
      double  z_ratio = ((float)usable_height/2) / max_z;
     
        // grid
     
      int x_axis_left_x = PAD_LEFT;
      int x_axis_left_y = usable_height + PAD_TOP;
      int x_axis_right_x = PAD_LEFT + usable_width;
      int x_axis_right_y  = usable_height + PAD_TOP;
     

      int y_axis_left_x = PAD_LEFT;
      int y_axis_left_y = usable_height + PAD_TOP;     
      int y_axis_right_x = PAD_LEFT + (int)((usable_height/2) / ANGLE_TAN );
      int y_axis_right_y = usable_height / 2;
     
      int z_axis_bottom_x = PAD_LEFT;
      int z_axis_bottom_y = usable_height + PAD_TOP;
      int z_axis_top_x  = PAD_LEFT;
      int z_axis_top_y  = PAD_TOP + usable_height / 2;
     
      Rectangle old_clip = image.getClipping();

      image.setClipping( new Rectangle( PAD_LEFT, PAD_RIGHT, usable_width, usable_height ));
     
      image.setForeground( Colors.light_grey );

      int  x_lines = 10;
     
      for (int i=1;i<x_lines;i++){
       
        int  x1 = x_axis_left_x + (( y_axis_right_x - y_axis_left_x )*i/x_lines);
        int  y1 = x_axis_left_y - (( y_axis_left_y - y_axis_right_y )*i/x_lines);
       
        int x2 = x_axis_right_x;
        int y2 = y1;
       
        image.drawLine( x1, y1, x2, y2 );
      }
     
      int  y_lines = 10;

      for (int i=1;i<y_lines;i++){
       
        int  x1 = y_axis_left_x + (( x_axis_right_x - x_axis_left_x )*i/x_lines);
        int  y1 = y_axis_left_y;
       
        int x2 = y_axis_right_x + (( x_axis_right_x - x_axis_left_x )*i/x_lines);
        int y2 = y_axis_right_y;
       
        image.drawLine( x1, y1, x2, y2 );
      }
     
      image.setClipping( old_clip );
     
      int  z_lines = 10;

      for (int i=1;i<z_lines;i++){

        int  z = z_axis_bottom_y + ( z_axis_top_y - z_axis_bottom_y )*i/z_lines;

        image.drawLine( z_axis_bottom_x, z, z_axis_bottom_x-4, z );
      }
     
        // now values
     
      for (int i=0;i<values.length;i++){
       
        int[]  entry = (int[])values[i];
       
        int  draw_x = (int)( x_ratio * entry[0] );
        int  draw_y = (int)( y_ratio * entry[1] );
        int  draw_z = (int)( z_ratio * entry[2] );
       
        draw_x += draw_y / ANGLE_TAN;
       
        image.setForeground( colours[(int)(((float)entry[2]/max_z)*(colours.length-1))]);
     
        image.drawLine(
            PAD_LEFT + draw_x,
            PAD_TOP + usable_height - draw_y,
            PAD_LEFT + draw_x,
            PAD_TOP + usable_height - ( draw_y + draw_z ));
      }
       
      image.setForeground( Colors.black );
     
      image.drawRectangle( bounds.x, bounds.y, bounds.width-1, bounds.height-1 );
     
      int  font_height = image.getFontMetrics().getHeight();
      int char_width  = image.getFontMetrics().getAverageCharWidth();
     
        // x axis
     
      image.drawLine( x_axis_left_x, x_axis_left_y, x_axis_right_x, x_axis_right_y );
      image.drawLine( usable_width, x_axis_right_y - 4, x_axis_right_x, x_axis_right_y );
      image.drawLine( usable_width, x_axis_right_y + 4, x_axis_right_x, x_axis_right_y );

      String x_text = labels[0] + " - " + formatters[0].format( max_x );
     
      image.drawText(
          x_text,
          x_axis_right_x - 20 - x_text.length()*char_width,
          x_axis_right_y - font_height - 2,
          SWT.DRAW_TRANSPARENT );
     
        // z axis
     
      String z_text = labels[2] + " - " + formatters[2].format( max_z );
     
      image.drawText( z_text, z_axis_top_x + 4, z_axis_top_y + 10, SWT.DRAW_TRANSPARENT );
     
      image.drawLine( z_axis_bottom_x, z_axis_bottom_y, z_axis_top_x, z_axis_top_y );
      image.drawLine( z_axis_top_x-4, z_axis_top_y + 10, z_axis_top_x, z_axis_top_y );
      image.drawLine( z_axis_top_x+4, z_axis_top_y + 10, z_axis_top_x, z_axis_top_y );

        // y axis
     
      image.drawLine( y_axis_left_x, y_axis_left_y, y_axis_right_x, y_axis_right_y );     
      image.drawLine( y_axis_right_x-6, y_axis_right_y,  y_axis_right_x, y_axis_right_y );     
      image.drawLine( y_axis_right_x, y_axis_right_y + 6, y_axis_right_x, y_axis_right_y );
     
      String  y_text = labels[1] + " - " + formatters[1].format( max_y );
     
      image.drawText(
          y_text,
          y_axis_right_x - (y_text.length() * char_width),
          y_axis_right_y - font_height - 2,
          SWT.DRAW_TRANSPARENT );


      image.drawText( title, ( bounds.width - title.length()*char_width )/2, 1, SWT.DRAW_TRANSPARENT );

      image.dispose();

    }finally{

      this_mon.exit();
    }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

      imageBuffer = new int[drawWidth];
      bImageBufferValid = false;
    }

    Image image = (Image) infoObj.getUserData("PiecesImage");
    GC gcImage;
    boolean bImageChanged;
    Rectangle imageBounds;
    if (image == null || image.isDisposed()) {
      bImageChanged = true;
    } else {
      imageBounds = image.getBounds();
      bImageChanged = imageBounds.width != newWidth
          || imageBounds.height != newHeight;
    }
    if (bImageChanged) {
      if (image != null && !image.isDisposed()) {
        image.dispose();
      }
      image = new Image(SWTThread.getInstance().getDisplay(), newWidth,
          newHeight);
      imageBounds = image.getBounds();
      bImageBufferValid = false;

      // draw border
      gcImage = new GC(image);
      gcImage.setForeground(Colors.grey);
      if (borderHorizontalSize > 0) {
        if (borderVerticalSize > 0) {
          gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1);
        } else {
          gcImage.drawLine(0, 0, newWidth - 1, 0);
          gcImage.drawLine(0, newHeight - 1, newWidth - 1, newHeight - 1);
        }
      } else if (borderVerticalSize > 0) {
        gcImage.drawLine(0, 0, 0, newHeight - 1);
        gcImage.drawLine(newWidth - 1, 0, newWidth - 1, newHeight - 1);
      }

      if (borderSplit > 0) {
        gcImage.setForeground(Colors.white);
        gcImage.drawLine(x0, completionHeight + borderHorizontalSize, x1,
            completionHeight + borderHorizontalSize);
      }
    } else {
      gcImage = new GC(image);
    }

    DiskManager disk_manager = infoObj.getDiskManager();

    DiskManagerPiece[] pieces = disk_manager == null ? null
        : disk_manager.getPieces();

    int nbPieces = infoObj.getNbPieces();

    try {

      int nbComplete = 0;
      int a0;
      int a1 = 0;
      for (int i = 0; i < drawWidth; i++) {
        if (i == 0) {
          // always start out with one piece
          a0 = 0;
          a1 = nbPieces / drawWidth;
          if (a1 == 0)
            a1 = 1;
        } else {
          // the last iteration, a1 will be nbPieces
          a0 = a1;
          a1 = ((i + 1) * nbPieces) / (drawWidth);
        }

        int index;

        if (a1 <= a0) {
          index = imageBuffer[i - 1];
        } else {
          int nbAvailable = 0;
          for (int j = a0; j < a1; j++)
            if (pieces != null && pieces[j].isDone())
              nbAvailable++;
          nbComplete += nbAvailable;
          index = (nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0);
          //System.out.println("i="+i+";nbAvailable="+nbAvailable+";nbComplete="+nbComplete+";nbPieces="+nbPieces+";a0="+a0+";a1="+a1);
        }

        if (!bImageBufferValid || imageBuffer[i] != index) {
          imageBuffer[i] = index;
          bImageChanged = true;
          gcImage.setForeground(index == INDEX_COLOR_NONEAVAIL ? Colors.red
              : Colors.blues[index]);
          gcImage.drawLine(i + x0, y0, i + x0, y1);
        }
      }

      // pieces can sometimes be 0 due to timing or bad torrent (well, there's a bug with a /0 error
      // so it can happen somehow :)

      int limit = nbPieces == 0 ? 0 : ((drawWidth * nbComplete) / nbPieces);

      if (limit < drawWidth) {
        gcImage.setBackground(Colors.blues[Colors.BLUES_LIGHTEST]);
        gcImage.fillRectangle(limit + x0, borderHorizontalSize, x1 - limit,
            completionHeight);
      }

      gcImage.setBackground(Colors.colorProgressBar);
      gcImage.fillRectangle(x0, borderHorizontalSize, limit, completionHeight);
    } catch (Exception e) {
      System.out.println("Error Drawing PiecesItem");
      Debug.printStackTrace(e);
    }
    gcImage.dispose();

    Image oldImage = null;
    Graphic graphic = cell.getGraphic();
    if (graphic instanceof UISWTGraphic) {
      oldImage = ((UISWTGraphic) graphic).getImage();
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

        buffer_image = draw( bounds );
      }

      if ( buffer_image != null ){
       
        GC gc = new GC( canvas );
 
        gc.drawImage( buffer_image, bounds.x, bounds.y );
 
        gc.dispose();  
      }
    }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

      int usable_width   = bounds.width - PAD_LEFT - PAD_RIGHT;
      int usable_height  = bounds.height - PAD_TOP - PAD_BOTTOM;

      Image image = new Image( canvas.getDisplay(), bounds );

      GC gc = new GC( image );

      try {
        gc.setAntialias( SWT.ON );
      } catch (Exception e) {
        // Ignore ERROR_NO_GRAPHICS_LIBRARY error or any others
      }

      int font_height   = gc.getFontMetrics().getHeight();
      int char_width   = gc.getFontMetrics().getAverageCharWidth();


      Color[] colours = plot_views[0].plotGraph.getColours();

      int  max_x     = 0;
      int  max_y     = 0;

      if ( zones.length > 0 ){
      
        int  max_metric  = 0;
 
        for (int i=0;i<zones.length;i++){
 
          SpeedManagerPingZone zone = zones[i];
 
          int  metric   = zone.getMetric();
 
          if ( metric > 0 ){
 
            max_metric = Math.max( max_metric, metric );
 
            max_x = Math.max( max_x, zone.getUploadEndBytesPerSec());
            max_y = Math.max( max_y, zone.getDownloadEndBytesPerSec());
          }
        }

        if ( max_x > 0 && max_y > 0 ){
       
          double x_ratio = (double)usable_width/max_x;
          double y_ratio = (double)usable_height/max_y;
         
          List  texts = new ArrayList();
         
          for (int i=0;i<zones.length;i++){
   
            SpeedManagerPingZone zone = zones[i];
   
            int  metric   = zone.getMetric();
            int  x1    = zone.getUploadStartBytesPerSec();
            int  y1     = zone.getDownloadStartBytesPerSec();
            int  x2     = zone.getUploadEndBytesPerSec();
            int  y2    = zone.getDownloadEndBytesPerSec();
               
            if ( metric > 0 ){
   
              int  colour_index = (int)((float)metric*colours.length/max_metric);
   
              if ( colour_index >= colours.length ){
   
                colour_index = colours.length-1;
              }
   
              gc.setBackground( colours[colour_index] );
   
              int  x     = PAD_LEFT + (int)(x1*x_ratio);
              int  y     = PAD_TOP  + (int)(y1*y_ratio);
              int  width   = (int)Math.ceil((x2-x1+1)*x_ratio);
              int  height  = (int)Math.ceil((y2-y1+1)*y_ratio );
             
              int  y_draw = usable_height + PAD_TOP + PAD_TOP - y - height;
             
              gc.fillRectangle( x, y_draw, width, height );
                 
              int  text_metric = zone.getMetric();
             
              String text = String.valueOf( metric );
               
              int  text_width = text.length()*char_width + 4;
             
              if ( width >= text_width && height >= font_height ){
               

                Rectangle text_rect =
                new Rectangle(
                    x + ((width-text_width)/2),
                    y_draw + ((height-font_height)/2),
                    text_width, font_height );
                 
                  // check for overlap with existing and delete older
               
                Iterator it = texts.iterator();
               
                while( it.hasNext()){
                 
                  Object[]  old = (Object[])it.next();
                 
                  Rectangle old_coords = (Rectangle)old[1];
                 
                  if ( old_coords.intersects( text_rect )){
                 
                    it.remove();
                  }
                }
               
                texts.add( new Object[]{ new Integer( text_metric ), text_rect })
              }
            }
          }
         
            // only do the last 100 texts as things get a little cluttered
         
          int  text_num = texts.size();
         
          for (int i=(text_num>100?(text_num-100):0);i<text_num;i++){
           
            Object[]  entry = (Object[])texts.get(i);
           
            String  str = String.valueOf(entry[0]);
           
            Rectangle  rect = (Rectangle)entry[1];
           
            gc.drawText(str, rect.x, rect.y, SWT.DRAW_TRANSPARENT );
          }
        }
      }
     
        // x axis

      int x_axis_left_x = PAD_LEFT;
      int x_axis_left_y = usable_height + PAD_TOP;

      int x_axis_right_x = PAD_LEFT + usable_width;
      int x_axis_right_y = x_axis_left_y;


      gc.drawLine( x_axis_left_x, x_axis_left_y, x_axis_right_x, x_axis_right_y );
      gc.drawLine( usable_width, x_axis_right_y - 4, x_axis_right_x, x_axis_right_y );
      gc.drawLine( usable_width, x_axis_right_y + 4, x_axis_right_x, x_axis_right_y );

      for (int i=1;i<10;i++){
       
        int  x = x_axis_left_x + ( x_axis_right_x - x_axis_left_x )*i/10;
       
        gc.drawLine( x, x_axis_left_y, x, x_axis_left_y+4 );
      }
     
      SpeedManagerLimitEstimate le = mapper.getEstimatedUploadLimit( false );
     
      if ( le != null ){
       
        gc.setForeground(Colors.grey );
       
        int[][] segs = le.getSegments();
       
        if ( segs.length > 0 ){
         
          int  max_metric   = 0;
          int  max_pos    = 0;
         
          for (int i=0;i<segs.length;i++){
           
            int[]  seg = segs[i];
           
            max_metric   = Math.max( max_metric, seg[0] );
            max_pos     = Math.max( max_pos, seg[2] );
          }
         
          double  metric_ratio   = max_metric==0?1:((float)50/max_metric);
          double  pos_ratio     = max_pos==0?1:((float)usable_width/max_pos);
         
          int  prev_x  = 1;
          int  prev_y  = 1;
         
          for (int i=0;i<segs.length;i++){
           
            int[]  seg = segs[i];
           
            int  next_x   = (int)((seg[1] + (seg[2]-seg[1])/2)*pos_ratio) + 1;
            int  next_y  = (int)((seg[0])*metric_ratio) + 1;
           
            gc.drawLine(
                x_axis_left_x + prev_x,
                x_axis_left_y - prev_y,
                x_axis_left_x + next_x,
                x_axis_left_y - next_y );
                           
            prev_x = next_x;
            prev_y = next_y;
          }
        }
       
        gc.setForeground( Colors.black );
      }
     
      SpeedManagerLimitEstimate[] bad_up = mapper.getBadUploadHistory();
     
      if ( bad_up.length > 0 ){
       
        gc.setLineWidth( 3 );
       
        gc.setForeground( Colors.red );

        for (int i=0;i<bad_up.length;i++){
         
          int speed = bad_up[i].getBytesPerSec();
         
          int  x = max_x == 0?0:(speed * usable_width / max_x);
       
          gc.drawLine(
              x_axis_left_x + x,
              x_axis_left_y - 0,
              x_axis_left_x + x,
              x_axis_left_y - 10 );

        }
       
        gc.setForeground( Colors.black );
       
        gc.setLineWidth( 1 );
      }
     
      String x_text = labels[0] + " - " + formatters[0].format( max_x+1 );

      gc.drawText(   x_text,
              x_axis_right_x - 20 - x_text.length()*char_width,
              x_axis_right_y - font_height - 2,
              SWT.DRAW_TRANSPARENT );

        // y axis

      int y_axis_bottom_x = PAD_LEFT;
      int y_axis_bottom_y = usable_height + PAD_TOP;

      int y_axis_top_x   = PAD_LEFT;
      int y_axis_top_y   = PAD_TOP;

      gc.drawLine( y_axis_bottom_x, y_axis_bottom_y, y_axis_top_x, y_axis_top_y );

      gc.drawLine( y_axis_top_x-4, y_axis_top_y+PAD_TOP,  y_axis_top_x, y_axis_top_y );
      gc.drawLine( y_axis_top_x+4, y_axis_top_y+PAD_TOP,  y_axis_top_x, y_axis_top_y );

      for (int i=1;i<10;i++){
       
        int  y = y_axis_bottom_y + ( y_axis_top_y - y_axis_bottom_y )*i/10;
       
        gc.drawLine( y_axis_bottom_x, y, y_axis_bottom_x-4, y );
      }
     
      le = mapper.getEstimatedDownloadLimit( false );
     
      if ( le != null ){
       
        gc.setForeground(Colors.grey );
       
        int[][] segs = le.getSegments();
       
        if ( segs.length > 0 ){
         
          int  max_metric   = 0;
          int  max_pos    = 0;
         
          for (int i=0;i<segs.length;i++){
           
            int[]  seg = segs[i];
           
            max_metric   = Math.max( max_metric, seg[0] );
            max_pos     = Math.max( max_pos, seg[2] );
          }
         
          double  metric_ratio   = max_metric==0?1:((float)50/max_metric);
          double  pos_ratio     = max_pos==0?1:((float)usable_height/max_pos);
         
          int  prev_x  = 1;
          int  prev_y  = 1;
         
          for (int i=0;i<segs.length;i++){
           
            int[]  seg = segs[i];
           
            int  next_x  = (int)((seg[0])*metric_ratio) + 1;
            int  next_y   = (int)((seg[1] + (seg[2]-seg[1])/2)*pos_ratio) + 1;
           
            gc.drawLine(
              y_axis_bottom_x + prev_x,
              y_axis_bottom_y - prev_y,
              y_axis_bottom_x + next_x,
              y_axis_bottom_y - next_y );
                           
            prev_x = next_x;
            prev_y = next_y;
          }
        }
       
        gc.setForeground( Colors.black );
      }
     
      SpeedManagerLimitEstimate[] bad_down = mapper.getBadDownloadHistory();
     
      if ( bad_down.length > 0 ){
       
        gc.setForeground( Colors.red );

        gc.setLineWidth( 3 );
       
        for (int i=0;i<bad_down.length;i++){
         
          int speed = bad_down[i].getBytesPerSec();
         
          int  y = max_y==0?0:( speed * usable_height / max_y );
       
          gc.drawLine(
                y_axis_bottom_x + 0,
                y_axis_bottom_y - y,
              y_axis_bottom_x + 10,
              y_axis_bottom_y - y );
        }
       
        gc.setForeground( Colors.black );
       
        gc.setLineWidth( 1 );
      }
     
      String  y_text = labels[1] + " - " + formatters[1].format( max_y+1 );

      gc.drawText( y_text, y_axis_top_x+4, y_axis_top_y + 2, SWT.DRAW_TRANSPARENT );

      gc.drawText( title, ( bounds.width - title.length()*char_width )/2, 1, SWT.DRAW_TRANSPARENT );
     
      gc.dispose();

      return( image );
    }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

      img.dispose();
    }
   
    img = new Image(display,size);
   
    GC gc = new GC(img);   
   
    gc.setForeground(white);
    gc.setBackground(white);
   
    gc.fillRectangle(size);
   
    if(SWT.getVersion() >= 3138 && antiAliasingAvailable) {
      try {
        //gc.setTextAntialias(SWT.ON);
        //gc.setAntialias(SWT.ON);
      } catch(Exception e) {
        antiAliasingAvailable = false;
      }
    }
   
   
    gc.setForeground(blue);
    gc.setBackground(white);    
   
    DHTNetworkPosition _ownPosition = self.getNetworkPosition(DHTNetworkPosition.POSITION_TYPE_VIVALDI_V1);

    if ( _ownPosition == null ){
      return;
    }
   
    VivaldiPosition ownPosition = (VivaldiPosition)_ownPosition;
    float ownErrorEstimate = ownPosition.getErrorEstimate();
    HeightCoordinatesImpl ownCoords =
      (HeightCoordinatesImpl) ownPosition.getCoordinates();
   
    gc.drawText("Our error: " + ownErrorEstimate,10,10);
   
    Color black = ColorCache.getColor(display, 0, 0, 0);
    gc.setBackground(black); // Color of the squares

    // Draw all known positions of other contacts
    Iterator iter = contacts.iterator();
    while(iter.hasNext()) {
      DHTControlContact contact = (DHTControlContact) iter.next();
      DHTNetworkPosition _position = contact.getTransportContact().getNetworkPosition(DHTNetworkPosition.POSITION_TYPE_VIVALDI_V1);
      if ( _position == null ){
        continue;
      }
      VivaldiPosition position = (VivaldiPosition)_position;
      HeightCoordinatesImpl coord = (HeightCoordinatesImpl) position.getCoordinates();
      if(coord.isValid()) {
        draw(gc,coord.getX(),coord.getY(),coord.getH(),contact,(int)ownCoords.distance(coord),position.getErrorEstimate());
      }
    }
   
    // Mark our own position
    Color red = ColorCache.getColor(display, 255, 0, 0);
    gc.setForeground(red);
    drawSelf(gc, ownCoords.getX(), ownCoords.getY(),
             ownCoords.getH(), ownErrorEstimate);
   
   
    gc.dispose();
   
    canvas.redraw();
  }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

    if (img != null && !img.isDisposed()) {
      img.dispose();
    }
   
    img = new Image(display,size);
    GC gc = new GC(img);
   
    Color white = ColorCache.getColor(display,255,255,255);
    gc.setForeground(white);
    gc.setBackground(white);
    gc.fillRectangle(size);
   
    Color blue = ColorCache.getColor(display,66,87,104);
    gc.setForeground(blue);
    gc.setBackground(blue);
   
   
   
    Iterator iter = vivaldiPositions.iterator();
    while(iter.hasNext()) {
      VivaldiPosition position  = (VivaldiPosition)iter.next();
      HeightCoordinatesImpl coord = (HeightCoordinatesImpl) position.getCoordinates();
     
      float error = position.getErrorEstimate() - VivaldiPosition.ERROR_MIN;
      if(error < 0) error = 0;
      if(error > 1) error = 1;
      int blueComponent = (int) (255 - error * 255);
      int redComponent = (int) (255*error);
      // Don't use ColorCache, as our color creation is temporary and
      // varying
      Color drawColor = new Color(display,redComponent,50,blueComponent);     
      gc.setForeground(drawColor);
      draw(gc,coord.getX(),coord.getY(),coord.getH());
      drawColor.dispose();
    }
   
    gc.dispose();
   
    canvas.redraw();
  }
View Full Code Here

Examples of org.eclipse.swt.graphics.GC

    layout_data.heightHint = TOP_GRADIENT_HEIGHT;
    window_top.setLayoutData(layout_data);
    window_top.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent arg0) {
        Rectangle rect = shell.getClientArea ();
        GC gc = arg0.gc;
        gc.setForeground (GRADIENT_COLOR_2);
        gc.setBackground (GRADIENT_COLOR_1);
        gc.fillGradientRectangle (rect.x, rect.y, rect.width, rect.height, false);
        Image image = SWTImageRepository.getImage(logo_image);
        gc.drawImage(image, rect.width - image.getImageData().width - 10, 5);
       
        gc.setForeground(new Color(SWTThread.getDisplay(),0,0,0));
        Font font = new Font(display,"Arial",14,SWT.NONE );
        gc.setFont(font);
        gc.drawText(JMConstants.JMULE_NAME, 20, TOP_GRADIENT_HEIGHT / 2 - 15,true);
       
        gc.setForeground(new Color(SWTThread.getDisplay(),0,0,0));
        font = new Font(display,"Arial",10,SWT.NONE );
        gc.setFont(font);
        gc.drawText("Version : " + JMConstants.JMULE_VERSION, 17, TOP_GRADIENT_HEIGHT / 2 + 5,true);
      }
    });
   
    Composite window_content = new Composite(shell,SWT.NONE);
    window_content.setLayoutData(new GridData(GridData.FILL_BOTH));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.