Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameSymbol.java @ 4203

History | View | Annotate | Download (5.56 KB)

1
/*
2
 * Created on 09-jul-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 com.iver.andami.PluginServices;
48

    
49
import com.iver.cit.gvsig.fmap.DriverException;
50
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
51
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
52
import com.iver.cit.gvsig.gui.layout.Layout;
53
import com.iver.cit.gvsig.gui.project.SaveException;
54

    
55
import com.iver.utiles.XMLEntity;
56

    
57
import java.awt.Graphics2D;
58
import java.awt.Rectangle;
59
import java.awt.geom.AffineTransform;
60
import java.awt.geom.Rectangle2D;
61
import java.awt.image.BufferedImage;
62

    
63

    
64
/**
65
 * FFrame para introducir una S?mbolo en el Layout.
66
 *
67
 * @author Vicente Caballero Navarro
68
 */
69
public class FFrameSymbol extends FFrame {
70
    private FSymbol m_Symbol;
71

    
72
    /**
73
     * Crea un nuevo FFrameSymbol.
74
     */
75
    public FFrameSymbol() {
76
    }
77

    
78
    /**
79
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
80
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
81
     * de dibujar.
82
     *
83
     * @param g Graphics
84
     * @param at Transformada afin.
85
     * @param rv rect?ngulo sobre el que hacer un clip.
86
     * @param imgBase Imagen para acelerar el dibujado.
87
     */
88
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
89
        BufferedImage imgBase) {
90
        Rectangle2D.Double re = getBoundingBox(at);
91
        g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2),
92
            re.y + (re.height / 2));
93

    
94
        if (intersects(rv, re)) {
95
            AffineTransform mT2 = new AffineTransform();
96
            mT2.setToIdentity();
97

    
98
            Rectangle rec = new Rectangle((int) re.x, (int) re.y,
99
                    (int) (re.width), (int) (re.height));
100

    
101
            FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol);
102
        }
103

    
104
        g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2),
105
            re.y + (re.height / 2));
106
    }
107

    
108
    /**
109
     * Pone el FSymbol.
110
     *
111
     * @param symbol
112
     * @param type Tipo de s?mbolo.
113
     */
114
    public void setSymbol(FSymbol symbol, int type) {
115
        m_Symbol = symbol;
116
    }
117

    
118
    /**
119
     * DOCUMENT ME!
120
     *
121
     * @return DOCUMENT ME!
122
     *
123
     * @throws SaveException
124
     *
125
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
126
     */
127
    public XMLEntity getXMLEntity() throws SaveException {
128
        XMLEntity xml = super.getXMLEntity();
129

    
130
        try {
131
            xml.putProperty("type", Layout.RECTANGLESYMBOL);
132
            xml.addChild(m_Symbol.getXMLEntity());
133
        } catch (Exception e) {
134
            throw new SaveException(e, this.getClass().getName());
135
        }
136

    
137
        return xml;
138
    }
139

    
140
    /**
141
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
142
     *      com.iver.cit.gvsig.project.Project)
143
     */
144
    public void setXMLEntity03(XMLEntity xml, Layout l) {
145
        if (xml.getIntProperty("m_Selected") != 0) {
146
            this.setSelected(true);
147
        } else {
148
            this.setSelected(false);
149
        }
150

    
151
        this.m_Symbol = FSymbol.createFromXML03(xml.getChild(0));
152
    }
153

    
154
    /**
155
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
156
     *      com.iver.cit.gvsig.project.Project)
157
     */
158
    public void setXMLEntity(XMLEntity xml) {
159
        if (xml.getIntProperty("m_Selected") != 0) {
160
            this.setSelected(true);
161
        } else {
162
            this.setSelected(false);
163
        }
164

    
165
        setRotation(xml.getDoubleProperty("m_rotation"));
166
        this.m_Symbol = FSymbol.createFromXML(xml.getChild(0));
167
    }
168

    
169
    /**
170
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
171
     */
172
    public String getNameFFrame() {
173
        return PluginServices.getText(this, "simbolo");
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
    /**
186
     * Devuelve el s?mbolo.
187
     *
188
     * @return S?mbolo.
189
     */
190
    public FSymbol getFSymbol() {
191
        return m_Symbol;
192
    }
193

    
194
    /**
195
     * Inserta el s?mbolo al FFrame.
196
     *
197
     * @param symbol S?mbolo a insertar.
198
     */
199
    public void setFSymbol(FSymbol symbol) {
200
        m_Symbol = symbol;
201
    }
202

    
203
        public void initialize() {
204
                // TODO Auto-generated method stub
205

    
206
        }
207
}