Revision 13826 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleFill.java
SimpleFill.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.16 2007-08-16 06:54:35 jvidal |
|
46 |
* Revision 1.17 2007-09-19 10:45:05 jvidal |
|
47 |
* bug solved |
|
48 |
* |
|
49 |
* Revision 1.16 2007/08/16 06:54:35 jvidal |
|
47 | 50 |
* javadoc updated |
48 | 51 |
* |
49 | 52 |
* Revision 1.15 2007/08/10 07:28:25 jaume |
... | ... | |
126 | 129 |
import java.awt.event.ActionListener; |
127 | 130 |
import java.util.ArrayList; |
128 | 131 |
|
132 |
import javax.swing.JCheckBox; |
|
129 | 133 |
import javax.swing.JPanel; |
130 | 134 |
import javax.swing.JSlider; |
131 | 135 |
import javax.swing.event.ChangeEvent; |
132 | 136 |
import javax.swing.event.ChangeListener; |
133 | 137 |
|
134 | 138 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
139 |
import org.gvsig.gui.beans.swing.JBlank; |
|
135 | 140 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
136 | 141 |
|
137 | 142 |
import com.iver.andami.PluginServices; |
138 | 143 |
import com.iver.andami.messages.NotificationManager; |
139 | 144 |
import com.iver.cit.gvsig.fmap.core.FShape; |
145 |
import com.iver.cit.gvsig.fmap.core.styles.ArrowDecoratorStyle; |
|
146 |
import com.iver.cit.gvsig.fmap.core.symbols.ArrowMarkerSymbol; |
|
140 | 147 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
141 | 148 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
142 | 149 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
... | ... | |
167 | 174 |
private JSlider sldFillTransparency; |
168 | 175 |
private JSlider sldOutlineTransparency; |
169 | 176 |
private int outlineAlpha, fillAlpha; |
177 |
private ILineSymbol outline; |
|
178 |
private JCheckBox useBorder; |
|
170 | 179 |
|
171 | 180 |
public SimpleFill(SymbolEditor owner) { |
172 | 181 |
super(owner); |
... | ... | |
202 | 211 |
btnOutline = new JSymbolPreviewButton(FShape.LINE); |
203 | 212 |
btnOutline.setPreferredSize(new Dimension(100, 35)); |
204 | 213 |
aux2.add(btnOutline); |
214 |
|
|
215 |
aux.addComponent(new JBlank(10, 10)); |
|
216 |
useBorder = new JCheckBox(PluginServices.getText(this, "use_outline")); |
|
217 |
aux.addComponent(useBorder, aux2); |
|
218 |
aux.addComponent(new JBlank(10, 10)); |
|
219 |
|
|
205 | 220 |
sldOutlineTransparency = new JSlider(); |
206 | 221 |
sldOutlineTransparency.setValue(100); |
207 | 222 |
aux.addComponent(PluginServices.getText(this, "outline")+":", |
... | ... | |
211 | 226 |
aux.addComponent(PluginServices.getText(this, "outline_width"), txtOutlineWidth); |
212 | 227 |
myTab.add(aux); |
213 | 228 |
|
229 |
useBorder.addActionListener(this); |
|
214 | 230 |
jccFillColor.addActionListener(this); |
215 | 231 |
sldFillTransparency.addChangeListener(this); |
216 | 232 |
btnOutline.addActionListener(this); |
... | ... | |
221 | 237 |
|
222 | 238 |
public ISymbol getLayer() { |
223 | 239 |
SimpleFillSymbol layer = new SimpleFillSymbol(); |
224 |
ILineSymbol outline =(ILineSymbol) btnOutline.getSymbol();
|
|
240 |
outline = useBorder.isSelected() ? (ILineSymbol) btnOutline.getSymbol() : null;
|
|
225 | 241 |
|
226 | 242 |
if (outline!=null) { |
227 | 243 |
outline.setLineWidth(txtOutlineWidth.getDouble()); |
228 | 244 |
outline.setAlpha(outlineAlpha); |
229 |
layer.setOutline(outline); |
|
230 | 245 |
} |
231 | 246 |
|
247 |
layer.setOutline(outline); |
|
232 | 248 |
Color c = jccFillColor.getColor(); |
233 | 249 |
c = new Color(c.getRed(), c.getGreen(), c.getBlue(), fillAlpha); |
234 | 250 |
layer.setFillColor(c); |
... | ... | |
242 | 258 |
// initialize defaults |
243 | 259 |
NotificationManager.addWarning(getClass().getName()+":: should be unreachable code", new Exception()); |
244 | 260 |
} else { |
261 |
|
|
262 |
|
|
263 |
//fill |
|
264 |
sldFillTransparency.removeChangeListener(this); |
|
245 | 265 |
sym = (SimpleFillSymbol) layer; |
246 | 266 |
jccFillColor.setColor(sym.getFillColor()); |
247 | 267 |
int value = 100; |
248 | 268 |
Color c = sym.getFillColor(); |
249 | 269 |
if (c!=null) { |
250 |
value = (c.getAlpha()/255)*100;
|
|
270 |
value = (int) ((c.getAlpha()/255D)*100);
|
|
251 | 271 |
} |
252 | 272 |
sldFillTransparency.setValue(value); |
253 |
btnOutline.setSymbol(sym.getOutline()); |
|
254 |
ILineSymbol outline = sym.getOutline(); |
|
273 |
sldFillTransparency.addChangeListener(this); |
|
274 |
|
|
275 |
|
|
276 |
//outline |
|
277 |
|
|
278 |
sldOutlineTransparency.removeChangeListener(this); |
|
279 |
|
|
280 |
useBorder.setSelected(outline!=null); |
|
281 |
|
|
282 |
outline=sym.getOutline(); |
|
283 |
btnOutline.setSymbol(outline); |
|
284 |
|
|
255 | 285 |
if (outline != null) { |
256 | 286 |
outlineAlpha = outline.getAlpha(); |
257 |
sldOutlineTransparency.setValue((outlineAlpha/255)*100);
|
|
287 |
sldOutlineTransparency.setValue((int)((outlineAlpha/255D)*100));
|
|
258 | 288 |
txtOutlineWidth.setDouble(outline.getLineWidth()); |
259 | 289 |
} else { |
260 | 290 |
sldOutlineTransparency.setValue(100); |
261 | 291 |
} |
262 | 292 |
|
293 |
sldOutlineTransparency.addChangeListener(this); |
|
263 | 294 |
|
264 | 295 |
|
296 |
|
|
265 | 297 |
} |
266 | 298 |
} catch (IndexOutOfBoundsException ioEx) { |
267 | 299 |
NotificationManager.addWarning("Symbol layer index out of bounds", ioEx); |
... | ... | |
278 | 310 |
} |
279 | 311 |
|
280 | 312 |
public void actionPerformed(ActionEvent e) { |
313 |
outline = (ILineSymbol) btnOutline.getSymbol(); |
|
281 | 314 |
fireSymbolChangedEvent(); |
282 | 315 |
} |
283 | 316 |
|
... | ... | |
288 | 321 |
} else if (s.equals(sldOutlineTransparency)) { |
289 | 322 |
outlineAlpha = (int) (255*(sldOutlineTransparency.getValue()/100.0)); |
290 | 323 |
} |
324 |
|
|
325 |
outline = (ILineSymbol) btnOutline.getSymbol(); |
|
326 |
|
|
291 | 327 |
fireSymbolChangedEvent(); |
292 | 328 |
} |
293 | 329 |
|
294 | 330 |
public EditorTool[] getEditorTools() { |
295 | 331 |
return null; |
296 | 332 |
} |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
297 | 337 |
} |
Also available in: Unified diff