本文整理了Java中org.eclipse.swt.graphics.GC.setTransform()
方法的一些代码示例,展示了GC.setTransform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.setTransform()
方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:setTransform
[英]Sets the transform that is currently being used by the receiver. If the argument is null
, the current transform is set to the identity transform.
This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
[中]设置接收器当前正在使用的变换。如果参数为null
,则当前转换将设置为标识转换。
此操作需要操作系统的高级图形子系统,该子系统在某些平台上可能不可用。
代码示例来源:origin: pentaho/pentaho-kettle
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;
}
代码示例来源:origin: pentaho/pentaho-kettle
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;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
protected Image renderRotated( Device device, int width, int height, double angleRadians ) {
Image result = new Image( device, width * 2, height * 2 );
GC gc = new GC( result );
int bw = bitmap.getBounds().width;
int bh = bitmap.getBounds().height;
Transform affineTransform = new Transform( device );
affineTransform.translate( width, height );
affineTransform.rotate( (float) Math.toDegrees( angleRadians ) );
affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh );
gc.setTransform( affineTransform );
gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh );
gc.dispose();
return result;
}
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Draws the provided path.
*
* @param p path to draw
*/
public void drawPath(final Path p) {
gc.setTransform(swtTransform);
gc.drawPath(p);
gc.setTransform(null);
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Draws a filled version of the provided path.
*
* @param p path to draw filled
*/
public void fillPath(final Path p) {
gc.setTransform(swtTransform);
gc.fillPath(p);
gc.setTransform(null);
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Renders the text of the specified String, using the current text
* attribute state in the Graphics2D context. The baseline of the first
* character is at position (x, y) in the User Space. The rendering
* attributes applied include the Clip, Transform, Paint, Font and Composite
* attributes. For characters in script systems such as Hebrew and Arabic,
* the glyphs can be rendered from right to left, in which case the
* coordinate supplied is the location of the leftmost character on the
* baseline.
*
* @param str the string to be rendered
* @param x the x coordinate of the location where the String should be
* rendered
* @param y the y coordinate of the location where the String should be
* rendered
* @param flags flags to apply to the string as defined by SWT
*/
public void drawText(final String str, final int x, final int y, final int flags) {
gc.setTransform(swtTransform);
gc.drawText(str, x, y, flags);
gc.setTransform(null);
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Renders the text of the specified String, using the current text
* attribute state in the Graphics2D context. The baseline of the first
* character is at position (x, y) in the User Space. The rendering
* attributes applied include the Clip, Transform, Paint, Font and Composite
* attributes. For characters in script systems such as Hebrew and Arabic,
* the glyphs can be rendered from right to left, in which case the
* coordinate supplied is the location of the leftmost character on the
* baseline.
*
* @param str the string to be rendered
* @param x the x coordinate of the location where the String should be
* rendered
* @param y the y coordinate of the location where the String should be
* rendered
* @param isTransparent whether a background should be painted behind the
* text
*/
public void drawString(final String str, final int x, final int y, final boolean isTransparent) {
gc.setTransform(swtTransform);
gc.drawString(str, x, y, isTransparent);
gc.setTransform(null);
}
代码示例来源:origin: org.jfree/swtgraphics2d
/**
* Sets the current transform.
*
* @param t the transform.
*/
@Override
public void setTransform(AffineTransform t) {
Transform transform = getSwtTransformFromPool(t);
this.gc.setTransform(transform);
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer
public void translate(double tx, double ty) {
if (_transform == null) {
_transform = new Transform(_gc.getDevice());
}
_transform.translate((int) tx, (int) ty);
_gc.setTransform(_transform);
if (_clippingArea != null) {
AffineTransform t = new AffineTransform();
t.translate(-tx, -ty);
_clippingArea.transform(t);
}
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void drawText ( final String string, final int x, final int y, final Float rotate )
{
final Transform t;
if ( rotate != null )
{
t = new Transform ( this.gc.getDevice () );
t.rotate ( rotate );
this.gc.setTransform ( t );
}
else
{
t = null;
}
this.gc.drawText ( string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT );
if ( t != null )
{
this.gc.setTransform ( null );
t.dispose ();
}
}
代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
@Override
public void drawText ( final String string, final int x, final int y, final Float rotate )
{
final Transform t;
if ( rotate != null )
{
t = new Transform ( this.gc.getDevice () );
t.rotate ( rotate );
this.gc.setTransform ( t );
}
else
{
t = null;
}
this.gc.drawText ( string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT );
if ( t != null )
{
this.gc.setTransform ( null );
t.dispose ();
}
}
代码示例来源:origin: stefanhaustein/flowgrid
public Image getIcon(Icon id) {
Image image = icons.get(id);
if (image == null) {
String vectorResName = "/icons/ic_" + id.name().toLowerCase() + (dark ? "_white_24dp.xml" : "_black_24dp.xml");
InputStream is = getClass().getResourceAsStream(vectorResName);
int expectedSize = Math.round(24 * pixelPerDp);
AndroidVectorDrawable avd = AndroidVectorDrawable.read(display, is, pixelPerDp);
image = new Image(display, expectedSize, expectedSize);
GC gc = new GC(image);
if (expectedSize != 24) {
Transform transform = new Transform(display);
gc.getTransform(transform);
transform.scale(expectedSize/24f, expectedSize/24f);
gc.setTransform(transform);
transform.dispose();
}
avd.draw(gc);
icons.put(id, image);
}
return image;
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer
/**
* Clean used resources.
*/
public void clean() {
if (_clippingPath != null) {
_gc.setClipping((Rectangle) null);
_clippingPath.dispose();
_clippingPath = null;
_clippingArea = null;
}
if (_color != null) {
_color.dispose();
_color = null;
}
if (_transform != null) {
_gc.setTransform(null);
_transform.dispose();
}
}
代码示例来源:origin: org.jfree/swtgraphics2d
/**
* Applies a translation.
*
* @param x the translation along the x-axis.
* @param y the translation along the y-axis.
*/
@Override
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();
}
代码示例来源:origin: org.jfree/swtgraphics2d
/**
* Applies a scale transform.
*
* @param scaleX the scale factor along the x-axis.
* @param scaleY the scale factor along the y-axis.
*/
@Override
public void scale(double scaleX, double scaleY) {
Transform swtTransform = new Transform(this.gc.getDevice());
this.gc.getTransform(swtTransform);
swtTransform.scale((float) scaleX, (float) scaleY);
this.gc.setTransform(swtTransform);
swtTransform.dispose();
}
代码示例来源:origin: org.jfree/swtgraphics2d
/**
* Concatenates the specified transform to the existing transform.
*
* @param t the transform.
*/
@Override
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();
}
代码示例来源:origin: org.xworker/xworker_swt
@ActionParams(names="canvas,gc,shape")
public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) {
Control control = (Control) shape.getData(KEY);
if(control != null && !control.isDisposed()) {
int offset = shape.isSelected() ? 12 : 0;
//System.out.println("ControlShape, selected=" + shape.isSelected());
Point clientSize = new Point(shape.getWidth() - offset, shape.getHeight() -offset);
control.setSize(clientSize);
control.setLocation(shape.getX() + offset/2, shape.getY() + offset/2);
//Point size = control.getSize();
//System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]);
Transform oldTransform = new Transform(gc.getDevice());
gc.getTransform(oldTransform);
Transform transform = new Transform(gc.getDevice());
transform.translate(shape.getX() + offset/2, shape.getY() + offset/2);
//transform.scale(1f * shape.getWidth() / (clientSize.x), 1f * shape.getHeight() / (clientSize.y));
//transform.multiply(oldTransform);
gc.setTransform(transform);
control.print(gc);
gc.setTransform(oldTransform);
transform.dispose();
oldTransform.dispose();
}
}
代码示例来源:origin: org.xworker/xworker_swt
@ActionParams(names="canvas,gc,shape")
public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) {
Control control = (Control) shape.getData(KEY);
if(control != null && !control.isDisposed()) {
int offset = shape.isSelected() ? 12 : 0;
//System.out.println("ControlShape, selected=" + shape.isSelected());
Point clientSize = new Point(shape.getWidth() - offset, shape.getHeight() -offset);
control.setSize(clientSize);
control.setLocation(shape.getX() + offset/2, shape.getY() + offset/2);
//Point size = control.getSize();
//System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]);
Transform oldTransform = new Transform(gc.getDevice());
gc.getTransform(oldTransform);
Transform transform = new Transform(gc.getDevice());
transform.translate(shape.getX() + offset/2, shape.getY() + offset/2);
//transform.scale(1f * shape.getWidth() / (clientSize.x), 1f * shape.getHeight() / (clientSize.y));
//transform.multiply(oldTransform);
gc.setTransform(transform);
control.print(gc);
gc.setTransform(oldTransform);
transform.dispose();
oldTransform.dispose();
}
}
代码示例来源:origin: org.xworker/xworker_swt
@ActionParams(names="canvas,gc,shape")
public static void draw(Canvas canvas, GC gc, SimpleShape shape, ActionContext actionContext) {
Thing thing = shape.getThing();
Path path = (Path) shape.getData(PATH);
if(path != null && !path.isDisposed()) {
float bounds[] = new float[4];
path.getBounds(bounds);
//System.out.println(bounds[0] + "," + bounds[1] + "," + bounds[2] + "," + bounds[3]);
Transform oldTransform = new Transform(gc.getDevice());
gc.getTransform(oldTransform);
Transform transform = new Transform(gc.getDevice());
transform.translate(shape.getX(), shape.getY());
transform.scale(shape.getWidth() / (bounds[0] + bounds[2]), shape.getHeight() / (bounds[1] + bounds[3]));
//transform.multiply(oldTransform);
gc.setTransform(transform);
if(thing.getBoolean("fill")) {
gc.fillPath(path);
}else {
gc.drawPath(path);
}
gc.setTransform(oldTransform);
transform.dispose();
oldTransform.dispose();
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
gc.setTransform(transform);
gc.drawImage(image, 0, 0);
内容来源于网络,如有侵权,请联系作者删除!