Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameBasic.java @ 23074

History | View | Annotate | Download (9.28 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 com.hardcode.gdbms.driver.exceptions.ReadDriverException;
59
import com.iver.andami.PluginServices;
60
import com.iver.cit.gvsig.ProjectExtension;
61
import com.iver.cit.gvsig.fmap.core.FShape;
62
import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
63
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter;
64
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
65
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol;
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.gui.Layout;
71
import com.iver.utiles.XMLEntity;
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

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

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

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

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

    
134
    /**
135
     * DOCUMENT ME!
136
     *
137
     * @return DOCUMENT ME!
138
     *
139
     * @throws SaveException
140
     *
141
     * @see com.iver.cit.gvsig.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
        return xml;
149
    }
150

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

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

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

    
191
    /**
192
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
193
     *      java.awt.geom.AffineTransform)
194
     */
195
    public void print(Graphics2D g, AffineTransform at,FShape shape, PrintRequestAttributeSet printingProperties)
196
        throws ReadDriverException {
197
//            fframeGraphics.setPrintingProperties(printingProperties);
198
            fframeGraphics.print(g,at,shape, printingProperties);
199
//            fframeGraphics.setPrintingProperties(null);
200
            if (fframe!=null) {
201
                    fframe.print(g,at,shape, printingProperties);
202
            }
203
    }
204

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

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

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

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

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

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

    
233
        public boolean contains(Double p) {
234
                return getFframeGraphics().contains(p);
235
        }
236

    
237
        public void drawDraft(Graphics2D g) {
238
                super.drawDraft(g);
239
        }
240

    
241
        public void drawEmpty(Graphics2D g) {
242
                super.drawEmpty(g);
243
        }
244

    
245
        public void drawSymbolTag(Graphics2D g) {
246
                super.drawSymbolTag(g);
247
        }
248

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

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

    
257
        public int getContains(Double p) {
258
                return getFframeGraphics().getContains(p);
259
        }
260

    
261
        public int getLevel() {
262
                return super.getLevel();
263
        }
264

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

    
269
        public String getName() {
270
                return super.getName();
271
        }
272

    
273
        public double getRotation() {
274
                return super.getRotation();
275
        }
276

    
277
        public int getSelected() {
278
                return fframeGraphics.getSelected();
279
        }
280

    
281
        public String getTag() {
282
                return super.getTag();
283
        }
284

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

    
289
        public void openTag() {
290
                super.openTag();
291
        }
292

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

    
301
        public void setLevel(int l) {
302
                super.setLevel(l);
303
        }
304

    
305
        public void setName(String n) {
306
                super.setName(n);
307
        }
308

    
309
        public void setNum(int i) {
310
                super.setNum(i);
311
        }
312

    
313
        public void setRotation(double rotation) {
314
                super.setRotation(rotation);
315
        }
316

    
317
        public void setSelected(boolean b) {
318
                fframeGraphics.setSelected(b);
319
        }
320

    
321
        public void setSelected(Point2D p,MouseEvent e) {
322
                fframeGraphics.setSelected(p,e);
323
        }
324

    
325
        public void setTag(String s) {
326
                super.setTag(s);
327
        }
328

    
329
        public void updateRect(Rectangle2D r, AffineTransform at) {
330
                getFframeGraphics().updateRect(r, at);
331
        }
332
        public void cloneActions(IFFrame frame) {
333
                // TODO Auto-generated method stub
334

    
335
        }
336
        public IFFrameDialog getPropertyDialog() {
337
                // TODO Auto-generated method stub
338
                return null;
339
        }
340
}