svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameBasic.java @ 10626
History | View | Annotate | Download (8.73 KB)
1 |
/*
|
---|---|
2 |
* Created on 20-feb-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.project.documents.layout.fframes; |
46 |
|
47 |
import java.awt.Color; |
48 |
import java.awt.Graphics2D; |
49 |
import java.awt.event.MouseEvent; |
50 |
import java.awt.geom.AffineTransform; |
51 |
import java.awt.geom.Point2D; |
52 |
import java.awt.geom.Rectangle2D; |
53 |
import java.awt.geom.Point2D.Double; |
54 |
import java.awt.image.BufferedImage; |
55 |
|
56 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
57 |
import com.iver.andami.PluginServices; |
58 |
import com.iver.cit.gvsig.ProjectExtension; |
59 |
import com.iver.cit.gvsig.fmap.core.FShape; |
60 |
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter; |
61 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
62 |
import com.iver.cit.gvsig.project.Project; |
63 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
64 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
65 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
66 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
67 |
import com.iver.utiles.XMLEntity; |
68 |
|
69 |
|
70 |
/**
|
71 |
* FFrame b?sica que contiene una FFrame de cualquier tipo.
|
72 |
*
|
73 |
* @author Vicente Caballero Navarro
|
74 |
*/
|
75 |
public class FFrameBasic extends FFrame { |
76 |
|
77 |
private FFrameGraphics fframeGraphics;
|
78 |
private IFFrame fframe;
|
79 |
|
80 |
|
81 |
public void setRectangle(Rectangle2D r){ |
82 |
FFrameGraphics graphics =(FFrameGraphics)FrameFactory.createFrameFromName(FFrameGraphicsFactory.registerName); |
83 |
graphics.setLayout(getLayout()); |
84 |
PolygonAdapter pa=new PolygonAdapter();
|
85 |
pa.addPoint(new Point2D.Double(r.getX(),r.getY())); |
86 |
pa.addPoint(new Point2D.Double(r.getMaxX(),r.getY())); |
87 |
pa.addPoint(new Point2D.Double(r.getMaxX(),r.getMaxY())); |
88 |
pa.addPoint(new Point2D.Double(r.getX(),r.getMaxY())); |
89 |
pa.addPoint(new Point2D.Double(r.getX(),r.getY())); |
90 |
pa.end(); |
91 |
graphics.setGeometryAdapter(pa); |
92 |
graphics.setBoundBox(r); |
93 |
FSymbol symbol=new FSymbol(FShape.POLYGON,Color.black); |
94 |
symbol.setColor(new Color(255,255,255,0)); |
95 |
symbol.setOutlineColor(Color.black);
|
96 |
graphics.setFSymbol(symbol); |
97 |
setFframeGraphics(graphics); |
98 |
} |
99 |
public FFrameBasic(){
|
100 |
|
101 |
} |
102 |
/**
|
103 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
104 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
105 |
* de dibujar.
|
106 |
*
|
107 |
* @param g Graphics
|
108 |
* @param at Transformada afin.
|
109 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
110 |
* @param imgBase Imagen para acelerar el dibujado.
|
111 |
*/
|
112 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
113 |
BufferedImage imgBase) throws ReadDriverException { |
114 |
fframeGraphics.draw(g,at,rv,imgBase); |
115 |
if (fframe!=null) |
116 |
fframe.draw(g,at,rv,imgBase); |
117 |
} |
118 |
|
119 |
/**
|
120 |
* DOCUMENT ME!
|
121 |
*
|
122 |
* @return DOCUMENT ME!
|
123 |
*
|
124 |
* @throws SaveException
|
125 |
*
|
126 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
127 |
*/
|
128 |
public XMLEntity getXMLEntity() throws SaveException { |
129 |
XMLEntity xml = super.getXMLEntity();
|
130 |
xml.addChild(fframeGraphics.getXMLEntity()); |
131 |
if (fframe!=null) |
132 |
xml.addChild(fframe.getXMLEntity()); |
133 |
return xml;
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* Incorpora los atributos del XMLEntity en el objeto actual.
|
138 |
*
|
139 |
* @param xml XMLEntity
|
140 |
* @param l Referencia al Layout.
|
141 |
*/
|
142 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Incorpora los atributos del XMLEntity en el objeto actual.
|
147 |
*
|
148 |
* @param xml XMLEntity
|
149 |
*/
|
150 |
public void setXMLEntity(XMLEntity xml) { |
151 |
ProjectExtension pe=(ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
152 |
Project project=pe.getProject(); |
153 |
try {
|
154 |
FFrameGraphics fframeGraphics = (FFrameGraphics)createFromXML(xml.getChild(0),project,null); |
155 |
this.setFframeGraphics(fframeGraphics);
|
156 |
} catch (OpenException e1) {
|
157 |
e1.printStackTrace(); |
158 |
} |
159 |
if (xml.getChildrenCount()>1){ |
160 |
try {
|
161 |
IFFrame fframe=FFrame.createFromXML(xml.getChild(1),project,null); |
162 |
this.setFframe(fframe);
|
163 |
} catch (OpenException e) {
|
164 |
e.printStackTrace(); |
165 |
} |
166 |
} |
167 |
} |
168 |
|
169 |
/**
|
170 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
171 |
*/
|
172 |
public String getNameFFrame() { |
173 |
return PluginServices.getText(this, "base") + num; |
174 |
} |
175 |
|
176 |
/**
|
177 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
178 |
* java.awt.geom.AffineTransform)
|
179 |
*/
|
180 |
public void print(Graphics2D g, AffineTransform at,FShape shape) |
181 |
throws ReadDriverException {
|
182 |
fframeGraphics.setPrintingProperties(printingProperties); |
183 |
fframeGraphics.print(g,at,shape); |
184 |
fframeGraphics.setPrintingProperties(null);
|
185 |
if (fframe!=null) { |
186 |
fframe.setPrintingProperties(printingProperties); |
187 |
fframe.print(g,at,shape); |
188 |
fframe.setPrintingProperties(null);
|
189 |
} |
190 |
} |
191 |
|
192 |
public IFFrame getFframe() {
|
193 |
return fframe;
|
194 |
} |
195 |
|
196 |
public void setFframe(IFFrame fframe) { |
197 |
this.fframe = fframe;
|
198 |
} |
199 |
|
200 |
public FFrameGraphics getFframeGraphics() {
|
201 |
return fframeGraphics;
|
202 |
} |
203 |
|
204 |
public void setFframeGraphics(FFrameGraphics fframeGraphics) { |
205 |
this.fframeGraphics = fframeGraphics;
|
206 |
} |
207 |
|
208 |
public void drawHandlers(Graphics2D g) { |
209 |
fframeGraphics.drawHandlers(g); |
210 |
} |
211 |
|
212 |
public IFFrame cloneFFrame(Layout layout) {
|
213 |
FFrameBasic basic=new FFrameBasic();
|
214 |
basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout)); |
215 |
if (fframe!=null) |
216 |
basic.setFframe(fframe.cloneFFrame(layout)); |
217 |
return basic;
|
218 |
} |
219 |
|
220 |
public boolean contains(Double p) { |
221 |
return getFframeGraphics().contains(p);
|
222 |
} |
223 |
|
224 |
public void drawDraft(Graphics2D g) { |
225 |
super.drawDraft(g);
|
226 |
} |
227 |
|
228 |
public void drawEmpty(Graphics2D g) { |
229 |
super.drawEmpty(g);
|
230 |
} |
231 |
|
232 |
public void drawSymbolTag(Graphics2D g) { |
233 |
super.drawSymbolTag(g);
|
234 |
} |
235 |
|
236 |
public java.awt.geom.Rectangle2D.Double getBoundBox() {
|
237 |
return getFframeGraphics().getBoundBox();
|
238 |
} |
239 |
|
240 |
public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) { |
241 |
return getFframeGraphics().getBoundingBox(at);
|
242 |
} |
243 |
|
244 |
public int getContains(Double p) { |
245 |
return getFframeGraphics().getContains(p);
|
246 |
} |
247 |
|
248 |
public int getLevel() { |
249 |
return super.getLevel(); |
250 |
} |
251 |
|
252 |
public Rectangle2D getMovieRect(int difx, int dify) { |
253 |
return fframeGraphics.getMovieRect(difx, dify);
|
254 |
} |
255 |
|
256 |
public String getName() { |
257 |
return super.getName(); |
258 |
} |
259 |
|
260 |
public double getRotation() { |
261 |
return super.getRotation(); |
262 |
} |
263 |
|
264 |
public int getSelected() { |
265 |
return fframeGraphics.getSelected();
|
266 |
} |
267 |
|
268 |
public String getTag() { |
269 |
return super.getTag(); |
270 |
} |
271 |
|
272 |
public boolean intersects(Rectangle2D rv, Rectangle2D r) { |
273 |
return super.intersects(rv, r); |
274 |
} |
275 |
|
276 |
public void openTag() { |
277 |
super.openTag();
|
278 |
} |
279 |
|
280 |
public void setBoundBox(Rectangle2D r) { |
281 |
if (getFframeGraphics()!=null) |
282 |
getFframeGraphics().setBoundBox(r); |
283 |
if (getFframe() != null) |
284 |
getFframe().setBoundBox(r); |
285 |
//super.setBoundBox(r);
|
286 |
} |
287 |
|
288 |
public void setLevel(int l) { |
289 |
super.setLevel(l);
|
290 |
} |
291 |
|
292 |
public void setName(String n) { |
293 |
super.setName(n);
|
294 |
} |
295 |
|
296 |
public void setNum(int i) { |
297 |
super.setNum(i);
|
298 |
} |
299 |
|
300 |
public void setRotation(double rotation) { |
301 |
super.setRotation(rotation);
|
302 |
} |
303 |
|
304 |
public void setSelected(boolean b) { |
305 |
fframeGraphics.setSelected(b); |
306 |
} |
307 |
|
308 |
public void setSelected(Point2D p,MouseEvent e) { |
309 |
fframeGraphics.setSelected(p,e); |
310 |
} |
311 |
|
312 |
public void setTag(String s) { |
313 |
super.setTag(s);
|
314 |
} |
315 |
|
316 |
public void updateRect(Rectangle2D r, AffineTransform at) { |
317 |
getFframeGraphics().updateRect(r, at); |
318 |
} |
319 |
public void cloneActions(IFFrame frame) { |
320 |
// TODO Auto-generated method stub
|
321 |
|
322 |
} |
323 |
public IFFrameDialog getPropertyDialog() {
|
324 |
// TODO Auto-generated method stub
|
325 |
return null; |
326 |
} |
327 |
} |