Statistics
| Revision:

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

History | View | Annotate | Download (9.15 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.iver.andami.PluginServices;
59
import com.iver.cit.gvsig.ProjectExtension;
60
import com.iver.cit.gvsig.fmap.core.FShape;
61
import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
62
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter;
63
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
64
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol;
65
import com.iver.cit.gvsig.project.Project;
66
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
67
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
68
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
69
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
70
import com.iver.utiles.XMLEntity;
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.setFSymbol(symbol);
110
        graphics.setType(FShape.LINE);
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
     * DOCUMENT ME!
135
     *
136
     * @return DOCUMENT ME!
137
     *
138
     * @throws SaveException
139
     *
140
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
141
     */
142
    public XMLEntity getXMLEntity() throws SaveException {
143
        XMLEntity xml = super.getXMLEntity();
144
        xml.addChild(fframeGraphics.getXMLEntity());
145
        if (fframe!=null)
146
                xml.addChild(fframe.getXMLEntity());
147
        return xml;
148
    }
149

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

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

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

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

    
203
        public IFFrame getFframe() {
204
                return fframe;
205
        }
206

    
207
        public void setFframe(IFFrame fframe) {
208
                this.fframe = fframe;
209
        }
210

    
211
        public FFrameGraphics getFframeGraphics() {
212
                return fframeGraphics;
213
        }
214

    
215
        public void setFframeGraphics(FFrameGraphics fframeGraphics) {
216
                this.fframeGraphics = fframeGraphics;
217
        }
218

    
219
        public void drawHandlers(Graphics2D g) {
220
                fframeGraphics.drawHandlers(g);
221
        }
222

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

    
231
        public boolean contains(Double p) {
232
                return getFframeGraphics().contains(p);
233
        }
234

    
235
        public void drawDraft(Graphics2D g) {
236
                super.drawDraft(g);
237
        }
238

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

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

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

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

    
255
        public int getContains(Double p) {
256
                return getFframeGraphics().getContains(p);
257
        }
258

    
259
        public int getLevel() {
260
                return super.getLevel();
261
        }
262

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

    
267
        public String getName() {
268
                return super.getName();
269
        }
270

    
271
        public double getRotation() {
272
                return super.getRotation();
273
        }
274

    
275
        public int getSelected() {
276
                return fframeGraphics.getSelected();
277
        }
278

    
279
        public String getTag() {
280
                return super.getTag();
281
        }
282

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

    
287
        public void openTag() {
288
                super.openTag();
289
        }
290

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

    
299
        public void setLevel(int l) {
300
                super.setLevel(l);
301
        }
302

    
303
        public void setName(String n) {
304
                super.setName(n);
305
        }
306

    
307
        public void setNum(int i) {
308
                super.setNum(i);
309
        }
310

    
311
        public void setRotation(double rotation) {
312
                super.setRotation(rotation);
313
        }
314

    
315
        public void setSelected(boolean b) {
316
                fframeGraphics.setSelected(b);
317
        }
318

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

    
323
        public void setTag(String s) {
324
                super.setTag(s);
325
        }
326

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

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