root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / styling / AbstractTypeSymbolEditor.java @ 29596
History | View | Annotate | Download (7.22 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: AbstractTypeSymbolEditor.java 29596 2009-06-29 16:02:00Z jpiera $
|
45 |
* $Log$
|
46 |
* Revision 1.3 2007-08-08 11:45:38 jaume
|
47 |
* some bugs fixed
|
48 |
*
|
49 |
* Revision 1.1 2007/08/03 11:29:13 jaume
|
50 |
* refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor
|
51 |
*
|
52 |
* Revision 1.12 2007/08/03 09:20:47 jaume
|
53 |
* refactored class names
|
54 |
*
|
55 |
* Revision 1.11 2007/08/03 09:07:01 jaume
|
56 |
* javadoc
|
57 |
*
|
58 |
* Revision 1.10 2007/08/03 07:34:15 jaume
|
59 |
* javadoc
|
60 |
*
|
61 |
* Revision 1.9 2007/07/30 12:56:04 jaume
|
62 |
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
|
63 |
*
|
64 |
* Revision 1.8 2007/07/18 06:56:03 jaume
|
65 |
* continuing with cartographic support
|
66 |
*
|
67 |
* Revision 1.7 2007/07/12 10:43:55 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.6 2007/06/29 13:07:33 jaume
|
71 |
* +PictureLineSymbol
|
72 |
*
|
73 |
* Revision 1.5 2007/05/08 15:44:07 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.4 2007/04/20 07:54:38 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.3 2007/04/05 16:08:34 jaume
|
80 |
* Styled labeling stuff
|
81 |
*
|
82 |
* Revision 1.2 2007/03/09 11:25:00 jaume
|
83 |
* Advanced symbology (start committing)
|
84 |
*
|
85 |
* Revision 1.1.2.3 2007/02/21 07:35:14 jaume
|
86 |
* *** empty log message ***
|
87 |
*
|
88 |
* Revision 1.1.2.2 2007/02/08 15:42:13 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume
|
92 |
* *** empty log message ***
|
93 |
*
|
94 |
* Revision 1.1 2007/01/16 11:52:11 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.6 2006/11/13 09:15:23 jaume
|
98 |
* javadoc and some clean-up
|
99 |
*
|
100 |
* Revision 1.5 2006/11/06 16:06:52 jaume
|
101 |
* *** empty log message ***
|
102 |
*
|
103 |
* Revision 1.4 2006/10/31 16:16:34 jaume
|
104 |
* *** empty log message ***
|
105 |
*
|
106 |
* Revision 1.3 2006/10/30 19:30:35 jaume
|
107 |
* *** empty log message ***
|
108 |
*
|
109 |
* Revision 1.2 2006/10/29 23:53:49 jaume
|
110 |
* *** empty log message ***
|
111 |
*
|
112 |
* Revision 1.1 2006/10/27 12:41:09 jaume
|
113 |
* GUI
|
114 |
*
|
115 |
*
|
116 |
*/
|
117 |
package org.gvsig.app.gui.styling; |
118 |
|
119 |
import javax.swing.JPanel; |
120 |
|
121 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
122 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
123 |
|
124 |
/**
|
125 |
* <p>
|
126 |
* Abstract class that all the Symbol settings GUI's must extend. <b>This
|
127 |
* is not Component by it self, but a bag of JPanels with the required
|
128 |
* interface to be operable from the SymbolEditor</b>. The panels provide
|
129 |
* by this are the tabs of the JTabbedPane of the options area in the
|
130 |
* SymbolEditor.
|
131 |
* </p>
|
132 |
* <p>
|
133 |
* The components contained by this panelset are automatically placed in
|
134 |
* the <b>SymbolEditor</b>'s symbol options area. In case other panel
|
135 |
* of this was already placed, then the old one is replaced by this.
|
136 |
* </p>
|
137 |
* <p>
|
138 |
* In order to the <b>SymbolEditor</b> owner of this to decide which
|
139 |
* <b>AbstractTypeSymbolEditorPanel</b> will be placed each symbol editor
|
140 |
* panel must define the type of the symbol it is able to configure.
|
141 |
* To do this, <b>AbstractTypeSymbolEditorPanel</b> includes the abstract
|
142 |
* method <b>getSymbolClass()</b> which will return the <b>Class</b> of
|
143 |
* the corresponding symbol. The symbol class must define an implementation
|
144 |
* of ISymbol in general, and one of IMarkerSymbol, ILineSymbol or
|
145 |
* IFillSymbol in particular, depending of the context of the symbology
|
146 |
* being edited.
|
147 |
* </p>
|
148 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
149 |
*/
|
150 |
public abstract class AbstractTypeSymbolEditor { |
151 |
protected SymbolEditor owner;
|
152 |
private boolean applying = false; |
153 |
|
154 |
/**
|
155 |
* Produces and returns the ISymbol according with the user settings.
|
156 |
*
|
157 |
* @return XMLEntity defining the ISymbol.
|
158 |
* @see getSymbolClass() method
|
159 |
*/
|
160 |
public abstract ISymbol getLayer(); |
161 |
|
162 |
/**
|
163 |
* Creates a new instance of this type symbol editor panel associated to
|
164 |
* its SymbolEditor parent which will be notified of the changes in
|
165 |
* order to keep the symbol preview in sync with the user settings.
|
166 |
* @param owner, the SymbolEditor which created this.
|
167 |
*/
|
168 |
public AbstractTypeSymbolEditor(SymbolEditor owner) {
|
169 |
this.owner = owner;
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* <p>
|
174 |
* Returns the name of the config tabs that will be shown in the selector combo box.
|
175 |
* This is typically a human-readable (and also translatable) name for the symbol that
|
176 |
* this TypeEditorPanel deals with, but maybe you prefer to use any other one.<br>
|
177 |
* </p>
|
178 |
* <p>
|
179 |
* The order of the entries in the combo is alphabetically-based. So you can force a
|
180 |
* position by defining a name that suits your needs.
|
181 |
* </p>
|
182 |
* @return A human-readable text naming this panel
|
183 |
*/
|
184 |
public abstract String getName(); |
185 |
|
186 |
/**
|
187 |
* <p>
|
188 |
* Due to the complexity that many symbols settings can reach, the SymbolEditorPanel is
|
189 |
* designed in a tabbed-based fashion. So, you can use as many of pages you want to put
|
190 |
* your components. This pages are regular JPanels that will be automatically added to
|
191 |
* the SymbolEditor dialog.<br>
|
192 |
* </p>
|
193 |
* <p>
|
194 |
* In case you need only one page, just return a JPanel array with a length of 1.
|
195 |
* </p>
|
196 |
* @return An array of JPanel containing the setting's interface.
|
197 |
*/
|
198 |
public abstract JPanel[] getTabs(); |
199 |
|
200 |
/**
|
201 |
* Invoked when the user selects or adds a new layer. This method fills up
|
202 |
* the components on the right according on the layer properties
|
203 |
* @param <b>ISymbol</b> layer, the symbol
|
204 |
*/
|
205 |
public abstract void refreshControls(ISymbol layer); |
206 |
|
207 |
/**
|
208 |
* This overrided method returns the text shown at the SymbolEditorPanel
|
209 |
* select combobox.
|
210 |
*/
|
211 |
public final String toString() { |
212 |
return getName();
|
213 |
} |
214 |
|
215 |
protected final void fireSymbolChangedEvent() { |
216 |
if (!applying) { // avoid unnecessary events |
217 |
applying = true;
|
218 |
ISymbol sym = getLayer(); |
219 |
|
220 |
if (sym instanceof CartographicSupport) { |
221 |
CartographicSupport cs = (CartographicSupport) sym; |
222 |
cs.setReferenceSystem(owner.getUnitsReferenceSystem()); |
223 |
cs.setUnit(owner.getUnit()); |
224 |
} |
225 |
|
226 |
owner.setLayerToSymbol(sym); |
227 |
owner.refresh(); |
228 |
applying = false;
|
229 |
} |
230 |
} |
231 |
|
232 |
/**
|
233 |
* Returns the symbol class that is handled by this configuration panel.
|
234 |
* @return <b>Class</b> (of the concrete ISymbol that this configuration panel deals with)
|
235 |
*/
|
236 |
public abstract Class getSymbolClass(); |
237 |
|
238 |
/**
|
239 |
* Returns the editor tools that are handled by this configuration panel.
|
240 |
* @return <b>EditorTool</b>
|
241 |
*/
|
242 |
public abstract EditorTool[] getEditorTools(); |
243 |
|
244 |
|
245 |
} |
246 |
|