Revision 40983 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/styling/AttrInTableLabelingStrategy.java
AttrInTableLabelingStrategy.java | ||
---|---|---|
138 | 138 |
|
139 | 139 |
public void setZoomConstraints(IZoomConstraints constraints) { |
140 | 140 |
this.zoom = constraints; |
141 |
} |
|
141 |
} |
|
142 |
|
|
143 |
private double getScale(ViewPort vp, PrintAttributes patts) |
|
144 |
throws ReadException { |
|
145 |
|
|
146 |
double dpi = 0; |
|
147 |
if (patts != null) { |
|
148 |
int len = PrintAttributes.PRINT_QUALITY_DPI.length; |
|
149 |
int priq = patts.getPrintQuality(); |
|
150 |
if (priq < 0 || priq >= len) { |
|
151 |
dpi = MapContext.getScreenDPI(); |
|
152 |
} else { |
|
153 |
dpi = PrintAttributes.PRINT_QUALITY_DPI[priq]; |
|
154 |
} |
|
155 |
} else { |
|
156 |
dpi = MapContext.getScreenDPI(); |
|
157 |
} |
|
158 |
|
|
159 |
// ============== We have dpi now ==================== |
|
160 |
|
|
161 |
IProjection proj = vp.getProjection(); |
|
162 |
|
|
163 |
if (vp.getImageSize() == null || vp.getAdjustedEnvelope() == null) { |
|
164 |
throw new ReadException("", |
|
165 |
new Exception("Viewport does not have image size or envelope")); |
|
166 |
} |
|
167 |
|
|
168 |
double[] trans2Meter = MapContext.getDistanceTrans2Meter(); |
|
169 |
if (proj == null) { |
|
170 |
double wmeters = ((vp.getImageSize().width / dpi) * 0.0254); |
|
171 |
return (long) ( |
|
172 |
(trans2Meter[vp.getMapUnits()] * vp.getAdjustedEnvelope().getLength(0)) |
|
173 |
/ wmeters); |
|
174 |
} else { |
|
175 |
return Math.round(proj.getScale( |
|
176 |
vp.getAdjustedEnvelope().getMinimum(0) |
|
177 |
* trans2Meter[vp.getMapUnits()], |
|
178 |
vp.getAdjustedEnvelope().getMaximum(0) |
|
179 |
* trans2Meter[vp.getMapUnits()], |
|
180 |
vp.getImageSize().width, |
|
181 |
dpi)); |
|
182 |
} |
|
183 |
|
|
184 |
} |
|
142 | 185 |
|
143 | 186 |
private void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
144 | 187 |
Cancellable cancel, PrintAttributes props) throws ReadException { |
145 | 188 |
|
146 |
double scale = viewPort.getScale();
|
|
147 |
|
|
189 |
double scale = getScale(viewPort, props);
|
|
190 |
|
|
148 | 191 |
SimpleTextSymbol sym = new SimpleTextSymbol(); |
149 |
|
|
150 | 192 |
sym.setFont(getFont()); |
151 |
|
|
152 | 193 |
sym.setUnit(unit); |
153 | 194 |
sym.setReferenceSystem(referenceSystem); |
154 | 195 |
if (zoom==null || |
Also available in: Unified diff