Revision 12970 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/MarkerFill.java
MarkerFill.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
|
42 | 42 |
/* CVS MESSAGES: |
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.15 2007-08-03 11:29:13 jaume |
|
47 |
* refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor |
|
48 |
* |
|
49 |
* Revision 1.14 2007/08/03 09:20:46 jaume |
|
50 |
* refactored class names |
|
51 |
* |
|
52 |
* Revision 1.13 2007/08/01 13:02:08 jaume |
|
53 |
* renamed methods |
|
54 |
* |
|
55 |
* Revision 1.12 2007/07/30 12:56:04 jaume |
|
56 |
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol |
|
57 |
* |
|
58 |
* Revision 1.11 2007/06/29 13:07:33 jaume |
|
59 |
* +PictureLineSymbol |
|
60 |
* |
|
61 |
* Revision 1.10 2007/05/28 13:34:28 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.9 2007/05/08 15:44:07 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.8 2007/04/27 12:10:17 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.7 2007/04/05 16:08:34 jaume |
|
71 |
* Styled labeling stuff |
|
72 |
* |
|
73 |
* Revision 1.6 2007/04/04 16:01:14 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* Revision 1.5 2007/03/28 16:44:08 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* Revision 1.4 2007/03/13 16:57:35 jaume |
|
80 |
* Added MultiVariable legend |
|
81 |
* |
|
82 |
* Revision 1.3 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:43:05 jaume |
|
89 |
* some bug fixes in the editor and removed unnecessary imports |
|
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.8 2007/01/10 17:05:05 jaume |
|
98 |
* moved to FMap and gvSIG |
|
99 |
* |
|
100 |
* Revision 1.7 2006/11/13 09:15:23 jaume |
|
101 |
* javadoc and some clean-up |
|
102 |
* |
|
103 |
* Revision 1.6 2006/11/06 16:06:52 jaume |
|
104 |
* *** empty log message *** |
|
105 |
* |
|
106 |
* Revision 1.5 2006/11/02 17:19:28 jaume |
|
107 |
* *** empty log message *** |
|
108 |
* |
|
109 |
* Revision 1.4 2006/10/31 16:16:34 jaume |
|
110 |
* *** empty log message *** |
|
111 |
* |
|
112 |
* Revision 1.3 2006/10/30 19:30:35 jaume |
|
113 |
* *** empty log message *** |
|
114 |
* |
|
115 |
* Revision 1.2 2006/10/29 23:53:49 jaume |
|
116 |
* *** empty log message *** |
|
117 |
* |
|
118 |
* Revision 1.1 2006/10/27 12:41:09 jaume |
|
119 |
* GUI |
|
120 |
* |
|
121 |
* |
|
122 |
*/ |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.16 2007-08-08 10:18:15 jvidal |
|
47 |
* javadoc |
|
48 |
* |
|
49 |
* Revision 1.15 2007/08/03 11:29:13 jaume |
|
50 |
* refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor |
|
51 |
* |
|
52 |
* Revision 1.14 2007/08/03 09:20:46 jaume |
|
53 |
* refactored class names |
|
54 |
* |
|
55 |
* Revision 1.13 2007/08/01 13:02:08 jaume |
|
56 |
* renamed methods |
|
57 |
* |
|
58 |
* Revision 1.12 2007/07/30 12:56:04 jaume |
|
59 |
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol |
|
60 |
* |
|
61 |
* Revision 1.11 2007/06/29 13:07:33 jaume |
|
62 |
* +PictureLineSymbol |
|
63 |
* |
|
64 |
* Revision 1.10 2007/05/28 13:34:28 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.9 2007/05/08 15:44:07 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.8 2007/04/27 12:10:17 jaume |
|
71 |
* *** empty log message *** |
|
72 |
* |
|
73 |
* Revision 1.7 2007/04/05 16:08:34 jaume |
|
74 |
* Styled labeling stuff |
|
75 |
* |
|
76 |
* Revision 1.6 2007/04/04 16:01:14 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* Revision 1.5 2007/03/28 16:44:08 jaume |
|
80 |
* *** empty log message *** |
|
81 |
* |
|
82 |
* Revision 1.4 2007/03/13 16:57:35 jaume |
|
83 |
* Added MultiVariable legend |
|
84 |
* |
|
85 |
* Revision 1.3 2007/03/09 11:25:00 jaume |
|
86 |
* Advanced symbology (start committing) |
|
87 |
* |
|
88 |
* Revision 1.1.2.3 2007/02/21 07:35:14 jaume |
|
89 |
* *** empty log message *** |
|
90 |
* |
|
91 |
* Revision 1.1.2.2 2007/02/08 15:43:05 jaume |
|
92 |
* some bug fixes in the editor and removed unnecessary imports |
|
93 |
* |
|
94 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume |
|
95 |
* *** empty log message *** |
|
96 |
* |
|
97 |
* Revision 1.1 2007/01/16 11:52:11 jaume |
|
98 |
* *** empty log message *** |
|
99 |
* |
|
100 |
* Revision 1.8 2007/01/10 17:05:05 jaume |
|
101 |
* moved to FMap and gvSIG |
|
102 |
* |
|
103 |
* Revision 1.7 2006/11/13 09:15:23 jaume |
|
104 |
* javadoc and some clean-up |
|
105 |
* |
|
106 |
* Revision 1.6 2006/11/06 16:06:52 jaume |
|
107 |
* *** empty log message *** |
|
108 |
* |
|
109 |
* Revision 1.5 2006/11/02 17:19:28 jaume |
|
110 |
* *** empty log message *** |
|
111 |
* |
|
112 |
* Revision 1.4 2006/10/31 16:16:34 jaume |
|
113 |
* *** empty log message *** |
|
114 |
* |
|
115 |
* Revision 1.3 2006/10/30 19:30:35 jaume |
|
116 |
* *** empty log message *** |
|
117 |
* |
|
118 |
* Revision 1.2 2006/10/29 23:53:49 jaume |
|
119 |
* *** empty log message *** |
|
120 |
* |
|
121 |
* Revision 1.1 2006/10/27 12:41:09 jaume |
|
122 |
* GUI |
|
123 |
* |
|
124 |
* |
|
125 |
*/ |
|
123 | 126 |
package com.iver.cit.gvsig.gui.styling; |
124 | 127 |
|
125 | 128 |
import java.awt.Color; |
... | ... | |
145 | 148 |
import com.iver.cit.gvsig.fmap.core.symbols.MarkerFillSymbol; |
146 | 149 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
147 | 150 |
/** |
148 |
* |
|
149 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
150 |
* |
|
151 |
*/ |
|
151 |
* <b>MarkerFill</b> allows the user to store and modify the properties that fills a |
|
152 |
* polygon with a padding made of markers and an outline<p> |
|
153 |
* <p> |
|
154 |
* This functionality is carried out thanks to two tabs (marker fill and MarkerFillProperties) |
|
155 |
* which are included in the panel to edit the properities of a symbol (SymbolEditor) |
|
156 |
* how is explained in AbstractTypeSymbolEditor.<p> |
|
157 |
* <p> |
|
158 |
* The first tab (marker fill)permits the user to select the marker for the padding and |
|
159 |
* other options such as the color for the fill (<b>btnChooseMarker</b>),to select the |
|
160 |
* ouline (<b>btnOutline</b>)and the distribution (grid or random) of the marker inside |
|
161 |
* the padding (<b>rdGrid,rdRandom</b>). |
|
162 |
* <p> |
|
163 |
* The second tab is implementes as a MarkerFillProperties class and offers the possibilities |
|
164 |
* to change the separtion and the offset. |
|
165 |
* |
|
166 |
* |
|
167 |
*@see MarkerFillProperties |
|
168 |
*@see AbstractTypeSymbolEditor |
|
169 |
*@author jaume dominguez faus - jaume.dominguez@iver.es |
|
170 |
*/ |
|
152 | 171 |
public class MarkerFill extends AbstractTypeSymbolEditor implements ActionListener { |
153 |
private ArrayList tabs = new ArrayList();
|
|
154 |
private ColorChooserPanel markerCC;
|
|
155 |
private JButton btnChooseMarker;
|
|
156 |
private JButton btnOutline;
|
|
157 |
private MarkerFillSymbol mfs = new MarkerFillSymbol();
|
|
158 |
private MarkerFillProperties panelStyle = new MarkerFillProperties();
|
|
159 |
private JRadioButton rdGrid;
|
|
172 |
private ArrayList tabs = new ArrayList();
|
|
173 |
private ColorChooserPanel markerCC;
|
|
174 |
private JButton btnChooseMarker;
|
|
175 |
private JButton btnOutline;
|
|
176 |
private MarkerFillSymbol mfs = new MarkerFillSymbol();
|
|
177 |
private MarkerFillProperties panelStyle = new MarkerFillProperties();
|
|
178 |
private JRadioButton rdGrid;
|
|
160 | 179 |
private JRadioButton rdRandom; |
161 | 180 |
private AbstractMarkerSymbol marker; |
181 |
/** |
|
182 |
* constructor method |
|
183 |
* @param owner |
|
184 |
*/ |
|
185 |
public MarkerFill(SymbolEditor owner) { |
|
186 |
super(owner); |
|
187 |
initialize(); |
|
188 |
} |
|
189 |
/** |
|
190 |
* Initializes the parameters that allows the user to fill the padding of |
|
191 |
* a polygon with a style made of markers.To do it, two tabs are created (marker |
|
192 |
* fill and MarkerFillProperties)inside the SymbolEditor panel with default values |
|
193 |
* for the different attributes. |
|
194 |
*/ |
|
195 |
private void initialize() { |
|
196 |
// GridLayout layout; |
|
197 |
JPanel myTab; |
|
198 |
// Marker fill tab |
|
162 | 199 |
|
163 |
public MarkerFill(SymbolEditor owner) { |
|
164 |
super(owner); |
|
165 |
initialize(); |
|
166 |
} |
|
200 |
{ |
|
201 |
myTab = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
|
202 |
myTab.setName(PluginServices.getText(this, "marker_fill")); |
|
167 | 203 |
|
168 |
private void initialize() { |
|
169 |
// GridLayout layout; |
|
170 |
JPanel myTab; |
|
171 |
// Marker fill tab |
|
204 |
GridBagLayoutPanel p = new GridBagLayoutPanel(); |
|
205 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
206 |
markerCC = new ColorChooserPanel(); |
|
207 |
markerCC.setAlpha(255); |
|
208 |
markerCC.addActionListener(this); |
|
209 |
aux.add(markerCC); |
|
172 | 210 |
|
173 |
{ |
|
174 |
myTab = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
|
175 |
myTab.setName(PluginServices.getText(this, "marker_fill")); |
|
211 |
p.addComponent(PluginServices.getText(this, "color"), aux); |
|
212 |
btnChooseMarker = new JButton(PluginServices.getText(this, "choose_marker")); |
|
213 |
btnChooseMarker.addActionListener(this); |
|
214 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
215 |
aux.add(btnChooseMarker); |
|
216 |
p.addComponent("", aux); |
|
176 | 217 |
|
177 |
GridBagLayoutPanel p = new GridBagLayoutPanel(); |
|
178 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
179 |
markerCC = new ColorChooserPanel(); |
|
180 |
markerCC.setAlpha(255); |
|
181 |
markerCC.addActionListener(this); |
|
182 |
aux.add(markerCC); |
|
218 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
219 |
btnOutline = new JButton(PluginServices.getText(this, "outline")); |
|
220 |
aux.add(btnOutline); |
|
221 |
btnOutline.setEnabled(false); |
|
222 |
p.addComponent("", aux); |
|
183 | 223 |
|
184 |
p.addComponent(PluginServices.getText(this, "color"), aux); |
|
185 |
btnChooseMarker = new JButton(PluginServices.getText(this, "choose_marker")); |
|
186 |
btnChooseMarker.addActionListener(this); |
|
187 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
188 |
aux.add(btnChooseMarker); |
|
189 |
p.addComponent("", aux); |
|
224 |
ButtonGroup group = new ButtonGroup(); |
|
225 |
rdGrid = new JRadioButton(PluginServices.getText(this, "grid")); |
|
226 |
rdGrid.addActionListener(this); |
|
227 |
rdRandom = new JRadioButton(PluginServices.getText(this, "random")); |
|
228 |
rdRandom.addActionListener(this); |
|
229 |
group.add(rdGrid); |
|
230 |
group.add(rdRandom); |
|
190 | 231 |
|
191 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
|
|
192 |
btnOutline = new JButton(PluginServices.getText(this, "outline"));
|
|
193 |
aux.add(btnOutline);
|
|
194 |
btnOutline.setEnabled(false);
|
|
195 |
p.addComponent("", aux);
|
|
232 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5));
|
|
233 |
aux.add(rdGrid);
|
|
234 |
aux.add(rdRandom);
|
|
235 |
rdGrid.setSelected(true);
|
|
236 |
p.addComponent("", aux);
|
|
196 | 237 |
|
197 |
ButtonGroup group = new ButtonGroup(); |
|
198 |
rdGrid = new JRadioButton(PluginServices.getText(this, "grid")); |
|
199 |
rdGrid.addActionListener(this); |
|
200 |
rdRandom = new JRadioButton(PluginServices.getText(this, "random")); |
|
201 |
rdRandom.addActionListener(this); |
|
202 |
group.add(rdGrid); |
|
203 |
group.add(rdRandom); |
|
238 |
myTab.add(p); |
|
204 | 239 |
|
205 |
aux = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
206 |
aux.add(rdGrid); |
|
207 |
aux.add(rdRandom); |
|
208 |
rdGrid.setSelected(true); |
|
209 |
p.addComponent("", aux); |
|
240 |
} |
|
241 |
tabs.add(myTab); |
|
210 | 242 |
|
211 |
myTab.add(p); |
|
243 |
// Fill properties tab |
|
244 |
tabs.add(panelStyle); |
|
245 |
panelStyle.addActionListener(this); |
|
246 |
} |
|
212 | 247 |
|
213 |
} |
|
214 |
tabs.add(myTab); |
|
248 |
public void refreshControls(ISymbol layer) { |
|
249 |
if (layer == null) { |
|
250 |
System.err.println(getClass().getName()+":: should be unreachable code"); |
|
251 |
// set defaults |
|
252 |
markerCC.setColor(Color.BLACK); |
|
253 |
rdGrid.setSelected(true); |
|
254 |
rdRandom.setSelected(false); |
|
255 |
} else { |
|
215 | 256 |
|
216 |
// Fill properties tab |
|
217 |
tabs.add(panelStyle); |
|
218 |
panelStyle.addActionListener(this); |
|
219 |
} |
|
257 |
MarkerFillSymbol mfs = (MarkerFillSymbol) layer; |
|
258 |
int fillStyle = mfs.getMarkerFillProperties().getFillStyle(); |
|
259 |
rdGrid.setSelected(fillStyle == SimpleMarkerFillPropertiesStyle.GRID_FILL); |
|
260 |
rdRandom.setSelected(fillStyle == SimpleMarkerFillPropertiesStyle.RANDOM_FILL); |
|
261 |
panelStyle.setModel(mfs.getMarkerFillProperties()); |
|
262 |
} |
|
263 |
} |
|
220 | 264 |
|
221 |
public void refreshControls(ISymbol layer) { |
|
222 |
if (layer == null) { |
|
223 |
System.err.println(getClass().getName()+":: should be unreachable code"); |
|
224 |
// set defaults |
|
225 |
markerCC.setColor(Color.BLACK); |
|
226 |
rdGrid.setSelected(true); |
|
227 |
rdRandom.setSelected(false); |
|
228 |
} else { |
|
265 |
public String getName() { |
|
266 |
return PluginServices.getText(this, "marker_fill"); |
|
267 |
} |
|
229 | 268 |
|
230 |
MarkerFillSymbol mfs = (MarkerFillSymbol) layer; |
|
231 |
int fillStyle = mfs.getMarkerFillProperties().getFillStyle(); |
|
232 |
rdGrid.setSelected(fillStyle == SimpleMarkerFillPropertiesStyle.GRID_FILL); |
|
233 |
rdRandom.setSelected(fillStyle == SimpleMarkerFillPropertiesStyle.RANDOM_FILL); |
|
234 |
panelStyle.setModel(mfs.getMarkerFillProperties()); |
|
235 |
} |
|
236 |
} |
|
269 |
public JPanel[] getTabs() { |
|
270 |
return (JPanel[]) tabs.toArray(new JPanel[0]); |
|
271 |
} |
|
237 | 272 |
|
238 |
public String getName() { |
|
239 |
return PluginServices.getText(this, "marker_fill"); |
|
240 |
} |
|
273 |
public void actionPerformed(ActionEvent e) { |
|
274 |
JComponent comp = (JComponent) e.getSource(); |
|
275 |
if (comp.equals(btnChooseMarker)) { |
|
276 |
SymbolSelector symSelect = new SymbolSelector( getLayer(), FShape.POINT); |
|
277 |
PluginServices.getMDIManager().addWindow(symSelect); |
|
278 |
marker = (AbstractMarkerSymbol) symSelect.getSelectedObject(); |
|
241 | 279 |
|
242 |
public JPanel[] getTabs() { |
|
243 |
return (JPanel[]) tabs.toArray(new JPanel[0]); |
|
244 |
} |
|
280 |
if (marker == null) return; |
|
245 | 281 |
|
246 |
public void actionPerformed(ActionEvent e) { |
|
247 |
JComponent comp = (JComponent) e.getSource(); |
|
248 |
if (comp.equals(btnChooseMarker)) { |
|
249 |
SymbolSelector symSelect = new SymbolSelector( getLayer(), FShape.POINT); |
|
250 |
PluginServices.getMDIManager().addWindow(symSelect); |
|
251 |
marker = (AbstractMarkerSymbol) symSelect.getSelectedObject(); |
|
282 |
mfs.setMarker(marker); |
|
283 |
} else if (comp.equals(markerCC)) { |
|
284 |
marker.setColor(markerCC.getColor()); |
|
285 |
} |
|
252 | 286 |
|
253 |
if (marker == null) return; |
|
287 |
IMarkerFillPropertiesStyle prop = panelStyle.getMarkerFillProperties(); |
|
288 |
prop.setFillStyle(rdGrid.isSelected() ? |
|
289 |
IMarkerFillPropertiesStyle.GRID_FILL : IMarkerFillPropertiesStyle.RANDOM_FILL); |
|
290 |
mfs.setMarkerFillProperties(prop); |
|
291 |
fireSymbolChangedEvent(); |
|
292 |
} |
|
254 | 293 |
|
255 |
mfs.setMarker(marker); |
|
256 |
} else if (comp.equals(markerCC)) { |
|
257 |
marker.setColor(markerCC.getColor()); |
|
258 |
} |
|
259 |
|
|
260 |
IMarkerFillPropertiesStyle prop = panelStyle.getMarkerFillProperties(); |
|
261 |
prop.setFillStyle(rdGrid.isSelected() ? |
|
262 |
IMarkerFillPropertiesStyle.GRID_FILL : IMarkerFillPropertiesStyle.RANDOM_FILL); |
|
263 |
mfs.setMarkerFillProperties(prop); |
|
264 |
fireSymbolChangedEvent(); |
|
265 |
} |
|
266 |
|
|
267 | 294 |
public Class getSymbolClass() { |
268 | 295 |
return MarkerFillSymbol.class; |
269 | 296 |
} |
Also available in: Unified diff