Revision 20905
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/symbols/PictureLineSymbol.java | ||
---|---|---|
268 | 268 |
} |
269 | 269 |
|
270 | 270 |
public void setXMLEntity(XMLEntity xml) { |
271 |
System.out.println(this.getClass().getClassLoader()); |
|
271 | 272 |
setDescription(xml.getStringProperty("desc")); |
272 | 273 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible")); |
273 | 274 |
imagePath = xml.getStringProperty("imagePath"); |
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/labeling/GeneralLabelingStrategy.java | ||
---|---|---|
154 | 154 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Jan 4, 2008 |
155 | 155 |
* |
156 | 156 |
*/ |
157 |
public class GeneralLabelingStrategy implements ILabelingStrategy { |
|
157 |
public class GeneralLabelingStrategy implements ILabelingStrategy, Cloneable {
|
|
158 | 158 |
private ILabelingMethod method; |
159 | 159 |
private IPlacementConstraints placementConstraints; |
160 | 160 |
protected FLyrVect layer; |
... | ... | |
229 | 229 |
// } |
230 | 230 |
//duplicates stuff |
231 | 231 |
|
232 |
boolean bLabelsReallocatable = !isAllowOverlapping();
|
|
232 |
boolean bLabelsReallocatable = !isAllowingOverlap();
|
|
233 | 233 |
BufferedImage levelImg = null, |
234 | 234 |
bi = new BufferedImage( |
235 | 235 |
mapImage.getWidth(), |
... | ... | |
308 | 308 |
} |
309 | 309 |
int total = placedCount+notPlacedCount; |
310 | 310 |
|
311 |
Logger.getLogger(getClass()).info("Labeled layer '"+layer.getName()+"' "+(System.currentTimeMillis()-t1)/1000D+" seconds. "+placedCount+"/"+total+" labels placed ("+NumberFormat.getInstance().format(100*placedCount/(double) total)+"%)"); |
|
311 |
if (total>0) |
|
312 |
Logger.getLogger(getClass()).info("Labeled layer '"+layer.getName()+"' "+(System.currentTimeMillis()-t1)/1000D+" seconds. "+placedCount+"/"+total+" labels placed ("+NumberFormat.getInstance().format(100*placedCount/(double) total)+"%)"); |
|
312 | 313 |
|
313 | 314 |
} |
314 | 315 |
|
... | ... | |
492 | 493 |
} |
493 | 494 |
} |
494 | 495 |
|
495 |
public boolean isAllowOverlapping() {
|
|
496 |
public boolean isAllowingOverlap() {
|
|
496 | 497 |
return allowOverlapping; |
497 | 498 |
} |
498 | 499 |
|
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/layerproperties/GeneralLabeling.java | ||
---|---|---|
76 | 76 |
import com.iver.andami.messages.NotificationManager; |
77 | 77 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
78 | 78 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
79 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
79 | 80 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingMethod; |
80 | 81 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy; |
81 | 82 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IPlacementConstraints; |
82 | 83 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.IZoomConstraints; |
83 | 84 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass; |
85 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelingFactory; |
|
84 | 86 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.ILabelingStrategyPanel; |
85 | 87 |
import com.iver.utiles.swing.JComboBox; |
86 | 88 |
|
87 | 89 |
public class GeneralLabeling extends JPanel implements ILabelingStrategyPanel, ActionListener { |
88 | 90 |
private static final long serialVersionUID = 8864709758980903351L; |
89 |
private static Hashtable<String, Class> methods = new Hashtable<String, Class>(); |
|
91 |
private static Hashtable<String, Class<? extends ILabelingMethod>> methods |
|
92 |
= new Hashtable<String, Class<? extends ILabelingMethod>>(); |
|
90 | 93 |
private static int newClassSuffix = 0; |
91 | 94 |
private JButton btnVisualization; |
92 | 95 |
private JButton btnRenameClass; |
... | ... | |
251 | 254 |
while (it.hasNext()) { |
252 | 255 |
String name = it.next(); |
253 | 256 |
|
254 |
Class methodClass = (Class) methods.get(name);
|
|
257 |
Class<? extends ILabelingMethod> methodClass = (Class<? extends ILabelingMethod>) methods.get(name);
|
|
255 | 258 |
ILabelingMethod method; |
256 | 259 |
try { |
257 | 260 |
method = (ILabelingMethod) methodClass.newInstance(); |
... | ... | |
355 | 358 |
fieldNames = lv.getRecordset().getFieldNames(); |
356 | 359 |
labelClassRenderingProperties.setFieldNames(fieldNames); |
357 | 360 |
if (str instanceof GeneralLabelingStrategy) { |
358 |
GeneralLabelingStrategy gStr = (GeneralLabelingStrategy) str; |
|
359 |
setMethod(str.getLabelingMethod()); |
|
360 |
placementConstraints = str.getPlacementConstraints(); |
|
361 |
getChkAllowLabelOverlapping().setSelected(gStr.isAllowOverlapping()); |
|
362 |
minScaleView = gStr.getMinScaleView(); |
|
363 |
maxScaleView = gStr.getMaxScaleView(); |
|
361 |
try { |
|
362 |
GeneralLabelingStrategy gStr = (GeneralLabelingStrategy) LabelingFactory.createStrategyFromXML(str.getXMLEntity(), layer.cloneLayer()); |
|
363 |
setMethod(str.getLabelingMethod()); |
|
364 |
placementConstraints = str.getPlacementConstraints(); |
|
365 |
getChkAllowLabelOverlapping().setSelected(gStr.isAllowingOverlap()); |
|
366 |
minScaleView = gStr.getMinScaleView(); |
|
367 |
maxScaleView = gStr.getMaxScaleView(); |
|
368 |
|
|
369 |
} catch (ReadDriverException e) { |
|
370 |
NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e); |
|
371 |
} catch (Exception e) { |
|
372 |
NotificationManager.addError(PluginServices.getText(this, "accessing_file_structure"), e); |
|
373 |
} |
|
364 | 374 |
} |
365 |
|
|
375 |
|
|
366 | 376 |
refreshControls(); |
367 | 377 |
labelClassRenderingProperties.setModel(getActiveClass()); |
368 | 378 |
|
... | ... | |
373 | 383 |
} |
374 | 384 |
|
375 | 385 |
|
376 |
public static void addLabelingMethod(String name, Class iLabelingMethodClass) { |
|
386 |
public static void addLabelingMethod(String name, Class<? extends ILabelingMethod> iLabelingMethodClass) {
|
|
377 | 387 |
methods.put(name, iLabelingMethodClass); |
378 | 388 |
} |
379 | 389 |
|
... | ... | |
543 | 553 |
public void setSelectedItem(Object anObject) { |
544 | 554 |
if (anObject instanceof MethodItem) { |
545 | 555 |
MethodItem methodItem = (MethodItem) anObject; |
556 |
for (int i = 0; i < getItemCount(); i++) { |
|
557 |
MethodItem aux = (MethodItem) getItemAt(i); |
|
558 |
if (aux.equals(methodItem)) { |
|
559 |
aux.method=methodItem.method; |
|
560 |
} |
|
561 |
} |
|
546 | 562 |
super.setSelectedItem(methodItem); |
547 |
((MethodItem) super.getSelectedItem()).method = methodItem.method; |
|
563 |
// ((MethodItem) super.getSelectedItem()).method = methodItem.method;
|
|
548 | 564 |
} |
549 | 565 |
} |
550 | 566 |
} |
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/styling/PictureMarker.java | ||
---|---|---|
52 | 52 |
import java.util.ArrayList; |
53 | 53 |
|
54 | 54 |
import javax.swing.JButton; |
55 |
import javax.swing.JFileChooser; |
|
56 | 55 |
import javax.swing.JLabel; |
57 | 56 |
import javax.swing.JPanel; |
58 | 57 |
import javax.swing.filechooser.FileFilter; |
59 | 58 |
|
60 | 59 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
60 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
61 | 61 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
62 | 62 |
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol; |
63 | 63 |
|
... | ... | |
138 | 138 |
return PluginServices.getText(this, "bitmap_and_svg_image_files"); |
139 | 139 |
} |
140 | 140 |
}; |
141 |
JFileChooser jfc = new JFileChooser(lastDir);
|
|
141 |
JUrlFileChooser jfc = new JUrlFileChooser(getName(), null);
|
|
142 | 142 |
jfc.setFileFilter(ff); |
143 | 143 |
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); |
144 | 144 |
jfc.setSelectedFile(picFile); |
145 | 145 |
jfc.setMultiSelectionEnabled(false); |
146 | 146 |
int returnVal = jfc.showOpenDialog(PictureMarker.this.owner); |
147 | 147 |
if(returnVal == JFileChooser.APPROVE_OPTION) { |
148 |
File myFile = jfc.getSelectedFile(); |
|
148 |
|
|
149 |
URL url = jfc.getSelectedURL(); |
|
150 |
if (url == null) return; |
|
149 | 151 |
lastDir = jfc.getCurrentDirectory(); |
150 |
if (myFile != null && myFile.exists()) { |
|
151 |
if (isSelection) { |
|
152 |
selPicFile = myFile; |
|
153 |
} else { |
|
154 |
picFile = myFile; |
|
155 |
} |
|
156 |
try { |
|
157 |
targetLbl.setText(myFile.toURL().toString()); |
|
158 |
} catch (MalformedURLException e1) { |
|
159 |
NotificationManager.addError(PluginServices.getText(this, "Error en la creaci?n" + |
|
160 |
"de la URL"), e1); |
|
161 |
} |
|
162 |
fireSymbolChangedEvent(); |
|
163 |
} |
|
152 |
targetLbl.setText(url.toString()); |
|
153 |
fireSymbolChangedEvent(); |
|
164 | 154 |
} |
155 |
// if(returnVal == JFileChooser.APPROVE_OPTION) { |
|
156 |
// File myFile = jfc.getSelectedFile(); |
|
157 |
// lastDir = jfc.getCurrentDirectory(); |
|
158 |
// if (myFile != null && myFile.exists()) { |
|
159 |
// if (isSelection) { |
|
160 |
// selPicFile = myFile; |
|
161 |
// } else { |
|
162 |
// picFile = myFile; |
|
163 |
// } |
|
164 |
// try { |
|
165 |
// targetLbl.setText(myFile.toURL().toString()); |
|
166 |
// } catch (MalformedURLException e1) { |
|
167 |
// NotificationManager.addError(PluginServices.getText(this, "Error en la creaci?n" + |
|
168 |
// "de la URL"), e1); |
|
169 |
// } |
|
170 |
// fireSymbolChangedEvent(); |
|
171 |
// } |
|
172 |
// } |
|
165 | 173 |
|
166 | 174 |
|
167 | 175 |
} |
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/styling/JUrlFileChooser.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 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 |
package org.gvsig.symbology.gui.styling; |
|
42 |
|
|
43 |
import java.io.File; |
|
44 |
import java.net.MalformedURLException; |
|
45 |
import java.net.URL; |
|
46 |
|
|
47 |
import javax.swing.filechooser.FileFilter; |
|
48 |
|
|
49 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
50 |
|
|
51 |
import com.iver.andami.PluginServices; |
|
52 |
|
|
53 |
public class JUrlFileChooser extends JFileChooser { |
|
54 |
|
|
55 |
private static final long serialVersionUID = 1844355534608274984L; |
|
56 |
|
|
57 |
public JUrlFileChooser(String fileChooserID, String defaultDirectory) { |
|
58 |
super(fileChooserID, defaultDirectory); |
|
59 |
this.setFileFilter(ff); |
|
60 |
this.setFileSelectionMode(JFileChooser.FILES_ONLY); |
|
61 |
this.setMultiSelectionEnabled(false); |
|
62 |
} |
|
63 |
|
|
64 |
FileFilter ff = new FileFilter() { |
|
65 |
public boolean accept(File f) { |
|
66 |
if (f.isDirectory()) return true; |
|
67 |
String fName = f.getAbsolutePath(); |
|
68 |
if (fName!=null) { |
|
69 |
fName = fName.toLowerCase(); |
|
70 |
return fName.endsWith(".png") |
|
71 |
|| fName.endsWith(".gif") |
|
72 |
|| fName.endsWith(".jpg") |
|
73 |
|| fName.endsWith(".jpeg") |
|
74 |
|| fName.endsWith(".bmp") |
|
75 |
|| fName.endsWith(".svg"); |
|
76 |
} |
|
77 |
return false; |
|
78 |
} |
|
79 |
|
|
80 |
public String getDescription() { |
|
81 |
return PluginServices.getText(this, "bitmap_and_svg_image_files")+ "," + |
|
82 |
PluginServices.getText(this, "URL"); |
|
83 |
} |
|
84 |
}; |
|
85 |
|
|
86 |
public URL getSelectedURL() { |
|
87 |
String path; |
|
88 |
File f = getSelectedFile(); |
|
89 |
|
|
90 |
try { |
|
91 |
if(f.canRead()) { |
|
92 |
return f.toURL(); |
|
93 |
} |
|
94 |
else { |
|
95 |
path = f.toString(); |
|
96 |
|
|
97 |
if (!path.startsWith("http")) |
|
98 |
if(path.contains("http") && |
|
99 |
(path.endsWith(".png") |
|
100 |
|| path.endsWith(".gif") |
|
101 |
|| path.endsWith(".jpg") |
|
102 |
|| path.endsWith(".jpeg") |
|
103 |
|| path.endsWith(".bmp") |
|
104 |
|| path.endsWith(".svg"))) { |
|
105 |
|
|
106 |
path = path.substring(path.indexOf("http"), path.length()); |
|
107 |
path = path.replace('\\', '/'); |
|
108 |
path = path.replaceFirst("/", "//"); |
|
109 |
|
|
110 |
return new URL(path); |
|
111 |
} |
|
112 |
} |
|
113 |
} catch (MalformedURLException e) { |
|
114 |
return null; |
|
115 |
} |
|
116 |
return null; |
|
117 |
} |
|
118 |
|
|
119 |
|
|
120 |
} |
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/styling/LabelClassRenderingProperties.java | ||
---|---|---|
97 | 97 |
private ArrayList<String> expressions; |
98 | 98 |
// private ILabelingMethod method; |
99 | 99 |
private String[] fieldNames; |
100 |
private boolean noEvent = false; |
|
100 | 101 |
|
101 | 102 |
private class ExprEditorPanel extends JPanel implements IWindow { |
102 | 103 |
private static final long serialVersionUID = -3867224882591879900L; |
... | ... | |
207 | 208 |
|
208 | 209 |
ArrayList<String> exp = getExpressions(); |
209 | 210 |
|
210 |
// noEvent = true;
|
|
211 |
noEvent = true; |
|
211 | 212 |
if ( lc != null && |
212 | 213 |
lc.getLabelExpression()!=null && |
213 | 214 |
!lc.getLabelExpression().equals("") && |
... | ... | |
224 | 225 |
} else { |
225 | 226 |
getCmbExpressions().setSelectedItem(exp.get(0)); |
226 | 227 |
} |
227 |
// noEvent = false;
|
|
228 |
noEvent = false;
|
|
228 | 229 |
} |
229 | 230 |
|
230 | 231 |
private JButton getBtnEditExpression() { |
... | ... | |
299 | 300 |
} |
300 | 301 |
|
301 | 302 |
public void actionPerformed(ActionEvent e) { |
303 |
if (noEvent) return; |
|
302 | 304 |
Component c = (Component) e.getSource(); |
303 | 305 |
if (c.equals(btnEditExpression)) { |
304 | 306 |
ExprEditorPanel ep = new ExprEditorPanel((String) getCmbExpressions(). |
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/styling/PictureFill.java | ||
---|---|---|
50 | 50 |
import java.awt.event.ActionListener; |
51 | 51 |
import java.io.File; |
52 | 52 |
import java.io.IOException; |
53 |
import java.net.MalformedURLException; |
|
54 | 53 |
import java.net.URL; |
55 | 54 |
import java.util.ArrayList; |
56 | 55 |
|
57 | 56 |
import javax.swing.JCheckBox; |
58 |
import javax.swing.JFileChooser; |
|
59 | 57 |
import javax.swing.JLabel; |
60 | 58 |
import javax.swing.JPanel; |
61 | 59 |
import javax.swing.filechooser.FileFilter; |
... | ... | |
63 | 61 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
64 | 62 |
import org.gvsig.gui.beans.swing.JBlank; |
65 | 63 |
import org.gvsig.gui.beans.swing.JButton; |
64 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
66 | 65 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
67 | 66 |
import org.gvsig.symbology.fmap.symbols.PictureFillSymbol; |
68 | 67 |
|
... | ... | |
150 | 149 |
return PluginServices.getText(this, "bitmap_and_svg_image_files"); |
151 | 150 |
} |
152 | 151 |
}; |
153 |
JFileChooser jfc = new JFileChooser(lastDir);
|
|
152 |
JUrlFileChooser jfc = new JUrlFileChooser(getName(), null);
|
|
154 | 153 |
jfc.setFileFilter(ff); |
155 | 154 |
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); |
156 | 155 |
jfc.setSelectedFile(picFile); |
157 | 156 |
jfc.setMultiSelectionEnabled(false); |
158 | 157 |
int returnVal = jfc.showOpenDialog(PictureFill.this.owner); |
158 |
// if(returnVal == JFileChooser.APPROVE_OPTION) { |
|
159 |
// File myFile = jfc.getSelectedFile(); |
|
160 |
// lastDir = jfc.getCurrentDirectory(); |
|
161 |
// if (myFile != null && myFile.exists()) { |
|
162 |
// if(!isSelection){ |
|
163 |
// picFile = myFile; |
|
164 |
// } |
|
165 |
// else{ |
|
166 |
// selPicFile = myFile; |
|
167 |
// } |
|
168 |
// try { |
|
169 |
// targetLbl.setText(myFile.toURL().toString()); |
|
170 |
// } catch (MalformedURLException e1) { |
|
171 |
// NotificationManager.addError(PluginServices.getText(this, "invalid_url"), e1); |
|
172 |
// } |
|
173 |
// fireSymbolChangedEvent(); |
|
174 |
// } |
|
175 |
// } |
|
159 | 176 |
if(returnVal == JFileChooser.APPROVE_OPTION) { |
160 |
File myFile = jfc.getSelectedFile(); |
|
177 |
|
|
178 |
URL url = jfc.getSelectedURL(); |
|
179 |
if (url == null) return; |
|
161 | 180 |
lastDir = jfc.getCurrentDirectory(); |
162 |
if (myFile != null && myFile.exists()) { |
|
163 |
if(!isSelection){ |
|
164 |
picFile = myFile; |
|
165 |
} |
|
166 |
else{ |
|
167 |
selPicFile = myFile; |
|
168 |
} |
|
169 |
try { |
|
170 |
targetLbl.setText(myFile.toURL().toString()); |
|
171 |
} catch (MalformedURLException e1) { |
|
172 |
NotificationManager.addError(PluginServices.getText(this, "invalid_url"), e1); |
|
173 |
} |
|
174 |
fireSymbolChangedEvent(); |
|
175 |
} |
|
181 |
targetLbl.setText(url.toString()); |
|
182 |
fireSymbolChangedEvent(); |
|
176 | 183 |
} |
177 | 184 |
} |
178 | 185 |
|
Also available in: Unified diff