Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Rectangle


    if (!checkWidget(REQUIRE_TABLEITEM_INITIALIZED))
      return false;
   
    Image oldImage = item.getImage(0);
    if (oldImage != null) {
      Rectangle r = oldImage.getBounds();
      if (r.width == pt.x && r.height == pt.y)
        return false;
    }
   
    // set row height by setting image
View Full Code Here


   */
  public void invalidate() {
    if (!checkWidget(REQUIRE_TABLEITEM_INITIALIZED | REQUIRE_VISIBILITY))
      return;

    Rectangle r = item.getBounds(0);

    table.redraw(0, r.y, table.getClientArea().width, r.height, true);
  }
View Full Code Here

  /**
   * Center shell
   * @param shell shell which is needed to center
   */
  public static void centreWindow(Shell shell) {
    Rectangle displayArea; // area to center in
    try {
      displayArea = shell.getMonitor().getClientArea();
    } catch (NoSuchMethodError e) {
      displayArea = shell.getDisplay().getClientArea();
    }

    Rectangle shellRect = shell.getBounds();

    if (shellRect.height > displayArea.height) {
      shellRect.height = displayArea.height;
    }
    if (shellRect.width > displayArea.width - 50) {
View Full Code Here

  public static boolean drawImage(GC gc, Image image, Point srcStart,
      Rectangle dstRect, Rectangle clipping, int hOffset, int vOffset,
      boolean clearArea)
  {
    Rectangle srcRect;
    Point dstAdj;

    if (clipping == null) {
      dstAdj = new Point(0, 0);
      srcRect = new Rectangle(srcStart.x, srcStart.y, dstRect.width,
          dstRect.height);
    } else {
      if (!dstRect.intersects(clipping)) {
        return false;
      }

      dstAdj = new Point(Math.max(0, clipping.x - dstRect.x), Math.max(0,
          clipping.y - dstRect.y));

      srcRect = new Rectangle(0, 0, 0, 0);
      srcRect.x = srcStart.x + dstAdj.x;
      srcRect.y = srcStart.y + dstAdj.y;
      srcRect.width = Math.min(dstRect.width - dstAdj.x, clipping.x
          + clipping.width - dstRect.x);
      srcRect.height = Math.min(dstRect.height - dstAdj.y, clipping.y
          + clipping.height - dstRect.y);
    }

    if (!srcRect.isEmpty()) {
      try {
        if (clearArea) {
          gc.fillRectangle(dstRect.x + dstAdj.x + hOffset, dstRect.y + dstAdj.y
              + vOffset, srcRect.width, srcRect.height);
        }
View Full Code Here

    //cBlockView.moveAbove(null);

    cBlockView.addMouseListener(new MouseAdapter() {
        public void mouseDown(MouseEvent e) {
          Table table = getTable();
          Rectangle r = cBlockView.getBounds();
          TableItem[] item = { table.getItem(new Point(r.x, r.y)) };
          if (item[0] != null) {
            table.setSelection(item);
          }
          table.setFocus();
View Full Code Here

 
  public void locationChanged() {
    if (cBlockView == null || cBlockView.isDisposed())
      return;

    Rectangle bounds = getBoundsForCanvas();
    //In case item isn't displayed bounds is null
    if (bounds == null || image == null || image.isDisposed()) {
      return;
    }
    // moveAbove reduces the # redraws
View Full Code Here

  public void doPaint(GC gc) {
    if (cBlockView == null || cBlockView.isDisposed())
      return;

    //Compute bounds ...
    Rectangle bounds = getBoundsForCanvas();
    //In case item isn't displayed bounds is null
    if (bounds == null || image == null || image.isDisposed()) {
      return;
    }
    Rectangle canvasBounds = cBlockView.getBounds();
    if (canvasBounds.x != bounds.x || canvasBounds.y != bounds.y) {
      //cBlockView.moveAbove(null);
      cBlockView.setLocation(bounds.x, bounds.y);
      canvasBounds = cBlockView.getBounds();
      //debugOut("doPaint(GC): move cBlockView to " + bounds.x + "x" + bounds.y, false);
    }

    Table table = getTable();
    Rectangle tableBounds = table.getClientArea();
    if (tableBounds.y < table.getHeaderHeight()) {
      tableBounds.y = table.getHeaderHeight();
    }
    Rectangle rNewCanvas = bounds.intersection(tableBounds);
    //debugOut("doPaint(gc) rNewCanvas="+rNewCanvas+";canvasBounds="+canvasBounds+";tableBounds="+tableBounds, false);
    if (rNewCanvas.width <= 0 || rNewCanvas.height <= 0) {
      return;
    }
    if (!rNewCanvas.equals(canvasBounds) ||
        (orientation != SWT.FILL && !getRowBackground(table).equals(lastBackColor))) {
      rNewCanvas.x -= canvasBounds.x;
      rNewCanvas.y -= canvasBounds.y;
      doPaint(rNewCanvas);
    }
View Full Code Here

    if (cBlockView == null || cBlockView.isDisposed())
      return;

    Table table = getTable();
    //Compute bounds ...
    Rectangle bounds = getBoundsForCanvas();
    //In case item isn't displayed bounds is null
    if (bounds == null || image == null || image.isDisposed()) {
      return;
    }
   
    Rectangle canvasBounds = cBlockView.getBounds();
    //debugOut("Block:"+canvasBounds+";cell:"+bounds,false);
    if (canvasBounds.x != bounds.x || canvasBounds.y != bounds.y) {
      //cBlockView.moveAbove(null);
      cBlockView.setLocation(bounds.x, bounds.y);
      canvasBounds = cBlockView.getBounds();
      //debugOut("doPaint(clipping): move cBlockView to " + bounds.x + "x" + bounds.y, false);
    }
    if (bounds.width != canvasBounds.width ||
        bounds.height != canvasBounds.height) {
      cBlockView.setSize(bounds.width, bounds.height);
      canvasBounds = cBlockView.getBounds();
    }
    //debugOut("doPaint()" + ((gc == null) ? "GC NULL" : String.valueOf(gc.getClipping())) +
    //         "ta="+table.getClientArea()+";bounds="+bounds, false);
   
    if (orientation == SWT.FILL) {
      Rectangle imageBounds = image.getBounds();
      if (imageBounds.width != bounds.width ||
          imageBounds.height != bounds.height) {
        // Enable this for semi-fast visual update with some flicker
        cBlockView.setSize(bounds.width, bounds.height);
        GC gc = new GC(cBlockView);
        if (gc == null) {
          return;
        }
        gc.drawImage(image, 0, 0, imageBounds.width, imageBounds.height,
                     0, 0, bounds.width, bounds.height);
        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;
      }
    }
   
    if (clipping == null) {
      clipping = new Rectangle(0, 0, bounds.width, bounds.height);
    }
    Rectangle tableBounds = table.getClientArea();
    if (tableBounds.y < table.getHeaderHeight()) {
      tableBounds.y = table.getHeaderHeight();
    }
    //debugOut("doPaint() tableBounds="+tableBounds+";canvasBounds="+canvasBounds+";clipping="+clipping, false);
    tableBounds.x -= canvasBounds.x;
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

    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.