Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1013 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / FGraphic.java @ 13521

History | View | Annotate | Download (5.48 KB)

1 2901 fjp
/*
2
 * Created on 19-sep-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5 8765 jjdelcerro
 *
6 2901 fjp
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7 8765 jjdelcerro
 *
8 2901 fjp
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12 8765 jjdelcerro
 *
13 2901 fjp
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17 8765 jjdelcerro
 *
18 2901 fjp
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 8765 jjdelcerro
 *
22 2901 fjp
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33 8765 jjdelcerro
 *
34 2901 fjp
 *    or
35 8765 jjdelcerro
 *
36 2901 fjp
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40 8765 jjdelcerro
 *
41 2901 fjp
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.fmap.rendering;
45
46 3561 fjp
import java.awt.Graphics2D;
47
48
import com.iver.cit.gvsig.fmap.ViewPort;
49 2901 fjp
import com.iver.cit.gvsig.fmap.core.IGeometry;
50 8765 jjdelcerro
import com.iver.cit.gvsig.fmap.core.ISymbol;
51 2901 fjp
52 13373 ppiqueras
/**
53
 * <p>The class <code>FGraphic</code> defines a graphic symbol according to the <i>FMap philosophy</i>.</p>
54
 *
55
 * <p>This symbol represents a drawingable geometry with an identifier, and can optionally have attached a tag
56
 *  that can be text or an object.</p>
57
 */
58 2901 fjp
public class FGraphic {
59 13373 ppiqueras
        /**
60
         * Identifies this graphic symbol.
61
         *
62
         * @see #getIdSymbol()
63
         * @see #setIdSymbol(int)
64
         */
65 2901 fjp
    int idSymbol;
66 13373 ppiqueras
67
    /**
68
     * Geometry of this graphic symbol.
69
     *
70
     * @see #getGeom()
71
     * @see #setGeom(IGeometry)
72
     */
73 2901 fjp
    IGeometry geom;
74 13373 ppiqueras
75
    /**
76
     * Optional text associated to this graphic symbol as a tag.
77
     *
78
     * @see #getTag()
79
     * @see #setTag(String)
80
     */
81 2901 fjp
    String tag;
82 13373 ppiqueras
83
    /**
84 13508 ppiqueras
     * Optional object <i>(example: an icon)</i> associated to this graphic symbol as a tag.
85 13373 ppiqueras
     *
86
     * @see #getObjectTag()
87
     * @see #setObjectTag(Object)
88
     */
89 8765 jjdelcerro
    Object objectTag;
90
91 13373 ppiqueras
    /**
92
     * <p>Creates a graphic object according to the <i>FMap philosophy</i>, from a geometry and an identifier.</p>
93
     *
94
     * @param geom the geometry that this symbol will represent
95
     * @param idSymbol the identifier
96
     */
97 2901 fjp
    public FGraphic(IGeometry geom, int idSymbol)
98
    {
99
        this.idSymbol = idSymbol;
100 8765 jjdelcerro
        this.geom = geom;
101 2901 fjp
    }
102
103
    /**
104 13373 ppiqueras
     * Gets the text tag associated to this symbol.
105
     *
106 13508 ppiqueras
     * @return the text tag associated to this symbol, or <code>null</code> if undefined
107 13483 ppiqueras
     *
108
     * @see #setTag(String)
109 2901 fjp
     */
110
    public String getTag() {
111
        return tag;
112
    }
113
114
    /**
115 13373 ppiqueras
     * Sets a text tag associated to this symbol.
116
     *
117
     * @param tag a text tag associated to this symbol
118 13483 ppiqueras
     *
119
     * @see #getTag()
120 2901 fjp
     */
121
    public void setTag(String tag) {
122
        this.tag = tag;
123
    }
124
125
    /**
126 13373 ppiqueras
     * Gets the geometry of this symbol.
127
     *
128
     * @return an object indicating this component's geometry
129 13483 ppiqueras
     *
130
     * @see #setGeom(IGeometry)
131 2901 fjp
     */
132
    public IGeometry getGeom() {
133
        return geom;
134
    }
135
136
    /**
137 13373 ppiqueras
     * Changes the geometry of this symbol to the new one.
138
     *
139
     * @param geom an object indicating this component's geometry
140 13483 ppiqueras
     *
141
     * @see #getGeom()
142 2901 fjp
     */
143
    public void setGeom(IGeometry geom) {
144
        this.geom = geom;
145
    }
146
147
    /**
148 13373 ppiqueras
     * Gets the identifier of this symbol.
149
     *
150 2901 fjp
     * @return Returns the idSymbol.
151 13483 ppiqueras
     *
152
     * @see #setIdSymbol(int)
153 2901 fjp
     */
154
    public int getIdSymbol() {
155
        return idSymbol;
156
    }
157
158
    /**
159 13373 ppiqueras
     * Changes the identifier of this symbol to the new one.
160
     *
161
     * @param idSymbol the new identifier
162 13483 ppiqueras
     *
163
     * @see #getIdSymbol()
164 2901 fjp
     */
165
    public void setIdSymbol(int idSymbol) {
166
        this.idSymbol = idSymbol;
167
    }
168 8765 jjdelcerro
169 3561 fjp
    /**
170 13508 ppiqueras
     * <p>Defines the default logic of drawing an <i>FMap</i> graphic symbol.</p>
171 13373 ppiqueras
     *
172
     * <p>Using the rendering defined in {@link Graphics2D Graphics2D}, the symbol will
173
     *  be drawn in the viewport. That symbol must be which has the id <code>idSymbol<code>
174
     *  if we want to draw which represents this class.</p>
175
     *
176
     * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
177 13508 ppiqueras
     * @param viewPort information for drawing this graphic item
178 13373 ppiqueras
     * @param theSymbol the symbol that will be drawn (this parameter is generally used indicating
179
     *  the object that has the identifier <code>idSymbol</code>)
180 3561 fjp
     */
181 8765 jjdelcerro
    public void draw(Graphics2D g, ViewPort viewPort, ISymbol theSymbol )
182 3561 fjp
    {
183
        if (theSymbol.isShapeVisible())
184
        {
185
            IGeometry cloneGeom = geom.cloneGeometry();
186
            cloneGeom.draw(g,viewPort,theSymbol);
187 8765 jjdelcerro
        }
188 3561 fjp
    }
189 6945 fjp
190 13373 ppiqueras
    /**
191
     * Gets the object tag associated to this symbol.
192
     *
193 13508 ppiqueras
     * @return the object tag associated to this symbol, or <code>null</code> if  undefined
194 13483 ppiqueras
     *
195
     * @see #setObjectTag(Object)
196 13373 ppiqueras
     */
197 8765 jjdelcerro
        public Object getObjectTag() {
198
                return objectTag;
199
        }
200
201 13373 ppiqueras
        /**
202
         * Sets an object tag associated to this symbol.
203
         *
204
         * @param objectTag an object tag associated to this symbol
205 13483 ppiqueras
         *
206
         * @see #getObjectTag()
207 13373 ppiqueras
         */
208 8765 jjdelcerro
        public void setObjectTag(Object objectTag) {
209
                this.objectTag = objectTag;
210
        }
211 2901 fjp
}