Revision 13749
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AbstractLabelingMethod.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-03-21 11:01:28 jaume |
|
46 |
* Revision 1.4 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.3 2007/03/21 11:01:28 jaume |
|
47 | 50 |
* javadoc |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
... | ... | |
70 | 73 |
public abstract class AbstractLabelingMethod implements ILabelingMethod{ |
71 | 74 |
|
72 | 75 |
private LabelClass defaultLabel; |
73 |
protected ArrayList classes = new ArrayList();
|
|
76 |
protected ArrayList<LabelClass> classes = new ArrayList<LabelClass>();
|
|
74 | 77 |
|
75 | 78 |
public LabelClass getDefaultLabelClass() { |
76 | 79 |
if (defaultLabel == null) { |
... | ... | |
83 | 86 |
public LabelClass[] getLabelClasses() { |
84 | 87 |
if (!classes.contains(getDefaultLabelClass())) |
85 | 88 |
classes.add(0, getDefaultLabelClass()); |
86 |
return (LabelClass[]) classes.toArray(new LabelClass[0]);
|
|
89 |
return classes.toArray(new LabelClass[0]); |
|
87 | 90 |
} |
88 | 91 |
|
89 | 92 |
public LabelClass getLabelClassByName(String name) { |
90 | 93 |
for (int i = 0; i < classes.size(); i++) { |
91 |
LabelClass c = (LabelClass) classes.get(i);
|
|
94 |
LabelClass c = classes.get(i); |
|
92 | 95 |
if (c.getName().equals(name)) |
93 | 96 |
return c; |
94 | 97 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.12 2007-08-22 09:48:13 jvidal |
|
46 |
* Revision 1.13 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.12 2007/08/22 09:48:13 jvidal |
|
47 | 50 |
* javadoc |
48 | 51 |
* |
49 | 52 |
* Revision 1.11 2007/05/09 11:04:58 jaume |
... | ... | |
134 | 137 |
private ILabelStyle labelStyle; |
135 | 138 |
|
136 | 139 |
private String[] texts; |
140 |
|
|
137 | 141 |
/** |
138 | 142 |
* Returns true if the label will be showed in the map |
139 | 143 |
* |
... | ... | |
142 | 146 |
public boolean isVisible() { |
143 | 147 |
return isVisible; |
144 | 148 |
} |
149 |
|
|
145 | 150 |
/** |
146 | 151 |
* Stablishes if the label will be visible or not in the map. |
147 | 152 |
* |
... | ... | |
175 | 180 |
* Returns the text symbol that is being used for the text(the font, |
176 | 181 |
* size,style,aligment) |
177 | 182 |
* |
178 |
*@return label ITextSymbol |
|
183 |
* @return label ITextSymbol
|
|
179 | 184 |
*/ |
180 | 185 |
public ITextSymbol getLabelSymbol() { |
181 | 186 |
if (label == null) { |
... | ... | |
183 | 188 |
} |
184 | 189 |
return label; |
185 | 190 |
} |
191 |
|
|
186 | 192 |
/** |
187 | 193 |
* Stablishes the text symbol that is going to be used for the text(the |
188 | 194 |
* font,size,style,aligment) |
... | ... | |
194 | 200 |
if (label == null) |
195 | 201 |
label = new SimpleTextSymbol(); |
196 | 202 |
} |
203 |
|
|
197 | 204 |
/** |
198 | 205 |
* Stablishes the style for the label. |
199 | 206 |
* |
... | ... | |
202 | 209 |
public void setLabelStyle(ILabelStyle labelStyle) { |
203 | 210 |
this.labelStyle = labelStyle; |
204 | 211 |
} |
212 |
|
|
205 | 213 |
/** |
206 | 214 |
* Returns the style of the label |
207 | 215 |
* |
... | ... | |
209 | 217 |
public ILabelStyle getLabelStyle() { |
210 | 218 |
return this.labelStyle; |
211 | 219 |
} |
220 |
|
|
212 | 221 |
/** |
213 | 222 |
* Returns the name of the label |
214 | 223 |
* |
... | ... | |
216 | 225 |
public String getName() { |
217 | 226 |
return name; |
218 | 227 |
} |
228 |
|
|
219 | 229 |
/** |
220 | 230 |
* Stablishes the name of the label |
221 | 231 |
* @param name |
... | ... | |
227 | 237 |
public String toString() { |
228 | 238 |
return name; |
229 | 239 |
} |
240 |
|
|
230 | 241 |
/** |
231 | 242 |
* Sets the text for the label |
232 | 243 |
* |
... | ... | |
235 | 246 |
public void setTexts(String[] texts) { |
236 | 247 |
this.texts = texts; |
237 | 248 |
} |
249 |
|
|
238 | 250 |
/** |
239 | 251 |
* Useful to render a Label with size inside little rectangles. |
240 | 252 |
* |
... | ... | |
244 | 256 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds) { |
245 | 257 |
if (labelStyle != null) { |
246 | 258 |
// apply the offset to the markerPoint |
247 |
System.out.println(bounds); |
|
248 | 259 |
labelStyle.drawInsideRectangle(graphics, bounds); |
249 | 260 |
|
250 | 261 |
for (int i = 0; i < texts.length; i++) { |
... | ... | |
280 | 291 |
getLabelSymbol().drawInsideRectangle(graphics, null, textRect); |
281 | 292 |
} |
282 | 293 |
} else { |
283 |
getLabelSymbol().setText(texts[0]); |
|
294 |
if (texts.length>0) |
|
295 |
getLabelSymbol().setText(texts[0]); |
|
284 | 296 |
getLabelSymbol().draw(graphics, null, new FPoint2D(bounds.getX(), bounds.getY())); |
285 | 297 |
} |
286 | 298 |
} |
299 |
|
|
287 | 300 |
/** |
288 | 301 |
* Obtains the shape that contains the label |
289 | 302 |
* |
... | ... | |
302 | 315 |
p.transform(at); |
303 | 316 |
|
304 | 317 |
// 2. calculate the container shape |
318 |
FShape returnedValue; |
|
305 | 319 |
if (labelStyle == null) { |
306 | 320 |
// shape is defined by the symbol |
307 | 321 |
ITextSymbol sym = getLabelSymbol(); |
308 |
if (texts != null) { |
|
322 |
if (texts != null && texts.length>0) {
|
|
309 | 323 |
String lText = texts[0]; |
310 | 324 |
for (int i = 1; i < texts.length; i++) { |
311 | 325 |
lText += " "+ texts[i]; |
312 | 326 |
} |
313 | 327 |
sym.setText(lText); |
314 | 328 |
} |
315 |
return getLabelSymbol().getTextWrappingShape(p); |
|
329 |
returnedValue = getLabelSymbol().getTextWrappingShape(p);
|
|
316 | 330 |
} else { |
317 | 331 |
// shape is defined by the style |
318 | 332 |
// maybe this is incorrect but for the moment we'll go with it |
319 | 333 |
Rectangle bounds = labelStyle.getBounds(at); |
320 | 334 |
bounds.translate((int) p.getX() /* TODO : + aGap */, (int) p.getY()-bounds.height /* TODO :- aGap */); |
321 |
return new FPolygon2D(new GeneralPathX(bounds)); |
|
335 |
returnedValue = new FPolygon2D(new GeneralPathX(bounds));
|
|
322 | 336 |
} |
337 |
return returnedValue; |
|
323 | 338 |
} |
324 | 339 |
|
325 |
|
|
326 |
// public FShape getShape(Graphics2D g, AffineTransform at, IGeometry geom) { |
|
327 |
// if (labelStyle == null) { |
|
328 |
// // shape is defined by the symbol |
|
329 |
// FShape shp = null; |
|
330 |
// |
|
331 |
// switch (geom.getGeometryType()) { |
|
332 |
// case FShape.POINT: |
|
333 |
// shp = (FShape) geom.getInternalShape(); |
|
334 |
//// shp = new FPoint2D((Point2D) geom.getInternalShape()); |
|
335 |
// break; |
|
336 |
// case FShape.LINE: |
|
337 |
// shp = new FPolyline2D(new GeneralPathX(geom.getInternalShape())); |
|
338 |
// break; |
|
339 |
// case FShape.POLYGON: |
|
340 |
// shp = new FPolygon2D(new GeneralPathX(geom.getInternalShape())); |
|
341 |
// break; |
|
342 |
// } |
|
343 |
// shp.transform(at); |
|
344 |
// System.err.println(shp); |
|
345 |
// return getLabelSymbol().getTextWrappingShape(g, shp); |
|
346 |
// } else { |
|
347 |
// // shape is defined by the style |
|
348 |
// // maybe this is incorrect but for the moment we'll go with it |
|
349 |
// Rectangle bounds = labelStyle.getBounds(); |
|
350 |
// FPoint2D p = new FPoint2D(geom.getBounds().getX(), geom.getBounds().getY()); |
|
351 |
// p.transform(at); |
|
352 |
// bounds.translate((int) p.getX() /* TODO : + aGap */, (int) p.getY()-bounds.height /* TODO :- aGap */); |
|
353 |
// return new FPolygon2D(new GeneralPathX(bounds)); |
|
354 |
// } |
|
355 |
// } |
|
356 |
|
|
357 | 340 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/GeneralLabelingStrategy.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.1 2007-05-22 12:17:41 jaume |
|
46 |
* Revision 1.2 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.1 2007/05/22 12:17:41 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1 2007/05/22 10:05:31 jaume |
... | ... | |
107 | 110 |
import java.awt.Graphics2D; |
108 | 111 |
import java.awt.geom.Rectangle2D; |
109 | 112 |
import java.awt.image.BufferedImage; |
113 |
import java.util.ArrayList; |
|
110 | 114 |
import java.util.Hashtable; |
111 | 115 |
import java.util.logging.Level; |
112 | 116 |
import java.util.logging.Logger; |
... | ... | |
114 | 118 |
import javax.print.attribute.PrintRequestAttributeSet; |
115 | 119 |
|
116 | 120 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
121 |
import com.hardcode.gdbms.engine.values.Value; |
|
117 | 122 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
118 | 123 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
119 | 124 |
import com.iver.cit.gvsig.fmap.ViewPort; |
125 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
120 | 126 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
127 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
121 | 128 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
122 | 129 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
123 | 130 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
163 | 170 |
} |
164 | 171 |
|
165 | 172 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
173 |
Cancellable cancel) |
|
174 |
throws ReadDriverException { |
|
175 |
|
|
176 |
|
|
177 |
if (method == null) { |
|
178 |
Logger.getAnonymousLogger().warning("Layer '"+layer.getName()+"'. No labeling method was set, labels will not be drawn"); |
|
179 |
return; |
|
180 |
} |
|
181 |
|
|
182 |
if (zoomConstraints != null) { |
|
183 |
double scale = viewPort.getScale(); |
|
184 |
if (scale < zoomConstraints.getMinScale() || |
|
185 |
scale > zoomConstraints.getMaxScale()) |
|
186 |
return; |
|
187 |
} |
|
188 |
|
|
189 |
IFeatureIterator it = layer.getSource().getFeatureIterator( |
|
190 |
viewPort.getAdjustedExtent(), |
|
191 |
getUsedFields(), |
|
192 |
viewPort.getProjection(), |
|
193 |
true); |
|
194 |
|
|
195 |
try { |
|
196 |
while (!cancel.isCanceled() && it.hasNext()) { |
|
197 |
IFeature feat = it.next(); |
|
198 |
IGeometry geom = feat.getGeometry(); |
|
199 |
|
|
200 |
LabelClass lc = method.getDefaultLabelClass(); |
|
201 |
|
|
202 |
Value[] vv = feat.getAttributes(); |
|
203 |
String[] texts = new String[vv.length]; |
|
204 |
|
|
205 |
for (int i = 0; i < texts.length; i++) { |
|
206 |
texts[i] = vv[i].toString(); |
|
207 |
} |
|
208 |
|
|
209 |
lc.setTexts(texts); |
|
210 |
|
|
211 |
// refactor "if label shape is big enough" |
|
212 |
placementConstraints.placeLabel(g, geom, lc, null, viewPort.getAffineTransform()); |
|
213 |
|
|
214 |
} |
|
215 |
} catch (ExpansionFileReadException e) { |
|
216 |
throw new ReadDriverException( |
|
217 |
layer.getSource().getDriver().getName(), e); |
|
218 |
} |
|
219 |
} |
|
220 |
|
|
221 |
|
|
222 |
public void _draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
166 | 223 |
Cancellable cancel) |
167 | 224 |
throws ReadDriverException { |
168 | 225 |
|
... | ... | |
179 | 236 |
scale > zoomConstraints.getMaxScale()) |
180 | 237 |
return; |
181 | 238 |
} |
239 |
|
|
182 | 240 |
FBitSet bs; |
183 | 241 |
int i = -1; |
184 | 242 |
try { |
... | ... | |
288 | 346 |
} |
289 | 347 |
|
290 | 348 |
public String[] getUsedFields() { |
291 |
// // TODO Implement it |
|
292 |
// throw new Error("Not yet implemented!"); |
|
293 |
// |
|
294 |
// TODO |
|
295 |
|
|
296 |
return new String[0]; |
|
349 |
LabelClass[] lcs = method.getLabelClasses(); |
|
350 |
ArrayList<String> fieldNames = new ArrayList<String>(); |
|
351 |
for (int i = 0; i < lcs.length; i++) { |
|
352 |
String expr = lcs[i].getLabelExpression(); |
|
353 |
/* |
|
354 |
* TODO |
|
355 |
* implement the expression parser, and extract the names of the |
|
356 |
* fields involved |
|
357 |
*/ |
|
358 |
// this is just a provisional |
|
359 |
fieldNames.add( expr.replaceAll(" *", "").replaceAll("\\[|\\]", "") ); |
|
360 |
|
|
361 |
} |
|
362 |
return fieldNames.toArray(new String[fieldNames.size()]); |
|
297 | 363 |
} |
298 | 364 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java | ||
---|---|---|
47 | 47 |
import java.awt.image.BufferedImage; |
48 | 48 |
import java.io.File; |
49 | 49 |
import java.net.URI; |
50 |
import java.net.URL; |
|
51 | 50 |
import java.util.ArrayList; |
52 | 51 |
|
53 | 52 |
import javax.print.attribute.PrintRequestAttributeSet; |
... | ... | |
99 | 98 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
100 | 99 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
101 | 100 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager; |
102 |
import com.iver.cit.gvsig.fmap.rendering.IClassifiedVectorialLegend; |
|
103 | 101 |
import com.iver.cit.gvsig.fmap.rendering.ILegend; |
104 | 102 |
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend; |
105 | 103 |
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent; |
... | ... | |
114 | 112 |
import com.iver.cit.gvsig.fmap.spatialindex.QuadtreeGt2; |
115 | 113 |
import com.iver.cit.gvsig.fmap.spatialindex.QuadtreeJts; |
116 | 114 |
import com.iver.cit.gvsig.fmap.spatialindex.SpatialIndexException; |
117 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
118 | 115 |
import com.iver.utiles.FileUtils; |
119 | 116 |
import com.iver.utiles.IPersistance; |
120 | 117 |
import com.iver.utiles.NotExistInXMLEntity; |
... | ... | |
425 | 422 |
if (x<0 || y<0 || x>= imageLevels[zSort.getSymbolLevel(mySym)].getWidth() || y>=imageLevels[zSort.getSymbolLevel(mySym)].getHeight()) continue; |
426 | 423 |
imageLevels[zSort.getSymbolLevel(mySym)].setRGB(x, y, mySym.getOnePointRgb()); |
427 | 424 |
} else { |
428 |
// geom.drawInts(graphics[zSort.getSymbolLevel(mySym)], viewPort, mySym); |
|
429 |
|
|
430 | 425 |
if (!bDrawCartographicSupport) { |
431 | 426 |
geom.drawInts(graphics[zSort.getSymbolLevel(mySym)], viewPort, mySym); |
432 | 427 |
} else { |
... | ... | |
504 | 499 |
|
505 | 500 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
506 | 501 |
Cancellable cancel, double scale) throws ReadDriverException { |
507 |
forTestOnlyVariableUseIterators_REMOVE_THIS_FIELD = false;
|
|
502 |
forTestOnlyVariableUseIterators_REMOVE_THIS_FIELD = true;
|
|
508 | 503 |
if (forTestOnlyVariableUseIterators_REMOVE_THIS_FIELD) { |
509 | 504 |
_draw(image, g, viewPort, cancel, scale); |
510 | 505 |
} else { |
... | ... | |
1470 | 1465 |
|
1471 | 1466 |
} |
1472 | 1467 |
|
1473 |
} |
|
1474 |
// TODO lines |
|
1475 |
// TODO polygon |
|
1468 |
} |
|
1476 | 1469 |
return onePoint; |
1477 | 1470 |
} |
1478 | 1471 |
/* |
... | ... | |
1500 | 1493 |
public void drawLabels(BufferedImage image, Graphics2D g, ViewPort viewPort, |
1501 | 1494 |
Cancellable cancel, double scale) throws ReadDriverException { |
1502 | 1495 |
if (isWithinScale(scale)) { |
1503 |
strategy.draw(image, g, viewPort, cancel);
|
|
1496 |
strategy.draw(image, g, viewPort, cancel);
|
|
1504 | 1497 |
} |
1505 | 1498 |
} |
1506 | 1499 |
|
... | ... | |
1541 | 1534 |
return linkProperties.getLink(this,point,tolerance); |
1542 | 1535 |
} |
1543 | 1536 |
|
1544 |
} |
|
1537 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerMarkerSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.12 2007-09-17 11:37:55 jaume |
|
46 |
* Revision 1.13 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.12 2007/09/17 11:37:55 jaume |
|
47 | 50 |
* fixed multilayermarkersymbol unit symbol |
48 | 51 |
* |
49 | 52 |
* Revision 1.11 2007/08/09 07:57:51 jvidal |
... | ... | |
114 | 117 |
private MultiLayerMarkerSymbol selectionSymbol; |
115 | 118 |
private Point2D offset = new Point2D.Double(); |
116 | 119 |
private double rotation; |
117 |
private double size; |
|
118 | 120 |
public Color getColor() { |
119 | 121 |
/* |
120 | 122 |
* a multilayer symbol does not define any color, the color |
... | ... | |
131 | 133 |
return rotation; |
132 | 134 |
} |
133 | 135 |
|
134 |
public double getSize() { |
|
135 |
/* |
|
136 |
* will return the widest symbol's width |
|
137 |
*/ |
|
138 |
double size = Double.NEGATIVE_INFINITY; |
|
139 |
for (int i = 0; i < layers.length; i++) { |
|
140 |
size = Math.max(size, layers[i].getSize()); |
|
141 |
} |
|
142 |
return size; |
|
143 |
} |
|
144 | 136 |
|
145 | 137 |
public void setColor(Color color) { |
146 | 138 |
/* |
... | ... | |
160 | 152 |
} |
161 | 153 |
|
162 | 154 |
public void setSize(double size) { |
163 |
this.size = size; |
|
164 |
for (int i = 0; i < layers.length; i++) { |
|
165 |
double lSize = layers[i].getSize(); |
|
166 |
double scale = lSize/size; |
|
167 |
layers[i].setSize(lSize*scale); |
|
155 |
if (size > 0) { |
|
156 |
double scale = size / getSize(); |
|
157 |
super.setSize(size); |
|
158 |
for (int i = 0; i < layers.length; i++) { |
|
159 |
double lSize = layers[i].getSize(); |
|
160 |
layers[i].setSize(lSize*scale); |
|
161 |
} |
|
168 | 162 |
} |
169 | 163 |
} |
170 | 164 |
|
... | ... | |
216 | 210 |
xml.putProperty("className", getClass().getName()); |
217 | 211 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
218 | 212 |
xml.putProperty("desc", getDescription()); |
213 |
xml.putProperty("size", getSize()); |
|
214 |
xml.putProperty("unit", getUnit()); |
|
215 |
xml.putProperty("referenceSystem", getReferenceSystem()); |
|
219 | 216 |
for (int i = 0; i < layers.length; i++) { |
220 | 217 |
xml.addChild(layers[i].getXMLEntity()); |
221 | 218 |
} |
... | ... | |
234 | 231 |
public void setXMLEntity(XMLEntity xml) { |
235 | 232 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible")); |
236 | 233 |
setDescription(xml.getStringProperty("desc")); |
234 |
setSize(xml.getDoubleProperty("size")); |
|
235 |
setUnit(xml.getIntProperty("unit")); |
|
236 |
setReferenceSystem(xml.getIntProperty("referenceSystem")); |
|
237 | 237 |
layers = new IMarkerSymbol[xml.getChildrenCount()]; |
238 | 238 |
for (int i = 0; i < layers.length; i++) { |
239 | 239 |
layers[i] = (IMarkerSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(i), "layer" + i); |
... | ... | |
316 | 316 |
} |
317 | 317 |
|
318 | 318 |
@Override |
319 |
public void setUnit(int unitIndex) { |
|
319 |
public void setUnit(int unit) { |
|
320 |
super.setUnit(unit); |
|
320 | 321 |
for (int i = 0; i < layers.length; i++) { |
321 |
layers[i].setUnit(unitIndex);
|
|
322 |
layers[i].setUnit(unit); |
|
322 | 323 |
} |
323 | 324 |
} |
324 | 325 |
|
325 |
// public double computeCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
|
326 |
// double dpiScale = dpi/MapContext.getScreenDPI(); |
|
327 |
// int unit = getUnit(); |
|
328 |
// double sizeInPixel; |
|
329 |
// if (unit==-1) { |
|
330 |
// sizeInPixel = getSize(); |
|
331 |
// } else { |
|
332 |
// double dist1Pixel = viewPort.getDist1pixel()*MapContext.CHANGEM[viewPort.getMapUnits()]; |
|
333 |
// double lineWidth = getSize()*MapContext.CHANGEM[unit]; |
|
334 |
// sizeInPixel = lineWidth/dist1Pixel; |
|
335 |
// } |
|
336 |
// return new double[] { |
|
337 |
// getSize(), |
|
338 |
// (sizeInPixel*dpiScale) |
|
339 |
// }; |
|
340 |
// } |
|
341 |
|
|
326 |
@Override |
|
327 |
public void setReferenceSystem(int system) { |
|
328 |
super.setReferenceSystem(system); |
|
329 |
for (int i = 0; i < layers.length; i++) { |
|
330 |
layers[i].setReferenceSystem(system); |
|
331 |
} |
|
332 |
} |
|
342 | 333 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerLineSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.13 2007-09-17 09:33:47 jaume |
|
46 |
* Revision 1.14 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.13 2007/09/17 09:33:47 jaume |
|
47 | 50 |
* some multishapedsymbol bugs fixed |
48 | 51 |
* |
49 | 52 |
* Revision 1.12 2007/08/09 08:04:48 jvidal |
... | ... | |
120 | 123 |
ILineSymbol, IMultiLayerSymbol { |
121 | 124 |
private ILineSymbol[] layers = new ILineSymbol[0]; |
122 | 125 |
private ILineSymbol selectionSymbol; |
126 |
private double width; |
|
123 | 127 |
|
124 | 128 |
public Color getColor() { |
125 | 129 |
/* |
... | ... | |
138 | 142 |
} |
139 | 143 |
|
140 | 144 |
public double getLineWidth() { |
141 |
/* |
|
142 |
* will return the widest symbol's width |
|
143 |
*/ |
|
144 |
double width = Double.NEGATIVE_INFINITY; |
|
145 |
for (int i = 0; i < layers.length; i++) { |
|
146 |
width = Math.max(width, layers[i].getLineWidth()); |
|
147 |
} |
|
148 | 145 |
return width; |
149 | 146 |
} |
150 | 147 |
|
... | ... | |
171 | 168 |
* extract a factor scale that will be applied |
172 | 169 |
* to each layer. |
173 | 170 |
*/ |
174 |
double myWidth = getLineWidth(); |
|
175 |
double scaleFactor = width / myWidth; |
|
176 |
for (int i = 0; i < layers.length; i++) { |
|
177 |
layers[i].setLineWidth(layers[i].getLineWidth()*scaleFactor); |
|
171 |
if (width > 0) { |
|
172 |
double scaleFactor = width / getLineWidth(); |
|
173 |
this.width = width; |
|
174 |
for (int i = 0; i < layers.length; i++) { |
|
175 |
layers[i].setLineWidth(layers[i].getLineWidth()*scaleFactor); |
|
176 |
} |
|
178 | 177 |
} |
179 | 178 |
} |
180 | 179 |
|
... | ... | |
218 | 217 |
xml.putProperty("className", getClass().getName()); |
219 | 218 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
220 | 219 |
xml.putProperty("desc", getDescription()); |
220 |
xml.putProperty("lineWidth", getLineWidth()); |
|
221 |
xml.putProperty("unit", getUnit()); |
|
222 |
xml.putProperty("referenceSystem", getReferenceSystem()); |
|
221 | 223 |
for (int i = 0; i < layers.length; i++) { |
222 | 224 |
xml.addChild(layers[i].getXMLEntity()); |
223 | 225 |
} |
... | ... | |
235 | 237 |
public void setXMLEntity(XMLEntity xml) { |
236 | 238 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible")); |
237 | 239 |
setDescription(xml.getStringProperty("desc")); |
240 |
setLineWidth(xml.getDoubleProperty("lineWidth")); |
|
241 |
setUnit(xml.getIntProperty("unit")); |
|
242 |
setReferenceSystem(xml.getIntProperty("referenceSystem")); |
|
238 | 243 |
layers = new ILineSymbol[xml.getChildrenCount()]; |
239 | 244 |
for (int i = 0; i < layers.length; i++) { |
240 | 245 |
layers[i] = (ILineSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(i), "layer" + i); |
... | ... | |
355 | 360 |
layers[i].setUnit(unitIndex); |
356 | 361 |
} |
357 | 362 |
} |
358 |
|
|
363 |
|
|
364 |
|
|
359 | 365 |
// public double computeCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
360 | 366 |
// double dpiScale = dpi/MapContext.getScreenDPI(); |
361 | 367 |
// int unit = getUnit(); |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiShapeSymbol.java | ||
---|---|---|
168 | 168 |
if (marker!=null) { |
169 | 169 |
XMLEntity markerXML = marker.getXMLEntity(); |
170 | 170 |
markerXML.putProperty("id", "marker"); |
171 |
xml.addChild(marker.getXMLEntity());
|
|
171 |
xml.addChild(markerXML);
|
|
172 | 172 |
} |
173 | 173 |
|
174 | 174 |
if (line!=null) { |
175 |
XMLEntity markerXML = marker.getXMLEntity();
|
|
176 |
markerXML.putProperty("id", "line");
|
|
177 |
xml.addChild(marker.getXMLEntity());
|
|
175 |
XMLEntity lineXML = line.getXMLEntity();
|
|
176 |
lineXML.putProperty("id", "line");
|
|
177 |
xml.addChild(lineXML);
|
|
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
if (fill!=null) { |
181 |
XMLEntity markerXML = marker.getXMLEntity();
|
|
182 |
markerXML.putProperty("id", "fill");
|
|
183 |
xml.addChild(marker.getXMLEntity());
|
|
181 |
XMLEntity fillXML = fill.getXMLEntity();
|
|
182 |
fillXML.putProperty("id", "fill");
|
|
183 |
xml.addChild(fillXML);
|
|
184 | 184 |
} |
185 | 185 |
return xml; |
186 | 186 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/SymbologyFactory.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.9 2007-09-17 09:32:05 jaume |
|
46 |
* Revision 1.10 2007-09-17 14:16:11 jaume |
|
47 |
* multilayer symbols sizing bug fixed |
|
48 |
* |
|
49 |
* Revision 1.9 2007/09/17 09:32:05 jaume |
|
47 | 50 |
* view refresh frame rate now configurable |
48 | 51 |
* |
49 | 52 |
* Revision 1.8 2007/07/18 06:54:34 jaume |
... | ... | |
103 | 106 |
|
104 | 107 |
import org.apache.log4j.Logger; |
105 | 108 |
|
109 |
import com.iver.cit.gvsig.fmap.Messages; |
|
106 | 110 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
107 | 111 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
108 | 112 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
... | ... | |
198 | 202 |
|
199 | 203 |
Class clazz = null; |
200 | 204 |
IPersistance obj = null; |
201 |
|
|
205 |
String s = className; |
|
206 |
|
|
202 | 207 |
try { |
203 | 208 |
clazz = Class.forName(className); |
204 | 209 |
|
210 |
if (xml.contains("desc")) { |
|
211 |
s += " \"" + xml.getStringProperty("desc") +"\""; |
|
212 |
} |
|
205 | 213 |
// TODO remove the patch the day we deprecate FSymbol |
206 | 214 |
// begin patch |
207 | 215 |
if (clazz.equals(FSymbol.class)) |
... | ... | |
211 | 219 |
|
212 | 220 |
|
213 | 221 |
obj = (IPersistance) clazz.newInstance(); |
214 |
obj.setXMLEntity(xml); |
|
222 |
logger.info(Messages.getString("creating")+"....... "+s); |
|
223 |
try { |
|
224 |
obj.setXMLEntity(xml); |
|
225 |
} catch (NotExistInXMLEntity neiXML) { |
|
226 |
logger.error(Messages.getString("failed_creating_object")+": "+s); |
|
227 |
throw neiXML; |
|
228 |
} |
|
229 |
|
|
215 | 230 |
} |
216 | 231 |
|
217 | 232 |
} catch (InstantiationException e) { |
Also available in: Unified diff