root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / symbols / styles / IMask.java @ 29973
History | View | Annotate | Download (4.17 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 |
package org.gvsig.fmap.mapcontext.rendering.symbols.styles; |
42 |
|
43 |
import java.awt.BasicStroke; |
44 |
import java.awt.Graphics2D; |
45 |
import java.awt.Rectangle; |
46 |
import java.awt.Shape; |
47 |
|
48 |
import org.gvsig.fmap.geom.Geometry; |
49 |
import org.gvsig.fmap.geom.GeometryLocator; |
50 |
import org.gvsig.fmap.geom.GeometryManager; |
51 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
52 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
53 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
54 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
55 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol; |
56 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
57 |
import org.gvsig.utils.XMLEntity; |
58 |
import org.slf4j.Logger; |
59 |
import org.slf4j.LoggerFactory; |
60 |
|
61 |
|
62 |
/**
|
63 |
* Interface for the style of a mask.
|
64 |
*
|
65 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
66 |
*/
|
67 |
public interface IMask extends IStyle { |
68 |
|
69 |
public double getSize(); |
70 |
|
71 |
public void setSize(double size); |
72 |
|
73 |
public IFillSymbol getFillSymbol();
|
74 |
|
75 |
public void setFillSymbol(IFillSymbol fill); |
76 |
|
77 |
public Geometry getHaloShape(Shape shp); |
78 |
|
79 |
/**
|
80 |
* Class that implements the methods of the IMask interface showed above.
|
81 |
*
|
82 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
83 |
*
|
84 |
*/
|
85 |
class BasicMask extends AbstractStyle implements IMask { |
86 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
87 |
private static final Logger logger = LoggerFactory.getLogger(BasicMask.class); |
88 |
private double size; |
89 |
private IFillSymbol fill;
|
90 |
|
91 |
|
92 |
public double getSize() { |
93 |
return size;
|
94 |
} |
95 |
|
96 |
public void setSize(double size) { |
97 |
this.size = size;
|
98 |
} |
99 |
|
100 |
public IFillSymbol getFillSymbol() {
|
101 |
return fill;
|
102 |
|
103 |
} |
104 |
|
105 |
public void setFillSymbol(IFillSymbol fill) { |
106 |
this.fill = fill;
|
107 |
} |
108 |
|
109 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) { |
110 |
// TODO Implement it
|
111 |
throw new Error("Not yet implemented!"); |
112 |
|
113 |
} |
114 |
|
115 |
public Geometry getHaloShape(Shape shp) { |
116 |
BasicStroke stroke = new BasicStroke((int) /*falta CartographicSupport*/getSize()); |
117 |
Shape myShp = stroke.createStrokedShape(shp);
|
118 |
Geometry haloShape = null;;
|
119 |
try {
|
120 |
haloShape = geomManager.createSurface(new GeneralPathX(myShp.getBounds2D().getPathIterator(null)), SUBTYPES.GEOM2D); |
121 |
} catch (CreateGeometryException e) {
|
122 |
logger.error("Error creating a surface", e);
|
123 |
} |
124 |
|
125 |
return haloShape;
|
126 |
} |
127 |
|
128 |
public boolean isSuitableFor(ISymbol symbol) { |
129 |
// TODO Implement it
|
130 |
throw new Error("Not yet implemented!"); |
131 |
|
132 |
} |
133 |
|
134 |
public void drawOutline(Graphics2D g, Rectangle r) { |
135 |
// TODO Implement it
|
136 |
throw new Error("Not yet implemented!"); |
137 |
|
138 |
} |
139 |
|
140 |
public String getClassName() { |
141 |
return this.getClass().getName(); |
142 |
} |
143 |
|
144 |
public XMLEntity getXMLEntity() {
|
145 |
// TODO Implement it
|
146 |
throw new Error("Not yet implemented!"); |
147 |
|
148 |
} |
149 |
|
150 |
public void setXMLEntity(XMLEntity xml) { |
151 |
// TODO Implement it
|
152 |
throw new Error("Not yet implemented!"); |
153 |
|
154 |
} |
155 |
|
156 |
} |
157 |
} |