1 |
iliev |
1286 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
1743 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1286 |
* |
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 |
iliev |
1743 |
import javax.swing.plaf.basic.BasicPanelUI; |
30 |
iliev |
1286 |
|
31 |
|
|
import sun.swing.plaf.synth.Paint9Painter; |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* |
36 |
|
|
* @author Grigor Iliev |
37 |
|
|
*/ |
38 |
|
|
public class PixmapPane extends javax.swing.JPanel { |
39 |
|
|
private ImageIcon pixmap; |
40 |
|
|
private Insets pixmapInsets = null; |
41 |
|
|
|
42 |
|
|
private static Paint9Painter paint9Painter = new Paint9Painter(1); |
43 |
|
|
|
44 |
|
|
/** |
45 |
|
|
* Creates a new double buffered <code>PixmapPane</code> with |
46 |
|
|
* flow layout and with the specified pixmap to be used as background. |
47 |
|
|
* @param pixmap The pixmap to be used for background. |
48 |
|
|
*/ |
49 |
|
|
public |
50 |
|
|
PixmapPane(ImageIcon pixmap) { this(pixmap, new java.awt.FlowLayout()); } |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* Creates a new double buffered <code>PixmapPane</code> with |
54 |
|
|
* the specified layout manager and pixmap to be used as background. |
55 |
|
|
* @param pixmap The pixmap to be used for background. |
56 |
|
|
* @param layout the <code>LayoutManager</code> to use. |
57 |
|
|
*/ |
58 |
|
|
public |
59 |
|
|
PixmapPane(ImageIcon pixmap, java.awt.LayoutManager layout) { |
60 |
|
|
super(layout); |
61 |
|
|
|
62 |
|
|
setOpaque(false); |
63 |
|
|
this.pixmap = pixmap; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
protected void |
67 |
|
|
paintComponent(Graphics g) { |
68 |
|
|
super.paintComponent(g); |
69 |
|
|
paintComponent(this, g, pixmap, pixmapInsets); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
protected static void |
73 |
|
|
paintComponent(java.awt.Component c, Graphics g, ImageIcon pixmap, Insets pixmapInsets) { |
74 |
|
|
paint9Painter.paint ( |
75 |
|
|
c, g, 0, 0, c.getWidth(), c.getHeight(), pixmap.getImage(), |
76 |
|
|
pixmapInsets, pixmapInsets, |
77 |
|
|
Paint9Painter.PaintType.PAINT9_STRETCH, |
78 |
|
|
Paint9Painter.PAINT_ALL |
79 |
|
|
); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
/** |
83 |
|
|
* Gets the pixmap that is used for background. |
84 |
|
|
* @return The pixmap that is used for background. |
85 |
|
|
*/ |
86 |
|
|
public ImageIcon |
87 |
|
|
getPixmap() { return pixmap; } |
88 |
|
|
|
89 |
|
|
/** |
90 |
|
|
* Sets the pixmap to be used for background. |
91 |
|
|
* @param pixmap Specifies the pixmap to be used for background. |
92 |
|
|
*/ |
93 |
|
|
public void |
94 |
|
|
setPixmap(ImageIcon pixmap) { |
95 |
|
|
this.pixmap = pixmap; |
96 |
|
|
revalidate(); |
97 |
|
|
repaint(); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
public void |
101 |
|
|
setPixmapInsets(Insets insets) { |
102 |
|
|
pixmapInsets = insets; |
103 |
|
|
} |
104 |
iliev |
1743 |
|
105 |
|
|
public void |
106 |
|
|
updateUI() { setUI(new BasicPanelUI()); } |
107 |
iliev |
1286 |
} |