root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / styling / labeling / LabelClass.java @ 31296
History | View | Annotate | Download (17.5 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: LabelClass.java 13953 2007-09-21 12:26:04Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.14 2007-09-21 12:26:04 jaume
|
47 |
* cancellation support extended down to the IGeometry and ISymbol level
|
48 |
*
|
49 |
* Revision 1.13 2007/09/17 14:16:11 jaume
|
50 |
* multilayer symbols sizing bug fixed
|
51 |
*
|
52 |
* Revision 1.12 2007/08/22 09:48:13 jvidal
|
53 |
* javadoc
|
54 |
*
|
55 |
* Revision 1.11 2007/05/09 11:04:58 jaume
|
56 |
* refactored legend hierarchy
|
57 |
*
|
58 |
* Revision 1.10 2007/05/08 08:47:40 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.9 2007/04/26 11:41:00 jaume
|
62 |
* attempting to let defining size in world units
|
63 |
*
|
64 |
* Revision 1.8 2007/04/18 15:35:11 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.7 2007/04/12 14:28:43 jaume
|
68 |
* basic labeling support for lines
|
69 |
*
|
70 |
* Revision 1.6 2007/04/11 16:01:08 jaume
|
71 |
* maybe a label placer refactor
|
72 |
*
|
73 |
* Revision 1.5 2007/04/10 16:34:01 jaume
|
74 |
* towards a styled labeling
|
75 |
*
|
76 |
* Revision 1.4 2007/04/05 16:07:14 jaume
|
77 |
* Styled labeling stuff
|
78 |
*
|
79 |
* Revision 1.3 2007/04/02 16:34:56 jaume
|
80 |
* Styled labeling (start commiting)
|
81 |
*
|
82 |
* Revision 1.2 2007/03/09 08:33:43 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.1.2.6 2007/02/15 16:23:44 jaume
|
86 |
* *** empty log message ***
|
87 |
*
|
88 |
* Revision 1.1.2.5 2007/02/09 07:47:05 jaume
|
89 |
* Isymbol moved
|
90 |
*
|
91 |
* Revision 1.1.2.4 2007/02/02 16:21:24 jaume
|
92 |
* start commiting labeling stuff
|
93 |
*
|
94 |
* Revision 1.1.2.3 2007/02/01 17:46:49 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume
|
98 |
* *** empty log message ***
|
99 |
*
|
100 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume
|
101 |
* start commiting labeling stuff
|
102 |
*
|
103 |
*
|
104 |
*/
|
105 |
package com.iver.cit.gvsig.fmap.rendering.styling.labeling; |
106 |
|
107 |
import java.awt.Color; |
108 |
import java.awt.Dimension; |
109 |
import java.awt.Graphics2D; |
110 |
import java.awt.Rectangle; |
111 |
import java.awt.Shape; |
112 |
import java.awt.geom.AffineTransform; |
113 |
import java.awt.geom.Point2D; |
114 |
import java.awt.geom.Rectangle2D; |
115 |
|
116 |
import org.apache.batik.ext.awt.geom.PathLength; |
117 |
|
118 |
import com.iver.cit.gvsig.fmap.ViewPort; |
119 |
import com.iver.cit.gvsig.fmap.core.CartographicSupport; |
120 |
import com.iver.cit.gvsig.fmap.core.CartographicSupportToolkit; |
121 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
122 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
123 |
import com.iver.cit.gvsig.fmap.core.FShape; |
124 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
125 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
126 |
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
127 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
128 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
129 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
130 |
import com.iver.utiles.IPersistence; |
131 |
import com.iver.utiles.XMLEntity; |
132 |
|
133 |
/**
|
134 |
*
|
135 |
* LabelClass is the model of the label in the new simbology of gvSIG. In this
|
136 |
* class is contained its definition, the expresion that defines the text which
|
137 |
* is going to be showed, if it will be visible or not, the text symbol that is
|
138 |
* going to paint the label and the style for its background.
|
139 |
*
|
140 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
141 |
*/
|
142 |
public class LabelClass implements IPersistence, CartographicSupport { |
143 |
private String name; |
144 |
private ITextSymbol textSymbol;
|
145 |
private String[] labelExpressions; |
146 |
private boolean isVisible = true; |
147 |
private ILabelStyle labelStyle;
|
148 |
private String[] texts; |
149 |
private int priority; |
150 |
private double scale = 1; |
151 |
private String sqlQuery; |
152 |
private boolean useSqlQuery = false; |
153 |
|
154 |
|
155 |
/**
|
156 |
* Returns true if the label will be showed in the map
|
157 |
*
|
158 |
* @return isVisible boolean
|
159 |
*/
|
160 |
public boolean isVisible() { |
161 |
return isVisible;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Sets the visibility of the label in the map.
|
166 |
*
|
167 |
* @param isVisible boolean
|
168 |
*/
|
169 |
public void setVisible(boolean isVisible) { |
170 |
this.isVisible = isVisible;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Returns the expression that defines the text which will be showed in
|
175 |
* the label
|
176 |
*
|
177 |
* @return labelExpressions String[]
|
178 |
*/
|
179 |
public String[] getLabelExpressions() { |
180 |
return labelExpressions;
|
181 |
} |
182 |
/**
|
183 |
* Returns the expression that defines the text which will be showed in
|
184 |
* the label ready to be used for the label parser
|
185 |
*
|
186 |
* @return labelExpression String
|
187 |
*/
|
188 |
public String getStringLabelExpression(){ |
189 |
String expr = ""; |
190 |
|
191 |
if(labelExpressions != null && labelExpressions.length > 0){ |
192 |
|
193 |
for (int i = 0; i < labelExpressions.length-1; i++) { |
194 |
expr += (String) labelExpressions[i] + ":";//EOFIELD |
195 |
} |
196 |
expr += labelExpressions[labelExpressions.length - 1] +";";//EOEXPRESSION |
197 |
|
198 |
} |
199 |
else expr = ";"; |
200 |
return expr;
|
201 |
} |
202 |
|
203 |
|
204 |
/**
|
205 |
* Stablishes the expresion that, when it is evaluated, returns the text
|
206 |
* which will be showed by the label.
|
207 |
*
|
208 |
* @param labelExpression String
|
209 |
*/
|
210 |
public void setLabelExpressions(String[] labelExpressions) { |
211 |
this.labelExpressions = labelExpressions;
|
212 |
} |
213 |
|
214 |
/**
|
215 |
* Returns the text symbol that is being used for the text(the font,
|
216 |
* size,style,aligment)
|
217 |
*
|
218 |
* @return label ITextSymbol
|
219 |
*/
|
220 |
public ITextSymbol getTextSymbol() {
|
221 |
if (textSymbol == null) { |
222 |
textSymbol = new SimpleTextSymbol();
|
223 |
} |
224 |
return textSymbol;
|
225 |
} |
226 |
|
227 |
private Dimension getSize() { |
228 |
if (labelStyle == null) { |
229 |
if (texts!=null && texts.length >0) { |
230 |
String t = ""; |
231 |
for (int i = 0; i < texts.length; i++) { |
232 |
t += texts[i]; |
233 |
} |
234 |
getTextSymbol().setText(t); |
235 |
} |
236 |
|
237 |
Rectangle bounds = getTextSymbol().getBounds();
|
238 |
// bounds.setLocation(
|
239 |
// (int) Math.round(bounds.getX()),
|
240 |
// (int) Math.round(bounds.getY()+bounds.getHeight()));
|
241 |
return new Dimension(bounds.width, bounds.height); |
242 |
} else {
|
243 |
labelStyle.setTextFields(texts); |
244 |
return labelStyle.getSize();
|
245 |
} |
246 |
} |
247 |
/**
|
248 |
* Stablishes the text symbol that is going to be used for the text(the
|
249 |
* font,size,style,aligment)
|
250 |
*
|
251 |
* @param textSymbol ITextSymbol
|
252 |
*/
|
253 |
public void setTextSymbol(ITextSymbol textSymbol) { |
254 |
this.textSymbol = textSymbol;
|
255 |
if (textSymbol == null) { |
256 |
this.textSymbol = new SimpleTextSymbol(); |
257 |
} |
258 |
setReferenceSystem(referenceSystem); |
259 |
setUnit(unit); |
260 |
} |
261 |
|
262 |
/**
|
263 |
* Stablishes the style for the label.
|
264 |
*
|
265 |
* @param labelStyle ILabelStyle
|
266 |
*/
|
267 |
public void setLabelStyle(ILabelStyle labelStyle) { |
268 |
this.labelStyle = labelStyle;
|
269 |
} |
270 |
|
271 |
/**
|
272 |
* Returns the style of the label
|
273 |
*
|
274 |
*/
|
275 |
public ILabelStyle getLabelStyle() {
|
276 |
return this.labelStyle; |
277 |
} |
278 |
|
279 |
/**
|
280 |
* Returns the name of the label
|
281 |
*
|
282 |
*/
|
283 |
public String getName() { |
284 |
return name;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* Stablishes the name of the label
|
289 |
* @param name
|
290 |
*/
|
291 |
public void setName(String name) { |
292 |
this.name = name;
|
293 |
} |
294 |
|
295 |
public String toString() { |
296 |
// for debugging
|
297 |
// return name+"{label expression="+labelExpression+", visible="+isVisible+", priority="+priority+"}";
|
298 |
return getName();
|
299 |
} |
300 |
|
301 |
/**
|
302 |
* Sets the text for the label
|
303 |
*
|
304 |
* @param texts String[]
|
305 |
*/
|
306 |
public void setTexts(String[] texts) { |
307 |
this.texts = texts;
|
308 |
|
309 |
} |
310 |
|
311 |
/**
|
312 |
* Return the text for the label
|
313 |
*
|
314 |
* @param texts String[]
|
315 |
*/
|
316 |
public String[] getTexts() { |
317 |
return this.texts; |
318 |
} |
319 |
|
320 |
|
321 |
/**
|
322 |
* <p>
|
323 |
* LabelLocationMetrics, contains the anchor point, rotation, and some
|
324 |
* other geometric calculations computed by the PlacementManager.
|
325 |
* </p>
|
326 |
*
|
327 |
* <p>
|
328 |
* The shp argument is passed as an accessory for subclasses of this
|
329 |
* class in case they need futher geometric calculations
|
330 |
* </p>
|
331 |
* @param graphics, graphics to use to paint the label.
|
332 |
* @param llm, concrete settings of the placement of this layer
|
333 |
* @param shp, the Shape over whose the label is painted
|
334 |
*/
|
335 |
public void draw(Graphics2D graphics, LabelLocationMetrics llm, FShape shp) { |
336 |
if (scale == 0) |
337 |
return;
|
338 |
if (!isVisible)
|
339 |
return;
|
340 |
Dimension size = getSize();
|
341 |
int width = (int) Math.round(size.getWidth()*scale); |
342 |
if (width < 1) |
343 |
return;
|
344 |
|
345 |
int height = (int) Math.round(size.getHeight()*scale); |
346 |
if (height < 1) |
347 |
return;
|
348 |
|
349 |
Rectangle r = new Rectangle(0,0, width, height); |
350 |
FPoint2D anchor = new FPoint2D(llm.getAnchor());
|
351 |
double xAnchor = anchor.getX();
|
352 |
double yAnchor = anchor.getY();
|
353 |
double theta = llm.getRotation();
|
354 |
|
355 |
if (theta < 0) { |
356 |
theta = theta + (2 * Math.PI); |
357 |
} |
358 |
|
359 |
if ((theta > (Math.PI / 2)) && |
360 |
(theta < ((3 * Math.PI) / 2))) { |
361 |
theta = theta - (float) Math.PI; |
362 |
} |
363 |
|
364 |
|
365 |
// PathLength pathLen = new PathLength(shp);
|
366 |
//
|
367 |
// // if (pathLen.lengthOfPath() < width / mT.getScaleX()) return;
|
368 |
// float midDistance = pathLen.lengthOfPath() / 2;
|
369 |
// pAux = pathLen.pointAtLength(midDistance);
|
370 |
// angle = pathLen.angleAtLength(midDistance);
|
371 |
|
372 |
// if (angle < 0) {
|
373 |
// angle = angle + (float) (2 * Math.PI);
|
374 |
// }
|
375 |
//
|
376 |
// if ((angle > (Math.PI / 2)) &&
|
377 |
// (angle < ((3 * Math.PI) / 2))) {
|
378 |
// angle = angle - (float) Math.PI;
|
379 |
// }
|
380 |
//
|
381 |
// theLabel.setRotation(Math.toDegrees(angle));
|
382 |
|
383 |
|
384 |
float fontSizeBefore = textSymbol.getFont().getSize2D();
|
385 |
textSymbol.setFontSize(fontSizeBefore*scale); |
386 |
graphics.translate(xAnchor, yAnchor); |
387 |
graphics.rotate(theta); |
388 |
try {
|
389 |
drawInsideRectangle(graphics, r); |
390 |
} catch (SymbolDrawingException e) {
|
391 |
// TODO Auto-generated catch block
|
392 |
e.printStackTrace(); |
393 |
} |
394 |
graphics.rotate(-theta); |
395 |
graphics.translate(-xAnchor, -yAnchor); |
396 |
textSymbol.setFontSize(fontSizeBefore); |
397 |
} |
398 |
|
399 |
|
400 |
private void relativeToAbsolute(double[] xy, Rectangle r, Dimension labelSz, double ratioLabel, double ratioViewPort) { |
401 |
int x;
|
402 |
int y;
|
403 |
if (ratioViewPort > ratioLabel) {
|
404 |
// size is defined by the viewport height
|
405 |
y = (int) (r.height*xy[1]); |
406 |
x = (int) ((0.5*r.width) - (0.5-xy[0])*(ratioLabel*r.height)); |
407 |
} else {
|
408 |
// size is defined by the viewport width
|
409 |
x = (int) (r.width * xy[0]); |
410 |
y = (int) ((0.5 * r.height) - (0.5-xy[1])*(r.width/ratioLabel)); |
411 |
} |
412 |
xy[0] = x;
|
413 |
xy[1] = y;
|
414 |
} |
415 |
|
416 |
/**
|
417 |
* Useful to render a Label with size inside little rectangles.
|
418 |
*
|
419 |
* @param graphics Graphics2D
|
420 |
* @param bounds Rectangle
|
421 |
* @throws SymbolDrawingException
|
422 |
*/
|
423 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds) throws SymbolDrawingException { |
424 |
if (labelStyle != null) { |
425 |
labelStyle.drawInsideRectangle(graphics, bounds); |
426 |
Rectangle2D[] textBounds = labelStyle.getTextBounds(); |
427 |
Dimension labelSz = getSize();
|
428 |
final double ratioLabel = labelSz.getWidth()/labelSz.getHeight(); |
429 |
final double ratioViewPort = bounds.getWidth() / bounds.getHeight(); |
430 |
final double[] xy = new double[2]; |
431 |
|
432 |
|
433 |
// draw the text fields
|
434 |
if (textBounds.length > 0 && texts!=null) { |
435 |
for (int i = 0; i < textBounds.length && i < texts.length; i++) { |
436 |
getTextSymbol().setText(texts[i]); |
437 |
Rectangle2D textFieldArea = textBounds[i];
|
438 |
xy[0] = textFieldArea.getX();
|
439 |
xy[1] = textFieldArea.getY();
|
440 |
relativeToAbsolute(xy, bounds, labelSz, ratioLabel, ratioViewPort); |
441 |
int x = (int) Math.round(xy[0]); |
442 |
int y = (int) Math.round(xy[1]); |
443 |
|
444 |
xy[0] = textFieldArea.getMaxX();
|
445 |
xy[1] = textFieldArea.getMaxY();
|
446 |
relativeToAbsolute(xy, bounds, labelSz, ratioLabel, ratioViewPort); |
447 |
int width = (int) Math.round(xy[0]) -x; |
448 |
int height = (int) Math.round(xy[1] - y) ; |
449 |
|
450 |
Rectangle textRect = new Rectangle(x, y, width, height); |
451 |
Shape oldClip = graphics.getClip();
|
452 |
graphics.setClip(textRect); |
453 |
getTextSymbol().drawInsideRectangle(graphics, null, textRect, null); |
454 |
graphics.setClip(oldClip); |
455 |
} |
456 |
} |
457 |
} else {
|
458 |
|
459 |
if (texts != null && texts.length>0) |
460 |
getTextSymbol().setText(texts[0]);
|
461 |
getTextSymbol().drawInsideRectangle(graphics, null, bounds, null); |
462 |
} |
463 |
} |
464 |
|
465 |
public int getPriority() { |
466 |
return priority;
|
467 |
} |
468 |
|
469 |
public void setPriority(int priority) { |
470 |
this.priority = priority;
|
471 |
} |
472 |
|
473 |
public FShape getShape(LabelLocationMetrics llm) {
|
474 |
if (llm==null) |
475 |
return null; |
476 |
Point2D anchor = llm.getAnchor();
|
477 |
FPoint2D p = new FPoint2D(anchor);
|
478 |
double theta = llm.getRotation();
|
479 |
|
480 |
// 2. calculate the container shape
|
481 |
FShape returnedValue; |
482 |
Rectangle bounds = getBounds();
|
483 |
|
484 |
AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY()); |
485 |
at.concatenate(AffineTransform.getRotateInstance(theta));
|
486 |
|
487 |
returnedValue = new FPolygon2D(new GeneralPathX(bounds)); |
488 |
|
489 |
returnedValue.transform(at); |
490 |
return returnedValue;
|
491 |
} |
492 |
|
493 |
|
494 |
public String getClassName() { |
495 |
return getClass().getName();
|
496 |
} |
497 |
|
498 |
public XMLEntity getXMLEntity() {
|
499 |
XMLEntity xml = new XMLEntity();
|
500 |
xml.putProperty("className", getClassName());
|
501 |
xml.putProperty("isVisible", isVisible);
|
502 |
xml.putProperty("name", name);
|
503 |
if(labelExpressions != null) |
504 |
xml.putProperty("labelExpressions", labelExpressions);
|
505 |
xml.putProperty("unit", getUnit());
|
506 |
xml.putProperty("referenceSystem", getReferenceSystem());
|
507 |
xml.putProperty("priority", getPriority());
|
508 |
xml.putProperty("useSqlQuery",isUseSqlQuery());
|
509 |
|
510 |
if (texts != null) { |
511 |
xml.putProperty("texts", texts);
|
512 |
} |
513 |
if (sqlQuery != null) { |
514 |
xml.putProperty("sqlQuery", getSQLQuery());
|
515 |
} |
516 |
|
517 |
if (labelStyle!=null) { |
518 |
XMLEntity labelStyleXML = labelStyle.getXMLEntity(); |
519 |
labelStyleXML.putProperty("id", "labelStyle"); |
520 |
xml.addChild(labelStyleXML); |
521 |
} |
522 |
|
523 |
XMLEntity textSymXML = getTextSymbol().getXMLEntity(); |
524 |
textSymXML.putProperty("id", "TextSymbol"); |
525 |
xml.addChild(textSymXML); |
526 |
|
527 |
return xml;
|
528 |
} |
529 |
|
530 |
public void setXMLEntity(XMLEntity xml) { |
531 |
isVisible = xml.getBooleanProperty("isVisible");
|
532 |
name = xml.getStringProperty("name");
|
533 |
if(xml.contains("labelExpressions")) |
534 |
labelExpressions = xml.getStringArrayProperty("labelExpressions");
|
535 |
setUnit(xml.getIntProperty("unit"));
|
536 |
setReferenceSystem(xml.getIntProperty("referenceSystem"));
|
537 |
setTextSymbol( |
538 |
(ITextSymbol) SymbologyFactory. |
539 |
createSymbolFromXML(xml.firstChild("id", "TextSymbol"), null)); |
540 |
|
541 |
if(xml.contains("useSqlQuery")){ |
542 |
setUseSqlQuery(xml.getBooleanProperty("useSqlQuery"));
|
543 |
} |
544 |
|
545 |
if (xml.contains("texts")) { |
546 |
setTexts(xml.getStringArrayProperty("texts"));
|
547 |
} |
548 |
if (xml.contains("sqlQuery")) { |
549 |
setSQLQuery(xml.getStringProperty("sqlQuery"));
|
550 |
} |
551 |
|
552 |
if (xml.contains("priority")) { |
553 |
setPriority(xml.getIntProperty("priority"));
|
554 |
} |
555 |
// labelStyle
|
556 |
XMLEntity aux = xml.firstChild("id", "labelStyle"); |
557 |
if (aux!= null) { |
558 |
setLabelStyle((ILabelStyle) SymbologyFactory. |
559 |
createStyleFromXML(aux, "labelStyle"));
|
560 |
} |
561 |
} |
562 |
|
563 |
private int unit = CartographicSupportToolkit.DefaultMeasureUnit; |
564 |
private int referenceSystem = CartographicSupportToolkit.DefaultReferenceSystem; |
565 |
|
566 |
public double getCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
567 |
Dimension sz = getSize();
|
568 |
double width = sz.getWidth();
|
569 |
double height = sz.getHeight();
|
570 |
return CartographicSupportToolkit.
|
571 |
getCartographicLength(this,
|
572 |
Math.max(width, height),
|
573 |
viewPort, |
574 |
dpi); |
575 |
} |
576 |
|
577 |
public int getReferenceSystem() { |
578 |
return referenceSystem;
|
579 |
} |
580 |
|
581 |
public int getUnit() { |
582 |
return unit;
|
583 |
} |
584 |
|
585 |
public void setCartographicSize(double cartographicSize, FShape shp) { |
586 |
Dimension sz = getSize();
|
587 |
double width = sz.getWidth();
|
588 |
double height = sz.getHeight();
|
589 |
if (width >= height) {
|
590 |
scale = cartographicSize / width; |
591 |
} else {
|
592 |
scale = cartographicSize / height; |
593 |
} |
594 |
} |
595 |
|
596 |
public void setReferenceSystem(int referenceSystem) { |
597 |
this.referenceSystem = referenceSystem;
|
598 |
if (textSymbol != null && textSymbol instanceof CartographicSupport) { |
599 |
((CartographicSupport) textSymbol).setReferenceSystem(referenceSystem); |
600 |
} |
601 |
} |
602 |
|
603 |
public void setUnit(int unitIndex) { |
604 |
this.unit = unitIndex;
|
605 |
if (textSymbol != null && textSymbol instanceof CartographicSupport) { |
606 |
((CartographicSupport) textSymbol).setUnit(unitIndex); |
607 |
} |
608 |
} |
609 |
|
610 |
public double toCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
611 |
setCartographicSize(getCartographicSize( |
612 |
viewPort, |
613 |
dpi, |
614 |
shp), |
615 |
shp); |
616 |
return 0; |
617 |
} |
618 |
|
619 |
public Rectangle getBounds() { |
620 |
Dimension cBounds = getSize();
|
621 |
return new Rectangle( |
622 |
0,
|
623 |
0,
|
624 |
(int) Math.round(cBounds.width*scale), |
625 |
(int) Math.round(cBounds.height*scale)); |
626 |
} |
627 |
|
628 |
public String getSQLQuery() { |
629 |
if (sqlQuery == null) sqlQuery = ""; |
630 |
return sqlQuery;
|
631 |
} |
632 |
|
633 |
public void setSQLQuery(String sqlQuery) { |
634 |
this.sqlQuery = sqlQuery;
|
635 |
} |
636 |
|
637 |
public boolean isUseSqlQuery() { |
638 |
return useSqlQuery;
|
639 |
} |
640 |
|
641 |
public void setUseSqlQuery(boolean useSqlQuery) { |
642 |
this.useSqlQuery = useSqlQuery;
|
643 |
} |
644 |
} |