Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Rectangle


    this.scale = new Scale();
   
    canvas.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent e) {
        if (img != null && !img.isDisposed()) {
          Rectangle bounds = img.getBounds();
          if (bounds.width >= e.width && bounds.height >= e.height) {
            if (alpha != 255) {
              try {
                e.gc.setAlpha(alpha);
              } catch (Exception ex) {
View Full Code Here


    }
    lastContacts = contacts;
    lastSelf = self;
   
    if(canvas.isDisposed()) return;
    Rectangle size = canvas.getBounds();
   
    if (size.isEmpty()) {
      return;
    }
   
    scale.width = size.width;
    scale.height = size.height;
View Full Code Here

    canvas.redraw();
  }
 
  public void refresh(List vivaldiPositions) {
    if(canvas.isDisposed()) return;
    Rectangle size = canvas.getBounds();
   
    scale.width = size.width;
    scale.height = size.height;
   
    if (img != null && !img.isDisposed()) {
View Full Code Here

    if (dm == null) {
      return;
    }

    int sortVal = dm.getNumFileInfos();
    Rectangle bounds = cell.getBounds();
    Rectangle printArea = new Rectangle(bounds.x, bounds.y, bounds.width - 6,
        bounds.height);
    GCStringPrinter.printString(gc, "" + sortVal, printArea, true, true,
        SWT.RIGHT);
  }
View Full Code Here

  private void openFilesMiniView(DownloadManager dm, TableCell cell) {
    Shell shell = ShellFactory.createShell(Utils.findAnyShell(), SWT.SHELL_TRIM);

    shell.setLayout(new FillLayout());

    Rectangle bounds = ((TableCellSWT) cell).getBoundsOnDisplay();
    bounds.y += bounds.height;
    bounds.width = 630;
    bounds.height = (16 * dm.getNumFileInfos()) + 60;
    Rectangle realBounds = shell.computeTrim(0, 0, bounds.width, bounds.height);
    realBounds.width -= realBounds.x;
    realBounds.height -= realBounds.y;
    realBounds.x = bounds.x;
    realBounds.y = bounds.y;
    if (bounds.height > 500) {
View Full Code Here

    layout_data = new GridData(GridData.FILL_HORIZONTAL);
    layout_data.heightHint = TOP_GRADIENT_HEIGHT;
    window_top.setLayoutData(layout_data);
    window_top.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent arg0) {
        Rectangle rect = shell.getClientArea ();
        GC gc = arg0.gc;
        gc.setForeground (GRADIENT_COLOR_2);
        gc.setBackground (GRADIENT_COLOR_1);
        gc.fillGradientRectangle (rect.x, rect.y, rect.width, rect.height, false);
        Image image = SWTImageRepository.getImage(logo_image);
View Full Code Here

      // images with transparency need their area cleared first, otherwise we
      // end up multiplying values (alpha type) or not clearing pixels
      // (all types)
      Table table = getTable();

      Rectangle bounds = getBoundsForCanvas();
      //In case item isn't displayed bounds is null
      if (bounds == null)
        return;

      // This should trigger a doPaint(gc)
View Full Code Here

        return;
      neverDrawn = false;
    }

    //Compute bounds ...
    Rectangle bounds = getBoundsForCanvas();
    //In case item isn't displayed bounds is null
    if (bounds == null || image == null || image.isDisposed()) {
      //System.out.println(row.getIndex() + " nb");
      return;
    }
   
    Table table = getTable();

//    System.out.println("doPnt#" + row.getIndex()+": " +
//        ((gc == null) ? "GC NULL" : String.valueOf(gc.getClipping())) +
//        "ta="+table.getClientArea()+";bounds="+bounds);

    Rectangle imageBounds = image.getBounds();
   
    if (imageBounds.width <= 0 || imageBounds.height <= 0 || bounds.width <= 0
        || bounds.height <= 0) {
      //System.out.println(row.getIndex() + " < 0");
      return;
    }

    Rectangle tableBounds = table.getClientArea();
    if (bounds.y + bounds.height - tableBounds.y < table.getHeaderHeight()
        || bounds.y > tableBounds.height) {
//      System.out.println("doPnt#" + row.getIndex() + ": "
//          + (bounds.y + bounds.height - tableBounds.y) + "<" + tableBounds.y
//          + " || " + bounds.y + " > " + tableBounds.height);
      return;
    }
   
    if (orientation == SWT.FILL) {
      if (imageBounds.width != bounds.width
          || imageBounds.height != bounds.height) {
        //System.out.println("doPaint() sizewrong #"+row.getIndex()+ ".  Image="+imageBounds +";us="+bounds);
/**/
        // Enable this for semi-fast visual update with some flicker
        boolean ourGC = (gc == null);
        if (ourGC)
          gc = new GC(table);
        if (gc != null) {
          int iAdj = VerticalAligner.getTableAdjustVerticalBy(table);
          bounds.y += iAdj;
          iAdj = VerticalAligner.getTableAdjustHorizontallyBy(table);
          bounds.x += iAdj;

          gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height,
                       bounds.x, bounds.y, bounds.width, bounds.height);
          if (ourGC)
            gc.dispose();
        }
        // _OR_ enable refresh() for slower visual update with lots of flicker
        //refresh();
       
        // OR, disable both and image will be updated on next graphic bar update
       
        // TODO: make config option to choose
/**/
        invalidate();
        return;
      }
    } else {
      if (imageBounds.width < bounds.width) {
        if (orientation == SWT.CENTER)
          bounds.x += (bounds.width - imageBounds.width) / 2;
        else if (orientation == SWT.RIGHT)
          bounds.x = (bounds.x + bounds.width) - imageBounds.width;
      }

      if (imageBounds.height < bounds.height) {
        bounds.y += (bounds.height - imageBounds.height) / 2;
      }
    }
   
    Rectangle clipping = new Rectangle(bounds.x, bounds.y,
                                       bounds.width,
                                       bounds.height);
    int iMinY = table.getHeaderHeight() + tableBounds.y;
    if (clipping.y < iMinY) {
      clipping.height -= iMinY - clipping.y;
      clipping.y = iMinY;
    }
    int iMaxY = tableBounds.height + tableBounds.y;
    if (clipping.y + clipping.height > iMaxY)
      clipping.height = iMaxY - clipping.y + 1;

    if (clipping.width <= 0 || clipping.height <= 0) {
      //System.out.println(row.getIndex() + " clipping="+clipping + ";" + iMinY + ";" + iMaxY + ";tca=" + tableBounds);
      return;
    }

    // See Eclipse Bug 42416
    // "[Platform Inconsistency] GC(Table) has wrong origin"
    // Notes/Questions:
    // - GTK's "new GC(table)" starts under header, instead of above
    //   -- so, adjust bounds up
    // - Appears to apply to new GC(table) AND GC passed by PaintEvent from a Table PaintListener
    // - Q) .height may be effected (smaller than it should be).  How does this effect clipping?
    // - Q) At what version does this bug start appearing?
    //   A) Reports suggest at least 2.1.1
    int iAdj = VerticalAligner.getTableAdjustVerticalBy(table);
    bounds.y += iAdj;
    clipping.y += iAdj;
    // New: GTK M8+ has a bounds.x bug.. works fine in M7, but assume people have M8 or higher (3.0final)
    iAdj = VerticalAligner.getTableAdjustHorizontallyBy(table);
    bounds.x += iAdj;
    clipping.x += iAdj;

    boolean ourGC = (gc == null);
    if (ourGC) {
      gc = new GC(table);
      if (gc == null) {
        return;
      }
    }

    Point srcStart = new Point(clipping.x - bounds.x, clipping.y - bounds.y);
    Rectangle dstRect = new Rectangle(clipping.x, clipping.y,
        imageBounds.width - srcStart.x, imageBounds.height - srcStart.y);

    Utils.drawImage(gc, image, srcStart, dstRect, clipping, 0, 0, false);
   
    if (ourGC) {
View Full Code Here

 
  /** Calculate the bounds of the receiver should be drawing in
    * @return what size/position the canvas should be
    */
  public Rectangle getBoundsForCanvas() {
    Rectangle bounds = getBounds();
    if(bounds == null)
      return null;
    bounds.y += marginHeight;
    bounds.height -= (marginHeight * 2);
    bounds.x += marginWidth;
View Full Code Here

    bounds.width -= (marginWidth * 2);
    return bounds;
  }

  public Point getSize() {
    Rectangle bounds = getBounds();
    if(bounds == null)
      return new Point(0, 0);
    return new Point(bounds.width - (marginWidth * 2),
                     bounds.height - (marginHeight * 2));
  }
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.