1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.Graphics; |
26 |
import java.awt.Insets; |
27 |
|
28 |
import javax.swing.ImageIcon; |
29 |
|
30 |
import sun.swing.plaf.synth.Paint9Painter; |
31 |
|
32 |
|
33 |
/** |
34 |
* |
35 |
* @author Grigor Iliev |
36 |
*/ |
37 |
public class PixmapPane extends javax.swing.JPanel { |
38 |
private ImageIcon pixmap; |
39 |
private Insets pixmapInsets = null; |
40 |
|
41 |
private static Paint9Painter paint9Painter = new Paint9Painter(1); |
42 |
|
43 |
/** |
44 |
* Creates a new double buffered <code>PixmapPane</code> with |
45 |
* flow layout and with the specified pixmap to be used as background. |
46 |
* @param pixmap The pixmap to be used for background. |
47 |
*/ |
48 |
public |
49 |
PixmapPane(ImageIcon pixmap) { this(pixmap, new java.awt.FlowLayout()); } |
50 |
|
51 |
/** |
52 |
* Creates a new double buffered <code>PixmapPane</code> with |
53 |
* the specified layout manager and pixmap to be used as background. |
54 |
* @param pixmap The pixmap to be used for background. |
55 |
* @param layout the <code>LayoutManager</code> to use. |
56 |
*/ |
57 |
public |
58 |
PixmapPane(ImageIcon pixmap, java.awt.LayoutManager layout) { |
59 |
super(layout); |
60 |
|
61 |
setOpaque(false); |
62 |
this.pixmap = pixmap; |
63 |
} |
64 |
|
65 |
protected void |
66 |
paintComponent(Graphics g) { |
67 |
super.paintComponent(g); |
68 |
paintComponent(this, g, pixmap, pixmapInsets); |
69 |
} |
70 |
|
71 |
protected static void |
72 |
paintComponent(java.awt.Component c, Graphics g, ImageIcon pixmap, Insets pixmapInsets) { |
73 |
paint9Painter.paint ( |
74 |
c, g, 0, 0, c.getWidth(), c.getHeight(), pixmap.getImage(), |
75 |
pixmapInsets, pixmapInsets, |
76 |
Paint9Painter.PaintType.PAINT9_STRETCH, |
77 |
Paint9Painter.PAINT_ALL |
78 |
); |
79 |
} |
80 |
|
81 |
/** |
82 |
* Gets the pixmap that is used for background. |
83 |
* @return The pixmap that is used for background. |
84 |
*/ |
85 |
public ImageIcon |
86 |
getPixmap() { return pixmap; } |
87 |
|
88 |
/** |
89 |
* Sets the pixmap to be used for background. |
90 |
* @param pixmap Specifies the pixmap to be used for background. |
91 |
*/ |
92 |
public void |
93 |
setPixmap(ImageIcon pixmap) { |
94 |
this.pixmap = pixmap; |
95 |
revalidate(); |
96 |
repaint(); |
97 |
} |
98 |
|
99 |
public void |
100 |
setPixmapInsets(Insets insets) { |
101 |
pixmapInsets = insets; |
102 |
} |
103 |
} |