root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameBasic.java @ 20910
History | View | Annotate | Download (8.29 KB)
1 | 4779 | caballero | /*
|
---|---|---|---|
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.gui.layout.fframes; |
||
46 | |||
47 | import java.awt.Color; |
||
48 | import java.awt.Cursor; |
||
49 | import java.awt.Graphics2D; |
||
50 | import java.awt.event.MouseEvent; |
||
51 | import java.awt.geom.AffineTransform; |
||
52 | import java.awt.geom.Point2D; |
||
53 | import java.awt.geom.Rectangle2D; |
||
54 | import java.awt.geom.Point2D.Double; |
||
55 | import java.awt.image.BufferedImage; |
||
56 | |||
57 | import com.iver.andami.PluginServices; |
||
58 | import com.iver.cit.gvsig.ProjectExtension; |
||
59 | import com.iver.cit.gvsig.fmap.DriverException; |
||
60 | import com.iver.cit.gvsig.fmap.core.FShape; |
||
61 | import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter; |
||
62 | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
||
63 | import com.iver.cit.gvsig.gui.layout.Layout; |
||
64 | import com.iver.cit.gvsig.project.Project; |
||
65 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
66 | import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
||
67 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
||
68 | 4779 | caballero | import com.iver.utiles.XMLEntity; |
69 | |||
70 | |||
71 | /**
|
||
72 | * FFrame b?sica que contiene una FFrame de cualquier tipo.
|
||
73 | *
|
||
74 | * @author Vicente Caballero Navarro
|
||
75 | */
|
||
76 | public class FFrameBasic extends FFrame { |
||
77 | |||
78 | private FFrameGraphics fframeGraphics;
|
||
79 | private IFFrame fframe;
|
||
80 | |||
81 | |||
82 | public FFrameBasic(Rectangle2D r){ |
||
83 | FFrameGraphics graphics=new FFrameGraphics();
|
||
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 | * @throws DriverException
|
||
112 | */
|
||
113 | public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
||
114 | BufferedImage imgBase) throws DriverException { |
||
115 | fframeGraphics.draw(g,at,rv,imgBase); |
||
116 | if (fframe!=null) |
||
117 | fframe.draw(g,at,rv,imgBase); |
||
118 | } |
||
119 | |||
120 | /**
|
||
121 | * DOCUMENT ME!
|
||
122 | *
|
||
123 | * @return DOCUMENT ME!
|
||
124 | *
|
||
125 | * @throws SaveException
|
||
126 | *
|
||
127 | 8765 | jjdelcerro | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
128 | 4779 | caballero | */
|
129 | public XMLEntity getXMLEntity() throws SaveException { |
||
130 | XMLEntity xml = super.getXMLEntity();
|
||
131 | xml.addChild(fframeGraphics.getXMLEntity()); |
||
132 | if (fframe!=null) |
||
133 | xml.addChild(fframe.getXMLEntity()); |
||
134 | return xml;
|
||
135 | } |
||
136 | |||
137 | /**
|
||
138 | * Incorpora los atributos del XMLEntity en el objeto actual.
|
||
139 | *
|
||
140 | * @param xml XMLEntity
|
||
141 | * @param l Referencia al Layout.
|
||
142 | */
|
||
143 | public void setXMLEntity03(XMLEntity xml, Layout l) { |
||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * Incorpora los atributos del XMLEntity en el objeto actual.
|
||
148 | *
|
||
149 | * @param xml XMLEntity
|
||
150 | */
|
||
151 | public void setXMLEntity(XMLEntity xml) { |
||
152 | ProjectExtension pe=(ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
||
153 | Project project=pe.getProject(); |
||
154 | try {
|
||
155 | 5642 | caballero | FFrameGraphics fframeGraphics = (FFrameGraphics)createFFrame(xml.getChild(0),project,null); |
156 | 4779 | caballero | this.setFframeGraphics(fframeGraphics);
|
157 | } catch (OpenException e1) {
|
||
158 | e1.printStackTrace(); |
||
159 | } |
||
160 | 6864 | jaume | if (xml.getChildrenCount()>1){ |
161 | 4779 | caballero | try {
|
162 | 5642 | caballero | IFFrame fframe=FFrame.createFFrame(xml.getChild(1),project,null); |
163 | 4779 | caballero | this.setFframe(fframe);
|
164 | } catch (OpenException e) {
|
||
165 | e.printStackTrace(); |
||
166 | } |
||
167 | } |
||
168 | } |
||
169 | |||
170 | /**
|
||
171 | 8765 | jjdelcerro | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
172 | 4779 | caballero | */
|
173 | public String getNameFFrame() { |
||
174 | return PluginServices.getText(this, "base") + num; |
||
175 | } |
||
176 | |||
177 | /**
|
||
178 | 8765 | jjdelcerro | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
179 | 4779 | caballero | * java.awt.geom.AffineTransform)
|
180 | */
|
||
181 | public void print(Graphics2D g, AffineTransform at) |
||
182 | throws DriverException {
|
||
183 | draw(g, at, null, null); |
||
184 | } |
||
185 | |||
186 | public IFFrame getFframe() {
|
||
187 | return fframe;
|
||
188 | } |
||
189 | |||
190 | public void setFframe(IFFrame fframe) { |
||
191 | this.fframe = fframe;
|
||
192 | } |
||
193 | |||
194 | public FFrameGraphics getFframeGraphics() {
|
||
195 | return fframeGraphics;
|
||
196 | } |
||
197 | |||
198 | public void setFframeGraphics(FFrameGraphics fframeGraphics) { |
||
199 | this.fframeGraphics = fframeGraphics;
|
||
200 | } |
||
201 | |||
202 | public void drawHandlers(Graphics2D g) { |
||
203 | fframeGraphics.drawHandlers(g); |
||
204 | } |
||
205 | |||
206 | public IFFrame cloneFFrame(Layout layout) {
|
||
207 | FFrameBasic basic=new FFrameBasic();
|
||
208 | basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout)); |
||
209 | if (fframe!=null) |
||
210 | basic.setFframe(fframe.cloneFFrame(layout)); |
||
211 | return basic;
|
||
212 | } |
||
213 | |||
214 | public boolean contains(Double p) { |
||
215 | return getFframeGraphics().contains(p);
|
||
216 | } |
||
217 | |||
218 | public void drawDraft(Graphics2D g) { |
||
219 | super.drawDraft(g);
|
||
220 | } |
||
221 | |||
222 | public void drawEmpty(Graphics2D g) { |
||
223 | super.drawEmpty(g);
|
||
224 | } |
||
225 | |||
226 | public void drawSymbolTag(Graphics2D g) { |
||
227 | super.drawSymbolTag(g);
|
||
228 | } |
||
229 | |||
230 | public java.awt.geom.Rectangle2D.Double getBoundBox() {
|
||
231 | return getFframeGraphics().getBoundBox();
|
||
232 | } |
||
233 | |||
234 | public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) { |
||
235 | return getFframeGraphics().getBoundingBox(at);
|
||
236 | } |
||
237 | |||
238 | public int getContains(Double p) { |
||
239 | return getFframeGraphics().getContains(p);
|
||
240 | } |
||
241 | |||
242 | public int getLevel() { |
||
243 | return super.getLevel(); |
||
244 | } |
||
245 | |||
246 | public Cursor getMapCursor(Double p) { |
||
247 | return super.getMapCursor(p); |
||
248 | } |
||
249 | |||
250 | public Rectangle2D getMovieRect(int difx, int dify) { |
||
251 | return fframeGraphics.getMovieRect(difx, dify);
|
||
252 | } |
||
253 | |||
254 | public String getName() { |
||
255 | return super.getName(); |
||
256 | } |
||
257 | |||
258 | public double getRotation() { |
||
259 | return super.getRotation(); |
||
260 | } |
||
261 | |||
262 | public int getSelected() { |
||
263 | return fframeGraphics.getSelected();
|
||
264 | } |
||
265 | |||
266 | public String getTag() { |
||
267 | return super.getTag(); |
||
268 | } |
||
269 | |||
270 | public boolean intersects(Rectangle2D rv, Rectangle2D r) { |
||
271 | return super.intersects(rv, r); |
||
272 | } |
||
273 | |||
274 | public void openTag() { |
||
275 | super.openTag();
|
||
276 | } |
||
277 | |||
278 | public void setBoundBox(Rectangle2D r) { |
||
279 | 5474 | caballero | if (getFframeGraphics()!=null) |
280 | getFframeGraphics().setBoundBox(r); |
||
281 | 4779 | caballero | if (getFframe() != null) |
282 | getFframe().setBoundBox(r); |
||
283 | //super.setBoundBox(r);
|
||
284 | } |
||
285 | |||
286 | public void setLevel(int l) { |
||
287 | super.setLevel(l);
|
||
288 | } |
||
289 | |||
290 | public void setName(String n) { |
||
291 | super.setName(n);
|
||
292 | } |
||
293 | |||
294 | public void setNum(int i) { |
||
295 | super.setNum(i);
|
||
296 | } |
||
297 | |||
298 | public void setRotation(double rotation) { |
||
299 | super.setRotation(rotation);
|
||
300 | } |
||
301 | |||
302 | public void setSelected(boolean b) { |
||
303 | fframeGraphics.setSelected(b); |
||
304 | } |
||
305 | |||
306 | 4845 | caballero | public void setSelected(Point2D p,MouseEvent e) { |
307 | 4779 | caballero | fframeGraphics.setSelected(p,e); |
308 | } |
||
309 | |||
310 | public void setTag(String s) { |
||
311 | super.setTag(s);
|
||
312 | } |
||
313 | |||
314 | public void updateRect(Rectangle2D r, AffineTransform at) { |
||
315 | getFframeGraphics().updateRect(r, at); |
||
316 | } |
||
317 | 8765 | jjdelcerro | public void cloneActions(IFFrame frame) { |
318 | // TODO Auto-generated method stub
|
||
319 | |||
320 | } |
||
321 | 4779 | caballero | } |