Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Transform


    transform.multiply(transform2);
    gc.setTransform(transform);
  }

  public void scale(double scaleX, double scaleY) {
    Transform transform = new Transform(gc.getDevice());
    Transform transform2 = new Transform(gc.getDevice());
    gc.getTransform(transform);
    transform2.scale((float) scaleX, (float) scaleY);
    transform.multiply(transform2);
    gc.setTransform(transform);
  }
View Full Code Here


   * @see org.locationtech.udig.project.render.ViewportGraphics#translate(java.awt.Point)
   */
  public void translate(Point offset) {
        AWTSWTImageUtils.checkAccess();
        if( swtTransform==null ){
            swtTransform=new Transform(display);
        }
        swtTransform.translate(offset.x, offset.y);
        gc.setTransform(swtTransform);
  }
View Full Code Here

    public void setTransform( AffineTransform transform ) {
        AWTSWTImageUtils.checkAccess();
        double[] matrix=new double[6];
        transform.getMatrix(matrix);
        if( swtTransform==null ){
            swtTransform=new Transform(display,
                    (float)matrix[0], (float)matrix[1], (float)matrix[2],
                    (float)matrix[3], (float)matrix[4], (float)matrix[5] );
        }else{
            swtTransform.setElements(
                    (float)matrix[0], (float)matrix[1], (float)matrix[2],
View Full Code Here

    if ((text == null) || (text.length() == 0)) {
      return;
    }

    if (angle != 0.0) {
      final Transform transform = new Transform(g2.getDevice());
      transform.translate(rotateX, rotateY);
      transform.rotate((float) (-angle * 180 / Math.PI));
      transform.translate(-rotateX, -rotateY);
      g2.setTransform(transform);
      transform.dispose();
    }

    g2.drawString(text, (int) textX, (int) textY, true);

    if (angle != 0.0) {
View Full Code Here

             * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
             */
            public void paintControl(PaintEvent event) {

                GC gc = event.gc;
                Transform transform = null;
                if (orientation == SWT.VERTICAL) {
                  transform = new Transform(event.display);
                transform.translate(TrimUtil.TRIM_DEFAULT_HEIGHT, 0);
                transform.rotate(90);
                }
                ILabelProvider labelProvider = (ILabelProvider) getLabelProvider();

                int itemCount = Math.min(displayedItems.length, numShowItems);

                int yOffset = 0;
                int xOffset = 0;
                if (numShowItems == 1) {//If there is a single item try to center it
                    Rectangle clientArea = canvas.getParent().getClientArea();
                    if (orientation == SWT.HORIZONTAL) {
                      int size = clientArea.height;
                      yOffset = size - (fontMetrics.getHeight());
                      yOffset = yOffset / 2;
                    } else {
                      int size = clientArea.width;
                      xOffset = size - (fontMetrics.getHeight());
                      xOffset = xOffset / 2;
                    }
                }

                for (int i = 0; i < itemCount; i++) {
                    String string = labelProvider.getText(displayedItems[i]);
                    if(string == null) {
            string = "";//$NON-NLS-1$
          }
                    if (orientation == SWT.HORIZONTAL) {
                      gc.drawString(string, 2, yOffset + (i * fontMetrics.getHeight()), true);
                    } else {
                  gc.setTransform(transform);
                      gc.drawString(string, xOffset + (i * fontMetrics.getHeight()), 2, true);
                    }
                }
                if (transform != null)
                  transform.dispose();
            }
        });
    }
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

     * Returns the current transform.
     *
     * @return The current transform.
     */
    public AffineTransform getTransform() {
        Transform swtTransform = new Transform(this.gc.getDevice());
        this.gc.getTransform(swtTransform);
        AffineTransform awtTransform = toAwtTransform(swtTransform);
        swtTransform.dispose();
        return awtTransform;
    }
View Full Code Here

     * Sets the current transform.
     *
     * @param t  the transform.
     */
    public void setTransform(AffineTransform t) {
        Transform transform = getSwtTransformFromPool(t);
        this.gc.setTransform(transform);
    }
View Full Code Here

     * Concatenates the specified transform to the existing transform.
     *
     * @param t  the transform.
     */
    public void transform(AffineTransform t) {
        Transform swtTransform = new Transform(this.gc.getDevice());
        this.gc.getTransform(swtTransform);
        swtTransform.multiply(getSwtTransformFromPool(t));
        this.gc.setTransform(swtTransform);
        swtTransform.dispose();
    }
View Full Code Here

     *
     * @param x  the translation along the x-axis.
     * @param y  the translation along the y-axis.
     */
    public void translate(int x, int y) {
        Transform swtTransform = new Transform(this.gc.getDevice());
        this.gc.getTransform(swtTransform);
        swtTransform.translate(x, y);
        this.gc.setTransform(swtTransform);
        swtTransform.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.