Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameBasic.java @ 5642

History | View | Annotate | Download (8.07 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.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.gui.project.OpenException;
65
import com.iver.cit.gvsig.gui.project.SaveException;
66
import com.iver.cit.gvsig.project.Project;
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 FFrameBasic(Rectangle2D r){
82
                FFrameGraphics graphics=new FFrameGraphics();
83
        PolygonAdapter pa=new PolygonAdapter();
84
        pa.addPoint(new Point2D.Double(r.getX(),r.getY()));
85
        pa.addPoint(new Point2D.Double(r.getMaxX(),r.getY()));
86
        pa.addPoint(new Point2D.Double(r.getMaxX(),r.getMaxY()));
87
        pa.addPoint(new Point2D.Double(r.getX(),r.getMaxY()));
88
        pa.addPoint(new Point2D.Double(r.getX(),r.getY()));
89
        pa.end();
90
        graphics.setGeometryAdapter(pa);
91
        graphics.setBoundBox(r);
92
        FSymbol symbol=new FSymbol(FShape.POLYGON,Color.black);
93
        symbol.setColor(new Color(255,255,255,0));
94
        symbol.setOutlineColor(Color.black);
95
        graphics.setFSymbol(symbol);
96
        setFframeGraphics(graphics);
97
        }
98
        public FFrameBasic(){
99

    
100
        }
101
        /**
102
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
103
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
104
     * de dibujar.
105
     *
106
     * @param g Graphics
107
     * @param at Transformada afin.
108
     * @param rv rect?ngulo sobre el que hacer un clip.
109
     * @param imgBase Imagen para acelerar el dibujado.
110
     * @throws DriverException
111
     */
112
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
113
        BufferedImage imgBase) throws DriverException {
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.gui.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)createFFrame(xml.getChild(0),project,null);
155
                        this.setFframeGraphics(fframeGraphics);
156
                } catch (OpenException e1) {
157
                        e1.printStackTrace();
158
                }
159
                if (xml.getNumChild()>1){
160
                    try {
161
                                IFFrame fframe=FFrame.createFFrame(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.gui.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.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
178
     *      java.awt.geom.AffineTransform)
179
     */
180
    public void print(Graphics2D g, AffineTransform at)
181
        throws DriverException {
182
        draw(g, at, null, null);
183
    }
184

    
185
        public IFFrame getFframe() {
186
                return fframe;
187
        }
188

    
189
        public void setFframe(IFFrame fframe) {
190
                this.fframe = fframe;
191
        }
192

    
193
        public FFrameGraphics getFframeGraphics() {
194
                return fframeGraphics;
195
        }
196

    
197
        public void setFframeGraphics(FFrameGraphics fframeGraphics) {
198
                this.fframeGraphics = fframeGraphics;
199
        }
200

    
201
        public void drawHandlers(Graphics2D g) {
202
                fframeGraphics.drawHandlers(g);
203
        }
204

    
205
        public IFFrame cloneFFrame(Layout layout) {
206
                FFrameBasic basic=new FFrameBasic();
207
                basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout));
208
                if (fframe!=null)
209
                        basic.setFframe(fframe.cloneFFrame(layout));
210
                return basic;
211
        }
212

    
213
        public boolean contains(Double p) {
214
                return getFframeGraphics().contains(p);
215
        }
216

    
217
        public void drawDraft(Graphics2D g) {
218
                super.drawDraft(g);
219
        }
220

    
221
        public void drawEmpty(Graphics2D g) {
222
                super.drawEmpty(g);
223
        }
224

    
225
        public void drawSymbolTag(Graphics2D g) {
226
                super.drawSymbolTag(g);
227
        }
228

    
229
        public java.awt.geom.Rectangle2D.Double getBoundBox() {
230
                return getFframeGraphics().getBoundBox();
231
        }
232

    
233
        public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) {
234
                return getFframeGraphics().getBoundingBox(at);
235
        }
236

    
237
        public int getContains(Double p) {
238
                return getFframeGraphics().getContains(p);
239
        }
240

    
241
        public int getLevel() {
242
                return super.getLevel();
243
        }
244

    
245
        public Cursor getMapCursor(Double p) {
246
                return super.getMapCursor(p);
247
        }
248

    
249
        public Rectangle2D getMovieRect(int difx, int dify) {
250
                return fframeGraphics.getMovieRect(difx, dify);
251
        }
252

    
253
        public String getName() {
254
                return super.getName();
255
        }
256

    
257
        public double getRotation() {
258
                return super.getRotation();
259
        }
260

    
261
        public int getSelected() {
262
                return fframeGraphics.getSelected();
263
        }
264

    
265
        public String getTag() {
266
                return super.getTag();
267
        }
268

    
269
        public boolean intersects(Rectangle2D rv, Rectangle2D r) {
270
                return super.intersects(rv, r);
271
        }
272

    
273
        public void openTag() {
274
                super.openTag();
275
        }
276

    
277
        public void setBoundBox(Rectangle2D r) {
278
                if (getFframeGraphics()!=null)
279
                        getFframeGraphics().setBoundBox(r);
280
                if (getFframe() != null)
281
                        getFframe().setBoundBox(r);
282
                //super.setBoundBox(r);
283
        }
284

    
285
        public void setLevel(int l) {
286
                super.setLevel(l);
287
        }
288

    
289
        public void setName(String n) {
290
                super.setName(n);
291
        }
292

    
293
        public void setNum(int i) {
294
                super.setNum(i);
295
        }
296

    
297
        public void setRotation(double rotation) {
298
                super.setRotation(rotation);
299
        }
300

    
301
        public void setSelected(boolean b) {
302
                fframeGraphics.setSelected(b);
303
        }
304

    
305
        public void setSelected(Point2D p,MouseEvent e) {
306
                fframeGraphics.setSelected(p,e);
307
        }
308

    
309
        public void setTag(String s) {
310
                super.setTag(s);
311
        }
312

    
313
        public void updateRect(Rectangle2D r, AffineTransform at) {
314
                getFframeGraphics().updateRect(r, at);
315
        }
316
}