Statistics
| Revision:

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

History | View | Annotate | Download (9.37 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.MapContextLocator;
67
import org.gvsig.fmap.mapcontext.MapContextManager;
68
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
69
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.SimpleLineSymbol;
70
import org.gvsig.utils.XMLEntity;
71

    
72

    
73

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

    
81
        private FFrameGraphics fframeGraphics;
82
        private IFFrame fframe;
83
    
84
    private MapContextManager mapContextManager = MapContextLocator
85
                        .getMapContextManager();
86

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

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

    
107
        IFillSymbol symbol = (IFillSymbol) mapContextManager
108
                                .createSymbol(IFillSymbol.SYMBOL_NAME);
109
        symbol.setFillColor(new Color(255,255,255,0));
110
        SimpleLineSymbol blackOutline = new SimpleLineSymbol();
111
        blackOutline.setLineColor(Color.BLACK);
112
        symbol.setOutline(blackOutline);
113
        graphics.setSymbol(symbol);
114
        graphics.setType(Geometry.TYPES.CURVE);
115
        setFframeGraphics(graphics);
116
        }
117
        public FFrameBasic(){
118

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

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

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

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

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

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

    
210
        public IFFrame getFframe() {
211
                return fframe;
212
        }
213

    
214
        public void setFframe(IFFrame fframe) {
215
                this.fframe = fframe;
216
        }
217

    
218
        public FFrameGraphics getFframeGraphics() {
219
                return fframeGraphics;
220
        }
221

    
222
        public void setFframeGraphics(FFrameGraphics fframeGraphics) {
223
                this.fframeGraphics = fframeGraphics;
224
        }
225

    
226
        public void drawHandlers(Graphics2D g) {
227
                fframeGraphics.drawHandlers(g);
228
        }
229

    
230
        public IFFrame cloneFFrame(Layout layout) {
231
                FFrameBasic basic=new FFrameBasic();
232
                basic.setFframeGraphics((FFrameGraphics)fframeGraphics.cloneFFrame(layout));
233
                if (fframe!=null) {
234
                        basic.setFframe(fframe.cloneFFrame(layout));
235
                }
236
                return basic;
237
        }
238

    
239
        public boolean contains(Double p) {
240
                return getFframeGraphics().contains(p);
241
        }
242

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

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

    
251
        public void drawSymbolTag(Graphics2D g) {
252
                super.drawSymbolTag(g);
253
        }
254

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

    
259
        public java.awt.geom.Rectangle2D.Double getBoundingBox(AffineTransform at) {
260
                return getFframeGraphics().getBoundingBox(at);
261
        }
262

    
263
        public int getContains(Double p) {
264
                return getFframeGraphics().getContains(p);
265
        }
266

    
267
        public int getLevel() {
268
                return super.getLevel();
269
        }
270

    
271
        public Rectangle2D getMovieRect(int difx, int dify) {
272
                return fframeGraphics.getMovieRect(difx, dify);
273
        }
274

    
275
        public String getName() {
276
                return super.getName();
277
        }
278

    
279
        public double getRotation() {
280
                return super.getRotation();
281
        }
282

    
283
        public int getSelected() {
284
                return fframeGraphics.getSelected();
285
        }
286

    
287
        public String getTag() {
288
                return super.getTag();
289
        }
290

    
291
        public boolean intersects(Rectangle2D rv, Rectangle2D r) {
292
                return super.intersects(rv, r);
293
        }
294

    
295
        public void openTag() {
296
                super.openTag();
297
        }
298

    
299
        public void setBoundBox(Rectangle2D r) {
300
                if (getFframeGraphics()!=null) {
301
                        getFframeGraphics().setBoundBox(r);
302
                }
303
                if (getFframe() != null) {
304
                        getFframe().setBoundBox(r);
305
                //super.setBoundBox(r);
306
                }
307
        }
308

    
309
        public void setLevel(int l) {
310
                super.setLevel(l);
311
        }
312

    
313
        public void setName(String n) {
314
                super.setName(n);
315
        }
316

    
317
        public void setNum(int i) {
318
                super.setNum(i);
319
        }
320

    
321
        public void setRotation(double rotation) {
322
                super.setRotation(rotation);
323
        }
324

    
325
        public void setSelected(boolean b) {
326
                fframeGraphics.setSelected(b);
327
        }
328

    
329
        public void setSelected(Point2D p,MouseEvent e) {
330
                fframeGraphics.setSelected(p,e);
331
        }
332

    
333
        public void setTag(String s) {
334
                super.setTag(s);
335
        }
336

    
337
        public void updateRect(Rectangle2D r, AffineTransform at) {
338
                getFframeGraphics().updateRect(r, at);
339
        }
340
        public void cloneActions(IFFrame frame) {
341
                // TODO Auto-generated method stub
342

    
343
        }
344
        public IFFrameDialog getPropertyDialog() {
345
                // TODO Auto-generated method stub
346
                return null;
347
        }
348
}