當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。