Revision 2304
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/IFFrame.java | ||
---|---|---|
303 | 303 |
* @param g Graphics sobre el que dibujar. |
304 | 304 |
*/ |
305 | 305 |
public void drawSymbolTag(Graphics2D g); |
306 |
/** |
|
307 |
* Rellena la rotaci?n del BoundingBox. |
|
308 |
* |
|
309 |
* @param rotation rotaci?n que se quiere aplicar. |
|
310 |
*/ |
|
311 |
public void setRotation(double rotation); |
|
312 |
|
|
313 |
/** |
|
314 |
* Devuelve la rotaci?n del BoundingBox. |
|
315 |
* |
|
316 |
* @return Rotaci?n del BoundingBox. |
|
317 |
*/ |
|
318 |
public double getRotation(); |
|
306 | 319 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameView.java | ||
---|---|---|
73 | 73 |
import java.awt.image.BufferedImage; |
74 | 74 |
|
75 | 75 |
import java.util.ArrayList; |
76 |
import java.util.BitSet; |
|
76 | 77 |
|
77 | 78 |
|
78 | 79 |
/** |
... | ... | |
299 | 300 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
300 | 301 |
BufferedImage imgBase) throws com.iver.cit.gvsig.fmap.DriverException { |
301 | 302 |
Rectangle2D.Double r = getBoundingBox(at); |
302 |
|
|
303 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
304 |
r.y + (r.height / 2)); |
|
303 | 305 |
if (intersects(rv, r)) { |
304 | 306 |
if (getFMap() == null) { |
305 | 307 |
drawEmpty(g); |
... | ... | |
351 | 353 |
} |
352 | 354 |
} |
353 | 355 |
} |
356 |
g.rotate(Math.toRadians(-getRotation()), |
|
357 |
r.x + (r.width / 2), r.y + (r.height / 2)); |
|
354 | 358 |
} |
355 | 359 |
|
356 | 360 |
/** |
... | ... | |
359 | 363 |
*/ |
360 | 364 |
public void print(Graphics2D g, AffineTransform at) { |
361 | 365 |
Rectangle2D.Double r = getBoundingBox(at); |
362 |
|
|
366 |
|
|
363 | 367 |
// Dibujamos en impresora |
364 | 368 |
Rectangle rclip = g.getClipBounds(); |
365 | 369 |
g.clipRect((int) r.getMinX(), (int) r.getMinY(), (int) r.getWidth(), |
... | ... | |
495 | 499 |
xml.putProperty("m_bLinked", m_bLinked); |
496 | 500 |
xml.putProperty("m_mapUnits", m_mapUnits); |
497 | 501 |
xml.putProperty("m_Scale", m_Scale); |
502 |
xml.putProperty("m_rotation",getRotation()); |
|
498 | 503 |
|
499 |
|
|
500 | 504 |
xml.putProperty("tag", getTag()); |
501 | 505 |
|
502 | 506 |
ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
... | ... | |
653 | 657 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
654 | 658 |
this.m_bLinked = xml.getBooleanProperty("m_bLinked"); |
655 | 659 |
this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
656 |
|
|
660 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
657 | 661 |
ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
658 | 662 |
this.m_Scale = xml.getDoubleProperty("m_Scale"); |
659 | 663 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFramePicture.java | ||
---|---|---|
135 | 135 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
136 | 136 |
BufferedImage imgBase) { |
137 | 137 |
Rectangle2D.Double r = getBoundingBox(at); |
138 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
139 |
r.y + (r.height / 2)); |
|
138 | 140 |
double x = r.getMinX(); |
139 | 141 |
double y = r.getMinY(); |
140 | 142 |
double w = r.getWidth(); |
... | ... | |
170 | 172 |
} |
171 | 173 |
} |
172 | 174 |
} |
175 |
g.rotate(Math.toRadians(-getRotation()), |
|
176 |
r.x + (r.width / 2), r.y + (r.height / 2)); |
|
173 | 177 |
} |
174 | 178 |
|
175 | 179 |
/** |
... | ... | |
322 | 326 |
xml.putProperty("m_quality", m_quality); |
323 | 327 |
xml.putProperty("m_viewing", m_viewing); |
324 | 328 |
xml.putProperty("tag", getTag()); |
325 |
|
|
329 |
xml.putProperty("m_rotation",getRotation()); |
|
326 | 330 |
return xml; |
327 | 331 |
} |
328 | 332 |
|
... | ... | |
453 | 457 |
|
454 | 458 |
this.m_quality = xml.getIntProperty("m_quality"); |
455 | 459 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
460 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
456 | 461 |
} |
457 | 462 |
|
458 | 463 |
/** |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGroup.java | ||
---|---|---|
144 | 144 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
145 | 145 |
BufferedImage imgBase) throws DriverException { |
146 | 146 |
Rectangle2D.Double r = getBoundingBox(at); |
147 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
148 |
r.y + (r.height / 2)); |
|
147 | 149 |
m_at = at; |
148 | 150 |
|
149 | 151 |
for (int i = 0; i < m_fframes.size(); i++) { |
150 | 152 |
((IFFrame) m_fframes.get(i)).draw(g, at, rv, imgBase); |
151 | 153 |
} |
154 |
g.rotate(Math.toRadians(-getRotation()), |
|
155 |
r.x + (r.width / 2), r.y + (r.height / 2)); |
|
152 | 156 |
} |
153 | 157 |
|
154 | 158 |
/** |
... | ... | |
217 | 221 |
xml.putProperty("m_Selected", m_Selected); |
218 | 222 |
xml.putProperty("type", Layout.RECTANGLEGROUP); |
219 | 223 |
xml.putProperty("tag", getTag()); |
220 |
|
|
224 |
xml.putProperty("m_rotation",getRotation()); |
|
221 | 225 |
for (int i = 0; i < getFFrames().size(); i++) { |
222 | 226 |
xml.addChild(((IFFrame) getFFrames().get(i)).getXMLEntity()); |
223 | 227 |
} |
... | ... | |
260 | 264 |
} else { |
261 | 265 |
this.setSelected(false); |
262 | 266 |
} |
263 |
|
|
267 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
264 | 268 |
IFFrame fframechild = null; |
265 | 269 |
|
266 | 270 |
for (int i = 0; i < xml.getNumChild(); i++) { |
... | ... | |
290 | 294 |
*/ |
291 | 295 |
public void print(Graphics2D g, AffineTransform at) |
292 | 296 |
throws DriverException { |
297 |
Rectangle2D.Double r = getBoundingBox(at); |
|
298 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
299 |
r.y + (r.height / 2)); |
|
293 | 300 |
for (int i = 0; i < m_fframes.size(); i++) { |
294 | 301 |
((IFFrame) m_fframes.get(i)).print(g, at); |
295 | 302 |
} |
303 |
g.rotate(Math.toRadians(-getRotation()), |
|
304 |
r.x + (r.width / 2), r.y + (r.height / 2)); |
|
296 | 305 |
} |
297 | 306 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameScaleBar.java | ||
---|---|---|
384 | 384 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
385 | 385 |
BufferedImage imgBase) { |
386 | 386 |
Rectangle2D.Double r = getBoundingBox(at); |
387 |
|
|
387 |
g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2), |
|
388 |
r.y + (r.height / 2)); |
|
388 | 389 |
if (intersects(rv, r)) { |
389 | 390 |
if ((fframeview == null) || (fframeview.getFMap() == null)) { |
390 | 391 |
drawEmpty(g); |
... | ... | |
417 | 418 |
} |
418 | 419 |
} |
419 | 420 |
} |
421 |
g.rotate(Math.toRadians(-getRotation()), |
|
422 |
r.x + (r.width / 2), r.y + (r.height / 2)); |
|
420 | 423 |
} |
421 | 424 |
|
422 | 425 |
/** |
... | ... | |
917 | 920 |
xml.putProperty("fontName", m_f.getFontName()); |
918 | 921 |
xml.putProperty("fontStyle", m_f.getStyle()); |
919 | 922 |
xml.putProperty("tag", getTag()); |
923 |
xml.putProperty("m_rotation",getRotation()); |
|
920 | 924 |
|
921 | 925 |
/* xml.addChild(fframeview.getXMLEntity()); |
922 | 926 |
|
... | ... | |
1040 | 1044 |
this.m_mapUnits = xml.getIntProperty("m_mapUnits"); |
1041 | 1045 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
1042 | 1046 |
xml.getIntProperty("fontStyle"), 9); |
1043 |
|
|
1047 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
1044 | 1048 |
/*FFrameView fv=(FFrameView) FFrameView.createFFrame(xml.getChild(0), |
1045 | 1049 |
p); |
1046 | 1050 |
int indice = xml.getIntProperty("indice"); |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameLegend.java | ||
---|---|---|
158 | 158 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
159 | 159 |
BufferedImage imgBase) throws DriverException { |
160 | 160 |
Rectangle2D.Double re = getBoundingBox(at); |
161 |
|
|
161 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
|
162 |
re.y + (re.height / 2)); |
|
162 | 163 |
if ((fframeview != null) && (fframeview.getFMap() != null)) { |
163 | 164 |
layers = fframeview.getFMap().getLayers(); |
164 | 165 |
} |
... | ... | |
181 | 182 |
drawDraft(g); |
182 | 183 |
} |
183 | 184 |
} |
185 |
g.rotate(Math.toRadians(-getRotation()), |
|
186 |
re.x + (re.width / 2), re.y + (re.height / 2)); |
|
184 | 187 |
} |
185 | 188 |
|
186 | 189 |
/** |
... | ... | |
589 | 592 |
xml.putProperty("fontName", m_f.getFontName()); |
590 | 593 |
xml.putProperty("fontStyle", m_f.getStyle()); |
591 | 594 |
xml.putProperty("tag", getTag()); |
592 |
|
|
595 |
xml.putProperty("m_rotation",getRotation()); |
|
593 | 596 |
///xml.addChild(fframeview.getXMLEntity()); |
594 | 597 |
LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class); |
595 | 598 |
Layout layout = lc.getLayout(); |
... | ... | |
696 | 699 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
697 | 700 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
698 | 701 |
xml.getIntProperty("fontStyle"), 9); |
699 |
|
|
702 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
700 | 703 |
//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0), |
701 | 704 |
// p)); |
702 | 705 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrame.java | ||
---|---|---|
104 | 104 |
private Rectangle no = new Rectangle(); |
105 | 105 |
private String tag = null; |
106 | 106 |
protected int num = 0; |
107 |
|
|
107 |
private double m_rotation=0; |
|
108 | 108 |
/** |
109 | 109 |
* Dibuja los handlers sobre el boundingBox en el graphics que se pasa como |
110 | 110 |
* par?metro. |
... | ... | |
113 | 113 |
*/ |
114 | 114 |
public void drawHandlers(Graphics2D g) { |
115 | 115 |
int size = 10; |
116 |
Rectangle2D.Double r = getBoundingBox(null); |
|
117 |
|
|
118 |
//g.drawRect((int) r.x, (int) r.y, (int) r.width, (int) r.height); |
|
119 |
g.fillRect((int) r.x - size, (int) r.y - size, size, size); |
|
120 |
no.setRect((int) r.x - size, (int) r.y - size, size, size); |
|
121 |
g.fillRect((int) r.getMaxX(), (int) r.y - size, size, size); |
|
122 |
ne.setRect((int) r.getMaxX(), (int) r.y - size, size, size); |
|
123 |
g.fillRect((int) r.x - size, (int) r.getMaxY(), size, size); |
|
124 |
so.setRect((int) r.x - size, (int) r.getMaxY(), size, size); |
|
116 |
Rectangle2D r = getBoundingBox(null); |
|
117 |
Point2D p=new Point2D.Double(); |
|
118 |
g.rotate(Math.toRadians(getRotation()), r.getX() + (r.getWidth() / 2), |
|
119 |
r.getY() + (r.getHeight() / 2)); |
|
120 |
AffineTransform atRotate=new AffineTransform(); |
|
121 |
atRotate.rotate(Math.toRadians(getRotation()), r.getX() + (r.getWidth() / 2), |
|
122 |
r.getY() + (r.getHeight() / 2)); |
|
123 |
|
|
124 |
g.fillRect((int) r.getX() - size, (int) r.getY() - size, size, size); |
|
125 |
atRotate.transform(new Point2D.Double(r.getX()- size,r.getY()- size),p); |
|
126 |
no.setRect((int) p.getX(), (int) p.getY(), size, size); |
|
127 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
128 |
|
|
129 |
g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size); |
|
130 |
atRotate.transform(new Point2D.Double(r.getMaxX(),r.getY()- size),p); |
|
131 |
ne.setRect((int) p.getX(), (int) p.getY(), size, size); |
|
132 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
133 |
|
|
134 |
g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size); |
|
135 |
atRotate.transform(new Point2D.Double(r.getX() - size, r.getMaxY()),p); |
|
136 |
so.setRect((int) p.getX(), (int) p.getY(), size, size); |
|
137 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
138 |
|
|
125 | 139 |
g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size); |
126 |
se.setRect((int) r.getMaxX(), (int) r.getMaxY(), size, size); |
|
127 |
g.fillRect((int) r.getCenterX() - (size / 2), (int) r.y - size, size, |
|
128 |
size); |
|
129 |
n.setRect((int) r.getCenterX() - (size / 2), (int) r.y - size, size, |
|
130 |
size); |
|
131 |
g.fillRect((int) r.getCenterX() - (size / 2), (int) r.getMaxY(), size, |
|
132 |
size); |
|
133 |
s.setRect((int) r.getCenterX() - (size / 2), (int) r.getMaxY(), size, |
|
134 |
size); |
|
135 |
g.fillRect((int) r.x - size, (int) r.getCenterY() - (size / 2), size, |
|
136 |
size); |
|
137 |
o.setRect((int) r.x - size, (int) r.getCenterY() - (size / 2), size, |
|
138 |
size); |
|
139 |
g.fillRect((int) r.getMaxX(), (int) r.getCenterY() - (size / 2), size, |
|
140 |
size); |
|
141 |
e.setRect((int) r.getMaxX(), (int) r.getCenterY() - (size / 2), size, |
|
142 |
size); |
|
140 |
atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()),p); |
|
141 |
se.setRect((int) p.getX(), (int) p.getY(), size, size); |
|
142 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
143 |
|
|
144 |
g.fillRect((int) r.getCenterX() - (size / 2), (int) r.getY() - size, size,size); |
|
145 |
atRotate.transform(new Point2D.Double(r.getCenterX() - (size/2), r.getY()-size),p); |
|
146 |
n.setRect((int) p.getX(), (int) p.getY(), size,size); |
|
147 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
148 |
|
|
149 |
g.fillRect((int) r.getCenterX() - (size / 2), (int) r.getMaxY(), size,size); |
|
150 |
atRotate.transform(new Point2D.Double(r.getCenterX() - (size/2), r.getMaxY()),p); |
|
151 |
s.setRect((int) p.getX(), (int) p.getY(), size,size); |
|
152 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
153 |
|
|
154 |
g.fillRect((int) r.getX() - size, (int) r.getCenterY() - (size / 2), size,size); |
|
155 |
atRotate.transform(new Point2D.Double(r.getX() - size, r.getCenterY()- (size/2)),p); |
|
156 |
o.setRect((int) p.getX(), (int) p.getY(), size,size); |
|
157 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
158 |
|
|
159 |
g.fillRect((int) r.getMaxX(), (int) r.getCenterY() - (size / 2), size,size); |
|
160 |
atRotate.transform(new Point2D.Double(r.getMaxX(), r.getCenterY()-(size/2)),p); |
|
161 |
e.setRect((int) p.getX(), (int) p.getY(), size,size); |
|
162 |
//g.drawRect((int) p.getX(), (int) p.getY(), size, size); |
|
163 |
g.rotate(Math.toRadians(-getRotation()), |
|
164 |
r.getX() + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
|
165 |
|
|
166 |
|
|
143 | 167 |
} |
144 | 168 |
|
145 | 169 |
/** |
... | ... | |
569 | 593 |
* @param g Graphics so bre el que dibujar. |
570 | 594 |
*/ |
571 | 595 |
public void drawDraft(Graphics2D g) { |
572 |
Rectangle2D.Double r = getBoundingBox(null); |
|
596 |
Rectangle2D r = getBoundingBox(null); |
|
597 |
g.rotate(Math.toRadians(getRotation()), r.getX() + (r.getWidth() / 2), |
|
598 |
r.getY() + (r.getHeight() / 2)); |
|
599 |
|
|
600 |
|
|
573 | 601 |
g.setColor(Color.lightGray); |
574 |
g.fillRect((int) r.x, (int) r.y, (int) r.width, (int) r.height);
|
|
602 |
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
|
|
575 | 603 |
g.setColor(Color.black); |
576 | 604 |
|
577 |
int scale = (int) (r.width / 12);
|
|
605 |
int scale = (int) (r.getWidth() / 12);
|
|
578 | 606 |
Font f = new Font("SansSerif", Font.PLAIN, scale); |
579 | 607 |
g.setFont(f); |
580 | 608 |
g.drawString(getName(), |
581 | 609 |
(int) (r.getCenterX() - ((getName().length() * scale) / 4)), |
582 | 610 |
(int) (r.getCenterY())); |
611 |
g.rotate(Math.toRadians(-getRotation()), |
|
612 |
r.getX() + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
|
613 |
|
|
583 | 614 |
} |
584 | 615 |
|
585 | 616 |
/** |
... | ... | |
598 | 629 |
* @param g Graphics sobre el que dibujar. |
599 | 630 |
*/ |
600 | 631 |
public void drawEmpty(Graphics2D g) { |
601 |
Rectangle2D.Double r = getBoundingBox(null); |
|
632 |
Rectangle2D r = getBoundingBox(null); |
|
633 |
g.rotate(Math.toRadians(getRotation()), r.getX() + (r.getWidth() / 2), |
|
634 |
r.getY() + (r.getHeight() / 2)); |
|
602 | 635 |
g.setColor(Color.lightGray); |
603 |
g.fillRect((int) r.x, (int) r.y, (int) r.width, (int) r.height);
|
|
636 |
g.fillRect((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight());
|
|
604 | 637 |
g.setColor(Color.black); |
605 | 638 |
|
606 |
int scale = (int) (r.width / 12);
|
|
639 |
int scale = (int) (r.getWidth() / 12);
|
|
607 | 640 |
Font f = new Font("SansSerif", Font.PLAIN, scale); |
608 | 641 |
g.setFont(f); |
609 | 642 |
|
... | ... | |
612 | 645 |
|
613 | 646 |
g.drawString(s, (int) (r.getCenterX() - ((s.length() * scale) / 4)), |
614 | 647 |
(int) (r.getCenterY())); |
648 |
g.rotate(Math.toRadians(-getRotation()), |
|
649 |
r.getX() + (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
|
615 | 650 |
} |
616 | 651 |
|
617 | 652 |
/** |
... | ... | |
660 | 695 |
* @param g Graphics sobre el que dibujar el icono. |
661 | 696 |
*/ |
662 | 697 |
public void drawSymbolTag(Graphics2D g) { |
663 |
Rectangle2D.Double rec = getBoundingBox(null); |
|
664 |
|
|
698 |
Rectangle2D rec = getBoundingBox(null); |
|
699 |
g.rotate(Math.toRadians(getRotation()), rec.getX() + (rec.getWidth() / 2), |
|
700 |
rec.getY() + (rec.getHeight() / 2)); |
|
665 | 701 |
try { |
666 | 702 |
URL url = AddLayer.class.getClassLoader().getResource("images/symbolTag.gif"); |
667 | 703 |
Image image = new ImageIcon(url).getImage(); |
668 |
g.drawImage(image, (int) rec.x, (int) rec.y, 25, 30, null);
|
|
704 |
g.drawImage(image, (int) rec.getX(), (int) rec.getY(), 25, 30, null);
|
|
669 | 705 |
} catch (NullPointerException npe) { |
670 | 706 |
} |
707 |
g.rotate(Math.toRadians(-getRotation()), |
|
708 |
rec.getX() + (rec.getWidth() / 2), rec.getY() + (rec.getHeight() / 2)); |
|
671 | 709 |
} |
710 |
/** |
|
711 |
* Rellenar la rotaci?n para aplicar al FFrame. |
|
712 |
* |
|
713 |
* @param rotation rotaci?n que se quiere aplicar. |
|
714 |
*/ |
|
715 |
public void setRotation(double rotation) { |
|
716 |
m_rotation = rotation; |
|
717 |
} |
|
718 |
|
|
719 |
/** |
|
720 |
* Devuelve la rotaci?n del FFrame. |
|
721 |
* |
|
722 |
* @return Rotaci?n del FFrame. |
|
723 |
*/ |
|
724 |
public double getRotation() { |
|
725 |
return m_rotation; |
|
726 |
} |
|
672 | 727 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGraphics.java | ||
---|---|---|
180 | 180 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
181 | 181 |
BufferedImage imgBase) { |
182 | 182 |
Rectangle2D.Double rect = getBoundingBox(at); |
183 |
|
|
183 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
|
184 |
rect.y + (rect.height / 2)); |
|
184 | 185 |
if (intersects(rv, rect)) { |
185 | 186 |
g.setColor(Color.black); |
186 | 187 |
|
... | ... | |
261 | 262 |
break; |
262 | 263 |
} |
263 | 264 |
} |
265 |
g.rotate(Math.toRadians(-getRotation()), |
|
266 |
rect.x + (rect.width / 2), rect.y + (rect.height / 2)); |
|
264 | 267 |
} |
265 | 268 |
|
266 | 269 |
/** |
... | ... | |
278 | 281 |
xml.putProperty("type", Layout.GRAPHICS); |
279 | 282 |
xml.putProperty("m_type", m_type); |
280 | 283 |
xml.putProperty("tag", getTag()); |
284 |
xml.putProperty("m_rotation",getRotation()); |
|
281 | 285 |
xml.addChild(m_symbol.getXMLEntity()); |
282 | 286 |
return xml; |
283 | 287 |
} |
... | ... | |
323 | 327 |
public void setXMLEntity(XMLEntity xml, Layout p) { |
324 | 328 |
m_Selected=xml.getIntProperty("m_Selected"); |
325 | 329 |
m_type=xml.getIntProperty("m_type"); |
330 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
326 | 331 |
m_symbol=FSymbol.createFromXML(xml.getChild(0)); |
327 | 332 |
} |
328 | 333 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameText.java | ||
---|---|---|
72 | 72 |
public static final int RIGTH = 2; |
73 | 73 |
private ArrayList m_text = new ArrayList(); |
74 | 74 |
private boolean m_isFixed = false; |
75 |
private double m_rotation = 0; |
|
75 |
//private double m_rotation = 0;
|
|
76 | 76 |
private int m_pos = LEFT; |
77 | 77 |
private Color textColor = Color.BLACK; |
78 |
|
|
78 | 79 |
//jaume |
79 |
private boolean surrounded = false; // The text field is surrounded by a rectangle
|
|
80 |
private int cellPadding = 0; // The gap between the the text field and the surrounding rectangle
|
|
81 |
private boolean fixedFontSize = false; // The text field font size is constant fixed to the folio's size
|
|
82 |
private int fontSize; // Text field's font size
|
|
83 |
private boolean hasTitle; // The text field has title
|
|
84 |
private String title; // The text for the title
|
|
85 |
private int titleSize; // The title's font size
|
|
86 |
private int frameBorderSize; // The surrounding rectangle's border size
|
|
87 |
private Color frameColor=Color.BLACK; // The surrounding rectangle's color
|
|
88 |
private Color titleColor=Color.BLACK; // The title's color
|
|
89 |
|
|
80 |
private boolean surrounded = false; // The text field is surrounded by a rectangle |
|
81 |
private int cellPadding = 0; // The gap between the the text field and the surrounding rectangle
|
|
82 |
private boolean fixedFontSize = false; // The text field font size is constant fixed to the folio's size
|
|
83 |
private int fontSize; // Text field's font size
|
|
84 |
private boolean hasTitle; // The text field has title
|
|
85 |
private String title; // The text for the title
|
|
86 |
private int titleSize; // The title's font size
|
|
87 |
private int frameBorderSize; // The surrounding rectangle's border size
|
|
88 |
private Color frameColor = Color.BLACK; // The surrounding rectangle's color
|
|
89 |
private Color titleColor = Color.BLACK; // The title's color
|
|
90 |
|
|
90 | 91 |
//private int m_space=0; |
91 | 92 |
private Font m_f = null; |
92 |
|
|
93 |
|
|
93 | 94 |
/** |
94 | 95 |
* Crea un nuevo FFrameText. |
95 | 96 |
*/ |
96 |
// public FFrameText(Layout l) { |
|
97 |
// layout=l; |
|
98 |
// m_f = new Font("SansSerif", Font.PLAIN, 9); |
|
99 |
// } |
|
97 |
|
|
98 |
// public FFrameText(Layout l) { |
|
99 |
// layout=l; |
|
100 |
// m_f = new Font("SansSerif", Font.PLAIN, 9); |
|
101 |
// } |
|
100 | 102 |
public FFrameText() { |
101 |
m_f = new Font("SansSerif", Font.PLAIN, 9);
|
|
103 |
m_f = new Font("SansSerif", Font.PLAIN, 9);
|
|
102 | 104 |
} |
103 | 105 |
|
104 | 106 |
/** |
... | ... | |
119 | 121 |
return textColor; |
120 | 122 |
} |
121 | 123 |
|
122 |
/** |
|
123 |
* Obtiene el fixedFontSize |
|
124 |
* @return boolean |
|
125 |
*/ |
|
124 |
/** |
|
125 |
* Obtiene el fixedFontSize |
|
126 |
* |
|
127 |
* @return boolean |
|
128 |
*/ |
|
129 |
public boolean isFontSizeFixed() { |
|
130 |
return fixedFontSize; |
|
131 |
} |
|
126 | 132 |
|
127 |
public boolean isFontSizeFixed() { |
|
128 |
return fixedFontSize; |
|
129 |
} |
|
130 |
/** |
|
131 |
* Establece fixedFontSize |
|
132 |
* @param fixedFontSize |
|
133 |
*/ |
|
134 |
public void setFixedFontSize(boolean fixedFontSize) { |
|
135 |
this.fixedFontSize = fixedFontSize; |
|
136 |
} |
|
137 |
/** |
|
138 |
* Obtiene el fontSize |
|
139 |
* @return int |
|
140 |
*/ |
|
133 |
/** |
|
134 |
* Establece fixedFontSize |
|
135 |
* |
|
136 |
* @param fixedFontSize |
|
137 |
*/ |
|
138 |
public void setFixedFontSize(boolean fixedFontSize) { |
|
139 |
this.fixedFontSize = fixedFontSize; |
|
140 |
} |
|
141 | 141 |
|
142 |
public int getFontSize() { |
|
143 |
return fontSize; |
|
144 |
} |
|
145 |
/** |
|
146 |
* Establece fontSize |
|
147 |
* @param fontSize |
|
148 |
*/ |
|
149 |
public void setFontSize(int fontSize) { |
|
150 |
this.fontSize = fontSize; |
|
151 |
} |
|
152 |
/** |
|
153 |
* Obtiene el cellPadding |
|
154 |
* @return int |
|
155 |
*/ |
|
142 |
/** |
|
143 |
* Obtiene el fontSize |
|
144 |
* |
|
145 |
* @return int |
|
146 |
*/ |
|
147 |
public int getFontSize() { |
|
148 |
return fontSize; |
|
149 |
} |
|
156 | 150 |
|
157 |
public int getCellPadding() { |
|
158 |
return cellPadding; |
|
159 |
} |
|
160 | 151 |
/** |
152 |
* Establece fontSize |
|
153 |
* |
|
154 |
* @param fontSize |
|
155 |
*/ |
|
156 |
public void setFontSize(int fontSize) { |
|
157 |
this.fontSize = fontSize; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* Obtiene el cellPadding |
|
162 |
* |
|
163 |
* @return int |
|
164 |
*/ |
|
165 |
public int getCellPadding() { |
|
166 |
return cellPadding; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
161 | 170 |
* Inserta el color del texto a escribir. |
162 | 171 |
* |
163 | 172 |
* @param color Color del texto. |
... | ... | |
213 | 222 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
214 | 223 |
BufferedImage imgBase) { |
215 | 224 |
g.setColor(Color.BLACK); |
216 |
Rectangle2D.Double rec = getBoundingBox(at); |
|
217 |
Rectangle2D.Double raux = (Rectangle2D.Double)rec.clone(); |
|
225 |
Rectangle2D.Double rec = getBoundingBox(at); |
|
226 |
Rectangle2D.Double raux = (Rectangle2D.Double) rec.clone(); |
|
227 |
g.rotate(Math.toRadians(getRotation()), raux.x + (raux.width / 2), |
|
228 |
raux.y + (raux.height / 2)); |
|
218 | 229 |
int longmax = 1; |
230 |
|
|
219 | 231 |
if (intersects(rv, raux)) { // comprueba que no cae fuera de la pantalla |
232 |
|
|
220 | 233 |
if (m_text.isEmpty()) { |
221 | 234 |
drawEmpty(g); |
222 | 235 |
} else { |
... | ... | |
225 | 238 |
longmax = ((String) m_text.get(i)).length(); |
226 | 239 |
} |
227 | 240 |
} |
241 |
|
|
228 | 242 |
FontRenderContext frc = g.getFontRenderContext(); |
229 | 243 |
int scaledFontSize; |
230 |
|
|
244 |
|
|
231 | 245 |
// TODO myScale es la escala sobre la que se extraen todos los escalados. Esto |
232 | 246 |
// funciona bien tal cual est? si la ratio de aspecto (alto/ancho) del folio es constante |
233 | 247 |
// porque se toma como medidas el ancho del folio real y el ancho del folio en pantalla. |
234 | 248 |
// No se que pasar? si la ratio cambia, por ejemplo si se usan USLetter en lugar de DIN A4 |
235 |
|
|
236 |
double myScale = at.getScaleX()*0.024;//FLayoutUtilities.fromSheetDistance(folio.getAncho(),at)/rv.getWidth(); |
|
237 |
|
|
249 |
double myScale = at.getScaleX() * 0.024; //FLayoutUtilities.fromSheetDistance(folio.getAncho(),at)/rv.getWidth(); |
|
250 |
|
|
238 | 251 |
// Distinguish when the font has fixed size or not |
239 |
if (isFontSizeFixed()){ |
|
240 |
scaledFontSize = (int)(myScale*fontSize);
|
|
241 |
} else {
|
|
242 |
scaledFontSize = ((int) (raux.width * 2.2)) / longmax;
|
|
252 |
if (isFontSizeFixed()) {
|
|
253 |
scaledFontSize = (int) (myScale * fontSize);
|
|
254 |
} else {
|
|
255 |
scaledFontSize = ((int) (raux.width)) / longmax;
|
|
243 | 256 |
|
244 |
if (scaledFontSize > (int) ((raux.height * 10) / 4 / (m_text.size() * 1.3))) { |
|
245 |
scaledFontSize = (int) (((raux.height * 10) / 4) / (m_text.size() * 1.3)); |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
int ht = (int) (raux.height / m_text.size()); |
|
257 |
if (scaledFontSize > (int) ((raux.height) / m_text.size())) { |
|
258 |
scaledFontSize = (int) ((raux.height) / m_text.size()); |
|
259 |
} |
|
260 |
} |
|
252 | 261 |
|
253 | 262 |
if (m_f != null) { |
254 |
// esto sirve de algo? |
|
255 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), scaledFontSize); |
|
263 |
// Aqu? se ajusta a partir de las caracter?sticas de la fuente, una nueva fuente con el tama?o ajustado. |
|
264 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), |
|
265 |
scaledFontSize); |
|
256 | 266 |
} else { |
267 |
// Aqu? pasa cuando se abre el di?logo para seleccionar un tipo de fuente y se cierra sin haber seleccionado ninguna. |
|
257 | 268 |
m_f = new Font("SansSerif", Font.PLAIN, scaledFontSize); |
258 | 269 |
} |
259 | 270 |
|
260 | 271 |
// Draw the text title if it exists |
261 |
if (hasTitle()){ |
|
262 |
int scaledTitleFontSize = (int) (myScale*titleSize); |
|
263 |
int gap = 3; |
|
264 |
if (isSurrounded()){ |
|
265 |
// Para evitar que el marco se pinte sobre el t?tulo |
|
266 |
gap += (int) (frameBorderSize*myScale); |
|
267 |
} |
|
268 |
|
|
269 |
g.setColor(titleColor); |
|
270 |
Font titleFont = new Font(m_f.getFontName(), m_f.getStyle(), scaledTitleFontSize); |
|
271 |
TextLayout titleTextLayout = new TextLayout(getTitle(), titleFont, frc); |
|
272 |
titleTextLayout.draw(g, (float) raux.getX(), (float) (raux.getY()-(gap*myScale))); |
|
272 |
if (hasTitle()) { |
|
273 |
int scaledTitleFontSize = (int) (myScale * titleSize); |
|
274 |
int gap = 3; |
|
275 |
|
|
276 |
if (isSurrounded()) { |
|
277 |
// Para evitar que el marco se pinte sobre el t?tulo |
|
278 |
gap += (int) (frameBorderSize * myScale); |
|
279 |
} |
|
280 |
|
|
281 |
g.setColor(titleColor); |
|
282 |
|
|
283 |
Font titleFont = new Font(m_f.getFontName(), |
|
284 |
m_f.getStyle(), scaledTitleFontSize); |
|
285 |
TextLayout titleTextLayout = new TextLayout(getTitle(), |
|
286 |
titleFont, frc); |
|
287 |
titleTextLayout.draw(g, (float) raux.getX(), |
|
288 |
(float) (raux.getY() - (gap * myScale))); |
|
273 | 289 |
} |
274 |
|
|
290 |
|
|
275 | 291 |
// Draw the frame involving the text if it exists |
276 |
if (isSurrounded()){ |
|
277 |
g.setColor(frameColor); |
|
278 |
g.drawRect((int) raux.x, (int) raux.y, (int)raux.width, (int)raux.height); |
|
279 |
double scaledCellPadding = cellPadding*myScale; |
|
280 |
if (frameBorderSize > 1){ |
|
281 |
System.out.println("borderSize = "+frameBorderSize); |
|
282 |
int scaledBorderSize = (int) (frameBorderSize*myScale); |
|
283 |
for (int i=scaledBorderSize-1; i>0; i--) |
|
284 |
g.drawRect((int) raux.x-i, (int) raux.y-i, (int) raux.width+2*i, (int) raux.height+2*i); |
|
285 |
|
|
286 |
} |
|
287 |
|
|
288 |
|
|
289 |
// Recalibro el rectangulo para establecer el ?rea donde se dibujan las fuentes |
|
290 |
// al ?rea marcada con el rat?n menos la distancia al marco especificada |
|
291 |
raux.setRect(raux.getX() + scaledCellPadding, raux.getY() - scaledCellPadding, |
|
292 |
raux.getWidth()- scaledCellPadding*2, raux.getHeight()- scaledCellPadding*2); |
|
293 |
|
|
292 |
if (isSurrounded()) { |
|
293 |
g.setColor(frameColor); |
|
294 |
g.drawRect((int) raux.x, (int) raux.y, (int) raux.width, |
|
295 |
(int) raux.height); |
|
296 |
|
|
297 |
double scaledCellPadding = cellPadding * myScale; |
|
298 |
|
|
299 |
if (frameBorderSize > 1) { |
|
300 |
System.out.println("borderSize = " + frameBorderSize); |
|
301 |
|
|
302 |
int scaledBorderSize = (int) (frameBorderSize * myScale); |
|
303 |
|
|
304 |
for (int i = scaledBorderSize - 1; i > 0; i--) |
|
305 |
g.drawRect((int) raux.x - i, (int) raux.y - i, |
|
306 |
(int) raux.width + (2 * i), |
|
307 |
(int) raux.height + (2 * i)); |
|
308 |
} |
|
309 |
|
|
310 |
// Recalibro el rectangulo para establecer el ?rea donde se dibujan las fuentes |
|
311 |
// al ?rea marcada con el rat?n menos la distancia al marco especificada |
|
312 |
raux.setRect(raux.getX() + scaledCellPadding, |
|
313 |
raux.getY() - scaledCellPadding, |
|
314 |
raux.getWidth() - (scaledCellPadding * 2), |
|
315 |
raux.getHeight() - (scaledCellPadding * 2)); |
|
294 | 316 |
} |
317 |
|
|
318 |
g.setColor(textColor); |
|
295 | 319 |
|
296 |
for (int i = 0; i < m_text.size(); i++) { |
|
297 |
if (!((String) m_text.get(i)).equals("")) { |
|
298 |
TextLayout textLayout = new TextLayout((String) m_text.get( |
|
299 |
i), m_f, frc); |
|
300 |
g.setColor(textColor); |
|
301 |
g.rotate(Math.toRadians(m_rotation), |
|
302 |
raux.x + (raux.width / 2), raux.y + (raux.height / 2)); |
|
303 |
|
|
304 |
int l = ((String) m_text.get(i)).length(); |
|
305 |
|
|
306 |
switch (m_pos) { |
|
307 |
case (LEFT): |
|
308 |
textLayout.draw(g, (float) raux.getX(), |
|
309 |
(float) (raux.getY() + (ht * (i +1)))); |
|
310 |
|
|
311 |
break; |
|
312 | 320 |
|
313 |
case (CENTER): |
|
314 |
float pos1 = (float) ((raux.width - |
|
315 |
((l * scaledFontSize) / 2.2)) / 2); |
|
316 |
textLayout.draw(g, (float) raux.getX() + pos1, |
|
317 |
(float) (raux.getY() + (ht * (i + 1)))); |
|
318 |
|
|
319 |
break; |
|
321 |
drawText(raux, scaledFontSize, g); |
|
322 |
g.rotate(Math.toRadians(-getRotation()), |
|
323 |
raux.x + (raux.width / 2), raux.y + (raux.height / 2)); |
|
324 |
} |
|
325 |
} |
|
320 | 326 |
|
321 |
case (RIGTH): |
|
322 |
float pos2 = (float) ((raux.width - |
|
323 |
((l * scaledFontSize) / 2.2))); |
|
324 |
textLayout.draw(g, (float) raux.getX() + pos2, |
|
325 |
(float) (raux.getY() + (ht * (i + 1)))); //- (ht / 2)))); |
|
326 |
break; |
|
327 |
} |
|
327 |
raux = null; |
|
328 |
} |
|
328 | 329 |
|
329 |
g.rotate(Math.toRadians(-m_rotation), |
|
330 |
raux.x + (raux.width / 2), raux.y + (raux.height / 2)); |
|
331 |
|
|
330 |
/** |
|
331 |
* Dibuja el texto sobre el graphics con el tama?o adecuado. |
|
332 |
* |
|
333 |
* @param r Rect?ngulo sobre el que dibujar. |
|
334 |
* @param sfs Tama?o aproximado del texto. |
|
335 |
* @param g Graphics sobre el que dibujar el texto. |
|
336 |
*/ |
|
337 |
private void drawText(Rectangle2D r, int sfs, Graphics2D g) { |
|
338 |
int minSFS = Integer.MAX_VALUE; |
|
339 |
FontRenderContext frc = g.getFontRenderContext(); |
|
340 |
int ht = (int) (r.getHeight() / m_text.size()); |
|
341 |
|
|
342 |
for (int i = 0; i < m_text.size(); i++) { |
|
343 |
if (!((String) m_text.get(i)).equals("")) { |
|
344 |
TextLayout textaux = new TextLayout((String) m_text.get(i), |
|
345 |
m_f, frc); |
|
346 |
Rectangle2D txtBound = textaux.getBounds(); |
|
347 |
double difW = txtBound.getWidth() / r.getWidth(); |
|
348 |
double difH = (txtBound.getHeight() * m_text.size()) / (r.getHeight()); |
|
349 |
|
|
350 |
if (difW > difH) { |
|
351 |
if (minSFS > sfs) { |
|
352 |
minSFS = (int) (sfs / difW); |
|
332 | 353 |
} |
333 |
|
|
354 |
} else { |
|
355 |
if (minSFS > sfs) { |
|
356 |
minSFS = (int) (sfs / difH); |
|
357 |
} |
|
334 | 358 |
} |
335 | 359 |
} |
336 | 360 |
} |
337 |
raux = null; |
|
361 |
|
|
362 |
TextLayout textLayout = null; |
|
363 |
|
|
364 |
for (int i = 0; i < m_text.size(); i++) { |
|
365 |
if (!((String) m_text.get(i)).equals("")) { |
|
366 |
m_f = new Font(m_f.getFontName(), m_f.getStyle(), minSFS); |
|
367 |
|
|
368 |
textLayout = new TextLayout((String) m_text.get(i), m_f, frc); |
|
369 |
|
|
370 |
Rectangle2D txtBound = textLayout.getBounds(); |
|
371 |
int l = ((String) m_text.get(i)).length(); |
|
372 |
float difW = (float) (r.getWidth() - txtBound.getWidth()); |
|
373 |
|
|
374 |
switch (m_pos) { |
|
375 |
case (LEFT): |
|
376 |
textLayout.draw(g, (float) r.getX(), |
|
377 |
(float) (r.getY() + (ht * (i + 1)))); |
|
378 |
|
|
379 |
break; |
|
380 |
|
|
381 |
case (CENTER): |
|
382 |
textLayout.draw(g, (float) r.getX() + (difW / 2), |
|
383 |
(float) (r.getY() + (ht * (i + 1)))); |
|
384 |
|
|
385 |
break; |
|
386 |
|
|
387 |
case (RIGTH): |
|
388 |
textLayout.draw(g, (float) r.getX() + difW, |
|
389 |
(float) (r.getY() + (ht * (i + 1)))); //- (ht / 2)))); |
|
390 |
|
|
391 |
break; |
|
392 |
} |
|
393 |
} |
|
394 |
} |
|
338 | 395 |
} |
339 | 396 |
|
340 | 397 |
/** |
... | ... | |
381 | 438 |
return m_isFixed; |
382 | 439 |
} |
383 | 440 |
|
384 |
/** |
|
385 |
* Rellenar la rotaci?n para aplicar al texto. |
|
386 |
* |
|
387 |
* @param rotation rotaci?n que se quiere aplicar. |
|
388 |
*/ |
|
389 |
public void setRotation(double rotation) { |
|
390 |
m_rotation = rotation; |
|
391 |
} |
|
441 |
|
|
392 | 442 |
|
393 | 443 |
/** |
394 |
* Devuelve la rotaci?n del texto. |
|
395 |
* |
|
396 |
* @return Rotaci?n del texto. |
|
397 |
*/ |
|
398 |
public double getRotation() { |
|
399 |
return m_rotation; |
|
400 |
} |
|
401 |
|
|
402 |
/** |
|
403 | 444 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity() |
404 | 445 |
*/ |
405 | 446 |
public XMLEntity getXMLEntity() { |
... | ... | |
416 | 457 |
String[] s = (String[]) m_text.toArray(new String[0]); |
417 | 458 |
xml.putProperty("s", s); |
418 | 459 |
xml.putProperty("m_isFixed", m_isFixed); |
419 |
|
|
460 |
xml.putProperty("m_rotation",getRotation()); |
|
420 | 461 |
xml.putProperty("m_pos", m_pos); |
421 |
xml.putProperty("m_rotation", m_rotation); |
|
462 |
|
|
422 | 463 |
xml.putProperty("fontName", m_f.getFontName()); |
423 | 464 |
xml.putProperty("fontStyle", m_f.getStyle()); |
424 | 465 |
xml.putProperty("tag", getTag()); |
425 |
xml.putProperty("textColor",StringUtilities.color2String(textColor)); |
|
426 |
|
|
466 |
xml.putProperty("textColor", StringUtilities.color2String(textColor));
|
|
467 |
|
|
427 | 468 |
// jaume |
428 | 469 |
xml.putProperty("cellPadding", cellPadding); |
429 | 470 |
xml.putProperty("fontSize", fontSize); |
... | ... | |
435 | 476 |
xml.putProperty("frameBorderSize", frameBorderSize); |
436 | 477 |
xml.putProperty("frameColor", StringUtilities.color2String(frameColor)); |
437 | 478 |
xml.putProperty("titleColor", StringUtilities.color2String(titleColor)); |
479 |
|
|
438 | 480 |
return xml; |
439 | 481 |
} |
440 |
|
|
482 |
|
|
441 | 483 |
/** |
442 | 484 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity, |
443 | 485 |
* com.iver.cit.gvsig.project.Project) |
... | ... | |
457 | 499 |
|
458 | 500 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
459 | 501 |
this.m_pos = xml.getIntProperty("m_pos"); |
460 |
this.m_rotation = xml.getDoubleProperty("m_rotation"); |
|
502 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
503 |
|
|
461 | 504 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
462 | 505 |
xml.getIntProperty("fontStyle"), 9); |
463 |
if (xml.contains("textColor")) |
|
464 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty("textColor")); |
|
465 |
|
|
506 |
|
|
507 |
if (xml.contains("textColor")) { |
|
508 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty( |
|
509 |
"textColor")); |
|
510 |
} |
|
466 | 511 |
} |
467 |
|
|
512 |
|
|
468 | 513 |
/** |
469 | 514 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity, |
470 | 515 |
* com.iver.cit.gvsig.project.Project) |
... | ... | |
484 | 529 |
|
485 | 530 |
this.m_isFixed = xml.getBooleanProperty("m_isFixed"); |
486 | 531 |
this.m_pos = xml.getIntProperty("m_pos"); |
487 |
this.m_rotation = xml.getDoubleProperty("m_rotation");
|
|
532 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
|
488 | 533 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
489 | 534 |
xml.getIntProperty("fontStyle"), 9); |
490 |
if (xml.contains("textColor")){ |
|
491 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty("textColor")); |
|
535 |
|
|
536 |
if (xml.contains("textColor")) { |
|
537 |
this.textColor = StringUtilities.string2Color(xml.getStringProperty( |
|
538 |
"textColor")); |
|
492 | 539 |
} |
493 |
|
|
540 |
|
|
494 | 541 |
// jaume |
495 |
if (xml.contains("cellPadding")) |
|
496 |
this.cellPadding = xml.getIntProperty("cellPadding"); |
|
497 |
if (xml.contains("fontSize")) |
|
498 |
this.fontSize = xml.getIntProperty("fontSize"); |
|
499 |
if (xml.contains("fixedFontSize")) |
|
500 |
this.fixedFontSize = xml.getBooleanProperty("fixedFontSize"); |
|
501 |
if (xml.contains("surrounded")) |
|
502 |
this.surrounded = xml.getBooleanProperty("surrounded"); |
|
503 |
if (xml.contains("hasTitle")) |
|
504 |
this.hasTitle = xml.getBooleanProperty("hasTitle"); |
|
505 |
if (xml.contains("title")) |
|
506 |
this.title = xml.getStringProperty("title"); |
|
507 |
if (xml.contains("titleSize")) |
|
508 |
this.titleSize = xml.getIntProperty("titleSize"); |
|
509 |
if (xml.contains("frameBorderSize")) |
|
510 |
this.frameBorderSize = xml.getIntProperty("frameBorderSize"); |
|
511 |
if (xml.contains("frameColor")) |
|
512 |
this.frameColor = StringUtilities.string2Color(xml.getStringProperty("frameColor")); |
|
513 |
if (xml.contains("titleColor")) |
|
514 |
this.titleColor = StringUtilities.string2Color(xml.getStringProperty("titleColor")); |
|
515 |
|
|
542 |
if (xml.contains("cellPadding")) { |
|
543 |
this.cellPadding = xml.getIntProperty("cellPadding"); |
|
544 |
} |
|
545 |
|
|
546 |
if (xml.contains("fontSize")) { |
|
547 |
this.fontSize = xml.getIntProperty("fontSize"); |
|
548 |
} |
|
549 |
|
|
550 |
if (xml.contains("fixedFontSize")) { |
|
551 |
this.fixedFontSize = xml.getBooleanProperty("fixedFontSize"); |
|
552 |
} |
|
553 |
|
|
554 |
if (xml.contains("surrounded")) { |
|
555 |
this.surrounded = xml.getBooleanProperty("surrounded"); |
|
556 |
} |
|
557 |
|
|
558 |
if (xml.contains("hasTitle")) { |
|
559 |
this.hasTitle = xml.getBooleanProperty("hasTitle"); |
|
560 |
} |
|
561 |
|
|
562 |
if (xml.contains("title")) { |
|
563 |
this.title = xml.getStringProperty("title"); |
|
564 |
} |
|
565 |
|
|
566 |
if (xml.contains("titleSize")) { |
|
567 |
this.titleSize = xml.getIntProperty("titleSize"); |
|
568 |
} |
|
569 |
|
|
570 |
if (xml.contains("frameBorderSize")) { |
|
571 |
this.frameBorderSize = xml.getIntProperty("frameBorderSize"); |
|
572 |
} |
|
573 |
|
|
574 |
if (xml.contains("frameColor")) { |
|
575 |
this.frameColor = StringUtilities.string2Color(xml.getStringProperty( |
|
576 |
"frameColor")); |
|
577 |
} |
|
578 |
|
|
579 |
if (xml.contains("titleColor")) { |
|
580 |
this.titleColor = StringUtilities.string2Color(xml.getStringProperty( |
|
581 |
"titleColor")); |
|
582 |
} |
|
516 | 583 |
} |
517 | 584 |
|
518 | 585 |
/** |
... | ... | |
522 | 589 |
return PluginServices.getText(this, "texto") + num; |
523 | 590 |
} |
524 | 591 |
|
525 |
/** |
|
526 |
* Sets FFrameText to draw an involving rectangle |
|
527 |
* @param b |
|
528 |
*/ |
|
529 |
public void setSurrounded(boolean b) { |
|
530 |
surrounded = b; |
|
531 |
} |
|
532 |
|
|
533 |
/** |
|
534 |
* True if the FFrameText is set to draw an involving rectangle, or false |
|
535 |
* if not. |
|
536 |
* @return boolean |
|
537 |
*/ |
|
538 |
public boolean isSurrounded(){ |
|
539 |
return surrounded; |
|
540 |
} |
|
541 |
/** |
|
542 |
* Sets the gap between the involving rectangle and the text |
|
543 |
* @param i |
|
544 |
*/ |
|
545 |
public void setCellPadding(int i) { |
|
546 |
cellPadding = i; |
|
547 |
} |
|
548 |
|
|
592 |
/** |
|
593 |
* Sets FFrameText to draw an involving rectangle |
|
594 |
* |
|
595 |
* @param b |
|
596 |
*/ |
|
597 |
public void setSurrounded(boolean b) { |
|
598 |
surrounded = b; |
|
599 |
} |
|
549 | 600 |
|
550 |
/** |
|
551 |
* @return |
|
552 |
*/ |
|
553 |
public boolean hasTitle() { |
|
554 |
return hasTitle; |
|
555 |
} |
|
601 |
/** |
|
602 |
* True if the FFrameText is set to draw an involving rectangle, or false |
|
603 |
* if not. |
|
604 |
* |
|
605 |
* @return boolean |
|
606 |
*/ |
|
607 |
public boolean isSurrounded() { |
|
608 |
return surrounded; |
|
609 |
} |
|
556 | 610 |
|
557 |
/** |
|
558 |
* @return |
|
559 |
*/ |
|
560 |
public String getTitle() { |
|
561 |
return title; |
|
562 |
} |
|
611 |
/** |
|
612 |
* Sets the gap between the involving rectangle and the text |
|
613 |
* |
|
614 |
* @param i |
|
615 |
*/ |
|
616 |
public void setCellPadding(int i) { |
|
617 |
cellPadding = i; |
|
618 |
} |
|
563 | 619 |
|
564 |
/** |
|
565 |
* @param b |
|
566 |
*/ |
|
567 |
public void setHasTitle(boolean b) { |
|
568 |
hasTitle = b; |
|
569 |
} |
|
620 |
/** |
|
621 |
* DOCUMENT ME! |
|
622 |
* |
|
623 |
* @return |
|
624 |
*/ |
|
625 |
public boolean hasTitle() { |
|
626 |
return hasTitle; |
|
627 |
} |
|
570 | 628 |
|
571 |
/** |
|
572 |
* @param text |
|
573 |
*/ |
|
574 |
public void setTitle(String text) { |
|
575 |
title = text; |
|
576 |
} |
|
629 |
/** |
|
630 |
* DOCUMENT ME! |
|
631 |
* |
|
632 |
* @return |
|
633 |
*/ |
|
634 |
public String getTitle() { |
|
635 |
return title; |
|
636 |
} |
|
577 | 637 |
|
578 |
/** |
|
579 |
* @return |
|
580 |
*/ |
|
581 |
public int getTitleSize() { |
|
582 |
return titleSize; |
|
583 |
} |
|
584 |
|
|
585 |
public void setTitleSize(int size) { |
|
586 |
titleSize = size; |
|
587 |
} |
|
638 |
/** |
|
639 |
* DOCUMENT ME! |
|
640 |
* |
|
641 |
* @param b |
|
642 |
*/ |
|
643 |
public void setHasTitle(boolean b) { |
|
644 |
hasTitle = b; |
|
645 |
} |
|
588 | 646 |
|
589 |
/** |
|
590 |
* @param i |
|
591 |
*/ |
|
592 |
public void setFrameBorderSize(int size) { |
|
593 |
frameBorderSize = size; |
|
594 |
} |
|
647 |
/** |
|
648 |
* DOCUMENT ME! |
|
649 |
* |
|
650 |
* @param text |
|
651 |
*/ |
|
652 |
public void setTitle(String text) { |
|
653 |
title = text; |
|
654 |
} |
|
595 | 655 |
|
596 |
/** |
|
597 |
* @return |
|
598 |
*/ |
|
599 |
public int getFrameBorderSize() { |
|
600 |
return frameBorderSize; |
|
601 |
} |
|
656 |
/** |
|
657 |
* DOCUMENT ME! |
|
658 |
* |
|
659 |
* @return |
|
660 |
*/ |
|
661 |
public int getTitleSize() { |
|
662 |
return titleSize; |
|
663 |
} |
|
602 | 664 |
|
603 |
/** |
|
604 |
* @param frameColor |
|
605 |
*/ |
|
606 |
public void setFrameColor(Color frameColor) { |
|
607 |
this.frameColor = frameColor; |
|
608 |
} |
|
609 |
|
|
610 |
public void setTitleColor(Color titleColor) { |
|
611 |
this.titleColor = titleColor; |
|
612 |
} |
|
613 |
|
|
614 |
public Color getFrameColor(){ |
|
615 |
return frameColor; |
|
616 |
} |
|
617 |
|
|
618 |
public Color getTitleColor(){ |
|
619 |
return titleColor; |
|
620 |
} |
|
621 |
|
|
622 |
/** |
|
623 |
* Use this method if you want the text in the FFrameText to be removed. |
|
624 |
* |
|
625 |
*/ |
|
626 |
public void clearText(){ |
|
627 |
m_text.clear(); |
|
628 |
} |
|
665 |
/** |
|
666 |
* DOCUMENT ME! |
|
667 |
* |
|
668 |
* @param size DOCUMENT ME! |
|
669 |
*/ |
|
670 |
public void setTitleSize(int size) { |
|
671 |
titleSize = size; |
|
672 |
} |
|
673 |
|
|
674 |
/** |
|
675 |
* DOCUMENT ME! |
|
676 |
* |
|
677 |
* @param size |
|
678 |
*/ |
|
679 |
public void setFrameBorderSize(int size) { |
|
680 |
frameBorderSize = size; |
|
681 |
} |
|
682 |
|
|
683 |
/** |
|
684 |
* DOCUMENT ME! |
|
685 |
* |
|
686 |
* @return |
|
687 |
*/ |
|
688 |
public int getFrameBorderSize() { |
|
689 |
return frameBorderSize; |
|
690 |
} |
|
691 |
|
|
692 |
/** |
|
693 |
* DOCUMENT ME! |
|
694 |
* |
|
695 |
* @param frameColor |
|
696 |
*/ |
|
697 |
public void setFrameColor(Color frameColor) { |
|
698 |
this.frameColor = frameColor; |
|
699 |
} |
|
700 |
|
|
701 |
/** |
|
702 |
* DOCUMENT ME! |
|
703 |
* |
|
704 |
* @param titleColor DOCUMENT ME! |
|
705 |
*/ |
|
706 |
public void setTitleColor(Color titleColor) { |
|
707 |
this.titleColor = titleColor; |
|
708 |
} |
|
709 |
|
|
710 |
/** |
|
711 |
* DOCUMENT ME! |
|
712 |
* |
|
713 |
* @return DOCUMENT ME! |
|
714 |
*/ |
|
715 |
public Color getFrameColor() { |
|
716 |
return frameColor; |
|
717 |
} |
|
718 |
|
|
719 |
/** |
|
720 |
* DOCUMENT ME! |
|
721 |
* |
|
722 |
* @return DOCUMENT ME! |
|
723 |
*/ |
|
724 |
public Color getTitleColor() { |
|
725 |
return titleColor; |
|
726 |
} |
|
727 |
|
|
728 |
/** |
|
729 |
* Use this method if you want the text in the FFrameText to be removed. |
|
730 |
*/ |
|
731 |
public void clearText() { |
|
732 |
m_text.clear(); |
|
733 |
} |
|
629 | 734 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameSymbol.java | ||
---|---|---|
88 | 88 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
89 | 89 |
BufferedImage imgBase) { |
90 | 90 |
Rectangle2D.Double re = getBoundingBox(at); |
91 |
|
|
91 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
|
92 |
re.y + (re.height / 2)); |
|
92 | 93 |
if (intersects(rv, re)) { |
93 | 94 |
Rectangle r = new Rectangle((int) re.x, (int) re.y, (int) re.width, |
94 | 95 |
(int) re.height); |
... | ... | |
102 | 103 |
//pSD.draw(g, r, m_type); |
103 | 104 |
FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol); |
104 | 105 |
} |
106 |
g.rotate(Math.toRadians(-getRotation()), |
|
107 |
re.x + (re.width / 2), re.y + (re.height / 2)); |
|
105 | 108 |
} |
106 | 109 |
|
107 | 110 |
/** |
... | ... | |
129 | 132 |
xml.putProperty("m_Selected", m_Selected); |
130 | 133 |
xml.putProperty("type", Layout.RECTANGLESYMBOL); |
131 | 134 |
xml.putProperty("tag", getTag()); |
132 |
|
|
135 |
xml.putProperty("m_rotation",getRotation()); |
|
133 | 136 |
xml.addChild(m_Symbol.getXMLEntity()); |
134 | 137 |
|
135 | 138 |
return xml; |
... | ... | |
179 | 182 |
} else { |
180 | 183 |
this.setSelected(false); |
181 | 184 |
} |
182 |
|
|
185 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
183 | 186 |
this.m_Symbol = FSymbol.createFromXML(xml.getChild(0)); |
184 | 187 |
} |
185 | 188 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Layout.java | ||
---|---|---|
590 | 590 |
if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { |
591 | 591 |
Rectangle2D rectangle = fframe.getMovieRect(difx, |
592 | 592 |
dify); |
593 |
|
|
593 |
((Graphics2D)g).rotate(Math.toRadians(fframe.getRotation()), rectangle.getX() + (rectangle.getWidth() / 2), |
|
594 |
rectangle.getY() + (rectangle.getHeight() / 2)); |
|
594 | 595 |
if (rectangle != null) { |
595 | 596 |
if (isCuadricula) { |
596 | 597 |
FLayoutUtilities.setRectGrid(rectangle, |
... | ... | |
604 | 605 |
(int) rectangle.getWidth(), |
605 | 606 |
(int) rectangle.getHeight()); |
606 | 607 |
} |
608 |
((Graphics2D)g).rotate(Math.toRadians(-fframe.getRotation()), |
|
609 |
rectangle.getX() + (rectangle.getWidth() / 2), rectangle.getY() + (rectangle.getHeight() / 2)); |
|
607 | 610 |
} |
608 | 611 |
} |
609 | 612 |
} |
Also available in: Unified diff