Examples of GC


Examples of com.ponysdk.core.instruction.GC

            final Long parentObjectID = parentObjectIDByReferences.remove(reference);
            referenceByObjectID.remove(objectID);
            if (log.isDebugEnabled()) log.debug("Removing reference on object #" + objectID);

            if (parentObjectID != null) {
                Txn.get().getTxnContext().save(new GC(objectID, parentObjectID));
            }
        }
    }
View Full Code Here

Examples of com.sun.jna.examples.unix.X11.GC

            final X11 x11 = X11.INSTANCE;
            Rectangle bounds = raster.getBounds();
            int width = bounds.x + bounds.width;
            int height = bounds.y + bounds.height;
            final Pixmap pm = x11.XCreatePixmap(dpy, win, width, height, 1);
            final GC gc = x11.XCreateGC(dpy, pm, new NativeLong(0), null);
            if (gc == null) {
                return null;
            }
            x11.XSetForeground(dpy, gc, new NativeLong(0));
            x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
View Full Code Here

Examples of com.sun.jna.platform.unix.X11.GC

            final X11 x11 = X11.INSTANCE;
            Rectangle bounds = raster.getBounds();
            int width = bounds.x + bounds.width;
            int height = bounds.y + bounds.height;
            final Pixmap pm = x11.XCreatePixmap(dpy, win, width, height, 1);
            final GC gc = x11.XCreateGC(dpy, pm, new NativeLong(0), null);
            if (gc == null) {
                return null;
            }
            x11.XSetForeground(dpy, gc, new NativeLong(0));
            x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
View Full Code Here

Examples of org.eclipse.jgit.internal.storage.file.GC

import org.eclipse.jgit.lib.TextProgressMonitor;

class Gc extends TextBuiltin {
  @Override
  protected void run() throws Exception {
    GC gc = new GC((FileRepository) db);
    gc.setProgressMonitor(new TextProgressMonitor());
    gc.gc();
  }
View Full Code Here

Examples of org.eclipse.jgit.storage.file.GC

  @Override
  public Properties call() throws GitAPIException {
    checkCallable();

    GC gc = new GC((FileRepository) repo);
    gc.setProgressMonitor(monitor);
    if (this.expire != null)
      gc.setExpire(expire);

    try {
      gc.gc();
      return toProperties(gc.getStatistics());
    } catch (IOException e) {
      throw new JGitInternalException(JGitText.get().gcFailed, e);
    } catch (ParseException e) {
      throw new JGitInternalException(JGitText.get().gcFailed, e);
    }
View Full Code Here

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

Examples of org.eclipse.swt.graphics.GC

    }
    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

Examples of org.eclipse.swt.graphics.GC

        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

Examples of org.eclipse.swt.graphics.GC

      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

Examples of org.eclipse.swt.graphics.GC

        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
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.