Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Image


    Object ds = cell.getDataSource();
    if (noIconForYou(ds, cell)) {
      return;
    }
    boolean canStream = PlayUtils.canStreamDS(ds, -1);
    Image img = canStream ? imgEnabled : imgDisabled;

    if (!canStream && PlayUtils.canPlayDS(ds, -1)) {
      return;
    }

    Rectangle cellBounds = cell.getBounds();

    if (img != null && !img.isDisposed()) {
      Rectangle imgBounds = img.getBounds();
      gc.drawImage(img, cellBounds.x
          + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
          + ((cellBounds.height - imgBounds.height) / 2));
    }
  }
View Full Code Here


   */
  public ColumnUnopened(String tableID) {
    super(COLUMN_ID, tableID);
   
    if (graphicCheck == null) {
      Image img = ImageLoader.getInstance().getImage("image.unopened");
      graphicCheck = new UISWTGraphicImpl(img);
    }
    if (graphicUnCheck == null) {
      Image img = ImageLoader.getInstance().getImage("image.opened");
      graphicUnCheck = new UISWTGraphicImpl(img);
    }

    if (graphicsProgress == null) {
     
View Full Code Here

    if (isShare) {
      image_name += "_shared";
    }

    ImageLoader imageLoader = ImageLoader.getInstance();
    Image img = imageLoader.getImage(image_name);

    try {
      Rectangle cellBounds = cell.getBounds();
 
      if (img != null && !img.isDisposed()) {
        Rectangle imgBounds = img.getBounds();
        gc.drawImage(img, cellBounds.x
            + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
            + ((cellBounds.height - imgBounds.height) / 2));
      }
    } finally {
View Full Code Here

    // Named infoObj so code can be copied easily to the other PiecesItem
    DownloadManager infoObj = (DownloadManager) cell.getDataSource();
    if (infoObj == null)
      return;

    Image img = (Image) infoObj.getUserData("PiecesImage");
    if (img != null && !img.isDisposed())
      img.dispose();

    infoObj.setUserData("PiecesImageBuffer", null);
    infoObj.setUserData("PiecesImage", null);
  }
View Full Code Here

    if (imageBuffer == null || imageBuffer.length != drawWidth) {
      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();
    }
    if (bImageChanged || image != oldImage || !cell.isValid()) {
View Full Code Here

      final int  PAD_LEFT  = 10;

      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 );
View Full Code Here

          && (cell instanceof TableCellSWT)) {
        String path = dm.getDownloadState().getPrimaryFile();
        if (path != null) {
          // Don't ever dispose of PathIcon, it's cached and may be used elsewhere
          TOTorrent torrent = dm.getTorrent();
          Image icon = ImageRepository.getPathIcon(path, false, torrent != null
              && !torrent.isSimpleTorrent());
          ((TableCellSWT) cell).setIcon(icon);
        }
      }
    }
View Full Code Here

  private void disposeCellIcon(TableCell cell) {
    if (!(cell instanceof TableCellSWT)) {
      return;
    }
    final Image img = ((TableCellSWT) cell).getIcon();
    if (img != null) {
      ((TableCellSWT) cell).setIcon(null);
      if (!img.isDisposed()) {
        img.dispose();
      }
    }
  }
View Full Code Here

   
    if (img != null && !img.isDisposed()) {
      img.dispose();
    }
   
    img = new Image(display,size);
   
    GC gc = new GC(img);   
   
    gc.setForeground(white);
    gc.setBackground(white);
View Full Code Here

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