Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.GC


    return btn;
  }

 
  public static int computeFontHeight(Drawable element) {
    GC gc = new GC(element);
      FontMetrics fm = gc.getFontMetrics ();
      gc.dispose();
      return fm.getHeight();
  }
View Full Code Here


    }
    return result;
  }
 
  private int getAvarageCharWith(Control control) {
    GC gc= null;
    try {
      gc= new GC(control);
      return gc.getFontMetrics().getAverageCharWidth();
    } finally {
      if (gc != null)
        gc.dispose();
    }
  }
View Full Code Here

        downloading[availabilties[i]] = true;
    }
   
    Image img = new Image(comp.getDisplay(),pieceDistCanvas.getBounds());
   
    GC gc = new GC(img);

    try
    {
      int stepWidthX = (int) Math.floor(rect.width / upperBound);
      int barGap = 1;
      int barWidth = stepWidthX - barGap - 1;
      int barFillingWidth = barWidth - 1;
      double stepWidthY = 1.0 * (rect.height - 1) / avlPeak;
      int offsetY = rect.height;
     
      gc.setForeground(Colors.green);
      for (int i = 0; i <= connected; i++)
      {
        Color curColor;
        if (i == 0)
          curColor = Colors.colorError;
        else if (i <= seeds)
          curColor = Colors.green;
        else
          curColor = Colors.blues[Colors.BLUES_DARKEST];

         
        gc.setBackground(curColor);
        gc.setForeground(curColor);
       
        if(globalPiecesPerAvailability[i] == 0)
        {
          gc.setLineWidth(2);
          gc.drawLine(stepWidthX * i, offsetY - 1, stepWidthX * (i + 1) - barGap, offsetY - 1);
        } else
        {
          gc.setLineWidth(1);
          if (downloading[i])
            gc.setLineStyle(SWT.LINE_DASH);
          gc.fillRectangle(stepWidthX * i + 1, offsetY - 1, barFillingWidth, (int) (Math.ceil(stepWidthY * datasourcePiecesPerAvailability[i] - 1) * -1));
          gc.drawRectangle(stepWidthX * i, offsetY, barWidth, (int) (Math.ceil(stepWidthY * globalPiecesPerAvailability[i]) + 1) * -1);
        }

        if(i==minAvail)
        {
          gc.setForeground(Colors.blue);
          gc.drawRectangle(stepWidthX*i+1, offsetY-1, barWidth-2, (int)(Math.ceil(stepWidthY*globalPiecesPerAvailability[i]-1))*-1);
        }
       
       
        gc.setLineStyle(SWT.LINE_SOLID);
      }
      gc.setLineWidth(1);
     
     
      CoordinateTransform t = new CoordinateTransform(rect);
      t.shiftExternal(rect.width,0);
      t.scale(-1.0, 1.0);
     
      String[] boxContent = new String[] {
        MessageText.getString("PiecesView.DistributionView.NoAvl"),
        MessageText.getString("PiecesView.DistributionView.SeedAvl"),
        MessageText.getString("PiecesView.DistributionView.PeerAvl"),
        MessageText.getString("PiecesView.DistributionView.RarestAvl",new String[] {globalPiecesPerAvailability[minAvail]+"",minAvail+""}),
        MessageText.getString("PiecesView.DistributionView."+ (isMe? "weHave" : "theyHave")),
        MessageText.getString("PiecesView.DistributionView.weDownload")       
        };

      int charWidth = gc.getFontMetrics().getAverageCharWidth();
      int charHeight = gc.getFontMetrics().getHeight();
      int maxBoxOffsetY = charHeight + 2;
      int maxBoxWidth = 0;
      int maxBoxOffsetX = 0;
      for (int i = 0; i < boxContent.length; i++)
        maxBoxWidth = Math.max(maxBoxWidth, boxContent[i].length());
     
      maxBoxOffsetX = (maxBoxWidth+5) * charWidth;
      maxBoxWidth = ++maxBoxWidth * charWidth;
     
     
      int boxNum = 1;
      gc.setForeground(Colors.colorError);
      gc.setBackground(Colors.background);
      gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
      gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);
     
      boxNum++;
      gc.setForeground(Colors.green);
      gc.setBackground(Colors.background);
      gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
      gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);
     
      boxNum++;
      gc.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
      gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
      gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);
     
      boxNum++;
      gc.setForeground(Colors.blue);
      gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
      gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);
     
      boxNum++;
      gc.setForeground(Colors.black);
      gc.setBackground(Colors.black);
      gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
      gc.fillRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth/2,charHeight);
      gc.setForeground(Colors.grey);
      gc.setBackground(Colors.background);
      gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);
     
      if(isMe)
      {
        boxNum++;
        gc.setForeground(Colors.black);
        gc.setLineStyle(SWT.LINE_DASH);
        gc.drawRectangle(t.x(maxBoxOffsetX),t.y(maxBoxOffsetY*boxNum),maxBoxWidth,charHeight);
        gc.drawString(boxContent[boxNum-1],t.x(maxBoxOffsetX-5),t.y(maxBoxOffsetY*boxNum),true);       
      }
     
      gc.setLineStyle(SWT.LINE_SOLID);
   
    } finally
    {
      gc.dispose();
    }
   
    if (imgToPaint != null) {
      imgToPaint.dispose();
    }
View Full Code Here

      return;
    int[] imageBuffer = (int [])infoObj.getData("PiecesImageBuffer");
    boolean bImageBufferValid = imageBuffer != null && imageBuffer.length == drawWidth;

    Image image = (Image)infoObj.getData("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);
    }

    final BitFlags peerHave = infoObj.getAvailable();
    boolean established = ((PEPeerTransport)infoObj).getConnectionState() == PEPeerTransport.CONNECTION_FULLY_ESTABLISHED;
   
    if (established && peerHave != null && peerHave.flags.length > 0) {
      if (imageBuffer == null || imageBuffer.length != drawWidth) {
        imageBuffer = new int[drawWidth];
      }
        final boolean available[] =peerHave.flags;
    try {
     
      int nbComplete = 0;
      int nbPieces = available.length;
     
      DiskManager disk_manager = infoObj.getManager().getDiskManager();
      DiskManagerPiece[]  pieces = disk_manager==null?null:disk_manager.getPieces();
                     
     
      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;
        int nbNeeded = 0;

        if (a1 <= a0) {
          index = imageBuffer[i - 1];
        } else {
          int nbAvailable = 0;
          for (int j = a0; j < a1; j++) {
            if (available[j]) {
              if (pieces==null || !pieces[j].isDone()) {
                nbNeeded++;
              }
              nbAvailable++;
            }
          }
          nbComplete += nbAvailable;
          index = (nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0);
          if (nbNeeded <= nbAvailable / 2)
            index += INDEX_COLOR_FADEDSTARTS;
        }

        if (imageBuffer[i] != index) {
          imageBuffer[i] = index;
          if (bImageBufferValid) {
            bImageChanged = true;
            if (imageBuffer[i] >= INDEX_COLOR_FADEDSTARTS)
              gcImage.setForeground(Colors.faded[index - INDEX_COLOR_FADEDSTARTS]);
            else
              gcImage.setForeground(Colors.blues[index]);
            gcImage.drawLine(i + x0, y0, i + x0, y1);
          }
        }
      }
      if (!bImageBufferValid) {
        if(established) {
          int iLastIndex = imageBuffer[0];
          int iWidth = 1;
          for (int i = 1; i < drawWidth; i++) {
            if (iLastIndex == imageBuffer[i]) {
              iWidth++;
            } else {
              if (iLastIndex >= INDEX_COLOR_FADEDSTARTS) {
                gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
              } else
                gcImage.setBackground(Colors.blues[iLastIndex]);
              gcImage.fillRectangle(i - iWidth + x0, y0, iWidth, y1 - y0 + 1);
              iWidth = 1;
              iLastIndex = imageBuffer[i];
            }
          }
          if (iLastIndex >= INDEX_COLOR_FADEDSTARTS)
            gcImage.setBackground(Colors.faded[iLastIndex - INDEX_COLOR_FADEDSTARTS]);
          else
            gcImage.setBackground(Colors.blues[iLastIndex]);
          gcImage.fillRectangle(x1 - iWidth + 1, y0, iWidth, y1 - y0 + 1);
          bImageChanged = true;
        }
      }

      int limit = (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 );
    } } else {
        gcImage.setForeground(Colors.grey);
        gcImage.setBackground(Colors.grey);
        gcImage.fillRectangle(x0,y0,newWidth,y1);
    }
    gcImage.dispose();

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

        rs[i] = Math.sqrt(1/(deltaYXs[i] * deltaYXs[i] / (a*a) + deltaYYs[i] * deltaYYs[i] / (b * b)));
        perimeter += rs[i];
      }
    }
    Image buffer = new Image(display,panelSize.x,panelSize.y);
    GC gcBuffer = new GC(buffer);   
    gcBuffer.setBackground(Colors.white);  
    gcBuffer.setForeground(Colors.blue);
    gcBuffer.fillRectangle(0,0,panelSize.x,panelSize.y);

    if(SWT.getVersion() >= 3138 && antiAliasingAvailable) {
      try {
        //gcBuffer.setTextAntialias(SWT.ON);
        //gcBuffer.setAntialias(SWT.ON);
      } catch(Exception e) {
        antiAliasingAvailable = false;
      }
    }
   
    gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDLIGHT]);     
   
    int nbPeers = sortedPeers.length;
   
    int iAngle = 0;
    double currentPerimeter = 0;   
    double angle,r;  

    for(int i = 0 ; i < nbPeers ; i++) {
      PEPeer peer = sortedPeers[i];
      do {
        angle = angles[iAngle];
        r     = rs[iAngle];
        currentPerimeter += r;
        if(iAngle + 1 < NB_ANGLES) iAngle++;
      } while( currentPerimeter < i * perimeter / nbPeers);
           
      angle = (4 * i - nbPeers) * Math.PI  / (2 * nbPeers) - Math.PI / 2;
     
      int[] triangle = new int[6];
     
     
      int percent_received   = peer.getPercentDoneOfCurrentIncomingRequest();
      int percent_sent     = peer.getPercentDoneOfCurrentOutgoingRequest();

        // set up base line state
     

      boolean  drawLine = false;
     
        // unchoked
     
      if ( !peer.isChokingMe() || percent_received >= 0 ){
        gcBuffer.setForeground(Colors.blues[1] );
       drawLine = true;
      }

        // unchoking
     
      if ( !peer.isChokedByMe() || percent_sent >= 0 ){
      gcBuffer.setForeground(Colors.blues[3]);
      drawLine = true;
      }
        
        // receiving from choked peer (fast request in)
     
      if ( !peer.isChokingMe() && peer.isUnchokeOverride() && peer.isInteresting()){
      gcBuffer.setForeground(Colors.green);
      drawLine = true;
      }
     
        // sending to choked peer (fast request out)
     
      if ( peer.isChokedByMe() && percent_sent >= 0 ){
      gcBuffer.setForeground(Colors.green);
      drawLine = true;
      }
     
      if ( drawLine ){
    int x1 = x0 + (int) ( r * deltaYXs[iAngle] );
    int y1 = y0 + (int) ( r * deltaYYs[iAngle] );       
    gcBuffer.drawLine(x0,y0,x1,y1);
      }   
     
     
     
      if(percent_received >= 0) {
        gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
        double r1 = r - r * percent_received / 100;
        triangle[0] = (int) (x0 + (r1-10) * deltaYXs[iAngle] + 0.5);
        triangle[1] = (int) (y0 + (r1-10) * deltaYYs[iAngle] + 0.5);
       
        triangle[2] (int) (x0 + deltaXXs[iAngle] * 4 + (r1) * deltaYXs[iAngle] + 0.5);
        triangle[3] (int) (y0 + deltaXYs[iAngle] * 4 + (r1) * deltaYYs[iAngle] + 0.5);
       
       
        triangle[4] (int) (x0 - deltaXXs[iAngle] * 4 + (r1) * deltaYXs[iAngle] + 0.5);
        triangle[5] (int) (y0 - deltaXYs[iAngle] * 4 + (r1) * deltaYYs[iAngle] + 0.5);
       
        gcBuffer.fillPolygon(triangle);
      }
     
     
     
      if(percent_sent >= 0) {
        gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDLIGHT]);
        double r1 = r * percent_sent / 100;
        triangle[0] = (int) (x0 + r1 * deltaYXs[iAngle] + 0.5);
        triangle[1] = (int) (y0 + r1 * deltaYYs[iAngle] + 0.5);
       
        triangle[2] (int) (x0 + deltaXXs[iAngle] * 4 + (r1-10) * deltaYXs[iAngle] + 0.5);
        triangle[3] (int) (y0 + deltaXYs[iAngle] * 4 + (r1-10) * deltaYYs[iAngle] + 0.5);
       
       
        triangle[4] (int) (x0 - deltaXXs[iAngle] * 4 + (r1-10) * deltaYXs[iAngle] + 0.5);
        triangle[5] (int) (y0 - deltaXYs[iAngle] * 4 + (r1-10) * deltaYYs[iAngle] + 0.5);
        gcBuffer.fillPolygon(triangle);
      }
     
     
     
      int x1 = x0 + (int) (r * deltaYXs[iAngle]);
      int y1 = y0 + (int) (r * deltaYYs[iAngle]);
      gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
      if(peer.isSnubbed()) {
        gcBuffer.setBackground(Colors.grey);
      }
     
      /*int PS = (int) (PEER_SIZE);     
        if (deltaXY == 0) {
          PS = (int) (PEER_SIZE * 2);
        } else {
          if (deltaYY > 0) {
            PS = (int) (PEER_SIZE / deltaXY);
          }
        }*/
      //PieUtils.drawPie(gcBuffer,(x1 - PS / 2),y1 - PS / 2,PS,PS,peer.getPercentDoneInThousandNotation() / 10);
      PieUtils.drawPie(gcBuffer,x1 - PEER_SIZE / 2,y1 - PEER_SIZE / 2,PEER_SIZE,PEER_SIZE,peer.getPercentDoneInThousandNotation() / 10);
     
      //gcBuffer.drawText(peer.getIp() , x1 + 8 , y1 , true);
    }
   
    gcBuffer.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
    PieUtils.drawPie(gcBuffer,x0 - OWN_SIZE / 2 ,y0 - OWN_SIZE / 2,OWN_SIZE,OWN_SIZE,manager.getStats().getCompleted() / 10);
   
    gcBuffer.dispose();
    GC gcPanel = new GC(panel);
    gcPanel.drawImage(buffer,0,0);
    gcPanel.dispose();
    buffer.dispose();  
  }
View Full Code Here

        cell.setGraphic(null);
        return;
      }
     
      piecesImage = new Image(SWTThread.getInstance().getDisplay(), newWidth, newHeight);
      final GC gcImage = new GC(piecesImage);
     
      // dm may be null if this is a skeleton file view
      DownloadManager download_manager = fileInfo.getDownloadManager();
      PEPeerManager peer_manager = download_manager == null ? null : download_manager.getPeerManager();
      PEPiece[] pe_pieces = peer_manager == null ? null : peer_manager.getPieces();
      final long now = SystemTime.getCurrentTime();
     
      if (fileInfo != null && manager != null)
      {
        if (percentDone == 1000)
        {
          gcImage.setForeground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.setBackground(Colors.blues[Colors.BLUES_DARKEST]);
          gcImage.fillRectangle(1, 1, newWidth - 2, newHeight - 2);
        } else
        {
          final int firstPiece = fileInfo.getFirstPieceNumber();
          final int nbPieces = fileInfo.getNbPieces();
          final DiskManagerPiece[] dm_pieces = manager.getPieces();
          bNoRed = true;
          for (int i = 0; i < newWidth; i++)
          {
            final int a0 = (i * nbPieces) / newWidth;
            int a1 = ((i + 1) * nbPieces) / newWidth;
            if (a1 == a0)
              a1++;
            if (a1 > nbPieces && nbPieces != 0)
              a1 = nbPieces;
            int nbAvailable = 0;
            boolean written = false;
            boolean partially_written = false;
            if (firstPiece >= 0)
              for (int j = a0; j < a1; j++)
              {
                final int this_index = j + firstPiece;
                final DiskManagerPiece dm_piece = dm_pieces[this_index];
                if (dm_piece.isDone())
                  nbAvailable++;
                if (written)
                  continue;
                if (pe_pieces != null)
                {
                  PEPiece pe_piece = pe_pieces[this_index];
                  if (pe_piece != null)
                    written = written || (pe_piece.getLastDownloadTime(now) + 500) > last_draw_time;
                }
                if ((!written) && (!partially_written))
                {
                  final boolean[] blocks = dm_piece.getWritten();
                  if (blocks != null)
                    for (int k = 0; k < blocks.length; k++)
                      if (blocks[k])
                      {
                        partially_written = true;
                        break;
                      }
                }
              } // for j
            else
              nbAvailable = 1;
            gcImage.setBackground(written ? Colors.red : partially_written ? Colors.grey : Colors.blues[(nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0)]);
            gcImage.fillRectangle(i, 1, 1, newHeight - 2);
            if (written)
              bNoRed = false;
          }
          gcImage.setForeground(Colors.grey);
        }
      } else
        gcImage.setForeground(Colors.grey);
     
      if (manager != null)
        gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1);
      gcImage.dispose();
     
      last_draw_time = now;
     
      if (cell instanceof TableCellSWT)
        ((TableCellSWT) cell).setGraphic(piecesImage);
View Full Code Here

      Rectangle bounds = super.getBounds();
     
      int wInside = bounds.width - (marginWidth * 2);
      int hInside = bounds.height - (marginHeight * 2);
      Image imageCellBG = new Image(Display.getDefault(), wInside, hInside);
      GC gc = new GC(imageCellBG);
      gc.drawImage(imageRowBG, bounds.x + marginWidth, 0 + marginHeight,
          wInside, hInside, 0, 0, wInside, hInside);
      gc.dispose();
     
      return imageCellBG;
    }
   
    TableOrTreeSWT table = row.getTable();
   
    Rectangle bounds = super.getBounds();
   
    if (bounds.isEmpty()) {
      return null;
    }
   
    Image image = new Image(Display.getDefault(), bounds.width
        - (marginWidth * 2), bounds.height - (marginHeight * 2));
   
    GC gc = new GC(image);
    gc.setForeground(getBackground());
    gc.setBackground(getBackground());
    gc.fillRectangle(0, 0, bounds.width, bounds.height);
    gc.dispose();
   
    return image;
  }
View Full Code Here

    consoleText.setLayoutData(gd);

    // XXX This doesn't work well, but it's better than nothing
    consoleText.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event event) {
        GC gc = new GC(consoleText);
        int charWidth = gc.getFontMetrics().getAverageCharWidth();
        gc.dispose();

        int areaWidth = consoleText.getBounds().width;
        consoleText.setTabs(areaWidth / 6 / charWidth);
      }
    });
View Full Code Here

    private Image createGradientImage(int height, Display display) {
        int width= 50;

        Image result= new Image(display, width, height);

        GC gc= new GC(result);

        Color colorC= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 35, display);
        Color colorD= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 45, display);
        Color colorE= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 80, display);
        Color colorF= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_LIST_BACKGROUND, 70, display);
        Color colorG= createColor(SWT.COLOR_WIDGET_BACKGROUND, SWT.COLOR_WHITE, 45, display);
        Color colorH= createColor(SWT.COLOR_WIDGET_NORMAL_SHADOW, SWT.COLOR_LIST_BACKGROUND, 35, display);

        try {
            drawLine(width, 0, colorC, gc);
            drawLine(width, 1, colorC, gc);

            gc.setForeground(colorD);
            gc.setBackground(colorE);
            gc.fillGradientRectangle(0, 2, width, 2 + 8, true);

            gc.setBackground(colorE);
            gc.fillRectangle(0, 2 + 9, width, height - 4);

            drawLine(width, height - 3, colorF, gc);
            drawLine(width, height - 2, colorG, gc);
            drawLine(width, height - 1, colorH, gc);

        } finally {
            gc.dispose();

            colorC.dispose();
            colorD.dispose();
            colorE.dispose();
            colorF.dispose();
View Full Code Here

*/
public class PieUtils {

  private static Image computePie(Display display,int width,int height,int percent) {
    Image image = new Image(display,width,height);
    GC gcImage = new GC(image);
    gcImage.setForeground(Colors.blue);
    int angle = (percent * 360) / 100;
    gcImage.setBackground(Colors.blues[Colors.BLUES_MIDDARK]);
    gcImage.fillArc(0,0,width,height,90-angle,angle);
    gcImage.drawOval(0 , 0 , width-1, height-1);
    gcImage.dispose();
    return image;
  }
View Full Code Here

TOP

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

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.