Revision 22953
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/styles/SimpleLabelStyle.java | ||
---|---|---|
186 | 186 |
xml.putProperty("minYArray", miny); |
187 | 187 |
xml.putProperty("widthArray", widths); |
188 | 188 |
xml.putProperty("heightArray", heights); |
189 |
XMLEntity bgXML = background.getXMLEntity(); |
|
190 |
bgXML.putProperty("id", "LabelStyle"); |
|
191 |
xml.addChild(bgXML); |
|
189 |
if(background != null){ |
|
190 |
XMLEntity bgXML = background.getXMLEntity(); |
|
191 |
bgXML.putProperty("id", "LabelStyle"); |
|
192 |
xml.addChild(bgXML); |
|
193 |
} |
|
192 | 194 |
return xml; |
193 | 195 |
} |
194 | 196 |
|
... | ... | |
221 | 223 |
} |
222 | 224 |
|
223 | 225 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) throws SymbolDrawingException { |
224 |
background.drawInsideRectangle(g, r); |
|
226 |
if(background != null) |
|
227 |
background.drawInsideRectangle(g, r); |
|
225 | 228 |
} |
226 | 229 |
|
227 | 230 |
|
... | ... | |
246 | 249 |
this.markerPoint = p; |
247 | 250 |
} |
248 | 251 |
|
249 |
private void relativeToAbsolute(double[] xy, Rectangle r, Dimension labelSz, double ratioLabel, double ratioViewPort) { |
|
250 |
double x, y; |
|
251 | 252 |
|
252 |
x = (r.width * xy[0]); |
|
253 |
y = (r.height * xy[1]); |
|
253 |
public void drawOutline(Graphics2D g, Rectangle r) throws SymbolDrawingException { |
|
254 |
if(background != null) |
|
255 |
background.drawOutline(g, r); |
|
254 | 256 |
|
255 |
xy[0] = x; |
|
256 |
xy[1] = y; |
|
257 | 257 |
|
258 |
} |
|
259 |
|
|
260 |
public void drawOutline(Graphics2D g, Rectangle r) throws SymbolDrawingException { |
|
261 |
background.drawOutline(g, r); |
|
262 |
Dimension labelSz = getSize(); |
|
263 |
final double ratioLabel = labelSz.getWidth()/labelSz.getHeight(); |
|
264 |
final double ratioViewPort = r.getWidth() / r.getHeight(); |
|
265 | 258 |
final double[] xy = new double[2]; |
266 | 259 |
// draw the pointer |
267 | 260 |
{ |
268 | 261 |
xy[0] = markerPoint.getX(); |
269 | 262 |
xy[1] = markerPoint.getY(); |
270 |
relativeToAbsolute(xy, r, labelSz, ratioLabel, ratioViewPort); |
|
271 |
int x = (int) Math.round(xy[0]); |
|
272 |
int y = (int) Math.round(xy[1]); |
|
273 | 263 |
|
264 |
int x = (int) Math.round(r.width * xy[0]); |
|
265 |
int y = (int) Math.round(r.height * xy[1]); |
|
266 |
|
|
274 | 267 |
int size = 7; |
275 | 268 |
g.setColor(Color.ORANGE.darker()); |
276 | 269 |
g.fillOval(x, y, size, size); |
... | ... | |
295 | 288 |
Rectangle2D textFieldArea = (Rectangle2D) textFieldAreas.get(i); |
296 | 289 |
xy[0] = textFieldArea.getX(); |
297 | 290 |
xy[1] = textFieldArea.getY(); |
298 |
relativeToAbsolute(xy, r, labelSz, ratioLabel, ratioViewPort); |
|
299 |
int x = (int) Math.round(xy[0]); |
|
300 |
int y = (int) Math.round(xy[1]); |
|
301 | 291 |
|
292 |
int x = (int) Math.round(((r.width) * xy[0])); |
|
293 |
int y = (int) Math.round((r.height) * xy[1]); |
|
294 |
|
|
302 | 295 |
xy[0] = textFieldArea.getMaxX(); |
303 | 296 |
xy[1] = textFieldArea.getMaxY(); |
304 |
relativeToAbsolute(xy, r, labelSz, ratioLabel, ratioViewPort); |
|
305 |
int width = (int) Math.round(xy[0]) -x; |
|
306 |
int height = (int) Math.round(xy[1] - y) ; |
|
307 | 297 |
|
298 |
int width = (int) Math.round((r.width * xy[0]) -x); |
|
299 |
int height = (int) Math.round((r.height * xy[1]) - y) ; |
|
300 |
|
|
308 | 301 |
Rectangle aux = new Rectangle(x, y, width, height); |
309 | 302 |
FShape shp = new FPolygon2D(new GeneralPathX(aux)); |
310 | 303 |
sym.draw(g, null, shp, null); |
... | ... | |
329 | 322 |
public void setSize(double width, double height) { |
330 | 323 |
sz = new Dimension( (int) Math.round(width), (int) Math.round(height)); |
331 | 324 |
} |
325 |
|
|
326 |
public BackgroundFileStyle getBackground() { |
|
327 |
return background; |
|
328 |
} |
|
329 |
|
|
330 |
public void setBackground(BackgroundFileStyle background) { |
|
331 |
this.background = background; |
|
332 |
} |
|
332 | 333 |
} |
Also available in: Unified diff