root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameBasic.java @ 24759
History | View | Annotate | Download (9.33 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 javax.print.attribute.PrintRequestAttributeSet; |
57 |
|
58 |
import org.gvsig.fmap.dal.exception.ReadException; |
59 |
import org.gvsig.fmap.geom.Geometry; |
60 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol; |
61 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleLineSymbol; |
62 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
63 |
|
64 |
import com.iver.andami.PluginServices; |
65 |
import com.iver.cit.gvsig.ProjectExtension; |
66 |
import com.iver.cit.gvsig.project.Project; |
67 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
68 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
69 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
70 |
import com.iver.cit.gvsig.project.documents.layout.geometryadapters.PolygonAdapter; |
71 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
72 |
import com.iver.utiles.XMLEntity; |
73 |
|
74 |
|
75 |
/**
|
76 |
* FFrame b?sica que contiene una FFrame de cualquier tipo.
|
77 |
*
|
78 |
* @author Vicente Caballero Navarro
|
79 |
*/
|
80 |
public class FFrameBasic extends FFrame { |
81 |
|
82 |
private FFrameGraphics fframeGraphics;
|
83 |
private IFFrame fframe;
|
84 |
|
85 |
|
86 |
public void setRectangle(Rectangle2D r){ |
87 |
FFrameGraphics graphics =(FFrameGraphics)FrameFactory.createFrameFromName(FFrameGraphicsFactory.registerName); |
88 |
graphics.setLayout(getLayout()); |
89 |
PolygonAdapter pa=new PolygonAdapter();
|
90 |
pa.addPoint(new Point2D.Double(r.getX(),r.getY())); |
91 |
pa.addPoint(new Point2D.Double(r.getMaxX(),r.getY())); |
92 |
pa.addPoint(new Point2D.Double(r.getMaxX(),r.getMaxY())); |
93 |
pa.addPoint(new Point2D.Double(r.getX(),r.getMaxY())); |
94 |
pa.addPoint(new Point2D.Double(r.getX(),r.getY())); |
95 |
pa.end(); |
96 |
graphics.setGeometryAdapter(pa); |
97 |
graphics.setBoundBox(r); |
98 |
|
99 |
/*
|
100 |
* jaume; moved to ISymbol
|
101 |
* FSymbol symbol=new FSymbol(FShape.POLYGON,Color.black);
|
102 |
* symbol.setColor(new Color(255,255,255,0));
|
103 |
* symbol.setOutlineColor(Color.black);
|
104 |
*/
|
105 |
|
106 |
IFillSymbol symbol= SymbologyFactory.createDefaultFillSymbol(); |
107 |
symbol.setFillColor(new Color(255,255,255,0)); |
108 |
SimpleLineSymbol blackOutline = new SimpleLineSymbol();
|
109 |
blackOutline.setLineColor(Color.BLACK);
|
110 |
symbol.setOutline(blackOutline); |
111 |
graphics.setSymbol(symbol); |
112 |
graphics.setType(Geometry.TYPES.CURVE); |
113 |
setFframeGraphics(graphics); |
114 |
} |
115 |
public FFrameBasic(){
|
116 |
|
117 |
} |
118 |
/**
|
119 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
120 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
121 |
* de dibujar.
|
122 |
*
|
123 |
* @param g Graphics
|
124 |
* @param at Transformada afin.
|
125 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
126 |
* @param imgBase Imagen para acelerar el dibujado.
|
127 |
*/
|
128 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
129 |
BufferedImage imgBase) throws ReadException { |
130 |
fframeGraphics.draw(g,at,rv,imgBase); |
131 |
if (fframe!=null) { |
132 |
fframe.draw(g,at,rv,imgBase); |
133 |
} |
134 |
} |
135 |
|
136 |
/**
|
137 |
* DOCUMENT ME!
|
138 |
*
|
139 |
* @return DOCUMENT ME!
|
140 |
*
|
141 |
* @throws SaveException
|
142 |
*
|
143 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
144 |
*/
|
145 |
public XMLEntity getXMLEntity() throws SaveException { |
146 |
XMLEntity xml = super.getXMLEntity();
|
147 |
xml.addChild(fframeGraphics.getXMLEntity()); |
148 |
if (fframe!=null) { |
149 |
xml.addChild(fframe.getXMLEntity()); |
150 |
} |
151 |
return xml;
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* Incorpora los atributos del XMLEntity en el objeto actual.
|
156 |
*
|
157 |
* @param xml XMLEntity
|
158 |
* @param l Referencia al Layout.
|
159 |
*/
|
160 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
161 |
} |
162 |
|
163 |
/**
|
164 |
* Incorpora los atributos del XMLEntity en el objeto actual.
|
165 |
*
|
166 |
* @param xml XMLEntity
|
167 |
*/
|
168 |
public void setXMLEntity(XMLEntity xml) { |
169 |
ProjectExtension pe=(ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
170 |
Project project=pe.getProject(); |
171 |
try {
|
172 |
FFrameGraphics fframeGraphics = (FFrameGraphics)createFromXML(xml.getChild(0),project,null); |
173 |
this.setFframeGraphics(fframeGraphics);
|
174 |
} catch (OpenException e1) {
|
175 |
e1.printStackTrace(); |
176 |
} |
177 |
if (xml.getChildrenCount()>1){ |
178 |
try {
|
179 |
IFFrame fframe=FFrame.createFromXML(xml.getChild(1),project,null); |
180 |
this.setFframe(fframe);
|
181 |
} catch (OpenException e) {
|
182 |
e.printStackTrace(); |
183 |
} |
184 |
} |
185 |
} |
186 |
|
187 |
/**
|
188 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
189 |
*/
|
190 |
public String getNameFFrame() { |
191 |
return PluginServices.getText(this, "base") + num; |
192 |
} |
193 |
|
194 |
/**
|
195 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
196 |
* java.awt.geom.AffineTransform)
|
197 |
*/
|
198 |
public void print(Graphics2D g, AffineTransform at,Geometry geom, PrintRequestAttributeSet printingProperties) |
199 |
throws ReadException {
|
200 |
// fframeGraphics.setPrintingProperties(printingProperties);
|
201 |
fframeGraphics.print(g,at,geom, printingProperties); |
202 |
// fframeGraphics.setPrintingProperties(null);
|
203 |
if (fframe!=null) { |
204 |
fframe.print(g,at,geom, printingProperties); |
205 |
} |
206 |
} |
207 |
|
208 |
public IFFrame getFframe() {
|
209 |
return fframe;
|
210 |
} |
211 |
|
212 |
public void setFframe(IFFrame fframe) { |
213 |
this.fframe = fframe;
|
214 |
} |
215 |
|
216 |
public FFrameGraphics getFframeGraphics() {
|
217 |
return fframeGraphics;
|
218 |
} |
219 |
|
220 |
public void setFframeGraphics(FFrameGraphics fframeGraphics) { |
221 |
this.fframeGraphics = fframeGraphics;
|
222 |
} |
223 |
|
224 |
public void drawHandlers(Graphics2D g) { |
225 |
fframeGraphics.drawHandlers(g); |
226 |
} |
227 |
|
228 |
public IFFrame cloneFFrame(Layout layout) {
|
229 |
FFrameBasic basic=new FFrameBasic();
|
230 |
basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout)); |
231 |
if (fframe!=null) { |
232 |
basic.setFframe(fframe.cloneFFrame(layout)); |
233 |
} |
234 |
return basic;
|
235 |
} |
236 |
|
237 |
public boolean contains(Double p) { |
238 |
return getFframeGraphics().contains(p);
|
239 |
} |
240 |
|
241 |
public void drawDraft(Graphics2D g) { |
242 |
super.drawDraft(g);
|
243 |
} |
244 |
|
245 |
public void drawEmpty(Graphics2D g) { |
246 |
super.drawEmpty(g);
|
247 |
} |
248 |
|
249 |
public void drawSymbolTag(Graphics2D g) { |
250 |
super.drawSymbolTag(g);
|
251 |
} |
252 |
|
253 |
public java.awt.geom.Rectangle2D.Double getBoundBox() {
|
254 |
return getFframeGraphics().getBoundBox();
|
255 |
} |
256 |
|
257 |
public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) { |
258 |
return getFframeGraphics().getBoundingBox(at);
|
259 |
} |
260 |
|
261 |
public int getContains(Double p) { |
262 |
return getFframeGraphics().getContains(p);
|
263 |
} |
264 |
|
265 |
public int getLevel() { |
266 |
return super.getLevel(); |
267 |
} |
268 |
|
269 |
public Rectangle2D getMovieRect(int difx, int dify) { |
270 |
return fframeGraphics.getMovieRect(difx, dify);
|
271 |
} |
272 |
|
273 |
public String getName() { |
274 |
return super.getName(); |
275 |
} |
276 |
|
277 |
public double getRotation() { |
278 |
return super.getRotation(); |
279 |
} |
280 |
|
281 |
public int getSelected() { |
282 |
return fframeGraphics.getSelected();
|
283 |
} |
284 |
|
285 |
public String getTag() { |
286 |
return super.getTag(); |
287 |
} |
288 |
|
289 |
public boolean intersects(Rectangle2D rv, Rectangle2D r) { |
290 |
return super.intersects(rv, r); |
291 |
} |
292 |
|
293 |
public void openTag() { |
294 |
super.openTag();
|
295 |
} |
296 |
|
297 |
public void setBoundBox(Rectangle2D r) { |
298 |
if (getFframeGraphics()!=null) { |
299 |
getFframeGraphics().setBoundBox(r); |
300 |
} |
301 |
if (getFframe() != null) { |
302 |
getFframe().setBoundBox(r); |
303 |
//super.setBoundBox(r);
|
304 |
} |
305 |
} |
306 |
|
307 |
public void setLevel(int l) { |
308 |
super.setLevel(l);
|
309 |
} |
310 |
|
311 |
public void setName(String n) { |
312 |
super.setName(n);
|
313 |
} |
314 |
|
315 |
public void setNum(int i) { |
316 |
super.setNum(i);
|
317 |
} |
318 |
|
319 |
public void setRotation(double rotation) { |
320 |
super.setRotation(rotation);
|
321 |
} |
322 |
|
323 |
public void setSelected(boolean b) { |
324 |
fframeGraphics.setSelected(b); |
325 |
} |
326 |
|
327 |
public void setSelected(Point2D p,MouseEvent e) { |
328 |
fframeGraphics.setSelected(p,e); |
329 |
} |
330 |
|
331 |
public void setTag(String s) { |
332 |
super.setTag(s);
|
333 |
} |
334 |
|
335 |
public void updateRect(Rectangle2D r, AffineTransform at) { |
336 |
getFframeGraphics().updateRect(r, at); |
337 |
} |
338 |
public void cloneActions(IFFrame frame) { |
339 |
// TODO Auto-generated method stub
|
340 |
|
341 |
} |
342 |
public IFFrameDialog getPropertyDialog() {
|
343 |
// TODO Auto-generated method stub
|
344 |
return null; |
345 |
} |
346 |
} |