Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / AbstractMarkerSymbol.java @ 12148

History | View | Annotate | Download (5.05 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42
/* CVS MESSAGES:
43
*
44
* $Id: AbstractMarkerSymbol.java 11741 2007-05-22 10:05:31Z jaume $
45
* $Log$
46
* Revision 1.9  2007-05-22 10:05:31  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.8  2007/05/09 16:07:26  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.7  2007/05/08 08:47:40  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.6  2007/03/26 14:24:13  jaume
56
* implemented Print
57
*
58
* Revision 1.5  2007/03/21 11:02:17  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.4  2007/03/09 11:20:56  jaume
62
* Advanced symbology (start committing)
63
*
64
* Revision 1.3.2.4  2007/02/16 10:54:12  jaume
65
* multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
66
*
67
* Revision 1.3.2.3  2007/02/15 16:23:44  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.3.2.2  2007/02/09 07:47:05  jaume
71
* Isymbol moved
72
*
73
* Revision 1.3.2.1  2007/02/02 16:21:24  jaume
74
* start commiting labeling stuff
75
*
76
* Revision 1.3  2007/01/25 16:25:23  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.2  2007/01/16 11:50:44  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.1  2007/01/10 16:31:36  jaume
83
* *** empty log message ***
84
*
85
* Revision 1.4  2006/12/04 17:13:39  fjp
86
* *** empty log message ***
87
*
88
* Revision 1.3  2006/11/14 11:10:27  jaume
89
* *** empty log message ***
90
*
91
* Revision 1.2  2006/11/09 18:39:05  jaume
92
* *** empty log message ***
93
*
94
* Revision 1.1  2006/10/31 16:16:34  jaume
95
* *** empty log message ***
96
*
97
* Revision 1.4  2006/10/30 19:30:35  jaume
98
* *** empty log message ***
99
*
100
* Revision 1.3  2006/10/26 16:27:33  jaume
101
* support for composite marker symbols (not tested)
102
*
103
* Revision 1.2  2006/10/26 07:46:58  jaume
104
* *** empty log message ***
105
*
106
* Revision 1.1  2006/10/25 10:50:41  jaume
107
* movement of classes and gui stuff
108
*
109
* Revision 1.1  2006/10/18 07:54:06  jaume
110
* *** empty log message ***
111
*
112
*
113
*/
114
package com.iver.cit.gvsig.fmap.core.symbols;
115

    
116
import java.awt.Color;
117
import java.awt.Graphics2D;
118
import java.awt.Point;
119
import java.awt.geom.AffineTransform;
120
import java.awt.geom.Point2D;
121

    
122
import javax.print.attribute.PrintRequestAttributeSet;
123
import javax.print.attribute.standard.PrintQuality;
124

    
125
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
126
import com.iver.cit.gvsig.fmap.core.FShape;
127
import com.iver.cit.gvsig.fmap.core.IGeometry;
128
import com.iver.cit.gvsig.fmap.core.styles.IMask;
129

    
130

    
131
/**
132
 * Abstract class that any MARKER SYMBOL should extend.
133
 * @author  jaume dominguez faus - jaume.dominguez@iver.es
134
 */
135
public abstract class AbstractMarkerSymbol extends AbstractSymbol implements IMarkerSymbol {
136
        private Color color = Color.BLACK;
137
        private double rotation;
138
        private Point2D offset = new Point2D.Double();
139
        private double size;
140
        private IMask mask;
141

    
142
        public double getRotation() {
143
                return rotation;
144
        }
145

    
146
        public void setRotation(double r) {
147
                this.rotation = r;
148
        }
149

    
150
        public Point2D getOffset() {
151
                if (offset == null) {
152
                        offset = new Point();
153
                }
154
                return offset;
155
        }
156

    
157
        public void setOffset(Point2D offset) {
158
                this.offset = offset;
159
        }
160

    
161
        public boolean isSuitableFor(IGeometry geom) {
162
                return geom.getGeometryType() == FShape.POINT;
163
        }
164

    
165
        public int getOnePointRgb() {
166
                return color.getRGB();
167
        }
168

    
169
        public double getSize() {
170
                return size;
171
        }
172

    
173
        public void setSize(double size) {
174
                this.size = size;
175
        }
176

    
177
        public Color getColor() {
178
                return color;
179
        }
180

    
181
        public void setColor(Color color) {
182
                this.color = color;
183
        }
184

    
185
        public void print(Graphics2D g, AffineTransform at, FShape shape, PrintRequestAttributeSet properties) throws ReadDriverException {
186
                double originalSize = getSize();
187
                // scale it to size
188
                PrintQuality pq = (PrintQuality) properties.get(PrintQuality.class);
189
                if (pq.equals(PrintQuality.NORMAL)){
190
                        originalSize *= (double) 300/72;
191
                }else if (pq.equals(PrintQuality.HIGH)){
192
                        originalSize *= (double) 600/72;
193
                }else if (pq.equals(PrintQuality.DRAFT)){
194
                        //        unitFactor *= 72; (which is the same than doing nothing)
195
                }
196
                setSize(originalSize);
197
        }
198

    
199
        public final IMask getMask() {
200
                return mask;
201
        }
202

    
203
        public final void setMask(IMask mask) {
204
                this.mask = mask;
205
        }
206

    
207
}