Revision 11486 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AttrInTableLabeling.java
AttrInTableLabeling.java | ||
---|---|---|
15 | 15 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
16 | 16 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
17 | 17 |
import com.iver.cit.gvsig.fmap.ViewPort; |
18 |
import com.iver.cit.gvsig.fmap.core.CartographicSupport; |
|
18 | 19 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
19 | 20 |
import com.iver.cit.gvsig.fmap.core.FShape; |
20 | 21 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
... | ... | |
35 | 36 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
36 | 37 |
* |
37 | 38 |
*/ |
38 |
public class AttrInTableLabeling implements ILabelingStrategy { |
|
39 |
public class AttrInTableLabeling implements ILabelingStrategy, CartographicSupport {
|
|
39 | 40 |
public static final double MIN_TEXT_SIZE = 3; |
40 | 41 |
private ILabelingMethod method = new DefaultLabelingMethod(); |
41 | 42 |
private IZoomConstraints zoom; |
... | ... | |
43 | 44 |
private int idHeightField; |
44 | 45 |
private int idRotationField; |
45 | 46 |
private FLyrVect layer; |
46 |
private double unitFactor = 1D; |
|
47 |
// private double unitFactor = 1D;
|
|
47 | 48 |
private double fixedSize; |
49 |
private int unit; |
|
48 | 50 |
private boolean useFixedSize; |
49 | 51 |
|
50 | 52 |
public ILabelingMethod getLabelingMethod() { |
... | ... | |
76 | 78 |
double scale = viewPort.getScale(); |
77 | 79 |
double fontScaleFactor = FConstant.FONT_HEIGHT_SCALE_FACTOR; |
78 | 80 |
|
79 |
if (unitFactor > 0) { |
|
80 |
// distance units |
|
81 |
fontScaleFactor *= Math.abs( |
|
82 |
viewPort.getAffineTransform().getScaleY()*unitFactor |
|
83 |
); |
|
84 |
} |
|
85 |
|
|
86 | 81 |
LabelClass lClass = method.getDefaultLabelClass(); |
87 | 82 |
SimpleTextSymbol sym = (SimpleTextSymbol) lClass.getLabelSymbol(); |
88 | 83 |
if (zoom==null || |
... | ... | |
120 | 115 |
size = sym.getFont().getSize(); |
121 | 116 |
} |
122 | 117 |
|
118 |
size = CartographicSupportToolkit. |
|
119 |
toScreenUnitYAxis(size, |
|
120 |
unit, |
|
121 |
viewPort |
|
122 |
); |
|
123 |
|
|
123 | 124 |
if (size <= MIN_TEXT_SIZE) { |
124 | 125 |
// label is too small to be readable, will be skipped |
125 | 126 |
// this speeds up the rendering in wider zooms |
... | ... | |
189 | 190 |
Logger.getAnonymousLogger().log(Level.SEVERE, "Acessing RotationField field.\n"+e.getMessage()); |
190 | 191 |
} |
191 | 192 |
|
192 |
xml.putProperty("UnitFactor", unitFactor);
|
|
193 |
xml.putProperty("Unit", unit);
|
|
193 | 194 |
return xml; |
194 | 195 |
|
195 | 196 |
} |
... | ... | |
247 | 248 |
setRotationField("RotationField"); |
248 | 249 |
|
249 | 250 |
if (xml.contains("UnitFactor")) |
250 |
setUnitFactor(xml.getDoubleProperty("UnitFactor"));
|
|
251 |
setUnit(xml.getIntProperty("Unit"));
|
|
251 | 252 |
} |
252 | 253 |
|
253 | 254 |
public void setTextField(String textFieldName) { |
... | ... | |
283 | 284 |
} |
284 | 285 |
} |
285 | 286 |
|
286 |
public void setUnitFactor(double unitFactor) { |
|
287 |
this.unitFactor = unitFactor; |
|
288 |
} |
|
289 | 287 |
|
290 |
public double getUnitFactor() { |
|
291 |
return unitFactor; |
|
292 |
} |
|
293 |
|
|
294 | 288 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, PrintRequestAttributeSet properties) throws ReadDriverException { |
295 | 289 |
draw(null, g, viewPort, cancel); |
296 | 290 |
} |
... | ... | |
310 | 304 |
public void setFixedSize(double fixedSize) { |
311 | 305 |
this.fixedSize = fixedSize; |
312 | 306 |
} |
307 |
|
|
308 |
public void setUnit(int unitIndex) { |
|
309 |
unit = unitIndex; |
|
310 |
|
|
311 |
} |
|
312 |
|
|
313 |
public int getUnit() { |
|
314 |
return unit; |
|
315 |
} |
|
313 | 316 |
} |
Also available in: Unified diff