/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/basic/PixmapPane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/basic/PixmapPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1785 - (show annotations) (download)
Tue Oct 7 00:07:14 2008 UTC (15 years, 6 months ago) by iliev
File size: 2934 byte(s)
* Fantasia: Implemented multiple channels panels
* Fantasia: Refactoring - all basic UI components moved to
  org.jsampler.view.fantasia.basic package

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 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.basic;
24
25 import java.awt.Graphics;
26 import java.awt.Insets;
27
28 import javax.swing.ImageIcon;
29 import javax.swing.plaf.basic.BasicPanelUI;
30
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 @Override
67 protected void
68 paintComponent(Graphics g) {
69 super.paintComponent(g);
70 paintComponent(this, g, pixmap, pixmapInsets);
71 }
72
73 protected static void
74 paintComponent(java.awt.Component c, Graphics g, ImageIcon pixmap, Insets pixmapInsets) {
75 paint9Painter.paint (
76 c, g, 0, 0, c.getWidth(), c.getHeight(), pixmap.getImage(),
77 pixmapInsets, pixmapInsets,
78 Paint9Painter.PaintType.PAINT9_STRETCH,
79 Paint9Painter.PAINT_ALL
80 );
81 }
82
83 /**
84 * Gets the pixmap that is used for background.
85 * @return The pixmap that is used for background.
86 */
87 public ImageIcon
88 getPixmap() { return pixmap; }
89
90 /**
91 * Sets the pixmap to be used for background.
92 * @param pixmap Specifies the pixmap to be used for background.
93 */
94 public void
95 setPixmap(ImageIcon pixmap) {
96 this.pixmap = pixmap;
97 revalidate();
98 repaint();
99 }
100
101 public void
102 setPixmapInsets(Insets insets) {
103 pixmapInsets = insets;
104 }
105
106 @Override
107 public void
108 updateUI() { setUI(new BasicPanelUI()); }
109 }

  ViewVC Help
Powered by ViewVC