Revision 18621 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleLineSymbol.java
SimpleLineSymbol.java | ||
---|---|---|
110 | 110 |
import java.awt.Color; |
111 | 111 |
import java.awt.Graphics2D; |
112 | 112 |
import java.awt.Rectangle; |
113 |
import java.awt.Shape; |
|
114 | 113 |
import java.awt.geom.AffineTransform; |
115 | 114 |
|
116 | 115 |
import javax.print.attribute.PrintRequestAttributeSet; |
117 | 116 |
|
118 | 117 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
119 | 118 |
import com.iver.cit.gvsig.fmap.MapContext; |
119 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
120 | 120 |
import com.iver.cit.gvsig.fmap.core.FShape; |
121 | 121 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
122 | 122 |
import com.iver.cit.gvsig.fmap.core.styles.ArrowDecoratorStyle; |
123 | 123 |
import com.iver.cit.gvsig.fmap.core.styles.ILineStyle; |
124 |
import com.iver.cit.gvsig.fmap.core.styles.Line2DOffset; |
|
124 | 125 |
import com.iver.utiles.StringUtilities; |
125 | 126 |
import com.iver.utiles.XMLEntity; |
126 | 127 |
import com.iver.utiles.swing.threads.Cancellable; |
... | ... | |
133 | 134 |
*/ |
134 | 135 |
public class SimpleLineSymbol extends AbstractLineSymbol { |
135 | 136 |
SimpleLineSymbol symbolForSelection; |
137 |
private double width; |
|
136 | 138 |
|
139 |
|
|
137 | 140 |
public ISymbol getSymbolForSelection() { |
138 | 141 |
if (symbolForSelection == null) { |
139 | 142 |
XMLEntity xml = getXMLEntity(); |
... | ... | |
146 | 149 |
|
147 | 150 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) { |
148 | 151 |
g.setStroke(getLineStyle().getStroke()); |
152 |
|
|
153 |
if (getLineStyle().getOffset() != 0) { |
|
154 |
double offset = getLineStyle().getOffset(); |
|
155 |
shp = new FPolygon2D(Line2DOffset.offsetLine(shp, offset)); |
|
156 |
} |
|
149 | 157 |
g.setColor(getColor()); |
150 | 158 |
g.draw(shp); |
151 | 159 |
|
... | ... | |
155 | 163 |
arrowDecorator.draw(g, affineTransform, shp); |
156 | 164 |
} |
157 | 165 |
|
158 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
|
159 |
Shape shp) { |
|
160 |
return 0; |
|
161 |
} |
|
162 |
|
|
163 | 166 |
public int getOnePointRgb() { |
164 | 167 |
return getColor().getRGB(); |
165 | 168 |
} |
... | ... | |
178 | 181 |
if (c!= null) |
179 | 182 |
xml.putProperty("color", StringUtilities.color2String(getColor())); |
180 | 183 |
|
184 |
setLineWidth(getLineWidth()); // not a joke |
|
181 | 185 |
xml.addChild(getLineStyle().getXMLEntity()); |
182 | 186 |
return xml; |
183 | 187 |
} |
184 | 188 |
|
185 | 189 |
public void drawInsideRectangle(Graphics2D g, |
186 |
AffineTransform scaleInstance, Rectangle r) { |
|
190 |
AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException {
|
|
187 | 191 |
g.setColor(getColor()); |
188 | 192 |
g.setStroke(getLineStyle().getStroke()); |
189 | 193 |
super.drawInsideRectangle(g, scaleInstance, r); |
... | ... | |
202 | 206 |
setLineStyle((ILineStyle) SymbologyFactory.createStyleFromXML(xml.getChild(0), null)); |
203 | 207 |
setReferenceSystem(xml.getIntProperty("referenceSystem")); |
204 | 208 |
setUnit(xml.getIntProperty("unit")); |
209 |
width = getLineStyle().getLineWidth(); // not a joke |
|
205 | 210 |
} |
206 | 211 |
|
207 | 212 |
public void print(Graphics2D g, AffineTransform at, FShape shape, PrintRequestAttributeSet properties) |
... | ... | |
212 | 217 |
} |
213 | 218 |
|
214 | 219 |
public void setLineWidth(double width) { |
220 |
this.width = width; |
|
215 | 221 |
getLineStyle().setLineWidth((float) width); |
216 | 222 |
} |
217 | 223 |
|
218 | 224 |
public double getLineWidth() { |
219 |
return getLineStyle().getLineWidth();
|
|
225 |
return width;
|
|
220 | 226 |
} |
221 | 227 |
|
222 | 228 |
} |
Also available in: Unified diff