Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Transform


     *
     * @param shearX  the x-factor.
     * @param shearY  the y-factor.
     */
    public void shear(double shearX, double shearY) {
        Transform swtTransform = new Transform(this.gc.getDevice());
        this.gc.getTransform(swtTransform);
        Transform shear = new Transform(this.gc.getDevice(), 1f, (float) shearX,
                (float) shearY, 1f, 0, 0);
        swtTransform.multiply(shear);
        this.gc.setTransform(swtTransform);
        swtTransform.dispose();
    }
View Full Code Here


     *
     * @param awtTransform The AWT transform to convert.
     * @return A SWT transform instance.
     */
    private Transform getSwtTransformFromPool(AffineTransform awtTransform) {
        Transform t = (Transform) this.transformsPool.get(awtTransform);
        if (t == null) {
            t = new Transform(this.gc.getDevice());
            double[] matrix = new double[6];
            awtTransform.getMatrix(matrix);
            t.setElements((float) matrix[0], (float) matrix[1],
                    (float) matrix[2], (float) matrix[3],
                    (float) matrix[4], (float) matrix[5]);
            addToResourcePool(t);
            this.transformsPool.put(awtTransform, t);
        }
View Full Code Here

                if (stroke != null) {
                    int x, y;
                    Rectangle rect = getClientArea();
                    x = (rect.width - 100) / 2;
                    y = (rect.height - 16) / 2;
                    Transform swtTransform = new Transform(e.gc.getDevice());
                    e.gc.getTransform(swtTransform);
                    swtTransform.translate(x, y);
                    e.gc.setTransform(swtTransform);
                    swtTransform.dispose();
                    e.gc.setBackground(getDisplay().getSystemColor(
                            SWT.COLOR_BLACK));
                    e.gc.setLineWidth((int) stroke.getLineWidth());
                    e.gc.drawLine(10, 8, 90, 8);
                }
View Full Code Here

  }

  void paint(PaintEvent event) {
    Image printerImage = null;
    GC printerGC = null;
    Transform printerTransform = null;

    Image displayImage = null;

    try {
      drawBackground(event);

      if (page == null || printerData == null)
        return;

      getPrinter();
      getPaperSize();
      getPaperDisplayBounds();

      if (printer == null || paperSize == null || page == null || paperDisplayBounds == null)
        return;

      drawPaper(event);

      Rectangle dirtyBounds = new Rectangle(event.x, event.y, event.width, event.height);

      // The portion of the dirty bounds which is displaying "paper"
      Rectangle dirtyPaperBounds = dirtyBounds.intersection(paperDisplayBounds);

      // Dirty region has no "paper"
      if (dirtyPaperBounds.width == 0 || dirtyPaperBounds.height == 0)
        return;

      printerImage = new Image(printer, dirtyPaperBounds.width, dirtyPaperBounds.height);
      printerGC = new GC(printerImage);
      printerTransform = new Transform(printer);

      printerGC.getTransform(printerTransform);
      printerTransform.translate(paperDisplayBounds.x - dirtyPaperBounds.x,
                  paperDisplayBounds.y - dirtyPaperBounds.y);
      printerTransform.scale((float) paperDisplayBounds.width
          / (float) paperSize.x, (float) paperDisplayBounds.height
          / (float) paperSize.y);
      printerGC.setTransform(printerTransform);
     
      PrintContext context = new PrintContext( printerGC, getDisplay().getDPI() );

      // get full paper size
      Rectangle pageArea = SWTUtils.getPrintableBounds(printer);
      context.translate( new Point(pageArea.x, pageArea.y));
     
      page.doPrint( context, new Point(pageArea.width, pageArea.height) );

      displayImage = new Image(event.display, printerImage.getImageData());
      event.gc.drawImage(displayImage, dirtyPaperBounds.x, dirtyPaperBounds.y);
    } finally {
      if (printerImage != null)
        printerImage.dispose();
      if (displayImage != null)
        displayImage.dispose();
      if (printerGC != null)
        printerGC.dispose();
      if (printerTransform != null)
        printerTransform.dispose();
    }
  }
View Full Code Here

    }

    public void paint(GC gc, Object value)
    {

        Transform transform = new Transform(gc.getDevice());
        transform.translate(getBounds().x, getBounds().y);
        gc.setTransform(transform);

        gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

        if (isHover())
        {
            gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
            // gc.fillRoundRectangle(0,0,16,17,5,5);
            gc.drawRoundRectangle(0, 0, 17, 17, 5, 5);
        }

        gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

        if (isExpanded())
        {
            gc.fillRectangle(4, 3, 9, 3);
            gc.drawRectangle(4, 3, 9, 3);
        }
        else
        {
            gc.fillRectangle(4, 3, 9, 9);
            gc.drawRectangle(4, 3, 9, 9);
            gc.drawLine(4, 5, 13, 5);
        }

        gc.setTransform(null);
        transform.dispose();

    }
View Full Code Here

        setSize(new Point(17, 16));
    }

    public void paint(GC gc, Object value)
    {
        Transform transform = new Transform(gc.getDevice());
        transform.translate(getBounds().x, getBounds().y);
        gc.setTransform(transform);

        Color back = gc.getBackground();
        Color fore = gc.getForeground();

        if (isHover())
        {
            Color old = gc.getForeground();
            gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
            gc.drawRoundRectangle(0, 0, 16, 15, 5, 5);
            gc.setForeground(old);
        }

        if (isExpanded())
        {
            gc.drawPolygon(new int[] {5, 6, 8, 3, 11, 6, 10, 6, 8, 4, 6, 6 });

            gc.drawPolygon(new int[] {5, 10, 8, 7, 11, 10, 10, 10, 8, 8, 6, 10 });
        }
        else
        {
            gc.drawPolygon(new int[] {5, 4, 8, 7, 11, 4, 10, 4, 8, 6, 6, 4 });

            gc.drawPolygon(new int[] {5, 8, 8, 11, 11, 8, 10, 8, 8, 10, 6, 8 });
        }

        if (isFocus())
        {
            gc.setBackground(back);
            gc.setForeground(fore);
            gc.drawFocus(2, 2, 13, 12);
        }

        gc.setTransform(null);
        transform.dispose();

    }
View Full Code Here

        setSize(new Point(9, 9));
    }

    public void paint(GC gc, Object value)
    {
        Transform transform = new Transform(gc.getDevice());
        transform.translate(getBounds().x, getBounds().y);
        gc.setTransform(transform);

        Color back = gc.getBackground();
        Color fore = gc.getForeground();

        gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
        gc.fillRectangle(0, 0, 8, 8);

        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
        gc.drawLine(2, 4, 6, 4);
        if (!isExpanded())
        {
            gc.drawLine(4, 2, 4, 6);
        }
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        gc.drawRectangle(0, 0, 8, 8);

        if (isFocus())
        {
            gc.setBackground(back);
            gc.setForeground(fore);
            gc.drawFocus(-1, -1, 11, 11);
        }

        gc.setTransform(null);
        transform.dispose();
    }
View Full Code Here

        setSize(new Point(10, 10));
    }

    public void paint(GC gc, Object value)
    {
        Transform transform = new Transform(gc.getDevice());
        transform.translate(getBounds().x, getBounds().y);
        gc.setTransform(transform);

        Color back = gc.getBackground();
        Color fore = gc.getForeground();

        if (!isHover())
        {
            gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        }
        else
        {
            gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
        }

        gc.setBackground(gc.getForeground());
        if (isExpanded())
        {
            gc.drawPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 });
            gc.fillPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 });
        }
        else
        {
            gc.drawPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 });
            gc.fillPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 });
        }

        if (isFocus())
        {
            gc.setBackground(back);
            gc.setForeground(fore);
            gc.drawFocus(-1, -1, 12, 12);
        }

        gc.setTransform(null);
        transform.dispose();
    }
View Full Code Here

    Display display = getDisplay();
    Image image = item.getImage();
    Rectangle boundsNow = item.getBoundsNow();
    Rectangle imageBounds = computeImageBounds(item, boundsNow);

    Transform transform = new Transform(display);
   
    if (placement.isRotateAll()) {
      transform.translate(imageBounds.x, imageBounds.y);
     
      if (placement == Placement.LEFT_ROTATE_ALL) {
        transform.translate(0, imageBounds.height);
        transform.rotate(-90);
      } else if (placement == Placement.RIGHT_ROTATE_ALL) {
        transform.rotate(90);
        transform.translate(0, -imageBounds.width);
      }
     
      transform.translate(-imageBounds.x, -imageBounds.y);
    }
   
    gc.setTransform(transform);
   
    gc.drawImage(image, imageBounds.x, imageBounds.y);
   
    gc.setTransform(null);
    transform.dispose();
  }
View Full Code Here

    Display display = getDisplay();
    String text = item.getText();
    Rectangle boundsNow = item.getBoundsNow();
    Rectangle textBounds = computeTextBounds(item, boundsNow);
   
    Transform transform = new Transform(display);
   
    if (placement != Placement.TOP) {
      transform.translate(textBounds.x, textBounds.y);
     
      if (placement.isLeft()) {
        transform.translate(0, textBounds.height);
        transform.rotate(-90);
      } else if (placement.isRight()) {
        transform.rotate(90);
        transform.translate(0, -textBounds.width);
      }
     
      transform.translate(-textBounds.x, -textBounds.y);
    }
   
    gc.setTransform(transform);
   
    gc.drawText(text, textBounds.x, textBounds.y, true);
   
    gc.setTransform(null);
    transform.dispose();
  }
View Full Code Here

TOP

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

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.