Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Image


      return imageLeft;
    }
    if (imageLeftID == null) {
      return null;
    }
    Image img = null;
    if (suffix == null) {
      img = ImageLoader.getInstance().getImage(imageLeftID);
    } else {
      img = ImageLoader.getInstance().getImage(imageLeftID + suffix);
    }
View Full Code Here


          {
            if ( instance instanceof UISWTInstance ){
             
              UISWTInstance  swt = (UISWTInstance)instance;
             
              Image  image = swt.loadImage( "com/aelitis/azureus/plugins/magnet/icons/magnet.gif" );

              menu1.setGraphic( swt.createGraphic( image ));
              menu2.setGraphic( swt.createGraphic( image ));             
            }
          }
View Full Code Here

    }
    cell.setFillCell(true);
  }

  public void dispose(TableCell cell) {
    Image img = ((TableCellSWT) cell).getGraphicSWT();
    if (img != null && !img.isDisposed())
      img.dispose();
  }
View Full Code Here

    if (x1 < 10 || y1 < 3) {
      dispose(cell);
      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;
    int pxRes = 0;
    long pxBlockStep = 0;
    int factor = 4;

    while (iPixelsPerBlock <= 0) {
      blocksPerPixel++;
      iPixelsPerBlock = (int) ((x1 + 1) / (lNumBlocks / blocksPerPixel));
    }

    pxRes = (int) (x1 - ((lNumBlocks / blocksPerPixel) * iPixelsPerBlock)); // kolik mi zbyde
    if (pxRes <= 0)
      pxRes = 1;
    pxBlockStep = (lNumBlocks * factor) / pxRes; // kolikaty blok na +1 k sirce
    long addBlocks = (lNumBlocks * factor) / pxBlockStep;
    if ((addBlocks * iPixelsPerBlock) > pxRes)
      pxBlockStep += 1;

    /*      String msg = "iPixelsPerBlock = "+iPixelsPerBlock + ", blocksPerPixel = " + blocksPerPixel;
          msg += ", pxRes = " + pxRes + ", pxBlockStep = " + pxBlockStep + ", addBlocks = " + addBlocks + ", x1 = " + x1;
          Debug.out(msg);*/

    TOTorrent torrent = pePiece.getManager().getDiskManager().getTorrent();

    boolean[] written = pePiece.getDMPiece().getWritten();
    boolean piece_written = pePiece.isWritten();
    int drawnWidth = 0;
    int blockStep = 0;

    int pieceNumber = pePiece.getPieceNumber();
    long[] offsets = new long[(int) lNumBlocks];
    long[] lengths = (long[]) offsets.clone();
    Arrays.fill(offsets,
        (long) pePiece.getManager().getDiskManager().getPieceLength()
            * (long) pieceNumber);
    for (int i = 0; i < lNumBlocks; lengths[i] = pePiece.getBlockSize(i), offsets[i] += DiskManager.BLOCK_SIZE * i, i++)
      ;

    boolean[] isCached = cacheStats == null ? null
        : cacheStats.getBytesInCache(torrent, offsets, lengths);

    for (int i = 0; i < lNumBlocks; i += blocksPerPixel) {
      int nextWidth = iPixelsPerBlock;

      blockStep += blocksPerPixel * factor;
      if (blockStep >= pxBlockStep) { // pokud jsem prelezl dany pocet bloku, zvys tomuhle sirku
        nextWidth += (int) (blockStep / pxBlockStep);
        blockStep -= pxBlockStep;
      }

      if (i >= lNumBlocks - blocksPerPixel) { // pokud je posledni, at zasahuje az na konec
        nextWidth = x1 - drawnWidth;
      }
      color = Colors.white;

      if ((written == null && piece_written) || (written != null && written[i])) {

        color = colors[COLOR_WRITTEN];

      } else if (pePiece.isDownloaded(i)) {

        color = colors[COLOR_DOWNLOADED];

      } else if (pePiece.isRequested(i)) {

        color = colors[COLOR_REQUESTED];
      }

      gcImage.setBackground(color);
      gcImage.fillRectangle(drawnWidth + 1, 1, nextWidth, y1);

      if (isCached[i]) {
        gcImage.setBackground(colors[COLOR_INCACHE]);
        gcImage.fillRectangle(drawnWidth + 1, 1, nextWidth, 3);

      }

      drawnWidth += nextWidth;

    }
    gcImage.dispose();
   
    Image oldImage = null;
    Graphic graphic = cell.getGraphic();
    if (graphic instanceof UISWTGraphic) {
      oldImage = ((UISWTGraphic)graphic).getImage();
    }

    if (cell instanceof TableCellSWT) {
      ((TableCellSWT) cell).setGraphic(image);
    } else {
      cell.setGraphic(new UISWTGraphicImpl(image));
    }
    if (oldImage != null && !oldImage.isDisposed())
      oldImage.dispose();

    gcImage.dispose();
  }
View Full Code Here

        return;     
     
      if(bufferScale != null && ! bufferScale.isDisposed())
        bufferScale.dispose();
     
      bufferScale = new Image(drawCanvas.getDisplay(),bounds);
     
      GC gcBuffer = new GC(bufferScale);
      try {
      gcBuffer.drawImage(bufferBackground,0,0);
      gcBuffer.setForeground(Colors.black);
View Full Code Here

       
      //If bufferedImage is not null, dispose it
      if(bufferImage != null && ! bufferImage.isDisposed())
        bufferImage.dispose();
     
      bufferImage = new Image(drawCanvas.getDisplay(),bounds);
     
      GC gcImage = new GC(bufferImage);
     
      gcImage.drawImage(bufferScale,0,0);
     
View Full Code Here

 
  public static void main (String [] args) {
    Display display = new Display ();
    Image[] images = new Image[IMAGES_TO_CREATE];
    for(int i = 0 ; i < IMAGES_TO_CREATE ; i++) {
      images[i] = new Image(display,800,600);
    }
    for(int i = 0 ; i < IMAGES_TO_CREATE ; i++) {
      images[i].dispose();
    }
    display.dispose ();
View Full Code Here

      if(bufferBackground != null && ! bufferBackground.isDisposed())
        bufferBackground.dispose();
     
      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;
View Full Code Here

        is.close();
      } catch (IOException e) {
        Debug.out(e);
      }
       
      return new Image(getDisplay(), imageData);
    }
   
    return null;
  }
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();
    colorChooser.setImage(img);
    if(oldImg != null && ! oldImg.isDisposed())
      oldImg.dispose();
  }
View Full Code Here

TOP

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

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.