Revision 8729 trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/fmap/core/symbols/DotDensityFillSymbol.java
DotDensityFillSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2006-11-13 09:15:23 jaume |
|
46 |
* Revision 1.4 2006-11-14 11:10:27 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* Revision 1.3 2006/11/13 09:15:23 jaume |
|
47 | 50 |
* javadoc and some clean-up |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2006/11/09 18:39:05 jaume |
... | ... | |
69 | 72 |
import com.iver.utiles.StringUtilities; |
70 | 73 |
import com.iver.utiles.XMLEntity; |
71 | 74 |
|
75 |
/** |
|
76 |
* <p> |
|
77 |
* Symbol that draws a set of points within a polygon. The amount of points is |
|
78 |
* defined by the field dotCount.<br> |
|
79 |
* </p> |
|
80 |
* <p> |
|
81 |
* This symbol only draws the points. The outline and the fill of the polygon is |
|
82 |
* handled by a SimpleFillSymboll where a DotDensityFillSymbol should be |
|
83 |
* embedded.<br> |
|
84 |
* </p> |
|
85 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
86 |
* |
|
87 |
*/ |
|
72 | 88 |
public class DotDensityFillSymbol extends AbstractFillSymbol { |
73 | 89 |
private int dotCount; |
74 | 90 |
private double dotSize; |
75 | 91 |
private double dotSpacing; |
76 | 92 |
private boolean fixedPlacement; |
77 |
|
|
78 | 93 |
public DotDensityFillSymbol() { |
79 | 94 |
super(); |
80 | 95 |
isShapeVisible = true; |
81 | 96 |
} |
82 | 97 |
|
83 | 98 |
public ISymbol getSymbolForSelection() { |
84 |
// TODO Auto-generated method stub |
|
85 |
throw new Error("Not yet implemented!"); |
|
99 |
return this; // the selection color is applied in the SimpleFillSymbol |
|
86 | 100 |
} |
87 | 101 |
|
88 | 102 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
... | ... | |
93 | 107 |
Random random = new Random(); |
94 | 108 |
g.setClip(shp); |
95 | 109 |
g.setColor(color); |
110 |
g.setBackground(null); |
|
96 | 111 |
int size = (int) dotSize; |
97 | 112 |
for (int i = 0; i < dotCount; i++) { |
98 | 113 |
int x = (int) Math.abs(random.nextDouble() * width); |
... | ... | |
101 | 116 |
y = y + miny; |
102 | 117 |
g.fillRect(x, y, size, size); |
103 | 118 |
} |
119 |
g.setClip(null); |
|
104 | 120 |
} |
105 | 121 |
|
106 | 122 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
... | ... | |
131 | 147 |
// dot spacing |
132 | 148 |
xml.putProperty("dotSpacing", dotSpacing); |
133 | 149 |
|
134 |
|
|
135 |
// layers |
|
136 |
if (layers!=null) |
|
137 |
for (int i = 0; i < layers.length; i++) { |
|
138 |
xml.addChild(layers[i].getXMLEntity()); |
|
139 |
} |
|
140 |
|
|
141 | 150 |
return xml; |
142 | 151 |
} |
143 | 152 |
|
... | ... | |
151 | 160 |
int y = r.y; |
152 | 161 |
int width = r.width; |
153 | 162 |
int height= r.height; |
154 |
int size = height / 15;
|
|
163 |
int size = height / 8;
|
|
155 | 164 |
g.setColor(color); |
165 |
g.setBackground(null); |
|
156 | 166 |
g.fillRect((int) (x+height*0.2), (int) (y+width*0.2), size, size); |
157 | 167 |
g.fillRect((int) (x+height*0.25), (int) (y+width*0.7), size, size); |
158 | 168 |
g.fillRect((int) (x+height*0.65), (int) (y+width*0.5), size, size); |
... | ... | |
185 | 195 |
// dot spacing |
186 | 196 |
dotSpacing = xml.getDoubleProperty("dotSpacing"); |
187 | 197 |
|
198 |
layers = new ISymbol[xml.getChildrenCount()]; |
|
199 |
|
|
188 | 200 |
} |
189 | 201 |
|
190 | 202 |
public int getDotCount() { |
Also available in: Unified diff