Revision 25807 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/styles/SimpleLabelStyle.java
SimpleLabelStyle.java | ||
---|---|---|
226 | 226 |
} |
227 | 227 |
if (xml.contains("sizeW")) |
228 | 228 |
sz=new Dimension(xml.getIntProperty("sizeW"),xml.getIntProperty("sizeH")); |
229 |
} |
|
229 |
}
|
|
230 | 230 |
|
231 | 231 |
public Rectangle2D[] getTextBounds() { |
232 | 232 |
return (Rectangle2D[]) textFieldAreas.toArray(new Rectangle2D[textFieldAreas.size()]); |
... | ... | |
265 | 265 |
if(getBackgroundFileStyle() != null) |
266 | 266 |
getBackgroundFileStyle().drawOutline(g, r); |
267 | 267 |
|
268 |
|
|
269 | 268 |
final double[] xy = new double[2]; |
270 | 269 |
// draw the pointer |
271 | 270 |
{ |
... | ... | |
296 | 295 |
outline.setLineColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 100)); |
297 | 296 |
sym.setOutline(outline); |
298 | 297 |
for (int i = 0; i < textFieldAreas.size(); i++) { |
299 |
Rectangle2D textFieldArea = (Rectangle2D) textFieldAreas.get(i); |
|
300 |
xy[0] = textFieldArea.getX(); |
|
301 |
xy[1] = textFieldArea.getY(); |
|
298 |
//FIXME: Esto es un parche, habr?a que cambiar el API de los simbolos y/o estilos |
|
299 |
//pero mientras tanto |
|
300 |
if(getBackgroundFileStyle() == null){ |
|
301 |
Rectangle2D textFieldArea = (Rectangle2D) textFieldAreas.get(i); |
|
302 |
xy[0] = textFieldArea.getX(); |
|
303 |
xy[1] = textFieldArea.getY(); |
|
302 | 304 |
|
303 |
int x = (int) Math.round(((r.width) * xy[0])); |
|
304 |
int y = (int) Math.round((r.height) * xy[1]); |
|
305 |
int x = (int) Math.round(((r.width) * xy[0]));
|
|
306 |
int y = (int) Math.round((r.height) * xy[1]);
|
|
305 | 307 |
|
306 |
xy[0] = textFieldArea.getMaxX(); |
|
307 |
xy[1] = textFieldArea.getMaxY(); |
|
308 |
xy[0] = textFieldArea.getMaxX();
|
|
309 |
xy[1] = textFieldArea.getMaxY();
|
|
308 | 310 |
|
309 |
int width = (int) Math.round((r.width * xy[0]) -x); |
|
310 |
int height = (int) Math.round((r.height * xy[1]) - y) ; |
|
311 |
int width = (int) Math.round((r.width * xy[0]) -x);
|
|
312 |
int height = (int) Math.round((r.height * xy[1]) - y) ;
|
|
311 | 313 |
|
312 |
Rectangle aux = new Rectangle(x, y, width, height); |
|
313 |
FShape shp = new FPolygon2D(new GeneralPathX(aux)); |
|
314 |
sym.draw(g, null, shp, null); |
|
315 |
g.setColor(Color.BLACK); |
|
316 |
g.drawString(String.valueOf(i+1), x+5, y + 10); // start with 1 |
|
314 |
Rectangle aux = new Rectangle(x, y, width, height); |
|
315 |
FShape shp = new FPolygon2D(new GeneralPathX(aux)); |
|
316 |
sym.draw(g, null, shp, null); |
|
317 |
g.setColor(Color.BLACK); |
|
318 |
g.drawString(String.valueOf(i+1), x+5, y + 10); // start with 1 |
|
319 |
} else { |
|
320 |
double xOffset = 0; |
|
321 |
double yOffset = 0; |
|
322 |
double scale = 1; |
|
323 |
Dimension backgroundBounds = getSize(); |
|
324 |
if (backgroundBounds.getWidth()>backgroundBounds.getHeight()) { |
|
325 |
scale = r.getWidth()/backgroundBounds.getWidth(); |
|
326 |
yOffset = 0.5*(r.getHeight() - backgroundBounds.getHeight()*scale); |
|
327 |
} else { |
|
328 |
scale = r.getHeight()/backgroundBounds.getHeight(); |
|
329 |
xOffset = 0.5*(r.getWidth() - backgroundBounds.getWidth()*scale); |
|
330 |
} |
|
331 |
|
|
332 |
Rectangle2D textFieldArea = (Rectangle2D) textFieldAreas.get(i); |
|
333 |
xy[0] = textFieldArea.getX(); |
|
334 |
xy[1] = textFieldArea.getY(); |
|
335 |
|
|
336 |
int x = (int) Math.round(xy[0]*backgroundBounds.getWidth()*scale+xOffset); |
|
337 |
int y = (int) Math.round(xy[1]*backgroundBounds.getHeight()*scale+yOffset); |
|
338 |
|
|
339 |
xy[0] = textFieldArea.getMaxX(); |
|
340 |
xy[1] = textFieldArea.getMaxY(); |
|
341 |
|
|
342 |
int width = (int) Math.round((xy[0]*backgroundBounds.getWidth()*scale+xOffset)-x); |
|
343 |
int height = (int) Math.round((xy[1]*backgroundBounds.getHeight()*scale+yOffset)-y); |
|
344 |
|
|
345 |
Rectangle aux = new Rectangle(x, y, width, height); |
|
346 |
FShape shp = new FPolygon2D(new GeneralPathX(aux)); |
|
347 |
sym.draw(g, null, shp, null); |
|
348 |
g.setColor(Color.BLACK); |
|
349 |
g.drawString(String.valueOf(i+1), x+5, y + 10); // start with 1 |
|
350 |
|
|
351 |
} |
|
317 | 352 |
} |
318 | 353 |
} |
319 | 354 |
} |
Also available in: Unified diff