Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Rectangle


    } else {
      Matcher htmlMatcher = patHREF.matcher(string);
      string = htmlMatcher.replaceAll("$2");
    }

    Rectangle rectDraw = new Rectangle(printArea.x, printArea.y,
        printArea.width, printArea.height);

    Rectangle oldClipping = null;
    try {
      if (!skipClip && !noDraw) {
        oldClipping = gc.getClipping();

        // Protect the GC from drawing outside the drawing area
View Full Code Here


    //System.out.println("PW: " + word);
    if (images != null && word.length() >= 2 && word.charAt(0) == '%') {
      int imgIdx = word.charAt(1) - '0';
      if (images.length > imgIdx && imgIdx >= 0 && images[imgIdx] != null) {
        Image img = images[imgIdx];
        Rectangle bounds = img.getBounds();
        if (imageScales != null && imageScales.length > imgIdx) {
          bounds.width = (int) (bounds.width * imageScales[imgIdx]);
          bounds.height = (int) (bounds.height * imageScales[imgIdx]);
        }
       
 
View Full Code Here

          if (imgIdx >= images.length || imgIdx < 0 || images[imgIdx] == null) {
            String sStart = s.substring(lastPos, pctPos + 1);
            textExtent = gc.textExtent(sStart);
            int centerY = y + (height / 2 - textExtent.y / 2);
            if (hitAreas != null) {
              hitAreas.add(new Rectangle(x, centerY, textExtent.x, textExtent.y));
            }
            if (!nodraw) {
              gc.drawText(sStart, x, centerY, true);
            }
            x += textExtent.x;
            w += textExtent.x;
            h = Math.max(h, textExtent.y);

            lastPos = pctPos + 1;
            pctPos = s.indexOf('%', pctPos + 1);
            continue;
          }
         
          String sStart = s.substring(lastPos, pctPos);
          textExtent = gc.textExtent(sStart);
          int centerY = y + (height / 2 - textExtent.y / 2);
          if (!nodraw) {
            gc.drawText(sStart, x, centerY, true);
          }
          x += textExtent.x;
          w += textExtent.x;
          h = Math.max(h, textExtent.y);
          if (hitAreas != null) {
            hitAreas.add(new Rectangle(x, centerY, textExtent.x, textExtent.y));
          }

          //System.out.println("drawimage: " + x + "x" + y + ";idx=" + imgIdx);
          Rectangle imgBounds = images[imgIdx].getBounds();
          float scale = 1.0f;
          if (imageScales != null && imageScales.length > imgIdx) {
            scale = imageScales[imgIdx];
          }
          int scaleImageWidth = (int) (imgBounds.width * scale);
          int scaleImageHeight = (int) (imgBounds.height * scale);

         
          centerY = y + (height / 2 - scaleImageHeight / 2);
          if (hitAreas != null) {
            hitAreas.add(new Rectangle(x, centerY, scaleImageWidth, scaleImageHeight));
          }
          if (!nodraw) {
            //gc.drawImage(images[imgIdx], x, centerY);
            gc.drawImage(images[imgIdx], 0, 0, imgBounds.width,
                imgBounds.height, x, centerY, scaleImageWidth, scaleImageHeight);
          }
          x += scaleImageWidth;
          w += scaleImageWidth;
         
          h = Math.max(h, scaleImageHeight);
        }
        lastPos = pctPos + 2;
        pctPos = s.indexOf('%', lastPos);
      }

      if (s.length() >= lastPos) {
        String sEnd = s.substring(lastPos);
        textExtent = gc.textExtent(sEnd);
        int centerY = y + (height / 2 - textExtent.y / 2);
        if (hitAreas != null) {
          hitAreas.add(new Rectangle(x, centerY, textExtent.x, textExtent.y));
        }
        if (!nodraw) {
          gc.drawText(sEnd, x, centerY, true);
        }
        x += textExtent.x;
        w += textExtent.x;
        h = Math.max(h, textExtent.y);
      }
      return new Point(w, h);
    }


    if (!nodraw) {
      gc.drawText(s, x, y, true);
    }
    textExtent = gc.textExtent(s);
    if (hitAreas != null) {
      hitAreas.add(new Rectangle(x, y, textExtent.x, textExtent.y));
    }
    return textExtent;
  }
View Full Code Here

    }
    for (Iterator iter = listUrlInfo.iterator(); iter.hasNext();) {
      URLInfo urlInfo = (URLInfo) iter.next();
      if (urlInfo.hitAreas != null) {
        for (Iterator iter2 = urlInfo.hitAreas.iterator(); iter2.hasNext();) {
          Rectangle r = (Rectangle) iter2.next();
          if (r.contains(x, y)) {
            return urlInfo;
          }
        }
      }
    }
View Full Code Here

    y += margin_width;
   
    float k = (float)(width)/(float)(file_size);
    //Gaps
    gc.setBackground(gaplist_bg_color);
    gc.fillRectangle(new Rectangle(x,y,width,height));
    gc.setBackground(gaplist_fg_color);
    for(Gap gap : gap_list.getGaps()) {
      int startPos = Math.round((float)(gap.getStart() * k));
      int length = Math.round((float)((gap.getEnd() - gap.getStart()) * k));
      Rectangle rect = new Rectangle(x + startPos,y + 0,length,height);
      gc.fillRectangle(rect);
    }
    //Draw progress bar
    long downloaded = file_size - gap_list.byteCount();
    long progress = Math.round(((downloaded* 100f)/ (float) file_size));
    k = (float)(width)/100f;
    Rectangle progress_bar = new Rectangle(x, y,(int)( width), PROGRESS_BAR_HEIGHT);
    gc.setBackground(progress_bar_bg_color);
    gc.fillRectangle(progress_bar);
    progress_bar = new Rectangle(x,y,(int)(progress* k),PROGRESS_BAR_HEIGHT);
    gc.setBackground(progress_bar_fg_color);
    gc.fillRectangle(progress_bar);
   
    gc.setForeground(separator_color);
    gc.drawLine(x,y + PROGRESS_BAR_HEIGHT,x + width, y + PROGRESS_BAR_HEIGHT);
View Full Code Here

        e.gc.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
        e.gc.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));

        e.gc.fillRectangle(0, 0, WIDTH, TEXT_HEIGHT);

        GCStringPrinter.printString(e.gc,title+"\n"+ _getStringValue(), new Rectangle(0,
            0, WIDTH, HEIGHT), true, false, SWT.CENTER | SWT.TOP | SWT.WRAP);

        e.gc.drawLine(0, TEXT_HEIGHT - 1, WIDTH, TEXT_HEIGHT - 1);

        // options list
        int y = TEXT_HEIGHT;
        Point mousePos = composite.toControl(display.getCursorLocation());
        for (Iterator iter = mapOptions.keySet().iterator(); iter.hasNext();) {
          long value = (Long) iter.next();
          String text = (String) mapOptions.get(value);

          Rectangle area = new Rectangle(0, y, WIDTH, OPTION_HEIGHT);
          Color bg;
          if (area.contains(mousePos)) {
            bg = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
            e.gc.setBackground(bg);
            e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
            e.gc.fillRectangle(area);
          } else {
            bg = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
            e.gc.setBackground(bg);
            e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
          }

          int ovalSize = OPTION_HEIGHT - 6;
          if (getValue() == value) {
            Color saveColor = e.gc.getBackground();
            e.gc.setBackground(e.gc.getForeground());
            e.gc.fillOval(4, y + 5, ovalSize - 3, ovalSize - 3);
            e.gc.setBackground(saveColor);
          }
          if (JMConstants.isLinux) {
            // Hack: on linux, drawing oval seems to draw a line from last pos
            // to start of oval.. drawing a point (anywhere) seems to clear the
            // path
            Color saveColor = e.gc.getForeground();
            e.gc.setForeground(bg);
            e.gc.drawPoint(2, y + 3);
            e.gc.setForeground(saveColor);
          }
          e.gc.drawOval(2, y + 3, ovalSize, ovalSize);

          GCStringPrinter.printString(e.gc, text, new Rectangle(OPTION_HEIGHT,
              y, WIDTH - OPTION_HEIGHT, OPTION_HEIGHT), true, false, SWT.LEFT);
          y += OPTION_HEIGHT;
        }

        // typed value
        if (sValue.length() > 0) {
          Point extent = e.gc.textExtent(sValue);
          if (extent.x > WIDTH - 10) {
            extent.x = WIDTH - 10;
          }
          Rectangle rect = new Rectangle(WIDTH - 8 - extent.x, 14,
              extent.x + 5, extent.y + 4 + 14 > TEXT_HEIGHT ? TEXT_HEIGHT - 15
                  : extent.y + 4);
          e.gc.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
          e.gc.fillRectangle(rect);

          try {
            e.gc.setAlpha(TYPED_TEXT_ALPHA);
          } catch (Exception ex) {
          }
          e.gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
          e.gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
          //e.gc.drawRectangle(rect);

          GCStringPrinter.printString(e.gc, sValue , new Rectangle(rect.x + 2,
              rect.y + 2, WIDTH - 5, OPTION_HEIGHT), true, false, SWT.LEFT
              | SWT.BOTTOM);
        }
      }
    });

    Point location = display.getCursorLocation();

    location.y -= getBaselinePos();
    int x = (int) (WIDTH_NO_PADDING * (value > maxValue ? 1 : (double) value
        / maxValue));
    location.x -= PADDING_X0 + x;

    Rectangle bounds = new Rectangle(location.x, location.y, WIDTH, HEIGHT);
    Monitor mouseMonitor = shell.getMonitor();
    Monitor[] monitors = display.getMonitors();
    for (int i = 0; i < monitors.length; i++) {
      Monitor monitor = monitors[i];
      if (monitor.getBounds().contains(location)) {
        mouseMonitor = monitor;
        break;
      }
    }
    Rectangle monitorBounds = mouseMonitor.getBounds();
    Rectangle intersection = monitorBounds.intersection(bounds);
    if (intersection.width != bounds.width) {
      bounds.x = monitorBounds.x + monitorBounds.width - WIDTH;
      bounds.width = WIDTH;
    }
    if (intersection.height != bounds.height) {
View Full Code Here

  }

  private SelectedPointer getSelectedPointer(int x,int y) {
    int up_coord = getUpCoord();
    int down_coord = getDownCoord();
    Rectangle area;
    area = new Rectangle(up_coord - pointer_width,getY() - pointer_height, pointer_width*2,pointer_height);
    if (area.contains(x, y)) return SelectedPointer.UP;
    area = new Rectangle(down_coord - pointer_width,getY() + bar_height, pointer_width * 2 , pointer_height);
    if (area.contains(x, y)) return SelectedPointer.DOWN;
    return null;
  }
View Full Code Here

   
    sash.setLayoutData(sash_data);
   
    sash.addListener (SWT.Selection, new Listener () {
      public void handleEvent (Event e) {
        Rectangle sashRect = sash.getBounds ();
        Rectangle shellRect = parent.getClientArea ();
        int right = shellRect.width - sashRect.width - limit;
        e.x = Math.max (Math.min (e.x, right), limit);
        if (e.x != sashRect.x)  {
          sash_data.left = new FormAttachment (0, e.x);
          //sashData_messages.right = new FormAttachment (0, e.x+4);
View Full Code Here

    //sash_data.bottom = new FormAttachment (init_percent+2, 0);
    sash.setLayoutData (sash_data);
   
    sash.addListener (SWT.Selection, new Listener () {
      public void handleEvent (Event e) {
        Rectangle sashRect = sash.getBounds ();
        Rectangle shellRect = parent.getClientArea ();
        int right = shellRect.height - sashRect.height - limit;
        e.y = Math.max (Math.min (e.y, right), limit);
        if (e.y != sashRect.y)  {
          sash_data.top = new FormAttachment (0,e.y);
          //sash_data.bottom = new FormAttachment (0,e.y+4);
View Full Code Here

    // Some Platforms (OSX) don't handle getBounds properly (3.2M4) when
    // item doesn't exist in table
    if (table.indexOf(item) == -1)
      return null;

    Rectangle r = item.getBounds(index);
    if (r == null || r.width == 0 || r.height == 0)
      return null;

    return r;
  }
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.