• 追加された行はこの色です。
  • 削除された行はこの色です。
TITLE:Shapeの反転
#navi(../)
*Shapeの反転 [#ac299306]
Posted by [[terai]] at 2008-07-28
---
category: swing
folder: HorizontalFlip
title: Shapeの反転
tags: [Shape, Font, AffineTransform]
author: aterai
pubdate: 2008-07-28T12:01:57+09:00
description: AffineTransformで図形や画像を反転して表示します。
image: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTN731lMzI/AAAAAAAAAbk/Wc0qp3ocR88/s800/HorizontalFlip.png
---
* 概要 [#summary]
`AffineTransform`で図形や画像を反転して表示します。

#contents
#download(https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTN731lMzI/AAAAAAAAAbk/Wc0qp3ocR88/s800/HorizontalFlip.png)

**概要 [#l97f4418]
AffineTransform で図形や画像を反転します。

-&jnlp;
-&jar;
-&zip;

#screenshot

**サンプルコード [#ie746204]
#code{{
Font font = new Font("Monospace", Font.PLAIN, 200);
* サンプルコード [#sourcecode]
#code(link){{
Font font = new Font(Font.MONOSPACED, Font.PLAIN, 200);
FontRenderContext frc = new FontRenderContext(null, true, true);
Shape copyright = new TextLayout("\u00a9", font, frc).getOutline(null);
AffineTransform at = AffineTransform.getScaleInstance(-1.0, 1.0);
//at.translate(-copyright.getBounds().getWidth(), 0);
//AffineTransform at = new AffineTransform(-1d,0,0,1d,-copyright.getBounds().getWidth(),0);
//AffineTransform at = new AffineTransform(-1d,0,0,1d,0,0);
AffineTransform at = AffineTransform.getScaleInstance(-1d, 1d);
// Rectangle r = copyright.getBounds();
// at.translate(r.getWidth(), r.getHeight());
// AffineTransform at = new AffineTransform(
//    -1d, 0d, 0d, 1d, r.getWidth(), r.getHeight());
Shape copyleft = at.createTransformedShape(copyright);
}}

**解説 [#m5fa2d66]
上記のサンプルでは、コピーライトの文字を鏡像反転して、コピーレフトのアイコン((http://ja.wikipedia.org/wiki/コピーレフト))を作成しています。
* 解説 [#explanation]
上記のサンプルでは、コピーライトの文字を鏡像(左右)反転してコピーレフトの文字アイコンを作成しています。

//**参考リンク
**コメント [#c9ea5267]
- 上下反転の場合は`AffineTransform.getScaleInstance(1d, -1d)`が使用可能

* 参考リンク [#reference]
- [http://en.wikipedia.org/wiki/Copyleft コピーレフト - Wikipedia]
- [[AffineTransformOpで画像を反転する>Swing/AffineTransformOp]]

* コメント [#comment]
#comment
#comment