Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / fframes / FFrameBasic.java @ 29596

History | View | Annotate | Download (9.17 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 org.gvsig.app.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 org.gvsig.andami.PluginServices;
57
import org.gvsig.app.extension.ProjectExtension;
58
import org.gvsig.app.project.Project;
59
import org.gvsig.app.project.documents.exceptions.OpenException;
60
import org.gvsig.app.project.documents.exceptions.SaveException;
61
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
62
import org.gvsig.app.project.documents.layout.geometryadapters.PolygonAdapter;
63
import org.gvsig.app.project.documents.layout.gui.Layout;
64
import org.gvsig.compat.print.PrintAttributes;
65
import org.gvsig.fmap.geom.Geometry;
66
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol;
67
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleLineSymbol;
68
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
69
import org.gvsig.utils.XMLEntity;
70

    
71

    
72

    
73
/**
74
 * FFrame b?sica que contiene una FFrame de cualquier tipo.
75
 *
76
 * @author Vicente Caballero Navarro
77
 */
78
public class FFrameBasic extends FFrame {
79

    
80
        private FFrameGraphics fframeGraphics;
81
        private IFFrame fframe;
82

    
83

    
84
        public void setRectangle(Rectangle2D r){
85
                FFrameGraphics graphics =(FFrameGraphics)FrameFactory.createFrameFromName(FFrameGraphicsFactory.registerName);
86
       graphics.setLayout(getLayout());
87
        PolygonAdapter pa=new PolygonAdapter();
88
        pa.addPoint(new Point2D.Double(r.getX(),r.getY()));
89
        pa.addPoint(new Point2D.Double(r.getMaxX(),r.getY()));
90
        pa.addPoint(new Point2D.Double(r.getMaxX(),r.getMaxY()));
91
        pa.addPoint(new Point2D.Double(r.getX(),r.getMaxY()));
92
        pa.addPoint(new Point2D.Double(r.getX(),r.getY()));
93
        pa.end();
94
        graphics.setGeometryAdapter(pa);
95
        graphics.setBoundBox(r);
96

    
97
        /*
98
         * jaume; moved to ISymbol
99
         * FSymbol symbol=new FSymbol(FShape.POLYGON,Color.black);
100
         * symbol.setColor(new Color(255,255,255,0));
101
         * symbol.setOutlineColor(Color.black);
102
         */
103

    
104
        IFillSymbol symbol= SymbologyFactory.createDefaultFillSymbol();
105
        symbol.setFillColor(new Color(255,255,255,0));
106
        SimpleLineSymbol blackOutline = new SimpleLineSymbol();
107
        blackOutline.setLineColor(Color.BLACK);
108
        symbol.setOutline(blackOutline);
109
        graphics.setSymbol(symbol);
110
        graphics.setType(Geometry.TYPES.CURVE);
111
        setFframeGraphics(graphics);
112
        }
113
        public FFrameBasic(){
114

    
115
        }
116
        /**
117
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
118
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
119
     * de dibujar.
120
     *
121
     * @param g Graphics
122
     * @param at Transformada afin.
123
     * @param rv rect?ngulo sobre el que hacer un clip.
124
     * @param imgBase Imagen para acelerar el dibujado.
125
     */
126
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
127
        BufferedImage imgBase) {
128
            fframeGraphics.draw(g,at,rv,imgBase);
129
            if (fframe!=null) {
130
                        fframe.draw(g,at,rv,imgBase);
131
                }
132
    }
133

    
134
    /**
135
     * DOCUMENT ME!
136
     *
137
     * @return DOCUMENT ME!
138
     *
139
     * @throws SaveException
140
     *
141
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getXMLEntity()
142
     */
143
    public XMLEntity getXMLEntity() throws SaveException {
144
        XMLEntity xml = super.getXMLEntity();
145
        xml.addChild(fframeGraphics.getXMLEntity());
146
        if (fframe!=null) {
147
                        xml.addChild(fframe.getXMLEntity());
148
                }
149
        return xml;
150
    }
151

    
152
    /**
153
     * Incorpora los atributos del XMLEntity en el objeto actual.
154
     *
155
     * @param xml XMLEntity
156
     * @param l Referencia al Layout.
157
     */
158
    public void setXMLEntity03(XMLEntity xml, Layout l) {
159
    }
160

    
161
    /**
162
     * Incorpora los atributos del XMLEntity en el objeto actual.
163
     *
164
     * @param xml XMLEntity
165
     */
166
    public void setXMLEntity(XMLEntity xml) {
167
            ProjectExtension pe=(ProjectExtension)PluginServices.getExtension(ProjectExtension.class);
168
            Project project=pe.getProject();
169
            try {
170
                        FFrameGraphics fframeGraphics = (FFrameGraphics)createFromXML(xml.getChild(0),project,null);
171
                        this.setFframeGraphics(fframeGraphics);
172
                } catch (OpenException e1) {
173
                        e1.printStackTrace();
174
                }
175
                if (xml.getChildrenCount()>1){
176
                    try {
177
                                IFFrame fframe=FFrame.createFromXML(xml.getChild(1),project,null);
178
                                this.setFframe(fframe);
179
                    } catch (OpenException e) {
180
                                e.printStackTrace();
181
                        }
182
            }
183
    }
184

    
185
    /**
186
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNameFFrame()
187
     */
188
    public String getNameFFrame() {
189
        return PluginServices.getText(this, "base") + num;
190
    }
191

    
192
    /**
193
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
194
     *      java.awt.geom.AffineTransform)
195
     */
196
    public void print(Graphics2D g, AffineTransform at, Geometry geom,
197
                        PrintAttributes printingProperties) {
198
//            fframeGraphics.setPrintingProperties(printingProperties);
199
            fframeGraphics.print(g,at,geom, printingProperties);
200
//            fframeGraphics.setPrintingProperties(null);
201
            if (fframe!=null) {
202
                    fframe.print(g,at,geom, printingProperties);
203
            }
204
    }
205

    
206
        public IFFrame getFframe() {
207
                return fframe;
208
        }
209

    
210
        public void setFframe(IFFrame fframe) {
211
                this.fframe = fframe;
212
        }
213

    
214
        public FFrameGraphics getFframeGraphics() {
215
                return fframeGraphics;
216
        }
217

    
218
        public void setFframeGraphics(FFrameGraphics fframeGraphics) {
219
                this.fframeGraphics = fframeGraphics;
220
        }
221

    
222
        public void drawHandlers(Graphics2D g) {
223
                fframeGraphics.drawHandlers(g);
224
        }
225

    
226
        public IFFrame cloneFFrame(Layout layout) {
227
                FFrameBasic basic=new FFrameBasic();
228
                basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout));
229
                if (fframe!=null) {
230
                        basic.setFframe(fframe.cloneFFrame(layout));
231
                }
232
                return basic;
233
        }
234

    
235
        public boolean contains(Double p) {
236
                return getFframeGraphics().contains(p);
237
        }
238

    
239
        public void drawDraft(Graphics2D g) {
240
                super.drawDraft(g);
241
        }
242

    
243
        public void drawEmpty(Graphics2D g) {
244
                super.drawEmpty(g);
245
        }
246

    
247
        public void drawSymbolTag(Graphics2D g) {
248
                super.drawSymbolTag(g);
249
        }
250

    
251
        public java.awt.geom.Rectangle2D.Double getBoundBox() {
252
                return getFframeGraphics().getBoundBox();
253
        }
254

    
255
        public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) {
256
                return getFframeGraphics().getBoundingBox(at);
257
        }
258

    
259
        public int getContains(Double p) {
260
                return getFframeGraphics().getContains(p);
261
        }
262

    
263
        public int getLevel() {
264
                return super.getLevel();
265
        }
266

    
267
        public Rectangle2D getMovieRect(int difx, int dify) {
268
                return fframeGraphics.getMovieRect(difx, dify);
269
        }
270

    
271
        public String getName() {
272
                return super.getName();
273
        }
274

    
275
        public double getRotation() {
276
                return super.getRotation();
277
        }
278

    
279
        public int getSelected() {
280
                return fframeGraphics.getSelected();
281
        }
282

    
283
        public String getTag() {
284
                return super.getTag();
285
        }
286

    
287
        public boolean intersects(Rectangle2D rv, Rectangle2D r) {
288
                return super.intersects(rv, r);
289
        }
290

    
291
        public void openTag() {
292
                super.openTag();
293
        }
294

    
295
        public void setBoundBox(Rectangle2D r) {
296
                if (getFframeGraphics()!=null) {
297
                        getFframeGraphics().setBoundBox(r);
298
                }
299
                if (getFframe() != null) {
300
                        getFframe().setBoundBox(r);
301
                //super.setBoundBox(r);
302
                }
303
        }
304

    
305
        public void setLevel(int l) {
306
                super.setLevel(l);
307
        }
308

    
309
        public void setName(String n) {
310
                super.setName(n);
311
        }
312

    
313
        public void setNum(int i) {
314
                super.setNum(i);
315
        }
316

    
317
        public void setRotation(double rotation) {
318
                super.setRotation(rotation);
319
        }
320

    
321
        public void setSelected(boolean b) {
322
                fframeGraphics.setSelected(b);
323
        }
324

    
325
        public void setSelected(Point2D p,MouseEvent e) {
326
                fframeGraphics.setSelected(p,e);
327
        }
328

    
329
        public void setTag(String s) {
330
                super.setTag(s);
331
        }
332

    
333
        public void updateRect(Rectangle2D r, AffineTransform at) {
334
                getFframeGraphics().updateRect(r, at);
335
        }
336
        public void cloneActions(IFFrame frame) {
337
                // TODO Auto-generated method stub
338

    
339
        }
340
        public IFFrameDialog getPropertyDialog() {
341
                // TODO Auto-generated method stub
342
                return null;
343
        }
344
}