Revision 28367 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleTextSymbol.java
SimpleTextSymbol.java | ||
---|---|---|
55 | 55 |
import javax.print.attribute.PrintRequestAttributeSet; |
56 | 56 |
import javax.print.attribute.standard.PrintQuality; |
57 | 57 |
|
58 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
59 | 58 |
import com.iver.cit.gvsig.fmap.MapContext; |
60 | 59 |
import com.iver.cit.gvsig.fmap.ViewPort; |
61 | 60 |
import com.iver.cit.gvsig.fmap.core.CartographicSupportToolkit; |
... | ... | |
87 | 86 |
private boolean autoresize; |
88 | 87 |
private Rectangle bounds = null; |
89 | 88 |
private FShape horizontalTextWrappingShape = null; |
89 |
private PrintRequestAttributeSet properties; |
|
90 | 90 |
|
91 | 91 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) { |
92 | 92 |
if (!isShapeVisible()) return; |
93 | 93 |
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
94 | 94 |
g.setColor(textColor); |
95 |
float size=font.getSize2D(); |
|
96 |
if (properties!=null){ |
|
97 |
PrintQuality pq = (PrintQuality) properties.get(PrintQuality.class); |
|
98 |
if (pq.equals(PrintQuality.NORMAL)){ |
|
99 |
size *= (float) 300/72; |
|
100 |
}else if (pq.equals(PrintQuality.HIGH)){ |
|
101 |
size *= (float) 600/72; |
|
102 |
}else if (pq.equals(PrintQuality.DRAFT)){ |
|
103 |
// unitFactor *= 72; (which is the same than doing nothing) |
|
104 |
} |
|
105 |
font=font.deriveFont(size); |
|
106 |
} |
|
95 | 107 |
g.setFont(font); |
96 | 108 |
g.translate(((FPoint2D) shp).getX(), ((FPoint2D) shp).getY()); |
97 | 109 |
|
... | ... | |
103 | 115 |
// Alineamos el texto de manera que la parte superior |
104 | 116 |
// izquierda de la primera letra est? en (0,0). |
105 | 117 |
g.drawString(getText(), 0, (int)-bounds.getY()); |
118 |
if (properties!=null){ |
|
119 |
font=font.deriveFont(size); |
|
120 |
g.setFont(font); |
|
121 |
} |
|
106 | 122 |
g.rotate(-rotation); |
107 | 123 |
g.translate(-((FPoint2D) shp).getX(), -((FPoint2D) shp).getY()); |
108 | 124 |
} |
109 | 125 |
|
110 | 126 |
public void drawInsideRectangle(Graphics2D g, |
111 |
AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException { |
|
127 |
AffineTransform scaleInstance, Rectangle r, PrintRequestAttributeSet properties) throws SymbolDrawingException {
|
|
112 | 128 |
int s = getFont().getSize(); |
113 | 129 |
|
114 | 130 |
if (autoresize) { |
... | ... | |
136 | 152 |
|
137 | 153 |
//Only for debugging purpose |
138 | 154 |
// g.drawRect((int)r.getX(), (int)r.getY(), (int)r.getWidth(), (int)r.getHeight()); |
155 |
if (properties==null) |
|
156 |
draw(g, null, new FPoint2D(r.getX(), r.getY()), null); |
|
157 |
else |
|
158 |
print(g, new AffineTransform(), new FPoint2D(r.getX(), r.getY()), properties); |
|
139 | 159 |
|
140 |
draw(g, null, new FPoint2D(r.getX(), r.getY()), null); |
|
141 |
|
|
142 |
|
|
143 | 160 |
} |
144 | 161 |
|
145 | 162 |
public int getOnePointRgb() { |
... | ... | |
199 | 216 |
return getClass().getName(); |
200 | 217 |
} |
201 | 218 |
|
202 |
public void print(Graphics2D g, AffineTransform at, FShape shape, PrintRequestAttributeSet properties) |
|
203 |
throws ReadDriverException {
|
|
204 |
// TODO Implement it
|
|
205 |
throw new Error("Not yet implemented!");
|
|
219 |
public void print(Graphics2D g, AffineTransform at, FShape shape, PrintRequestAttributeSet properties) {
|
|
220 |
this.properties=properties;
|
|
221 |
draw(g, at, shape, null);
|
|
222 |
this.properties=null;
|
|
206 | 223 |
|
207 | 224 |
} |
208 | 225 |
|
Also available in: Unified diff