Revision 10099
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LabeledTestFLayer.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.2 2007-02-01 17:46:49 jaume |
|
46 |
* Revision 1.1.2.3 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.2 2007/02/01 17:46:49 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
... | ... | |
53 | 56 |
*/ |
54 | 57 |
package com.iver.cit.gvsig.fmap.layers; |
55 | 58 |
|
59 |
import java.awt.Graphics2D; |
|
60 |
import java.awt.image.BufferedImage; |
|
61 |
|
|
62 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
63 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
56 | 64 |
import com.iver.cit.gvsig.fmap.core.ILabelable; |
57 |
import com.iver.cit.gvsig.fmap.rendering.LabelingFactory; |
|
58 | 65 |
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingMethod; |
59 | 66 |
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingStrategy; |
67 |
import com.iver.cit.gvsig.fmap.rendering.styling.LabelingFactory; |
|
60 | 68 |
import com.iver.utiles.XMLEntity; |
69 |
import com.iver.utiles.swing.threads.Cancellable; |
|
61 | 70 |
|
62 | 71 |
public class LabeledTestFLayer extends FLyrVect implements ILabelable { |
63 | 72 |
|
... | ... | |
86 | 95 |
this.strategy = strategy; |
87 | 96 |
} |
88 | 97 |
|
98 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException { |
|
99 |
super.draw(image, g, viewPort, cancel, scale); |
|
100 |
drawLabels(image, g, viewPort, cancel, scale); |
|
101 |
} |
|
102 |
|
|
89 | 103 |
public XMLEntity getXMLEntity() throws XMLException { |
90 | 104 |
XMLEntity xml = super.getXMLEntity(); |
91 | 105 |
xml.remove("className"); |
... | ... | |
117 | 131 |
} |
118 | 132 |
|
119 | 133 |
} |
134 |
|
|
135 |
public void drawLabels(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException { |
|
136 |
if (isWithinScale(scale) && isLabeled()) { |
|
137 |
|
|
138 |
} |
|
139 |
} |
|
120 | 140 |
} |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrText.java | ||
---|---|---|
219 | 219 |
e.printStackTrace(); |
220 | 220 |
throw new DriverException(e); |
221 | 221 |
} |
222 |
|
|
223 | 222 |
} |
224 | 223 |
|
225 | 224 |
/** |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/LabelingFactory.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1.2.1 2007-01-30 18:10:45 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.fmap.rendering; |
|
52 |
|
|
53 |
import org.apache.log4j.Logger; |
|
54 |
|
|
55 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
56 |
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingMethod; |
|
57 |
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingStrategy; |
|
58 |
import com.iver.utiles.IPersistance; |
|
59 |
import com.iver.utiles.NotExistInXMLEntity; |
|
60 |
import com.iver.utiles.XMLEntity; |
|
61 |
|
|
62 |
public class LabelingFactory { |
|
63 |
private static Logger logger = Logger.getLogger(SymbolFactory.class.getName()); |
|
64 |
|
|
65 |
|
|
66 |
private static Object createFromXML(XMLEntity xml) { |
|
67 |
String className = null; |
|
68 |
try { |
|
69 |
className = xml.getStringProperty("className"); |
|
70 |
} catch (NotExistInXMLEntity e) { |
|
71 |
logger.error("Symbol class name not set.\n" + |
|
72 |
" Maybe you forgot to add the" + |
|
73 |
" putProperty(\"className\", yourClassName)" + |
|
74 |
" call in the getXMLEntity method of your symbol", e); |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
Class clazz = null; |
|
79 |
Object obj = null; |
|
80 |
try { |
|
81 |
clazz = Class.forName(className); |
|
82 |
// TODO remove the patch the day we deprecate FSymbol |
|
83 |
obj = clazz.newInstance(); |
|
84 |
((IPersistance) obj).setXMLEntity(xml); |
|
85 |
|
|
86 |
} catch (InstantiationException e) { |
|
87 |
logger.error("Trying to instantiate an interface" + |
|
88 |
" or abstract class + "+className, e); |
|
89 |
} catch (IllegalAccessException e) { |
|
90 |
logger.error(null, e); |
|
91 |
} catch (ClassNotFoundException e) { |
|
92 |
logger.error("No class called " + className + |
|
93 |
" was found.\nCheck the following.\n<br>" + |
|
94 |
"\t- The fullname of the class you're looking " + |
|
95 |
"for matches the value in the className " + |
|
96 |
"property of the XMLEntity ("+className+").\n<br>" + |
|
97 |
"\t- The jar file containing your symbol class is in" + |
|
98 |
"the application classpath<br>", e); |
|
99 |
} |
|
100 |
return obj; |
|
101 |
} |
|
102 |
|
|
103 |
public static ILabelingStrategy createStrategyFromXML(XMLEntity xml) { |
|
104 |
return (ILabelingStrategy) createFromXML(xml); |
|
105 |
} |
|
106 |
|
|
107 |
public static ILabelingMethod createMethodFromXML(XMLEntity xml) { |
|
108 |
return (ILabelingMethod) createFromXML(xml); |
|
109 |
} |
|
110 |
|
|
111 |
|
|
112 |
} |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelingStrategyFactory.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1.2.1 2007-02-01 17:46:49 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
|
52 |
|
|
53 |
public class LabelingStrategyFactory { |
|
54 |
public static ILabelingStrategy createDefaultStrategy(int shapeType) { |
|
55 |
return new DefaultLabelingStrategy(shapeType); |
|
56 |
} |
|
57 |
|
|
58 |
public static ILabelingStrategy createStrategy(int shapeType, ILabelingMethod method, PlacementConstraints placement, ZoomConstraints zoom) { |
|
59 |
if (method == null && placement == null && zoom == null) |
|
60 |
return createDefaultStrategy(shapeType); |
|
61 |
|
|
62 |
return createDefaultStrategy(shapeType); |
|
63 |
/* solament per a proves, ac? falta muntar el sistema expert que |
|
64 |
* decidisca quina estrat?gia ?s la millor a partir dels par?metres. |
|
65 |
*/ |
|
66 |
} |
|
67 |
} |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.2 2007-02-01 11:42:47 jaume |
|
46 |
* Revision 1.1.2.3 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
... | ... | |
57 | 60 |
|
58 | 61 |
|
59 | 62 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
63 |
import org.cresques.px.gml.MultiPolygon; |
|
64 |
|
|
60 | 65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
66 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
67 |
import com.iver.cit.gvsig.fmap.core.symbols.TextSymbol; |
|
61 | 68 |
|
62 | 69 |
public class PlacementConstraints implements Cloneable { |
63 | 70 |
// constants regarding label duplication |
... | ... | |
172 | 179 |
return duplicateLabelsMode; |
173 | 180 |
} |
174 | 181 |
|
182 |
/** |
|
183 |
* Calculates the |
|
184 |
* |
|
185 |
* @param geom, the geometry surface |
|
186 |
* @param label, the label to be placed |
|
187 |
* @param MultiPolygon exclusionZone |
|
188 |
* @return the FShape where the label will be placed |
|
189 |
*/ |
|
190 |
public FShape getLocationFor(IGeometry geom, TextSymbol label, MultiPolygon exclusionZone) { |
|
191 |
// TODO Implement it |
|
192 |
throw new Error("Not yet implemented!"); |
|
193 |
|
|
194 |
} |
|
195 |
|
|
175 | 196 |
} |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/DefaultLabelingStrategy.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.1 2007-02-01 17:46:49 jaume |
|
46 |
* Revision 1.1.2.2 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.1 2007/02/01 17:46:49 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* |
... | ... | |
51 | 54 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
52 | 55 |
|
53 | 56 |
import java.awt.Graphics2D; |
57 |
import java.awt.geom.Rectangle2D; |
|
54 | 58 |
import java.awt.image.BufferedImage; |
59 |
import java.util.logging.Level; |
|
60 |
import java.util.logging.Logger; |
|
55 | 61 |
|
56 | 62 |
import com.iver.cit.gvsig.fmap.DriverException; |
57 | 63 |
import com.iver.cit.gvsig.fmap.ViewPort; |
64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
66 |
import com.iver.cit.gvsig.fmap.core.symbols.TextSymbol; |
|
67 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
68 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
69 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
70 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
58 | 71 |
import com.iver.utiles.XMLEntity; |
59 | 72 |
import com.iver.utiles.swing.threads.Cancellable; |
60 | 73 |
|
... | ... | |
64 | 77 |
* |
65 | 78 |
*/ |
66 | 79 |
public class DefaultLabelingStrategy implements ILabelingStrategy { |
67 |
|
|
80 |
private static Logger logger = Logger.getAnonymousLogger(); |
|
68 | 81 |
private ILabelingMethod method; |
69 | 82 |
private PlacementConstraints placementConstraints; |
83 |
private FLyrVect layer; |
|
70 | 84 |
|
71 |
protected DefaultLabelingStrategy(int shapeType) { |
|
72 |
placementConstraints = new PlacementConstraints(shapeType); |
|
85 |
protected DefaultLabelingStrategy(FLayer layer) throws DriverException { |
|
86 |
FLyrVect l = (FLyrVect) layer; |
|
87 |
this.layer = l; |
|
88 |
placementConstraints = new PlacementConstraints(l.getShapeType()); |
|
73 | 89 |
method = new EquallyLabeled(); |
74 | 90 |
} |
75 | 91 |
|
... | ... | |
80 | 96 |
public void setLabelingMethod(ILabelingMethod method) {} |
81 | 97 |
|
82 | 98 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) throws DriverException { |
83 |
// TODO Implement it |
|
84 |
throw new Error("Not yet implemented!"); |
|
99 |
Rectangle2D theExtent = viewPort.getAdjustedExtent(); |
|
100 |
|
|
101 |
|
|
102 |
FBitSet bs = layer.queryByRect(theExtent); |
|
103 |
LabelClass lc = method.getDefaultLabelClass(); |
|
104 |
|
|
105 |
|
|
106 |
// TODO meter el ZoomConstraints |
|
107 |
|
|
108 |
TextSymbol sym = lc.getLabelSymbol(); |
|
109 |
for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { |
|
110 |
IGeometry geom; |
|
111 |
try { |
|
112 |
geom = layer.getSource().getShape(i); |
|
113 |
FShape shp = placementConstraints.getLocationFor(geom, sym, null); |
|
114 |
sym.draw(g, viewPort.getAffineTransform(), shp); |
|
115 |
} catch (DriverIOException e) { |
|
116 |
// TODO Auto-generated catch block |
|
117 |
logger.log(Level.SEVERE, "Draw label for "+i+"th shape of "+layer.getName()); |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
} |
|
85 | 122 |
} |
86 | 123 |
|
87 | 124 |
public String getClassName() { |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.3 2007-02-01 17:46:49 jaume |
|
46 |
* Revision 1.1.2.4 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.3 2007/02/01 17:46:49 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume |
... | ... | |
57 | 60 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
58 | 61 |
|
59 | 62 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
63 |
import com.iver.cit.gvsig.fmap.core.symbols.TextSymbol; |
|
60 | 64 |
|
61 | 65 |
|
62 | 66 |
public class LabelClass { |
63 | 67 |
private String name; |
64 |
private ISymbol symbol;
|
|
68 |
private TextSymbol label;
|
|
65 | 69 |
private String labelExpression; |
66 | 70 |
private boolean isVisible; |
67 | 71 |
|
... | ... | |
82 | 86 |
this.labelExpression = labelExpression; |
83 | 87 |
} |
84 | 88 |
|
85 |
public ISymbol getSymbol() {
|
|
86 |
return symbol;
|
|
89 |
public TextSymbol getLabelSymbol() {
|
|
90 |
return label;
|
|
87 | 91 |
} |
88 | 92 |
|
89 |
public void setSymbol(ISymbol symbol) { |
|
90 |
this.symbol = symbol; |
|
93 |
public void setStyle(ISymbol style) { |
|
94 |
if (label == null) |
|
95 |
label = new TextSymbol(); |
|
96 |
label.setStyle(style); |
|
97 |
|
|
91 | 98 |
} |
92 | 99 |
|
93 | 100 |
/** |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelingFactory.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1.2.1 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
|
50 |
* start commiting labeling stuff |
|
51 |
* |
|
52 |
* |
|
53 |
*/ |
|
54 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
|
55 |
|
|
56 |
import org.apache.log4j.Logger; |
|
57 |
|
|
58 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
59 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
60 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
61 |
import com.iver.utiles.IPersistance; |
|
62 |
import com.iver.utiles.NotExistInXMLEntity; |
|
63 |
import com.iver.utiles.XMLEntity; |
|
64 |
|
|
65 |
public class LabelingFactory { |
|
66 |
private static Logger logger = Logger.getLogger(SymbolFactory.class.getName()); |
|
67 |
|
|
68 |
|
|
69 |
private static Object createFromXML(XMLEntity xml) { |
|
70 |
String className = null; |
|
71 |
try { |
|
72 |
className = xml.getStringProperty("className"); |
|
73 |
} catch (NotExistInXMLEntity e) { |
|
74 |
logger.error("Symbol class name not set.\n" + |
|
75 |
" Maybe you forgot to add the" + |
|
76 |
" putProperty(\"className\", yourClassName)" + |
|
77 |
" call in the getXMLEntity method of your symbol", e); |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
Class clazz = null; |
|
82 |
Object obj = null; |
|
83 |
try { |
|
84 |
clazz = Class.forName(className); |
|
85 |
// TODO remove the patch the day we deprecate FSymbol |
|
86 |
obj = clazz.newInstance(); |
|
87 |
((IPersistance) obj).setXMLEntity(xml); |
|
88 |
|
|
89 |
} catch (InstantiationException e) { |
|
90 |
logger.error("Trying to instantiate an interface" + |
|
91 |
" or abstract class + "+className, e); |
|
92 |
} catch (IllegalAccessException e) { |
|
93 |
logger.error(null, e); |
|
94 |
} catch (ClassNotFoundException e) { |
|
95 |
logger.error("No class called " + className + |
|
96 |
" was found.\nCheck the following.\n<br>" + |
|
97 |
"\t- The fullname of the class you're looking " + |
|
98 |
"for matches the value in the className " + |
|
99 |
"property of the XMLEntity ("+className+").\n<br>" + |
|
100 |
"\t- The jar file containing your symbol class is in" + |
|
101 |
"the application classpath<br>", e); |
|
102 |
} |
|
103 |
return obj; |
|
104 |
} |
|
105 |
|
|
106 |
public static ILabelingStrategy createStrategyFromXML(XMLEntity xml) { |
|
107 |
return (ILabelingStrategy) createFromXML(xml); |
|
108 |
} |
|
109 |
|
|
110 |
public static ILabelingMethod createMethodFromXML(XMLEntity xml) { |
|
111 |
return (ILabelingMethod) createFromXML(xml); |
|
112 |
} |
|
113 |
|
|
114 |
public static ILabelingStrategy createDefaultStrategy(FLayer layer) throws DriverException { |
|
115 |
return new DefaultLabelingStrategy(layer); |
|
116 |
} |
|
117 |
|
|
118 |
public static ILabelingStrategy createStrategy(FLayer layer, ILabelingMethod method, PlacementConstraints placement, ZoomConstraints zoom) throws DriverException { |
|
119 |
if (method == null && placement == null && zoom == null) |
|
120 |
return createDefaultStrategy(layer); |
|
121 |
|
|
122 |
return createDefaultStrategy(layer); |
|
123 |
/* solament per a proves, ac? falta muntar el sistema expert que |
|
124 |
* decidisca quina estrat?gia ?s la millor a partir dels par?metres. |
|
125 |
*/ |
|
126 |
} |
|
127 |
|
|
128 |
|
|
129 |
} |
|
0 | 130 |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/TextSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1 2007-01-24 17:58:22 jaume |
|
46 |
* Revision 1.1.2.1 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1 2007/01/24 17:58:22 jaume |
|
47 | 50 |
* new features and architecture error fixes |
48 | 51 |
* |
49 | 52 |
* |
50 | 53 |
*/ |
51 | 54 |
package com.iver.cit.gvsig.fmap.core.symbols; |
52 | 55 |
|
56 |
import java.awt.Color; |
|
53 | 57 |
import java.awt.Graphics2D; |
54 | 58 |
import java.awt.Rectangle; |
55 | 59 |
import java.awt.Shape; |
... | ... | |
62 | 66 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
63 | 67 |
import com.iver.utiles.XMLEntity; |
64 | 68 |
|
65 |
public class TextSymbol implements ISymbol { |
|
69 |
public class TextSymbol extends AbstractSymbol { |
|
70 |
private Color textColor; |
|
66 | 71 |
|
67 | 72 |
public ISymbol getSymbolForSelection() { |
68 |
// TODO Implement it |
|
69 |
throw new Error("Not yet implemented!"); |
|
70 |
|
|
73 |
return this; // a text is not selectable |
|
71 | 74 |
} |
72 | 75 |
|
73 | 76 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
74 |
// TODO Implement it |
|
75 |
throw new Error("Not yet implemented!"); |
|
76 | 77 |
|
77 | 78 |
} |
78 | 79 |
|
... | ... | |
83 | 84 |
} |
84 | 85 |
|
85 | 86 |
public int getOnePointRgb() { |
86 |
// TODO Implement it |
|
87 |
throw new Error("Not yet implemented!"); |
|
88 |
|
|
87 |
return textColor.getRGB(); |
|
89 | 88 |
} |
90 | 89 |
|
91 | 90 |
public XMLEntity getXMLEntity() { |
... | ... | |
94 | 93 |
|
95 | 94 |
} |
96 | 95 |
|
97 |
public String getDescription() { |
|
98 |
// TODO Implement it |
|
99 |
throw new Error("Not yet implemented!"); |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
public boolean isShapeVisible() { |
|
104 |
// TODO Implement it |
|
105 |
throw new Error("Not yet implemented!"); |
|
106 |
|
|
107 |
} |
|
108 |
|
|
109 |
public void setDescription(String desc) { |
|
110 |
// TODO Implement it |
|
111 |
throw new Error("Not yet implemented!"); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 | 96 |
public int getSymbolType() { |
116 | 97 |
// TODO Implement it |
117 | 98 |
throw new Error("Not yet implemented!"); |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractMarkerSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-01-25 16:25:23 jaume |
|
46 |
* Revision 1.3.2.1 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.3 2007/01/25 16:25:23 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/01/16 11:50:44 jaume |
... | ... | |
100 | 103 |
public abstract class AbstractMarkerSymbol extends AbstractSymbol { |
101 | 104 |
protected Color color = Color.BLACK; |
102 | 105 |
protected double rotation; |
103 |
protected Point2D offset; |
|
106 |
protected Point2D offset = new Point2D.Double();
|
|
104 | 107 |
protected double size; |
105 | 108 |
|
106 | 109 |
public double getRotation() { |
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/ILabelable.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1.2.2 2007-02-01 17:46:49 jaume |
|
46 |
* Revision 1.1.2.3 2007-02-02 16:21:24 jaume |
|
47 |
* start commiting labeling stuff |
|
48 |
* |
|
49 |
* Revision 1.1.2.2 2007/02/01 17:46:49 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume |
... | ... | |
53 | 56 |
*/ |
54 | 57 |
package com.iver.cit.gvsig.fmap.core; |
55 | 58 |
|
59 |
import java.awt.Graphics2D; |
|
60 |
import java.awt.image.BufferedImage; |
|
61 |
|
|
62 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
63 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
56 | 64 |
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingStrategy; |
65 |
import com.iver.utiles.swing.threads.Cancellable; |
|
57 | 66 |
|
58 | 67 |
public interface ILabelable { |
59 | 68 |
public boolean isLabeled(); |
60 | 69 |
public void setIsLabeled(boolean isLabeled); |
61 | 70 |
public ILabelingStrategy getLabelingStrategy(); |
62 | 71 |
public void setLabelingStrategy(ILabelingStrategy strategy); |
72 |
public void drawLabels(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException; |
|
63 | 73 |
} |
Also available in: Unified diff