Search in sources :

Example 31 with Transform

use of org.eclipse.swt.graphics.Transform in project pentaho-kettle by pentaho.

the class Sleak method paintCanvas.

void paintCanvas(Event event) {
    canvas.setCursor(null);
    int index = list.getSelectionIndex();
    if (index == -1) {
        return;
    }
    GC gc = event.gc;
    Object object = objects[index];
    if (object instanceof Color) {
        if (((Color) object).isDisposed()) {
            return;
        }
        gc.setBackground((Color) object);
        gc.fillRectangle(canvas.getClientArea());
        return;
    }
    if (object instanceof Cursor) {
        if (((Cursor) object).isDisposed()) {
            return;
        }
        canvas.setCursor((Cursor) object);
        return;
    }
    if (object instanceof Font) {
        if (((Font) object).isDisposed()) {
            return;
        }
        gc.setFont((Font) object);
        FontData[] array = gc.getFont().getFontData();
        String string = "";
        String lf = text.getLineDelimiter();
        for (int i = 0; i < array.length; i++) {
            FontData data = array[i];
            String style = "NORMAL";
            int bits = data.getStyle();
            if (bits != 0) {
                if ((bits & SWT.BOLD) != 0) {
                    style = "BOLD ";
                }
                if ((bits & SWT.ITALIC) != 0) {
                    style += "ITALIC";
                }
            }
            string += data.getName() + " " + data.getHeight() + " " + style + lf;
        }
        gc.drawString(string, 0, 0);
        return;
    }
    // }
    if (object instanceof Image) {
        if (((Image) object).isDisposed()) {
            return;
        }
        gc.drawImage((Image) object, 0, 0);
        return;
    }
    if (object instanceof Path) {
        if (((Path) object).isDisposed()) {
            return;
        }
        gc.drawPath((Path) object);
        return;
    }
    if (object instanceof Pattern) {
        if (((Pattern) object).isDisposed()) {
            return;
        }
        gc.setBackgroundPattern((Pattern) object);
        gc.fillRectangle(canvas.getClientArea());
        gc.setBackgroundPattern(null);
        return;
    }
    if (object instanceof Region) {
        if (((Region) object).isDisposed()) {
            return;
        }
        String string = ((Region) object).getBounds().toString();
        gc.drawString(string, 0, 0);
        return;
    }
    if (object instanceof TextLayout) {
        if (((TextLayout) object).isDisposed()) {
            return;
        }
        ((TextLayout) object).draw(gc, 0, 0);
        return;
    }
    if (object instanceof Transform) {
        if (((Transform) object).isDisposed()) {
            return;
        }
        String string = ((Transform) object).toString();
        gc.drawString(string, 0, 0);
        return;
    }
}
Also used : Path(org.eclipse.swt.graphics.Path) Pattern(org.eclipse.swt.graphics.Pattern) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) Cursor(org.eclipse.swt.graphics.Cursor) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) TextLayout(org.eclipse.swt.graphics.TextLayout) Region(org.eclipse.swt.graphics.Region) GC(org.eclipse.swt.graphics.GC) Transform(org.eclipse.swt.graphics.Transform)

Example 32 with Transform

use of org.eclipse.swt.graphics.Transform in project pentaho-kettle by pentaho.

the class SWTDirectGC method setTransform.

public void setTransform(float translationX, float translationY, int shadowsize, float magnification) {
    if (transform != null) {
        // dispose of previous to prevent leaking of handles
        transform.dispose();
    }
    transform = new Transform(gc.getDevice());
    transform.translate(translationX + shadowsize * magnification, translationY + shadowsize * magnification);
    transform.scale(magnification, magnification);
    gc.setTransform(transform);
    currentMagnification = magnification;
}
Also used : Transform(org.eclipse.swt.graphics.Transform)

Example 33 with Transform

use of org.eclipse.swt.graphics.Transform in project pentaho-kettle by pentaho.

the class SWTGC method setTransform.

public void setTransform(float translationX, float translationY, int shadowsize, float magnification) {
    if (transform != null) {
        // dispose of previous to prevent leaking of handles
        transform.dispose();
    }
    transform = new Transform(gc.getDevice());
    transform.translate(translationX + shadowsize * magnification, translationY + shadowsize * magnification);
    transform.scale(magnification, magnification);
    gc.setTransform(transform);
    currentMagnification = magnification;
}
Also used : Transform(org.eclipse.swt.graphics.Transform)

Example 34 with Transform

use of org.eclipse.swt.graphics.Transform in project archi by archimatetool.

the class SWTGraphics method initTransform.

private void initTransform(boolean force) {
    if (!force && translateX == 0 && translateY == 0) {
        return;
    }
    if (transform == null) {
        transform = new Transform(Display.getCurrent());
        elementsNeedUpdate = true;
        transform.translate(translateX, translateY);
        translateX = 0;
        translateY = 0;
        gc.setTransform(transform);
        currentState.graphicHints |= ADVANCED_GRAPHICS_MASK;
    }
}
Also used : Transform(org.eclipse.swt.graphics.Transform)

Aggregations

Transform (org.eclipse.swt.graphics.Transform)34 Device (org.eclipse.swt.graphics.Device)11 Path (org.eclipse.swt.graphics.Path)10 Point (org.eclipse.swt.graphics.Point)9 Font (org.eclipse.swt.graphics.Font)7 Image (org.eclipse.swt.graphics.Image)7 Rectangle (org.eclipse.swt.graphics.Rectangle)7 AffineTransform (java.awt.geom.AffineTransform)6 GC (org.eclipse.swt.graphics.GC)6 Pattern (org.eclipse.swt.graphics.Pattern)6 Color (org.eclipse.swt.graphics.Color)3 Cursor (org.eclipse.swt.graphics.Cursor)2 FontData (org.eclipse.swt.graphics.FontData)2 Region (org.eclipse.swt.graphics.Region)2 TextLayout (org.eclipse.swt.graphics.TextLayout)2 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)1 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)1 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)1 SWTException (org.eclipse.swt.SWTException)1 Printer (org.eclipse.swt.printing.Printer)1