Revision 38401 branches/v2_0_0_prep/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/line/impl/PictureLineSymbol.java
PictureLineSymbol.java | ||
---|---|---|
44 | 44 |
import java.awt.Color; |
45 | 45 |
import java.awt.Graphics2D; |
46 | 46 |
import java.awt.Rectangle; |
47 |
import java.awt.Shape; |
|
47 | 48 |
import java.awt.geom.AffineTransform; |
48 | 49 |
import java.awt.geom.PathIterator; |
49 | 50 |
import java.awt.geom.Point2D; |
... | ... | |
167 | 168 |
} |
168 | 169 |
|
169 | 170 |
private void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Cancellable cancel) { |
170 |
float csWidth = getLineStyle().getLineWidth(); |
|
171 |
g.setClip(new BasicStroke((float) csWidth, BasicStroke.CAP_ROUND,BasicStroke.CAP_ROUND).createStrokedShape(geom.getShape())); |
|
171 |
|
|
172 |
if (csXScale<=0 && csYScale<=0) { |
|
173 |
return; |
|
174 |
} |
|
175 |
|
|
176 |
float csWidth = getLineStyle().getLineWidth(); |
|
177 |
|
|
178 |
BasicStroke bs = new BasicStroke( |
|
179 |
(float) csWidth, |
|
180 |
BasicStroke.CAP_ROUND, |
|
181 |
BasicStroke.CAP_ROUND); |
|
182 |
|
|
183 |
Shape geom_transf_clip = geom.getShape(affineTransform); |
|
184 |
g.setClip(bs.createStrokedShape(geom_transf_clip)); |
|
185 |
|
|
172 | 186 |
BackgroundFileStyle bg = (!selected) ? bgImage : bgSelImage ; |
173 | 187 |
|
174 |
if (csXScale<=0 && csYScale<=0) |
|
175 |
return; |
|
176 |
|
|
177 | 188 |
Rectangle bounds = bg.getBounds(); |
178 | 189 |
final double imageWidth = bounds.getWidth() * csXScale; |
179 | 190 |
final double imageHeight = bounds.getHeight() * csYScale; |
... | ... | |
181 | 192 |
if (imageWidth==0 || imageHeight==0) return; |
182 | 193 |
int height = (int) csWidth; |
183 | 194 |
|
184 |
PathLength pl = new PathLength(geom.getShape());
|
|
185 |
PathIterator iterator = geom.getPathIterator(null, 0.8); |
|
195 |
PathLength pl = new PathLength(geom_transf_clip);
|
|
196 |
PathIterator iterator = geom_transf_clip.getPathIterator(null, 0.8);
|
|
186 | 197 |
double[] theData = new double[6]; |
187 | 198 |
Point2D firstPoint = null, startPoint = null, endPoint = null; |
188 | 199 |
if (!iterator.isDone()) { |
... | ... | |
237 | 248 |
g.rotate(theta); |
238 | 249 |
|
239 | 250 |
double xOffsetTranslation = imageWidth*i; |
240 |
|
|
241 |
|
|
242 | 251 |
g.translate(xOffsetTranslation, -csWidth); |
243 | 252 |
|
244 | 253 |
rect.setBounds(0, (int) Math.round(height*.5), (int) Math.ceil(imageWidth), height); |
... | ... | |
247 | 256 |
} catch (SymbolDrawingException e) { |
248 | 257 |
logger.warn(Messages.getText("label_style_could_not_be_painted"), e); |
249 | 258 |
} |
250 |
g.setColor(Color.red); |
|
251 | 259 |
g.translate(-xOffsetTranslation, csWidth); |
252 | 260 |
|
253 | 261 |
g.rotate(-theta); |
... | ... | |
258 | 266 |
currentPathLength += segmentLength; |
259 | 267 |
iterator.next(); |
260 | 268 |
} |
261 |
|
|
262 | 269 |
g.setClip(null); |
263 |
g.setColor(Color.red); |
|
264 |
|
|
265 | 270 |
} |
266 | 271 |
|
267 | 272 |
/** |
Also available in: Unified diff