本文整理汇总了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);
}
示例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);
}
示例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);
}