svn-gvsig-desktop / branches / simbologia / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SimpleFill.java @ 10437
History | View | Annotate | Download (4.93 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: SimpleFill.java 10437 2007-02-21 07:35:14Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.1.2.3 2007-02-21 07:35:14 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.1.2.2 2007/02/08 15:43:05 jaume
|
50 |
* some bug fixes in the editor and removed unnecessary imports
|
51 |
*
|
52 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.1 2007/01/16 11:52:11 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.4 2006/11/13 09:15:23 jaume
|
59 |
* javadoc and some clean-up
|
60 |
*
|
61 |
* Revision 1.3 2006/11/06 16:06:52 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.2 2006/10/30 19:30:35 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.1 2006/10/27 12:41:09 jaume
|
68 |
* GUI
|
69 |
*
|
70 |
*
|
71 |
*/
|
72 |
package com.iver.cit.gvsig.gui.styling; |
73 |
|
74 |
import java.awt.Dimension; |
75 |
import java.awt.FlowLayout; |
76 |
import java.awt.event.ActionEvent; |
77 |
import java.awt.event.ActionListener; |
78 |
import java.util.ArrayList; |
79 |
|
80 |
import javax.swing.JPanel; |
81 |
|
82 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
83 |
|
84 |
import sun.security.action.GetBooleanAction; |
85 |
|
86 |
import com.iver.andami.PluginServices; |
87 |
import com.iver.andami.messages.NotificationManager; |
88 |
import com.iver.cit.gvsig.fmap.core.FShape; |
89 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
90 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
91 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
92 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
93 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.JSymbolPreviewButton; |
94 |
|
95 |
import de.ios.framework.swing.JDecimalField; |
96 |
|
97 |
public class SimpleFill extends AbstractTypeSymbolEditorPanel implements ActionListener { |
98 |
private static final String NAME = PluginServices. |
99 |
getText(SimpleFill.class, "simple_fill");
|
100 |
private ColorChooserPanel jccFillColor;
|
101 |
private JDecimalField txtOutlineWidth;
|
102 |
private ArrayList tabs = new ArrayList(); |
103 |
private JSymbolPreviewButton btnOutline;
|
104 |
|
105 |
public SimpleFill(SymbolEditor owner) {
|
106 |
super(owner);
|
107 |
initialize(); |
108 |
} |
109 |
|
110 |
public String getName() { |
111 |
return NAME;
|
112 |
} |
113 |
|
114 |
public JPanel[] getTabs() { |
115 |
return (JPanel[]) tabs.toArray(new JPanel[0]); |
116 |
} |
117 |
|
118 |
private void initialize() { |
119 |
JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
120 |
myTab.setName(PluginServices.getText(this, "simple_fill")); |
121 |
GridBagLayoutPanel aux = new GridBagLayoutPanel();
|
122 |
jccFillColor = new ColorChooserPanel();
|
123 |
jccFillColor.setAlpha(255);
|
124 |
|
125 |
btnOutline = new JSymbolPreviewButton(FShape.LINE);
|
126 |
btnOutline.setPreferredSize(new Dimension(100, 35)); |
127 |
|
128 |
aux.addComponent(PluginServices.getText(this, "outline")+":", |
129 |
btnOutline ); |
130 |
txtOutlineWidth = new JDecimalField(25); |
131 |
// TODO restore previous outline width
|
132 |
aux.addComponent(PluginServices.getText(this, "outline_width")+":", |
133 |
txtOutlineWidth ); |
134 |
aux.setPreferredSize(new Dimension(300, 300)); |
135 |
myTab.add(aux); |
136 |
|
137 |
jccFillColor.addActionListener(this);
|
138 |
btnOutline.addActionListener(this);
|
139 |
txtOutlineWidth.addActionListener(this);
|
140 |
tabs.add(myTab); |
141 |
} |
142 |
|
143 |
public ISymbol getLayer() {
|
144 |
SimpleFillSymbol sfs = new SimpleFillSymbol();
|
145 |
sfs.setOutline((ILineSymbol) btnOutline.getSymbol()); |
146 |
sfs.setFillColor(jccFillColor.getColor()); |
147 |
return sfs;
|
148 |
} |
149 |
|
150 |
public void refreshControls(ISymbol layer) { |
151 |
SimpleFillSymbol sym; |
152 |
try {
|
153 |
if (layer == null) { |
154 |
// initialize defaults
|
155 |
} else {
|
156 |
sym = (SimpleFillSymbol) layer; |
157 |
jccFillColor.setColor(sym.getFillColor()); |
158 |
btnOutline.setSymbol(sym.getOutline()); |
159 |
} |
160 |
} catch (IndexOutOfBoundsException ioEx) { |
161 |
NotificationManager.addWarning("Symbol layer index out of bounds", ioEx);
|
162 |
} catch (ClassCastException ccEx) { |
163 |
NotificationManager.addWarning("Illegal casting from " +
|
164 |
layer.getClassName() + " to " + getSymbolClass().
|
165 |
getName() + ".", ccEx);
|
166 |
|
167 |
} |
168 |
} |
169 |
|
170 |
public Class getSymbolClass() { |
171 |
return SimpleFillSymbol.class;
|
172 |
} |
173 |
|
174 |
public void actionPerformed(ActionEvent e) { |
175 |
fireSymbolChangedEvent(); |
176 |
} |
177 |
} |