Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Rectangle


      return;
    }
  }
 
  public void cellPaint(GC gc, TableCellSWT cell) {
    Rectangle bounds = cell.getBounds();
   
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image viewImage = imageLoader.getImage("ic_view");
    if(imageWidth == -1 || imageHeight == -1) {
      imageWidth = viewImage.getBounds().width;
View Full Code Here


  // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.plugins.ui.tables.TableCell)
  public void cellPaint(GC gc, TableCellSWT cell) {
    VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource();

    Rectangle cellBounds = cell.getBounds();
    Image img = entry.getReadOn() <= 0 ? imgNew : imgOld;

    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

  // @see org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.ui.swt.views.table.TableCellSWT)
  public void cellPaint(GC gc, final TableCellSWT cell) {
    Object ds = cell.getDataSource();

    Rectangle cellBounds = cell.getBounds();

    Image[] imgThumbnail = TorrentUIUtilsV3.getContentImage(ds,
        cellBounds.width >= 20 && cellBounds.height >= 20,
        new ContentImageLoadedListener() {
          public void contentImageLoaded(Image image, boolean wasReturned) {
            if (!wasReturned) {
              // this may be triggered many times, so only invalidate and don't
              // force a refresh()
              cell.invalidate();
            }
          }
        });

    if (imgThumbnail == null) {
      // don't need to release a null image
      return;
    }

    if (cellBounds.height > 30) {
      cellBounds.y += 2;
      cellBounds.height -= 4;
    }

    Rectangle imgBounds = imgThumbnail[0].getBounds();

    int dstWidth;
    int dstHeight;
    if (imgBounds.height > cellBounds.height) {
      dstHeight = cellBounds.height;
      dstWidth = imgBounds.width * cellBounds.height / imgBounds.height;
    } else if (imgBounds.width > cellBounds.width)  {
      dstWidth = cellBounds.width - 4;
      dstHeight = imgBounds.height * cellBounds.width / imgBounds.width;
    } else {
      dstWidth = imgBounds.width;
      dstHeight = imgBounds.height;
    }

    try {
      gc.setAdvanced(true);
      gc.setInterpolation(SWT.HIGH);
    } catch (Exception e) {
    }
    int x = cellBounds.x + ((cellBounds.width - dstWidth + 1) / 2);
    int y = cellBounds.y + ((cellBounds.height - dstHeight + 1) / 2);
    if (dstWidth > 0 && dstHeight > 0 && !imgBounds.isEmpty()) {
      Rectangle dst = new Rectangle(x, y, dstWidth, dstHeight);
      Rectangle lastClipping = gc.getClipping();
      try {
        gc.setClipping(cellBounds);

        for (int i = 0; i < imgThumbnail.length; i++) {
          Image image = imgThumbnail[i];
          Rectangle srcBounds = image.getBounds();
          if (i == 0) {
            int w = dstWidth;
            int h = dstHeight;
            if (imgThumbnail.length > 1) {
              w = w * 9 / 10;
View Full Code Here

    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

    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

  public SimpleBrowserWindow(Shell parent, String url, double wPct, double hPct,
      boolean allowResize, boolean isModal) {
    if (parent == null) {
      init(parent, url, 0, 0, allowResize, isModal);
    } else {
      Rectangle clientArea = parent.getClientArea();
      init(parent, url, (int) (clientArea.width * wPct),
          (int) (clientArea.height * hPct), allowResize, isModal);
    }
  }
View Full Code Here

    }

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

        switch (ShellSlider.this.direction) {
          case SWT.UP:
          default:
            shell.setLocation(endBounds.x, endBounds.y);
            Rectangle displayBounds = null;
            try {
              boolean ok = false;
              Monitor[] monitors = shell.getDisplay().getMonitors();
              for (int i = 0; i < monitors.length; i++) {
                Monitor monitor = monitors[i];
                displayBounds = monitor.getBounds();
                if (displayBounds.contains(endBounds.x, endBounds.y)) {
                  ok = true;
                  break;
                }
              }
              if (!ok) {
                displayBounds = shell.getMonitor().getBounds();
              }
            } catch (Throwable t) {
              displayBounds = shell.getDisplay().getBounds();
            }

            shellBounds = new Rectangle(endBounds.x, displayBounds.y
                + displayBounds.height, endBounds.width, 0);
            break;
        }
        shell.setBounds(shellBounds);
        shell.setVisible(true);
View Full Code Here

      if ( canvas.isDisposed()){

        return;
      }

      Rectangle bounds = canvas.getClientArea();

      if ( bounds.height < 30 || bounds.width  < 100 || bounds.width > 2000 || bounds.height > 2000 ){
       
        return;
      }
View Full Code Here

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

TOP

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

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.