Revision 9639
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
52 |
|
|
53 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
54 |
|
|
55 |
public abstract class AbstractSymbol implements ISymbol { |
|
56 |
protected PrintRequestAttributeSet printProperties; |
|
57 |
private String desc; |
|
58 |
private boolean isShapeVisible = true; |
|
59 |
|
|
60 |
public void setPrintingProperties(PrintRequestAttributeSet printProperties) { |
|
61 |
this.printProperties = printProperties; |
|
62 |
} |
|
63 |
|
|
64 |
public final void setDescription(String desc) { |
|
65 |
this.desc = desc; |
|
66 |
} |
|
67 |
|
|
68 |
public final String getDescription() { |
|
69 |
return desc; |
|
70 |
} |
|
71 |
|
|
72 |
public final boolean isShapeVisible() { |
|
73 |
return isShapeVisible; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Sets this symbol to visible |
|
78 |
* @param isShapeVisible |
|
79 |
*/ |
|
80 |
public final void setIsShapeVisible(boolean isShapeVisible) { |
|
81 |
this.isShapeVisible = isShapeVisible; |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
0 | 85 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractMarkerSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.4 2006/12/04 17:13:39 fjp |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.3 2006/11/14 11:10:27 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.2 2006/11/09 18:39:05 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.1 2006/10/31 16:16:34 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.4 2006/10/30 19:30:35 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.3 2006/10/26 16:27:33 jaume |
|
65 |
* support for composite marker symbols (not tested) |
|
66 |
* |
|
67 |
* Revision 1.2 2006/10/26 07:46:58 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.1 2006/10/25 10:50:41 jaume |
|
71 |
* movement of classes and gui stuff |
|
72 |
* |
|
73 |
* Revision 1.1 2006/10/18 07:54:06 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* |
|
77 |
*/ |
|
78 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
79 |
|
|
80 |
import java.awt.Color; |
|
81 |
import java.awt.Point; |
|
82 |
import java.awt.geom.Point2D; |
|
83 |
import java.util.ArrayList; |
|
84 |
|
|
85 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
86 |
|
|
87 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
88 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
89 |
|
|
90 |
|
|
91 |
/** |
|
92 |
* Abstract class that any MARKER SYMBOL should extend. |
|
93 |
* |
|
94 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
95 |
*/ |
|
96 |
public abstract class AbstractMarkerSymbol extends AbstractSymbol { |
|
97 |
protected Color color = Color.BLACK; |
|
98 |
protected double rotation; |
|
99 |
protected Point2D offset; |
|
100 |
protected ISymbol[] subSymbols; // TODO maybe push it up to ISymbol |
|
101 |
|
|
102 |
public double getRotation() { |
|
103 |
return rotation; |
|
104 |
} |
|
105 |
|
|
106 |
public void setRotation(double r) { |
|
107 |
this.rotation = r; |
|
108 |
} |
|
109 |
public Point2D getOffset() { |
|
110 |
if (offset == null) { |
|
111 |
offset = new Point(); |
|
112 |
} |
|
113 |
return offset; |
|
114 |
} |
|
115 |
|
|
116 |
public void setOffset(Point offset) { |
|
117 |
this.offset = offset; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* TODO maybe push it up to ISymbol |
|
122 |
* @param sym |
|
123 |
*/ |
|
124 |
public void addSymbol(ISymbol sym) { |
|
125 |
int capacity = 0; |
|
126 |
if (subSymbols != null) |
|
127 |
capacity = subSymbols.length; |
|
128 |
ArrayList lst = new ArrayList(capacity); |
|
129 |
for (int i = 0; i < capacity; i++) { |
|
130 |
lst.add(subSymbols[i]); |
|
131 |
} |
|
132 |
subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]); |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* TODO maybe push it up to ISymbol |
|
137 |
* @param sym |
|
138 |
* @return true if this symbol contains the removed one |
|
139 |
*/ |
|
140 |
public boolean removeSymbol(ISymbol sym) { |
|
141 |
|
|
142 |
int capacity = 0; |
|
143 |
if (subSymbols != null) |
|
144 |
capacity = subSymbols.length; |
|
145 |
ArrayList lst = new ArrayList(capacity); |
|
146 |
for (int i = 0; i < capacity; i++) { |
|
147 |
lst.add(subSymbols[i]); |
|
148 |
} |
|
149 |
boolean contains = lst.remove(sym); |
|
150 |
subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]); |
|
151 |
return contains; |
|
152 |
} |
|
153 |
|
|
154 |
public boolean isSuitableFor(IGeometry geom) { |
|
155 |
return geom.getGeometryType() == FShape.POINT; |
|
156 |
} |
|
157 |
|
|
158 |
public int getOnePointRgb() { |
|
159 |
return color.getRGB(); |
|
160 |
} |
|
161 |
|
|
162 |
} |
|
0 | 163 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
52 |
|
|
53 |
import java.awt.Graphics2D; |
|
54 |
import java.awt.Rectangle; |
|
55 |
import java.awt.Shape; |
|
56 |
import java.awt.geom.AffineTransform; |
|
57 |
|
|
58 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
59 |
|
|
60 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
61 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
62 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
63 |
import com.iver.utiles.XMLEntity; |
|
64 |
|
|
65 |
public class MultiLayerSymbol extends AbstractSymbol { |
|
66 |
private ISymbol[] layers; |
|
67 |
private MultiLayerSymbol selectionSymbol; |
|
68 |
|
|
69 |
public ISymbol getLayer(int layerIndex) { |
|
70 |
try{ |
|
71 |
return layers[layerIndex]; |
|
72 |
} catch (Exception e) { |
|
73 |
return null; |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
public int getLayerCount() { |
|
78 |
if (layers == null) |
|
79 |
return -1; |
|
80 |
return layers.length; |
|
81 |
} |
|
82 |
|
|
83 |
public ISymbol getSymbolForSelection() { |
|
84 |
if (selectionSymbol == null) { |
|
85 |
selectionSymbol = new MultiLayerSymbol(); |
|
86 |
selectionSymbol.setDescription(getDescription()); |
|
87 |
for (int i = 0; i < layers.length; i++) { |
|
88 |
selectionSymbol.addLayer(layers[i].getSymbolForSelection()); |
|
89 |
} |
|
90 |
} |
|
91 |
return selectionSymbol; |
|
92 |
} |
|
93 |
|
|
94 |
public void addLayer(ISymbol newLayer) { |
|
95 |
selectionSymbol = null; /* forces the selection symbol to be re-created |
|
96 |
* next time it is required |
|
97 |
*/ |
|
98 |
ISymbol[] newLayers = new ISymbol[layers.length+1]; |
|
99 |
for (int i = 0; i < newLayers.length-1; i++) { |
|
100 |
newLayers[i] = layers[i]; |
|
101 |
} |
|
102 |
layers[layers.length] = newLayer; |
|
103 |
} |
|
104 |
|
|
105 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
|
106 |
for (int i = 0; i < layers.length; i++) { |
|
107 |
layers[i].draw(g, affineTransform, shp); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, Shape shp) { |
|
112 |
// TODO Auto-generated method stub |
|
113 |
throw new Error("Not yet implemented!"); |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
public int getOnePointRgb() { |
|
118 |
// will paint only the last layer pixel |
|
119 |
return layers[layers.length-1].getOnePointRgb(); |
|
120 |
} |
|
121 |
|
|
122 |
public XMLEntity getXMLEntity() { |
|
123 |
// TODO Auto-generated method stub |
|
124 |
throw new Error("Not yet implemented!"); |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
public int getSymbolType() { |
|
129 |
// TODO Auto-generated method stub |
|
130 |
throw new Error("Not yet implemented!"); |
|
131 |
|
|
132 |
} |
|
133 |
|
|
134 |
public boolean isSuitableFor(IGeometry geom) { |
|
135 |
// TODO Auto-generated method stub |
|
136 |
throw new Error("Not yet implemented!"); |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) { |
|
141 |
for (int i = 0; i < layers.length; i++) { |
|
142 |
layers[i].drawInsideRectangle(g, scaleInstance, r); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
public String getClassName() { |
|
147 |
return getClass().getName(); |
|
148 |
} |
|
149 |
|
|
150 |
public void setXMLEntity(XMLEntity xml) { |
|
151 |
// TODO Auto-generated method stub |
|
152 |
throw new Error("Not yet implemented!"); |
|
153 |
|
|
154 |
} |
|
155 |
|
|
156 |
public void setPrintingProperties(PrintRequestAttributeSet properties) { |
|
157 |
for (int i = 0; i < layers.length; i++) { |
|
158 |
layers[i].setPrintingProperties(properties); |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
|
|
163 |
} |
|
0 | 164 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MarkerFillSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.10 2006/11/09 18:39:05 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.9 2006/11/09 10:22:50 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.8 2006/11/08 13:05:51 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.7 2006/11/08 10:56:47 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.6 2006/11/07 08:52:30 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.5 2006/11/06 17:08:45 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.4 2006/11/06 16:06:52 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.3 2006/11/06 07:33:54 jaume |
|
71 |
* javadoc, source style |
|
72 |
* |
|
73 |
* Revision 1.2 2006/10/31 16:16:34 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* Revision 1.1 2006/10/30 19:30:35 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* |
|
80 |
*/ |
|
81 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
82 |
|
|
83 |
import java.awt.BasicStroke; |
|
84 |
import java.awt.Color; |
|
85 |
import java.awt.Dimension; |
|
86 |
import java.awt.Graphics2D; |
|
87 |
import java.awt.Paint; |
|
88 |
import java.awt.Rectangle; |
|
89 |
import java.awt.RenderingHints; |
|
90 |
import java.awt.Shape; |
|
91 |
import java.awt.TexturePaint; |
|
92 |
import java.awt.geom.AffineTransform; |
|
93 |
import java.awt.geom.Point2D; |
|
94 |
import java.awt.image.BufferedImage; |
|
95 |
import java.util.ArrayList; |
|
96 |
|
|
97 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
98 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
99 |
import com.iver.utiles.StringUtilities; |
|
100 |
import com.iver.utiles.XMLEntity; |
|
101 |
|
|
102 |
public class MarkerFillSymbol extends AbstractFillSymbol { |
|
103 |
private double rotation; |
|
104 |
private AbstractMarkerSymbol markerSymbol = new CharacterMarkerSymbol(); |
|
105 |
private boolean grid = true; |
|
106 |
private double xOffset = 0; |
|
107 |
private double yOffset = 0; |
|
108 |
private double xSeparation = 20; |
|
109 |
private double ySeparation = 20; |
|
110 |
|
|
111 |
public boolean isGrid() { |
|
112 |
return grid; |
|
113 |
} |
|
114 |
|
|
115 |
public void setGrid(boolean grid) { |
|
116 |
this.grid = grid; |
|
117 |
} |
|
118 |
|
|
119 |
public AbstractMarkerSymbol getMarkerSymbol() { |
|
120 |
return markerSymbol; |
|
121 |
} |
|
122 |
|
|
123 |
public void setMarkerSymbol(AbstractMarkerSymbol markerSymbol) { |
|
124 |
this.markerSymbol = markerSymbol; |
|
125 |
} |
|
126 |
|
|
127 |
public double getRotation() { |
|
128 |
return rotation; |
|
129 |
} |
|
130 |
|
|
131 |
public void setRotation(double rotation) { |
|
132 |
this.rotation = rotation; |
|
133 |
} |
|
134 |
|
|
135 |
public double getXOffset() { |
|
136 |
return xOffset; |
|
137 |
} |
|
138 |
|
|
139 |
public void setXOffset(double offset) { |
|
140 |
xOffset = offset; |
|
141 |
} |
|
142 |
|
|
143 |
public double getXSeparation() { |
|
144 |
return xSeparation; |
|
145 |
} |
|
146 |
|
|
147 |
public void setXSeparation(double separation) { |
|
148 |
xSeparation = separation; |
|
149 |
} |
|
150 |
|
|
151 |
public double getYOffset() { |
|
152 |
return yOffset; |
|
153 |
} |
|
154 |
|
|
155 |
public void setYOffset(double offset) { |
|
156 |
yOffset = offset; |
|
157 |
} |
|
158 |
|
|
159 |
public double getYSeparation() { |
|
160 |
return ySeparation; |
|
161 |
} |
|
162 |
|
|
163 |
public void setYSeparation(double separation) { |
|
164 |
ySeparation = separation; |
|
165 |
} |
|
166 |
|
|
167 |
public ISymbol getSymbolForSelection() { |
|
168 |
// TODO Auto-generated method stub |
|
169 |
throw new Error("Not yet implemented!"); |
|
170 |
} |
|
171 |
|
|
172 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
|
173 |
g.setColor(null); |
|
174 |
g.setStroke(new BasicStroke(0)); |
|
175 |
int w=7; |
|
176 |
int h=7; |
|
177 |
|
|
178 |
BufferedImage bi = null; |
|
179 |
|
|
180 |
|
|
181 |
Rectangle rProv = new Rectangle(); |
|
182 |
rProv.setFrame(0, 0,w,h); |
|
183 |
|
|
184 |
Paint resulPatternFill = null; |
|
185 |
bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
186 |
Graphics2D gAux = bi.createGraphics(); |
|
187 |
markerSymbol.drawInsideRectangle(gAux, new AffineTransform(), rProv); |
|
188 |
resulPatternFill = new TexturePaint(bi,rProv); |
|
189 |
g.setColor(null); |
|
190 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
191 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
192 |
|
|
193 |
g.setPaint(resulPatternFill); |
|
194 |
g.fill(shp); |
|
195 |
|
|
196 |
} |
|
197 |
|
|
198 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, Shape shp) { |
|
199 |
// TODO Auto-generated method stub |
|
200 |
throw new Error("Not yet implemented!"); |
|
201 |
} |
|
202 |
|
|
203 |
public XMLEntity getXMLEntity() { |
|
204 |
XMLEntity xml = new XMLEntity(); |
|
205 |
xml.putProperty("className", getClassName()); |
|
206 |
// color |
|
207 |
xml.putProperty("color", StringUtilities.color2String(color)); |
|
208 |
|
|
209 |
xml.putProperty("rotation", rotation); |
|
210 |
xml.putProperty("grid", grid); |
|
211 |
xml.putProperty("xOffset", xOffset); |
|
212 |
xml.putProperty("yOffset", yOffset); |
|
213 |
xml.putProperty("xSeparation", xSeparation); |
|
214 |
xml.putProperty("ySeparation", ySeparation); |
|
215 |
|
|
216 |
xml.addChild(markerSymbol.getXMLEntity()); |
|
217 |
return xml; |
|
218 |
} |
|
219 |
|
|
220 |
public int getSymbolType() { |
|
221 |
// TODO Auto-generated method stub |
|
222 |
throw new Error("Not yet implemented!"); |
|
223 |
} |
|
224 |
|
|
225 |
public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) { |
|
226 |
if (isGrid()) { |
|
227 |
// Use a TexturePaint |
|
228 |
int w=7; |
|
229 |
int h=7; |
|
230 |
|
|
231 |
BufferedImage bi = null; |
|
232 |
|
|
233 |
Rectangle rProv = new Rectangle(); |
|
234 |
rProv.setFrame(0, 0,w,h); |
|
235 |
|
|
236 |
Paint resulPatternFill = null; |
|
237 |
bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
238 |
Graphics2D gAux = bi.createGraphics(); |
|
239 |
markerSymbol.drawInsideRectangle(gAux, new AffineTransform(), rProv); |
|
240 |
resulPatternFill = new TexturePaint(bi,rProv); |
|
241 |
g.setColor(null); |
|
242 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
|
243 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
244 |
|
|
245 |
g.setPaint(resulPatternFill); |
|
246 |
g.fill(r); |
|
247 |
g.drawRect(0, 0, r.width, r.height); |
|
248 |
} else { |
|
249 |
Point2D[] points = ramdonizePoints(r); |
|
250 |
for (int i = 0; i < points.length; i++) { |
|
251 |
|
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
private Point2D[] ramdonizePoints(Rectangle r) { |
|
257 |
ArrayList points = new ArrayList(); |
|
258 |
throw new Error("Not yet implemented!"); |
|
259 |
// return (Point2D[]) points.toArray(new Point2D[0]); |
|
260 |
} |
|
261 |
|
|
262 |
public String getClassName() { |
|
263 |
return getClass().getName(); |
|
264 |
} |
|
265 |
|
|
266 |
public void setXMLEntity(XMLEntity xml) { |
|
267 |
rotation = xml.getDoubleProperty("rotation"); |
|
268 |
grid = xml.getBooleanProperty("grid"); |
|
269 |
xOffset = xml.getDoubleProperty("xOffset"); |
|
270 |
yOffset = xml.getDoubleProperty("yOffset"); |
|
271 |
xSeparation = xml.getDoubleProperty("xSeparation"); |
|
272 |
ySeparation = xml.getDoubleProperty("ySeparation"); |
|
273 |
markerSymbol = (AbstractMarkerSymbol) SymbolFactory. |
|
274 |
createFromXML(xml.getChild(0), null); |
|
275 |
} |
|
276 |
|
|
277 |
public void setMarker(AbstractMarkerSymbol marker) { |
|
278 |
this.markerSymbol = marker; |
|
279 |
} |
|
280 |
|
|
281 |
} |
|
0 | 282 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractFillSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.6 2006/12/04 17:13:39 fjp |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.5 2006/11/14 11:10:27 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.4 2006/11/09 18:39:05 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.3 2006/11/06 07:33:54 jaume |
|
59 |
* javadoc, source style |
|
60 |
* |
|
61 |
* Revision 1.2 2006/10/31 16:16:34 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.1 2006/10/30 19:30:35 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* |
|
68 |
*/ |
|
69 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
70 |
|
|
71 |
import java.awt.Color; |
|
72 |
|
|
73 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
74 |
|
|
75 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
76 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
77 |
|
|
78 |
|
|
79 |
/** |
|
80 |
* Abstract class that any FILL SYMBOL should extend |
|
81 |
* |
|
82 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
83 |
* |
|
84 |
*/ |
|
85 |
public abstract class AbstractFillSymbol extends AbstractSymbol { |
|
86 |
Color color = Color.WHITE; |
|
87 |
Color outline = Color.BLACK; // TODO aix? canviar? a AbsrtactLineSymbol quan existisca |
|
88 |
|
|
89 |
public boolean isSuitableFor(IGeometry geom) { |
|
90 |
return geom.getGeometryType() == FShape.POLYGON; |
|
91 |
} |
|
92 |
|
|
93 |
public int getOnePointRgb() { |
|
94 |
return outline.getRGB(); |
|
95 |
} |
|
96 |
} |
|
0 | 97 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleMarkerSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.1 2006/11/14 11:10:27 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* |
|
53 |
*/ |
|
54 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
55 |
|
|
56 |
import java.awt.Color; |
|
57 |
import java.awt.Graphics2D; |
|
58 |
import java.awt.Rectangle; |
|
59 |
import java.awt.Shape; |
|
60 |
import java.awt.geom.AffineTransform; |
|
61 |
|
|
62 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
63 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
64 |
import com.iver.utiles.StringUtilities; |
|
65 |
import com.iver.utiles.XMLEntity; |
|
66 |
|
|
67 |
public class SimpleMarkerSymbol extends AbstractMarkerSymbol { |
|
68 |
private boolean outline; |
|
69 |
private Color outlineColor; |
|
70 |
private double outlineSize; |
|
71 |
|
|
72 |
|
|
73 |
private ISymbol selectionSymbol; |
|
74 |
|
|
75 |
public ISymbol getSymbolForSelection() { |
|
76 |
if (selectionSymbol == null) { |
|
77 |
XMLEntity xml = getXMLEntity(); |
|
78 |
xml.putProperty("color", StringUtilities.color2String(Color.YELLOW)); |
|
79 |
selectionSymbol = SymbolFactory.createFromXML(xml, getDescription() + " version for selection."); |
|
80 |
} |
|
81 |
return selectionSymbol; |
|
82 |
} |
|
83 |
|
|
84 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
|
85 |
// TODO Auto-generated method stub |
|
86 |
throw new Error("Not yet implemented!"); |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, Shape shp) { |
|
91 |
// TODO Auto-generated method stub |
|
92 |
throw new Error("Not yet implemented!"); |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
public XMLEntity getXMLEntity() { |
|
97 |
// TODO Auto-generated method stub |
|
98 |
throw new Error("Not yet implemented!"); |
|
99 |
|
|
100 |
} |
|
101 |
|
|
102 |
public int getSymbolType() { |
|
103 |
// TODO Auto-generated method stub |
|
104 |
throw new Error("Not yet implemented!"); |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) { |
|
109 |
// TODO Auto-generated method stub |
|
110 |
throw new Error("Not yet implemented!"); |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
public String getClassName() { |
|
115 |
// TODO Auto-generated method stub |
|
116 |
throw new Error("Not yet implemented!"); |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
public void setXMLEntity(XMLEntity xml) { |
|
121 |
// TODO Auto-generated method stub |
|
122 |
throw new Error("Not yet implemented!"); |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
} |
|
0 | 127 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/DotDensityFillSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.4 2006/11/14 11:10:27 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.3 2006/11/13 09:15:23 jaume |
|
53 |
* javadoc and some clean-up |
|
54 |
* |
|
55 |
* Revision 1.2 2006/11/09 18:39:05 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.1 2006/11/09 10:22:50 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
64 |
|
|
65 |
import java.awt.Color; |
|
66 |
import java.awt.Graphics2D; |
|
67 |
import java.awt.Point; |
|
68 |
import java.awt.Rectangle; |
|
69 |
import java.awt.Shape; |
|
70 |
import java.awt.geom.AffineTransform; |
|
71 |
import java.util.Random; |
|
72 |
|
|
73 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
74 |
import com.iver.utiles.StringUtilities; |
|
75 |
import com.iver.utiles.XMLEntity; |
|
76 |
|
|
77 |
/** |
|
78 |
* <p> |
|
79 |
* Symbol that draws a set of points within a polygon. The amount of points is |
|
80 |
* defined by the field dotCount.<br> |
|
81 |
* </p> |
|
82 |
* <p> |
|
83 |
* This symbol only draws the points. The outline and the fill of the polygon is |
|
84 |
* handled by a SimpleFillSymboll where a DotDensityFillSymbol should be |
|
85 |
* embedded.<br> |
|
86 |
* </p> |
|
87 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
88 |
* |
|
89 |
*/ |
|
90 |
public class DotDensityFillSymbol extends AbstractFillSymbol { |
|
91 |
private int dotCount; |
|
92 |
private double dotSize; |
|
93 |
private double dotSpacing; |
|
94 |
private boolean fixedPlacement; |
|
95 |
|
|
96 |
public DotDensityFillSymbol() { |
|
97 |
super(); |
|
98 |
} |
|
99 |
|
|
100 |
public ISymbol getSymbolForSelection() { |
|
101 |
return this; // the selection color is applied in the SimpleFillSymbol |
|
102 |
} |
|
103 |
|
|
104 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
|
105 |
int width = shp.getBounds().width; |
|
106 |
int height = shp.getBounds().height; |
|
107 |
int minx = shp.getBounds().x; |
|
108 |
int miny = shp.getBounds().y; |
|
109 |
Random random = new Random(); |
|
110 |
g.setClip(shp); |
|
111 |
g.setColor(color); |
|
112 |
g.setBackground(null); |
|
113 |
int size = (int) dotSize; |
|
114 |
for (int i = 0; i < dotCount; i++) { |
|
115 |
int x = (int) Math.abs(random.nextDouble() * width); |
|
116 |
int y = (int) Math.abs(random.nextDouble() * height); |
|
117 |
x = x + minx; |
|
118 |
y = y + miny; |
|
119 |
g.fillRect(x, y, size, size); |
|
120 |
} |
|
121 |
g.setClip(null); |
|
122 |
} |
|
123 |
|
|
124 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
|
125 |
Shape shp) { |
|
126 |
// TODO Auto-generated method stub |
|
127 |
throw new Error("Not yet implemented!"); |
|
128 |
} |
|
129 |
|
|
130 |
public XMLEntity getXMLEntity() { |
|
131 |
XMLEntity xml = new XMLEntity(); |
|
132 |
xml.putProperty("className", getClassName()); |
|
133 |
|
|
134 |
// color |
|
135 |
xml.putProperty("color", StringUtilities.color2String(color)); |
|
136 |
|
|
137 |
// description |
|
138 |
xml.putProperty("desc", getDescription()); |
|
139 |
|
|
140 |
// is shape visible |
|
141 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
|
142 |
|
|
143 |
// dot count |
|
144 |
xml.putProperty("dotCount", dotCount); |
|
145 |
|
|
146 |
// dot size |
|
147 |
xml.putProperty("dotSize", dotSize); |
|
148 |
|
|
149 |
// dot spacing |
|
150 |
xml.putProperty("dotSpacing", dotSpacing); |
|
151 |
|
|
152 |
return xml; |
|
153 |
} |
|
154 |
|
|
155 |
public int getSymbolType() { |
|
156 |
return FShape.POLYGON; |
|
157 |
} |
|
158 |
|
|
159 |
public void drawInsideRectangle(Graphics2D g, |
|
160 |
AffineTransform scaleInstance, Rectangle r) { |
|
161 |
int x = r.x; |
|
162 |
int y = r.y; |
|
163 |
int width = r.width; |
|
164 |
int height= r.height; |
|
165 |
int size = height / 8; |
|
166 |
g.setColor(color); |
|
167 |
g.setBackground(null); |
|
168 |
g.fillRect((int) (x+height*0.2), (int) (y+width*0.2), size, size); |
|
169 |
g.fillRect((int) (x+height*0.25), (int) (y+width*0.7), size, size); |
|
170 |
g.fillRect((int) (x+height*0.65), (int) (y+width*0.5), size, size); |
|
171 |
g.fillRect((int) (x+height*0.8), (int) (y+width*0.1), size, size); |
|
172 |
g.fillRect((int) (x+height*0.8), (int) (y+width*0.8), size, size); |
|
173 |
g.fillRect((int) (x+height*0.9), (int) (y+width*0.3), size, size); |
|
174 |
g.fillRect((int) (x+height*1.1), (int) (y+width*0.8), size, size); |
|
175 |
} |
|
176 |
|
|
177 |
public String getClassName() { |
|
178 |
return getClass().getName(); |
|
179 |
} |
|
180 |
|
|
181 |
public void setXMLEntity(XMLEntity xml) { |
|
182 |
// color |
|
183 |
color = StringUtilities.string2Color(xml.getStringProperty("color")); |
|
184 |
|
|
185 |
// description |
|
186 |
setDescription(xml.getStringProperty("desc")); |
|
187 |
|
|
188 |
// is shape visible |
|
189 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible")); |
|
190 |
|
|
191 |
// dot count |
|
192 |
dotCount = xml.getIntProperty("dotCount"); |
|
193 |
|
|
194 |
// dot size |
|
195 |
dotSize = xml.getDoubleProperty("dotSize"); |
|
196 |
|
|
197 |
// dot spacing |
|
198 |
dotSpacing = xml.getDoubleProperty("dotSpacing"); |
|
199 |
} |
|
200 |
|
|
201 |
public int getDotCount() { |
|
202 |
return dotCount; |
|
203 |
} |
|
204 |
|
|
205 |
public void setDotCount(int dotCount) { |
|
206 |
this.dotCount = dotCount; |
|
207 |
} |
|
208 |
|
|
209 |
public double getDotSize() { |
|
210 |
return dotSize; |
|
211 |
} |
|
212 |
|
|
213 |
public void setDotSize(double dotSize) { |
|
214 |
this.dotSize = dotSize; |
|
215 |
} |
|
216 |
|
|
217 |
public double getDotSpacing() { |
|
218 |
return dotSpacing; |
|
219 |
} |
|
220 |
|
|
221 |
public void setDotSpacing(double dotSpacing) { |
|
222 |
this.dotSpacing = dotSpacing; |
|
223 |
} |
|
224 |
|
|
225 |
public Color getDotColor() { |
|
226 |
return color; |
|
227 |
} |
|
228 |
|
|
229 |
public void setDotColor(Color dotColor) { |
|
230 |
this.color = dotColor; |
|
231 |
} |
|
232 |
|
|
233 |
} |
|
0 | 234 |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/CharacterMarkerSymbol.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2007-01-10 16:31:36 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.6 2006/12/04 17:13:39 fjp |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.5 2006/11/14 11:10:27 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.4 2006/11/09 18:39:05 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.3 2006/11/08 10:56:47 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.2 2006/11/06 17:08:45 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.1 2006/10/31 16:16:34 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.4 2006/10/30 19:30:35 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.3 2006/10/29 23:53:49 jaume |
|
71 |
* *** empty log message *** |
|
72 |
* |
|
73 |
* Revision 1.2 2006/10/26 16:27:33 jaume |
|
74 |
* support for composite marker symbols (not tested) |
|
75 |
* |
|
76 |
* Revision 1.1 2006/10/25 10:50:41 jaume |
|
77 |
* movement of classes and gui stuff |
|
78 |
* |
|
79 |
* Revision 1.3 2006/10/24 19:54:16 jaume |
|
80 |
* added IPersistence |
|
81 |
* |
|
82 |
* Revision 1.2 2006/10/24 08:02:51 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* Revision 1.1 2006/10/18 07:54:06 jaume |
|
86 |
* *** empty log message *** |
|
87 |
* |
|
88 |
* |
|
89 |
*/ |
|
90 |
package com.iver.cit.gvsig.fmap.core.symbols; |
|
91 |
|
|
92 |
import java.awt.Color; |
|
93 |
import java.awt.Font; |
|
94 |
import java.awt.Graphics2D; |
|
95 |
import java.awt.Point; |
|
96 |
import java.awt.Rectangle; |
|
97 |
import java.awt.Shape; |
|
98 |
import java.awt.geom.AffineTransform; |
|
99 |
import java.awt.geom.Point2D; |
|
100 |
|
|
101 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
102 |
|
|
103 |
import org.apache.batik.ext.awt.geom.PathLength; |
|
104 |
|
|
105 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
106 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
107 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
108 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
109 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
110 |
import com.iver.utiles.StringUtilities; |
|
111 |
import com.iver.utiles.XMLEntity; |
|
112 |
import com.vividsolutions.jts.geom.Geometry; |
|
113 |
|
|
114 |
|
|
115 |
// TODO quitar batik-util.jar del classpath de extGraph cuando movamos esto a FMap |
|
116 |
/** |
|
117 |
* Symbol that manages symbols from a TrueType font source |
|
118 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
119 |
*/ |
|
120 |
public class CharacterMarkerSymbol extends AbstractMarkerSymbol { |
|
121 |
private Font font = new Font("Arial", Font.PLAIN, 20); |
|
122 |
private int symbol; |
|
123 |
private ISymbol selectionSymbol; |
|
124 |
|
|
125 |
/** |
|
126 |
* Creates a new instance of CharacterMarker with default values |
|
127 |
* |
|
128 |
*/ |
|
129 |
public CharacterMarkerSymbol() { |
|
130 |
super(); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Creates a new instance of CharacterMarker specifying the marker source |
|
135 |
* font, the character code corresponding to the symbol, and the color that |
|
136 |
* will be used in rendering time. |
|
137 |
* |
|
138 |
* @param font - |
|
139 |
* src Font |
|
140 |
* @param charCode - |
|
141 |
* character code of the symbol for this font |
|
142 |
* @param color - |
|
143 |
* color to be used in when rendering. |
|
144 |
*/ |
|
145 |
public CharacterMarkerSymbol(Font font, int charCode, Color color) { |
|
146 |
super(); |
|
147 |
this.font = font; |
|
148 |
symbol = charCode; |
|
149 |
this.color = color; |
|
150 |
} |
|
151 |
|
|
152 |
public Font getFont() { |
|
153 |
return font; |
|
154 |
} |
|
155 |
|
|
156 |
public void setFont(Font font) { |
|
157 |
this.font = font; |
|
158 |
} |
|
159 |
|
|
160 |
public ISymbol getSymbolForSelection() { |
|
161 |
if (selectionSymbol == null) { |
|
162 |
XMLEntity xml = getXMLEntity(); |
|
163 |
xml.putProperty("color", StringUtilities.color2String(Color.YELLOW)); |
|
164 |
selectionSymbol = SymbolFactory.createFromXML(xml, getDescription() + " version for selection."); |
|
165 |
} |
|
166 |
return selectionSymbol; |
|
167 |
} |
|
168 |
|
|
169 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
|
170 |
g.setFont(getFont()); |
|
171 |
g.setColor(color); |
|
172 |
g.rotate(getRotation()); |
|
173 |
Point2D p = null; |
|
174 |
switch (shp.getShapeType()) { |
|
175 |
case FShape.POINT: |
|
176 |
p = new Point2D.Double(((FPoint2D) shp).getX(), ((FPoint2D) shp) |
|
177 |
.getY()); |
|
178 |
break; |
|
179 |
case FShape.LINE: |
|
180 |
PathLength pathLen = new PathLength(shp); |
|
181 |
float midDistance = pathLen.lengthOfPath() / 2; |
|
182 |
p = pathLen.pointAtLength(midDistance); |
|
183 |
break; |
|
184 |
case FShape.POLYGON: |
|
185 |
Geometry geom = FConverter.java2d_to_jts(shp); |
|
186 |
com.vividsolutions.jts.geom.Point centroid = geom.getCentroid(); |
|
187 |
p = new Point2D.Double(centroid.getX(), centroid.getY()); |
|
188 |
} |
|
189 |
// p = affineTransform.transform(p, null); |
|
190 |
|
|
191 |
char[] text = new char[] { (char) symbol }; |
|
192 |
g.drawChars(text, 0, text.length, (int) p.getX(), (int) p.getY()); |
|
193 |
|
|
194 |
if (subSymbols!=null) { |
|
195 |
for (int i = 0; i < subSymbols.length; i++) { |
|
196 |
subSymbols[i].draw(g, affineTransform, shp); |
|
197 |
} |
|
198 |
} |
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
|
203 |
Shape shp) { |
|
204 |
// TODO Auto-generated method stub |
|
205 |
throw new Error("Not yet implemented!"); |
|
206 |
} |
|
207 |
|
|
208 |
public XMLEntity getXMLEntity() { |
|
209 |
XMLEntity xml = new XMLEntity(); |
|
210 |
|
|
211 |
// the class name |
|
212 |
xml.putProperty("className", getClassName()); |
|
213 |
|
|
214 |
// color |
|
215 |
xml.putProperty("color", StringUtilities.color2String(color)); |
|
216 |
|
|
217 |
// font |
|
218 |
xml.putProperty("font", font.getFontName()); |
|
219 |
|
|
220 |
// font style |
|
221 |
xml.putProperty("fontStyle", font.getStyle()); |
|
222 |
|
|
223 |
// symbol code |
|
224 |
xml.putProperty("symbolCode", symbol); |
|
225 |
|
|
226 |
// description |
|
227 |
xml.putProperty("desc", getDescription()); |
|
228 |
|
|
229 |
// is shape visible |
|
230 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
|
231 |
|
|
232 |
// x offset |
|
233 |
xml.putProperty("xOffset", getOffset().getX()); |
|
234 |
|
|
235 |
// y offset |
|
236 |
xml.putProperty("yOffset", getOffset().getY()); |
|
237 |
|
|
238 |
// rotation |
|
239 |
xml.putProperty("rotation", rotation); |
|
240 |
return xml; |
|
241 |
} |
|
242 |
|
|
243 |
public int getSymbolType() { |
|
244 |
return CHARACTER_MARKER; |
|
245 |
} |
|
246 |
|
|
247 |
public void drawInsideRectangle(Graphics2D g, |
|
248 |
AffineTransform scaleInstance, Rectangle r) { |
|
249 |
g.rotate(getRotation()); |
|
250 |
// Sirve de algo el scaleInstance??? |
|
251 |
// g.setFont(font.deriveFont(scaleInstance)); |
|
252 |
double h = r.getHeight(); |
|
253 |
Font myFont = font.deriveFont( |
|
254 |
(float) (h * FConstant.FONT_HEIGHT_SCALE_FACTOR)).deriveFont( |
|
255 |
scaleInstance); |
|
256 |
g.setFont(myFont); |
|
257 |
g.setColor(color); |
|
258 |
r.y = (int) h; |
|
259 |
|
Also available in: Unified diff