Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Region


  }

  public void renderStep(AnimationEngine engine) {
    if (shellRegion != null) {
      shellRegion.dispose();
      shellRegion = new Region(display);
    }

    // Iterate across the set of start/end rects
    Iterator currentRects = getCurrentRects(engine.amount()).iterator();
    while (currentRects.hasNext()) {
View Full Code Here


    display = theShell.getDisplay();
    Color color = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
    theShell.setBackground(color);

    // Ensure that the background won't show on the initial display
    shellRegion = new Region(display);
    theShell.setRegion(shellRegion);
  }
View Full Code Here

        Color back = getGroup().internalGetBackground();
        if (back != null)
        {
            gc.fillRectangle(0,0,getGroup().getSize().x,getGroup().getSize().y);
           
            Region reg = new Region();
            reg.add(0, 0, 5, 1);
            reg.add(0, 1, 3, 1);
            reg.add(0, 2, 2, 1);
            reg.add(0, 3, 1, 1);
            reg.add(0, 4, 1, 1);
           
            reg.add(getGroup().getSize().x - 5, 0, 5, 1);
            reg.add(getGroup().getSize().x - 3, 1, 3, 1);
            reg.add(getGroup().getSize().x - 2, 2, 2, 1);
            reg.add(getGroup().getSize().x - 1, 3, 1, 1);
            reg.add(getGroup().getSize().x - 1, 4, 1, 1);
           
            gc.setClipping(reg);
           
            getGroup().drawBackground(gc, 0, 0, getGroup().getSize().x,5);
           
            gc.setClipping((Region)null);
            reg.dispose();
        }
       
        Point imagePoint = new Point(0, 0);

        if (getGroup().getToggleRenderer() != null)
        {
            Point p = getGroup().getToggleRenderer().getSize();
            int toggleY = 0;

            toggleY = (titleHeight - p.y) / 2;

            int toggleX = 0;
            if ((getGroup().getTogglePosition() & SWT.LEAD) != 0)
            {
                toggleX = hMargin;
            }
            else
            {
                toggleX = getGroup().getSize().x - hMargin - p.x;
            }
            getGroup().getToggleRenderer().setLocation(new Point(toggleX, toggleY));
        }

        Region reg = new Region(getGroup().getDisplay());
        reg.add(0, 0, getGroup().getSize().x, titleHeight);
        reg.subtract(0, 0, 5, 1);
        reg.subtract(0, 1, 3, 1);
        reg.subtract(0, 2, 2, 1);
        reg.subtract(0, 3, 1, 1);
        reg.subtract(0, 4, 1, 1);

        reg.subtract(getGroup().getSize().x - 5, 0, 5, 1);
        reg.subtract(getGroup().getSize().x - 3, 1, 3, 1);
        reg.subtract(getGroup().getSize().x - 2, 2, 2, 1);
        reg.subtract(getGroup().getSize().x - 1, 3, 1, 1);
        reg.subtract(getGroup().getSize().x - 1, 4, 1, 1);

        gc.setClipping(reg);

        back = gc.getBackground();
        Color fore = gc.getForeground();
        gc.setForeground(initialBackColor);
        gc.setBackground(getGroup().getParent().getBackground());
        Pattern p = new Pattern(getGroup().getDisplay(), 0, 0, 0, titleHeight,
                                initialBackColor, 255, getGroup().getBackground(), 0);
        gc.setBackgroundPattern(p);
        gc.fillRectangle(0, 0, getGroup().getSize().x, titleHeight);
        p.dispose();
        gc.setBackgroundPattern(null);
       
        if (getGroup().getExpanded() && getGroup().getSize().x > 1)
        {           
            reg.subtract(1,titleHeight -1,getGroup().getSize().x -2,1);
            gc.setClipping(reg);
        }
       
        gc.setForeground(borderColor);
        GraphicUtils.drawRoundRectangle(gc, 0, 0, getGroup().getSize().x - 1, titleHeight, null,
                                        true, false);
       
        reg.dispose();
        gc.setClipping((Region)null);

        gc.setForeground(getGroup().getParent().getBackground());

//        if (getGroup().getExpanded())
View Full Code Here

  private class CalendarMouseAdapter extends MouseAdapter {
    private Region previousRegion;
    private Region nextRegion;
   
    public CalendarMouseAdapter() {
      previousRegion = new Region();
      previousRegion.add(previousMonth);
     
      nextRegion = new Region();
      nextRegion.add(nextMonth);
    }
View Full Code Here

            if ((getGroup().getImagePosition() & SWT.TOP) != 0 && image != null)
            {
                yOffset = titleHeight - titleAreaHeight;
            }
           
            Region reg = new Region();
            reg.add(0,yOffset + 0, 5, 1);
            reg.add(0,yOffset + 1, 3, 1);
            reg.add(0,yOffset + 2, 2, 1);
            reg.add(0,yOffset + 3, 1, 1);
            reg.add(0,yOffset + 4, 1, 1);
           
            reg.add(getGroup().getSize().x - 5,yOffset + 0, 5, 1);
            reg.add(getGroup().getSize().x - 3,yOffset + 1, 3, 1);
            reg.add(getGroup().getSize().x - 2,yOffset + 2, 2, 1);
            reg.add(getGroup().getSize().x - 1,yOffset + 3, 1, 1);
            reg.add(getGroup().getSize().x - 1,yOffset + 4, 1, 1);
           
            int height = getGroup().getSize().y;

            reg.add(0, height - 1, 5, 1);
            reg.add(0, height - 2, 3, 1);
            reg.add(0, height - 3, 2, 1);
            reg.add(0, height - 4, 1, 1);
            reg.add(0, height - 5, 1, 1);

            reg.add(getGroup().getSize().x - 5, height - 1, 5, 1);
            reg.add(getGroup().getSize().x - 3, height - 2, 3, 1);
            reg.add(getGroup().getSize().x - 2, height - 3, 2, 1);
            reg.add(getGroup().getSize().x - 1, height - 4, 1, 1);
            reg.add(getGroup().getSize().x - 1, height - 5, 1, 1);
           
            if (yOffset != 0)
            {
                reg.add(0,0,getGroup().getSize().x,yOffset);
            }
           
            gc.setClipping(reg);
           
            getGroup().drawBackground(gc, 0, 0, getGroup().getSize().x,getGroup().getSize().y);
           
            gc.setClipping((Region)null);
            reg.dispose();
        }
       
       
       

        // Paint rectangle
        int toggleHeight = 0;
        if (getGroup().getToggleRenderer() != null)
        {
            toggleHeight = getGroup().getToggleRenderer().getSize().y + (2 * vMargin);
        }

        Region reg = null;
        if ((getGroup().getStyle() & SWT.SMOOTH) != 0)
        {
            reg = new Region(getGroup().getDisplay());
            reg.add(0, 0, getGroup().getSize().x, titleHeight);

            int yOffset = 0;
            if ((getGroup().getImagePosition() & SWT.TOP) != 0 && image != null)
            {
                yOffset = titleHeight - titleAreaHeight;
            }

            reg.subtract(0, yOffset + 0, 5, 1);
            reg.subtract(0, yOffset + 1, 3, 1);
            reg.subtract(0, yOffset + 2, 2, 1);
            reg.subtract(0, yOffset + 3, 1, 1);
            reg.subtract(0, yOffset + 4, 1, 1);

            reg.subtract(getGroup().getSize().x - 5, yOffset + 0, 5, 1);
            reg.subtract(getGroup().getSize().x - 3, yOffset + 1, 3, 1);
            reg.subtract(getGroup().getSize().x - 2, yOffset + 2, 2, 1);
            reg.subtract(getGroup().getSize().x - 1, yOffset + 3, 1, 1);
            reg.subtract(getGroup().getSize().x - 1, yOffset + 4, 1, 1);

            if (!getGroup().getExpanded())
            {
                yOffset = titleHeight;

                reg.subtract(0, yOffset - 1, 5, 1);
                reg.subtract(0, yOffset - 2, 3, 1);
                reg.subtract(0, yOffset - 3, 2, 1);
                reg.subtract(0, yOffset - 4, 1, 1);
                reg.subtract(0, yOffset - 5, 1, 1);

                reg.subtract(getGroup().getSize().x - 5, yOffset - 1, 5, 1);
                reg.subtract(getGroup().getSize().x - 3, yOffset - 2, 3, 1);
                reg.subtract(getGroup().getSize().x - 2, yOffset - 3, 2, 1);
                reg.subtract(getGroup().getSize().x - 1, yOffset - 4, 1, 1);
                reg.subtract(getGroup().getSize().x - 1, yOffset - 5, 1, 1);
            }

            gc.setClipping(reg);
        }

        if ((getGroup().getImagePosition() & SWT.TOP) == 0 || image == null)
        {

            if (gradientColors != null)
            {
                GraphicUtils.fillGradientRectangle(gc, 0, 0, getGroup().getSize().x, Math
                    .max(titleHeight, toggleHeight), gradientColors, gradientPercents,
                                                   gradientVertical);
            }
            else
            {
                gc.fillRectangle(0, 0, getGroup().getSize().x, Math.max(titleHeight, toggleHeight));
                GraphicUtils.fillRoundRectangle(gc, 0, 0, getGroup().getSize().x, Math
                    .max(titleHeight, toggleHeight), null, true, !getGroup().getExpanded());
            }
            if ((getGroup().getStyle() & SWT.SMOOTH) != 0)
            {
                GraphicUtils.drawRoundRectangle(gc, 0, 0, getGroup().getSize().x, Math
                    .max(titleHeight, toggleHeight), null, null, true, !getGroup().getExpanded());
            }
        }
        else
        {

            // gc.setBackground(getGroup().getParent().getBackground());
            // gc.fillRectangle(0,0,getGroup().getSize().x,getTitleHeight() -
            // titleAreaHeight);

            if (gradientColors != null)
            {
                GraphicUtils.fillGradientRectangle(gc, 0, titleHeight - titleAreaHeight, getGroup()
                    .getSize().x, Math.max(titleAreaHeight, toggleHeight), gradientColors,
                                                   gradientPercents, gradientVertical);
            }
            else
            {
                gc.setBackground(getGroup().getBackground());
                gc.fillRectangle(0, titleHeight - titleAreaHeight, getGroup().getSize().x, Math
                    .max(titleAreaHeight, toggleHeight));
            }

            // if ((getGroup().getStyle() & SWT.SMOOTH) != 0){
            // GraphicUtils.drawRoundRectangle(gc,0,getTitleHeight() -
            // titleAreaHeight,getGroup().getSize().x
            // -1,Math.max(titleAreaHeight,toggleHeight)
            // ,getGroup().getParent().getBackground(),null,true,!getGroup().isExpanded());
            // }
        }

        if ((getGroup().getStyle() & SWT.SMOOTH) != 0)
        {
            gc.setClipping((Region)null);
            reg.dispose();
        }

        // Paint Image

        if (image != null)
        {
            if ((getGroup().getImagePosition() & SWT.LEAD) != 0)
            {
                if (getGroup().getToggleRenderer() != null)
                {
                    if (getGroup().getTogglePosition() == SWT.LEAD)
                    {
                        imagePoint.x = hMargin + getGroup().getToggleRenderer().getSize().x
                                       + betweenSpacing;
                    }
                    else
                    {
                        imagePoint.x = hMargin;
                    }
                }
                else
                {
                    imagePoint.x = hMargin;
                }
            }
            else
            {
                if (getGroup().getToggleRenderer() != null)
                {
                    if ((getGroup().getTogglePosition() & SWT.LEAD) != 0)
                    {
                        imagePoint.x = getGroup().getSize().x - (hMargin + image.getBounds().width);
                    }
                    else
                    {
                        imagePoint.x = getGroup().getSize().x
                                       - (hMargin + image.getBounds().width
                                          + getGroup().getToggleRenderer().getSize().x + betweenSpacing);
                    }
                }
                else
                {
                    imagePoint.x = getGroup().getSize().x - (hMargin + image.getBounds().width);
                }
            }
            if ((getGroup().getImagePosition() & SWT.TOP) == 0
                && image.getImageData().height > titleHeight)
            {
                imagePoint.y = (titleHeight - image.getImageData().height) / 2;
            }
            else
            {
                imagePoint.y = (titleHeight - image.getImageData().height) / 2;
            }
            gc.drawImage(image, imagePoint.x, imagePoint.y);
        }

        Rectangle textBounds = getTextBounds();

        gc.setForeground(getGroup().getForeground());
        gc.drawText(TextUtils.getShortString(gc, getGroup().getText(), textBounds.width),
                    textBounds.x, textBounds.y, true);

        if (!getGroup().getExpanded())
        {
            gc.setBackground(getGroup().getParent().getBackground());
            // gc.fillRectangle(0,getTitleHeight(),getGroup().getBounds().width,getGroup().getBounds().height);
        }
        else
        {
            Color _borderColor;
            if (borderColor == null)
            {
                _borderColor = getGroup().getBackground();
            }
            else
            {
                _borderColor = borderColor;
            }

            if ((getGroup().getStyle() & SWT.SMOOTH) != 0)
            {
                gc.setBackground(getGroup().getBackground());
                // gc.fillRectangle(0,getGroup().getSize().y -
                // 5,getGroup().getSize().x -1,5);
                gc.setForeground(_borderColor);

                reg = new Region(getGroup().getDisplay());
                reg.add(0, 0, getGroup().getSize().x, getGroup().getSize().y);

                int yOffset = getGroup().getSize().y;

                reg.subtract(0, yOffset - 1, 5, 1);
                reg.subtract(0, yOffset - 2, 3, 1);
                reg.subtract(0, yOffset - 3, 2, 1);
                reg.subtract(0, yOffset - 4, 1, 1);
                reg.subtract(0, yOffset - 5, 1, 1);

                reg.subtract(getGroup().getSize().x - 5, yOffset - 1, 5, 1);
                reg.subtract(getGroup().getSize().x - 3, yOffset - 2, 3, 1);
                reg.subtract(getGroup().getSize().x - 2, yOffset - 3, 2, 1);
                reg.subtract(getGroup().getSize().x - 1, yOffset - 4, 1, 1);
                reg.subtract(getGroup().getSize().x - 1, yOffset - 5, 1, 1);

                gc.setClipping(reg);

                GraphicUtils.drawRoundRectangle(gc, 0, titleHeight, getGroup().getSize().x - 1,
                                                getGroup().getSize().y - titleHeight, null, false,
                                                true);

                reg.dispose();
                gc.setClipping((Region)null);
            }
            else
            {
                gc.setForeground(_borderColor);
View Full Code Here

        super.create();
        addRegion(this.shell);
    }

    private void addRegion(Shell shell) {
        Region region = new Region();
        Point s = shell.getSize();

        /* Add entire Shell */
        region.add(0, 0, s.x, s.y);

        /* Subtract Top-Left Corner */
        region.subtract(0, 0, 1, 1);

        /* Subtract Top-Right Corner */
        region.subtract(s.x - 1, 0, 1, 1);

        /* Subtract Bottom-Left Corner */
        region.subtract(0, s.y - 1, 1, 1);

        /* Subtract Bottom-Right Corner */
        region.subtract(s.x - 1, s.y - 1, 1, 1);

        /* Dispose old first */
        if (shell.getRegion() != null) {
            shell.getRegion().dispose();
        }
View Full Code Here

        Color incompleteRegionColor = CellStyleUtil.getCellStyle(cell,
                configRegistry).getAttributeValue(
                PERCENTAGE_BAR_INCOMPLETE_REGION_COLOR);
        if (incompleteRegionColor != null) {
            Region incompleteRegion = new Region();

            incompleteRegion.add(rectangle);
            incompleteRegion.subtract(bar);
            Color originalBackgroundColor = gc.getBackground();
            gc.setBackground(incompleteRegionColor);
            gc.fillRectangle(incompleteRegion.getBounds());
            gc.setBackground(originalBackgroundColor);

            incompleteRegion.dispose();
        }

        super.paintCell(cell, gc, rectangle, configRegistry);
    }
View Full Code Here

      return;
    Device device = gc.getDevice();

    // array of coordinate points of polygon 1 (region 1)
    int[] polygon1 = new int[] { 10, height / 2, 9 * width / 16, 10, 9 * width / 16, height - 10 };
    Region region1 = new Region(device);
    region1.add(polygon1);

    // array of coordinate points of polygon 2 (region 2)
    int[] polygon2 = new int[] { 9 * width / 16, 10, 9 * width / 16, height / 8, 7 * width / 16, 2 * height / 8,
        9 * width / 16, 3 * height / 8, 7 * width / 16, 4 * height / 8, 9 * width / 16, 5 * height / 8,
        7 * width / 16, 6 * height / 8, 9 * width / 16, 7 * height / 8, 9 * width / 16, height - 10,
        width - 10, height / 2 };
    Region region2 = new Region(device);
    region2.add(polygon2);

    gc.setAlpha(127);

    int clippingIndex = clippingCb.getSelectionIndex();

    switch (clippingIndex) {
    case 0:
      // region 1
      gc.setClipping(region1);
      gc.setBackground(colorGB1.getBgColor1());
      gc.fillPolygon(polygon1);
      break;
    case 1:
      // region 2
      gc.setClipping(region2);
      gc.setBackground(colorGB2.getBgColor1());
      gc.fillPolygon(polygon2);
      break;
    case 2:
      // add
      region1.add(region2);
      break;
    case 3:
      // sub
      region1.subtract(region2);
      break;
    case 4:
      // intersect
      region1.intersect(region2);
      break;
    }

    if (clippingIndex > 1) {
      gc.setClipping(region1);

      gc.setBackground(colorGB1.getBgColor1());
      gc.fillPolygon(polygon1);

      gc.setBackground(colorGB2.getBgColor1());
      gc.fillPolygon(polygon2);
    }

    region1.dispose();
    region2.dispose();
  }
View Full Code Here

            paintImage = new Image(display, Math.max(rect.width, event.width + event.x), Math.max(
                rect.height, event.height + event.y));
            paintFDC.gc = new GC(paintImage);
          }
          // Setup clipping and the FDC
          Region clipRegion = new Region();
          event.gc.getClipping(clipRegion);
          paintFDC.gc.setClipping(clipRegion);
          clipRegion.dispose();

          paintFDC.xOffset = displayFDC.xOffset;
          paintFDC.yOffset = displayFDC.yOffset;
          paintFDC.xScale = displayFDC.xScale;
          paintFDC.yScale = displayFDC.yScale;
View Full Code Here

   * Erases any rubberband objects on the screen then clears the selection.
   * </p>
   */
  public void clearRubberbandSelection() {
    if (!isRubberbandHidden()) {
      Region region = new Region();
      rubberband.addDamagedRegion(displayFDC, region);
      Rectangle r = region.getBounds();
      paintCanvas.redraw(r.x, r.y, r.width, r.height, true);
      region.dispose();
    }
    rubberband.clear();

  }
View Full Code Here

TOP

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

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.