KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > apps > svgbrowser > PNGOptionPanel


1 /*
2
3    Copyright 2002-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.apps.svgbrowser;
19
20 import java.awt.Component JavaDoc;
21 import java.awt.GridBagConstraints JavaDoc;
22 import java.awt.GridBagLayout JavaDoc;
23 import java.awt.Insets JavaDoc;
24
25 import javax.swing.JCheckBox JavaDoc;
26 import javax.swing.JLabel JavaDoc;
27
28 import org.apache.batik.util.gui.ExtendedGridBagConstraints;
29
30 /**
31  * This class represents a panel to choose the color model
32  * of the PNG, i.e. RGB or INDEXED.
33  *
34  * @author <a HREF="mailto:jun@oop-reserch.com">Jun Inamori</a>
35  *
36  */

37 public class PNGOptionPanel extends OptionPanel {
38
39     /**
40      * The check box for outputing an indexed PNG.
41      */

42     protected JCheckBox JavaDoc check;
43
44     /**
45      * Creates a new panel.
46      */

47     public PNGOptionPanel() {
48     super(new GridBagLayout JavaDoc());
49
50     ExtendedGridBagConstraints constraints =
51         new ExtendedGridBagConstraints();
52
53     
54     constraints.insets = new Insets JavaDoc(5, 5, 5, 5);
55
56     constraints.weightx = 0;
57     constraints.weighty = 0;
58     constraints.fill = GridBagConstraints.NONE;
59     constraints.setGridBounds(0, 0, 1, 1);
60     add(new JLabel JavaDoc(resources.getString("PNGOptionPanel.label")),
61         constraints);
62
63     check=new JCheckBox JavaDoc();
64
65     constraints.weightx = 1.0;
66     constraints.fill = GridBagConstraints.HORIZONTAL;
67     constraints.setGridBounds(1, 0, 1, 1);
68     add(check, constraints);
69     }
70
71     /**
72      * Returns if indexed or not
73      */

74     public boolean isIndexed() {
75     return check.isSelected();
76     }
77
78     /**
79      * Shows a dialog to choose the indexed PNG.
80      */

81     public static boolean showDialog(Component JavaDoc parent) {
82         String JavaDoc title = resources.getString("PNGOptionPanel.dialog.title");
83         PNGOptionPanel panel = new PNGOptionPanel();
84     Dialog dialog = new Dialog(parent, title, panel);
85     dialog.pack();
86     dialog.show();
87     return panel.isIndexed();
88     }
89 }
90
Popular Tags