Revision 39569 trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/symbols/SmartTextSymbol.java
SmartTextSymbol.java | ||
---|---|---|
92 | 92 |
*/ |
93 | 93 |
package org.gvsig.symbology.fmap.symbols; |
94 | 94 |
|
95 |
import java.awt.BasicStroke; |
|
95 | 96 |
import java.awt.BorderLayout; |
96 | 97 |
import java.awt.Color; |
97 | 98 |
import java.awt.Dimension; |
... | ... | |
99 | 100 |
import java.awt.Graphics; |
100 | 101 |
import java.awt.Graphics2D; |
101 | 102 |
import java.awt.Rectangle; |
103 |
import java.awt.Shape; |
|
104 |
import java.awt.Stroke; |
|
102 | 105 |
import java.awt.event.ActionEvent; |
103 | 106 |
import java.awt.event.ActionListener; |
104 | 107 |
import java.awt.font.FontRenderContext; |
108 |
import java.awt.font.GlyphVector; |
|
105 | 109 |
import java.awt.font.LineMetrics; |
106 | 110 |
import java.awt.geom.AffineTransform; |
107 |
import java.awt.geom.Rectangle2D; |
|
108 | 111 |
import java.util.ArrayList; |
109 | 112 |
|
110 | 113 |
import javax.print.attribute.PrintRequestAttributeSet; |
... | ... | |
116 | 119 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
117 | 120 |
import org.gvsig.gui.beans.swing.JComboBoxFonts; |
118 | 121 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
122 |
import org.gvsig.symbology.fmap.labeling.placements.PointPlacementConstraints; |
|
119 | 123 |
|
120 | 124 |
import com.iver.cit.gvsig.fmap.ViewPort; |
121 | 125 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
... | ... | |
227 | 231 |
} |
228 | 232 |
} |
229 | 233 |
public SmartTextSymbol() { |
234 |
PointPlacementConstraints pc = new PointPlacementConstraints(); |
|
235 |
this.constraints = pc; |
|
236 |
|
|
230 | 237 |
} |
231 | 238 |
|
232 | 239 |
/** |
... | ... | |
249 | 256 |
g.setFont(font); |
250 | 257 |
FontRenderContext frc = g.getFontRenderContext(); |
251 | 258 |
LineMetrics lineMetrics = font.getLineMetrics(getText(), frc); |
259 |
|
|
260 |
// GlyphVector glyph = font.layoutGlyphVector(frc, charText, 0, charText.length, Font.LAYOUT_NO_START_CONTEXT); |
|
252 | 261 |
double cons = 0; |
253 | 262 |
|
254 | 263 |
/* Repartimos el leading (espacio de separaci?n entre lineas) |
... | ... | |
269 | 278 |
// cons = lineMetrics.getDescent()+(lineMetrics.getLeading()/2)-(lineMetrics.getHeight()/2); |
270 | 279 |
cons = lineMetrics.getDescent()+lineMetrics.getLeading()-(lineMetrics.getHeight()/2); |
271 | 280 |
} |
281 |
|
|
282 |
double[] coords = tp.nextPosForGlyph(0); |
|
283 |
float haloRadius = 4; |
|
284 |
// Shape outline = glyph.getOutline((float) coords[0], (float) coords[1]); |
|
285 |
Stroke haloStroke = new BasicStroke(2f * haloRadius, BasicStroke.CAP_ROUND, |
|
286 |
BasicStroke.JOIN_ROUND); |
|
287 |
// g.setStroke(haloStroke); |
|
288 |
// g.setColor(Color.white); |
|
289 |
// g.draw(outline); |
|
290 |
// g.setStroke(new BasicStroke()); |
|
291 |
// g.setColor(this.getTextColor()); |
|
292 |
// g.drawGlyphVector(glyph, (float) coords[0], (float) coords[1]); |
|
272 | 293 |
|
273 | 294 |
for (int i = 0; i < tp.getGlyphCount(); i++) { |
274 |
double[] coords = tp.nextPosForGlyph(i);
|
|
295 |
coords = tp.nextPosForGlyph(i); |
|
275 | 296 |
if (coords[0] == TextPath.NO_POS || coords[1] == TextPath.NO_POS) |
276 | 297 |
continue; |
277 | 298 |
|
... | ... | |
281 | 302 |
|
282 | 303 |
g.translate(coords[0]+xOffset, coords[1]-yOffset); |
283 | 304 |
g.rotate(coords[2]); |
305 |
|
|
306 |
char[] aux = new char[1]; |
|
307 |
aux[0] = charText[i]; |
|
308 |
GlyphVector glyph = font.createGlyphVector(frc, aux); |
|
309 |
Shape outlineChar = glyph.getOutline(); |
|
310 |
g.setStroke(haloStroke); |
|
311 |
g.setColor(Color.white); |
|
312 |
g.draw(outlineChar); |
|
313 |
|
|
314 |
|
|
284 | 315 |
g.setColor(this.getTextColor()); |
285 | 316 |
g.drawString(String.valueOf(charText[i]), 0, 0); |
286 | 317 |
g.rotate(-coords[2]); |
... | ... | |
453 | 484 |
|
454 | 485 |
gpx.moveTo(50, 100); |
455 | 486 |
gpx.lineTo(100, 50); |
487 |
gpx.lineTo(150, 100); |
|
488 |
gpx.lineTo(250, 50); |
|
456 | 489 |
|
457 | 490 |
SmartTextSymbol sms = new SmartTextSymbol(); |
458 | 491 |
FPolyline2D theLineShape = new FPolyline2D(gpx); |
Also available in: Unified diff