当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransform.setToTranslation方法代码示例

本文整理汇总了Java中java.awt.geom.AffineTransform.setToTranslation方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform.setToTranslation方法的具体用法?Java AffineTransform.setToTranslation怎么用?Java AffineTransform.setToTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.setToTranslation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
	Dimension d = vv.getSize();
	FontRenderContext frc = ((Graphics2D) g).getFontRenderContext();
	Font f = new Font("Times", Font.BOLD, 30);

	TextLayout tl = new TextLayout(str, f, frc);
	AffineTransform transform = new AffineTransform();
	transform.setToTranslation(d.width / 2, d.height / 2);
	transform.rotate(Math.toRadians(315));
	Shape shape = tl.getOutline(transform);
	g.translate(-shape.getBounds().width / 2,
			shape.getBounds().height / 2);
	g.setColor(Color.lightGray);
	((Graphics2D) g).draw(shape);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:17,代码来源:LayerViewer.java

示例2: paintMessage

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param g Description of the Parameter
 */
public void paintMessage(Graphics2D g) {
    if (message == null || message.length() < 1) {
        return;
    }

    int x = getSize().width / 2;
    int y = getSize().height / 2;

    g.setFont(bigFont);

    Font f = g.getFont();
    TextLayout txtLayout = new TextLayout(message, f, g.getFontRenderContext());
    float sw = (float) txtLayout.getBounds().getWidth();
    AffineTransform transform = new AffineTransform();
    transform.setToTranslation(x - sw / 2, y);

    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g.setStroke(thickStroke);
    g.setColor(colors[0]);
    g.draw(txtLayout.getOutline(transform));

    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:32,代码来源:YassBasicRenderer.java

示例3: createTransformedShape

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Creates and returns a translated version of a shape.
 *
 * @param shape  the base shape.
 * @param translateX  the x translation.
 * @param translateY  the y translation.
 *
 * @return The shape.
 */
protected synchronized Shape createTransformedShape(Shape shape,
                                                    double translateX, double translateY) {

    AffineTransform transformer = new AffineTransform();
    transformer.setToTranslation(translateX, translateY);
    return transformer.createTransformedShape(shape);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:AbstractRenderer.java


注:本文中的java.awt.geom.AffineTransform.setToTranslation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。