Swing/Zoom のバックアップ差分(No.1)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/Zoom へ行く。
- 1 (2007-05-18 (金) 13:11:04)
- 2 (2011-05-08 (日) 23:30:37)
- 3 (2013-02-22 (金) 18:59:56)
- 4 (2014-04-23 (水) 17:43:51)
- 5 (2014-09-04 (木) 13:54:02)
- 6 (2014-10-07 (火) 17:52:08)
- 7 (2015-10-01 (木) 19:26:04)
- 8 (2016-01-29 (金) 14:01:16)
- 9 (2016-08-12 (金) 15:40:11)
- 10 (2017-10-05 (木) 14:26:51)
- 11 (2019-04-12 (金) 16:44:54)
- 12 (2021-01-23 (土) 21:34:44)
- 13 (2023-12-08 (金) 17:08:03)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:MouseWheelで画像のズームイン・アウト表示 #navi(../) *MouseWheelで画像のズームイン・アウト表示 [#g39f1afa] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2006-10-16~ 更新日:&lastmod; #contents **概要 [#vb8f46d0] マウスホイールなどで画像をズームイン、ズームアウトします。 #screenshot **サンプルコード [#n33b6ada] #code{{ class ZoomImage extends JComponent implements MouseWheelListener { private final ImageIcon icon; private final int iw; private final int ih; private double scale = 1.0d; public ZoomImage(final ImageIcon icon) { super(); this.icon = icon; iw = icon.getIconWidth(); ih = icon.getIconWidth(); addMouseWheelListener(this); } public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.scale(scale, scale); g2.drawImage(icon.getImage(), 0, 0, iw, ih, this); } public void mouseWheelMoved(MouseWheelEvent e) { changeScale(e.getWheelRotation()); } public void initScale() { scale = 1.0d; repaint(); } public void changeScale(int iv) { scale = Math.max(0.05d, Math.min(5.0d, scale-iv*0.05d)); repaint(); } } }} -&jnlp; -&jar; -&zip; **解説 [#h16d4c28] 上記のサンプルではホイールの上回転で拡大、下回転で縮小しています。 //**参考リンク **コメント [#g84ab533] #comment