Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / AbstractTypeSymbolEditor.java @ 40560

History | View | Annotate | Download (6.87 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: AbstractTypeSymbolEditor.java 29596 2009-06-29 16:02:00Z jpiera $
27
* $Log$
28
* Revision 1.3  2007-08-08 11:45:38  jaume
29
* some bugs fixed
30
*
31
* Revision 1.1  2007/08/03 11:29:13  jaume
32
* refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor
33
*
34
* Revision 1.12  2007/08/03 09:20:47  jaume
35
* refactored class names
36
*
37
* Revision 1.11  2007/08/03 09:07:01  jaume
38
* javadoc
39
*
40
* Revision 1.10  2007/08/03 07:34:15  jaume
41
* javadoc
42
*
43
* Revision 1.9  2007/07/30 12:56:04  jaume
44
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
45
*
46
* Revision 1.8  2007/07/18 06:56:03  jaume
47
* continuing with cartographic support
48
*
49
* Revision 1.7  2007/07/12 10:43:55  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.6  2007/06/29 13:07:33  jaume
53
* +PictureLineSymbol
54
*
55
* Revision 1.5  2007/05/08 15:44:07  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.4  2007/04/20 07:54:38  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.3  2007/04/05 16:08:34  jaume
62
* Styled labeling stuff
63
*
64
* Revision 1.2  2007/03/09 11:25:00  jaume
65
* Advanced symbology (start committing)
66
*
67
* Revision 1.1.2.3  2007/02/21 07:35:14  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.1.2.2  2007/02/08 15:42:13  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.1.2.1  2007/01/26 13:49:03  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.1  2007/01/16 11:52:11  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.6  2006/11/13 09:15:23  jaume
80
* javadoc and some clean-up
81
*
82
* Revision 1.5  2006/11/06 16:06:52  jaume
83
* *** empty log message ***
84
*
85
* Revision 1.4  2006/10/31 16:16:34  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.3  2006/10/30 19:30:35  jaume
89
* *** empty log message ***
90
*
91
* Revision 1.2  2006/10/29 23:53:49  jaume
92
* *** empty log message ***
93
*
94
* Revision 1.1  2006/10/27 12:41:09  jaume
95
* GUI
96
*
97
*
98
*/
99
package org.gvsig.app.gui.styling;
100

    
101
import javax.swing.JPanel;
102

    
103
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
104
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
105

    
106
/**
107
 * <p>
108
 * Abstract class that all the Symbol settings GUI's must extend. <b>This
109
 * is not Component by it self, but a bag of JPanels with the required
110
 * interface to be operable from the SymbolEditor</b>. The panels provide
111
 * by this are the tabs of the JTabbedPane of the options area in the
112
 * SymbolEditor.
113
 * </p> 
114
 * <p> 
115
 * The components contained by this panelset are automatically placed in 
116
 * the <b>SymbolEditor</b>'s symbol options area. In case other panel 
117
 * of this was already placed, then the old one is replaced by this.
118
 * </p>
119
 * <p>
120
 * In order to the <b>SymbolEditor</b> owner of this to decide which
121
 * <b>AbstractTypeSymbolEditorPanel</b> will be placed each symbol editor
122
 * panel must define the type of the symbol it is able to configure.
123
 * To do this, <b>AbstractTypeSymbolEditorPanel</b> includes the abstract
124
 * method <b>getSymbolClass()</b> which will return the <b>Class</b> of
125
 * the corresponding symbol. The symbol class must define an implementation
126
 * of ISymbol in general, and one of IMarkerSymbol, ILineSymbol or
127
 * IFillSymbol in particular, depending of the context of the symbology
128
 * being edited.
129
 * </p>
130
 * @author jaume dominguez faus - jaume.dominguez@iver.es
131
 */
132
public abstract class AbstractTypeSymbolEditor {
133
        protected SymbolEditor owner;
134
        private boolean applying = false;
135

    
136
        /**
137
         * Produces and returns  the ISymbol according with the user settings.
138
         *
139
         * @return XMLEntity defining the ISymbol.
140
         * @see getSymbolClass() method
141
         */
142
        public abstract ISymbol getLayer();
143

    
144
        /**
145
         * Creates a new instance of this type symbol editor panel associated to
146
         * its SymbolEditor parent which will be notified of the changes in
147
         * order to keep the symbol preview in sync with the user settings.
148
         * @param owner, the SymbolEditor which created this.
149
         */
150
        public AbstractTypeSymbolEditor(SymbolEditor owner) {
151
                this.owner = owner;
152
        }
153

    
154
        /**
155
         * <p>
156
         * Returns the name of the config tabs that will be shown in the selector combo box.
157
         * This is typically a human-readable (and also translatable) name for the symbol that
158
         * this TypeEditorPanel deals with, but maybe you prefer to use any other one.<br>
159
         * </p>
160
         * <p>
161
         * The order of the entries in the combo is alphabetically-based. So you can force a
162
         * position by defining a name that suits your needs.
163
         * </p>
164
         * @return A human-readable text naming this panel
165
         */
166
        public abstract String getName();
167

    
168
        /**
169
         * <p>
170
         * Due to the complexity that many symbols settings can reach, the SymbolEditorPanel is
171
         * designed in a tabbed-based fashion. So, you can use as many of pages you want to put
172
         * your components. This pages are regular JPanels that will be automatically added to
173
         * the SymbolEditor dialog.<br>
174
         * </p>
175
         * <p>
176
         * In case you need only one page, just return a JPanel array with a length of 1.
177
         * </p>
178
         * @return An array of JPanel containing the setting's interface.
179
         */
180
        public abstract JPanel[] getTabs();
181

    
182
        /**
183
         * Invoked when the user selects or adds a new layer. This method fills up
184
         * the components on the right according on the layer properties
185
         * @param <b>ISymbol</b> layer, the symbol
186
         */
187
        public abstract void refreshControls(ISymbol layer);
188

    
189
        /**
190
         * This overrided method returns the text shown at the SymbolEditorPanel
191
         * select combobox.
192
         */
193
        public final String toString() {
194
                return getName();
195
        }
196

    
197
        protected final void fireSymbolChangedEvent() {
198
                if (!applying) { // avoid unnecessary events
199
                        applying = true;
200
                        ISymbol sym = getLayer();
201

    
202
                        if (sym instanceof CartographicSupport) {
203
                                CartographicSupport cs = (CartographicSupport) sym;
204
                                cs.setReferenceSystem(owner.getUnitsReferenceSystem());
205
                                cs.setUnit(owner.getUnit());
206
                        }
207
                        
208
                        owner.setLayerToSymbol(sym);
209
                        owner.refresh();
210
                        applying = false;
211
                }
212
        }
213

    
214
        public abstract boolean canManageSymbol(ISymbol symbol);
215
        
216
        /**
217
         * Returns the editor tools that are handled by this configuration panel.
218
         * @return <b>EditorTool</b>
219
         */
220
        public abstract EditorTool[] getEditorTools();
221

    
222

    
223
}
224