Revision 41899
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java | ||
---|---|---|
34 | 34 |
import java.awt.geom.AffineTransform; |
35 | 35 |
import java.awt.geom.Point2D; |
36 | 36 |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
import org.gvsig.fmap.dal.feature.Feature; |
|
37 | 41 |
import org.gvsig.fmap.geom.Geometry; |
38 | 42 |
import org.gvsig.fmap.geom.GeometryLocator; |
39 | 43 |
import org.gvsig.fmap.geom.GeometryManager; |
40 | 44 |
import org.gvsig.fmap.geom.handler.Handler; |
41 |
|
|
42 | 45 |
import org.gvsig.fmap.geom.operation.Draw; |
43 | 46 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
44 | 47 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
... | ... | |
48 | 51 |
import org.gvsig.fmap.mapcontext.ViewPort; |
49 | 52 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
50 | 53 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
51 |
import org.slf4j.Logger; |
|
52 |
import org.slf4j.LoggerFactory; |
|
53 | 54 |
|
54 | 55 |
/** |
55 | 56 |
* MapControlDrawer for a 2D view. |
56 |
*
|
|
57 |
* |
|
57 | 58 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
58 | 59 |
*/ |
59 | 60 |
public class MapControlDrawer2D extends DefaultPrimitivesDrawer implements MapControlDrawer{ |
60 | 61 |
private static final Logger LOG = LoggerFactory.getLogger(MapControlDrawer2D.class); |
61 |
|
|
62 |
|
|
62 | 63 |
protected GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
63 | 64 |
private ViewPort viewPort = null; |
64 | 65 |
|
... | ... | |
67 | 68 |
* @param viewPort |
68 | 69 |
*/ |
69 | 70 |
public MapControlDrawer2D() { |
70 |
super();
|
|
71 |
super(); |
|
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
/* (non-Javadoc) |
... | ... | |
75 | 76 |
*/ |
76 | 77 |
public void draw(Geometry geometry, ISymbol symbol) { |
77 | 78 |
if (geometry != null) { |
78 |
symbol.draw(graphics, viewPort.getAffineTransform(), geometry, null, null);
|
|
79 |
}
|
|
79 |
symbol.draw(graphics, viewPort.getAffineTransform(), geometry, null, null); |
|
80 |
} |
|
80 | 81 |
} |
81 | 82 |
|
83 |
public void draw(Geometry geometry, ISymbol symbol, Feature feature) { |
|
84 |
if (geometry != null) { |
|
85 |
symbol.draw(graphics, viewPort.getAffineTransform(), geometry, feature, null); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
82 | 89 |
/* |
83 | 90 |
* (non-Javadoc) |
84 | 91 |
* @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawHandlers(org.gvsig.fmap.geom.Geometry, java.awt.geom.AffineTransform, org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol) |
85 | 92 |
*/ |
86 | 93 |
public void drawHandlers(Handler[] handlers, AffineTransform at, ISymbol symbol) { |
87 | 94 |
for (int i = 0; i < handlers.length; i++) { |
88 |
|
|
95 |
|
|
89 | 96 |
try { |
90 | 97 |
Point2D point = handlers[i].getPoint(); |
91 | 98 |
at.transform(point, point); |
... | ... | |
100 | 107 |
* jmvivo experienced a "java.lang.InternalError" here, possibly |
101 | 108 |
* a graphic bug in the JRE when dealing with windows. |
102 | 109 |
* Since we are simply drawing a handler, we will ignore this |
103 |
* error and simply write a line in the log file..
|
|
110 |
* error and simply write a line in the log file.. |
|
104 | 111 |
*/ |
105 | 112 |
LOG.warn("Unexpected error while drawing handler: " + th.getMessage(), th); |
106 | 113 |
} |
... | ... | |
126 | 133 |
e.printStackTrace(); |
127 | 134 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) { |
128 | 135 |
e.printStackTrace(); |
129 |
}
|
|
136 |
} |
|
130 | 137 |
} |
131 | 138 |
|
132 | 139 |
/* (non-Javadoc) |
... | ... | |
135 | 142 |
public void drawImage(Image img, int x, int y) { |
136 | 143 |
if (img != null){ |
137 | 144 |
graphics.drawImage(img, x, y, null); |
138 |
}
|
|
139 |
}
|
|
145 |
} |
|
146 |
} |
|
140 | 147 |
|
141 | 148 |
/* |
142 | 149 |
* (non-Javadoc) |
... | ... | |
162 | 169 |
* @see org.gvsig.fmap.mapcontrol.tools.renderer.Renderer#drawImage(java.awt.Image, java.awt.geom.AffineTransform) |
163 | 170 |
*/ |
164 | 171 |
public void drawImage(Image img, AffineTransform xform) { |
165 |
graphics.drawImage(img, xform, null);
|
|
172 |
graphics.drawImage(img, xform, null); |
|
166 | 173 |
} |
167 | 174 |
|
168 | 175 |
/* (non-Javadoc) |
169 | 176 |
* @see org.gvsig.fmap.mapcontext.rendering.Renderer#setViewPort(org.gvsig.fmap.mapcontext.ViewPort) |
170 | 177 |
*/ |
171 | 178 |
public void setViewPort(ViewPort viewPort) { |
172 |
this.viewPort = viewPort;
|
|
179 |
this.viewPort = viewPort; |
|
173 | 180 |
} |
174 | 181 |
|
175 | 182 |
/* (non-Javadoc) |
... | ... | |
190 | 197 |
* @see org.gvsig.fmap.mapcontrol.MapControlDrawer#transform(java.awt.geom.AffineTransform) |
191 | 198 |
*/ |
192 | 199 |
public void transform(AffineTransform at) { |
193 |
graphics.transform(at);
|
|
200 |
graphics.transform(at); |
|
194 | 201 |
} |
195 | 202 |
|
196 | 203 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlDrawer.java | ||
---|---|---|
36 | 36 |
import java.awt.geom.AffineTransform; |
37 | 37 |
import java.awt.geom.Point2D; |
38 | 38 |
|
39 |
import org.gvsig.fmap.dal.feature.Feature; |
|
39 | 40 |
import org.gvsig.fmap.geom.Geometry; |
40 | 41 |
import org.gvsig.fmap.geom.handler.Handler; |
41 | 42 |
import org.gvsig.fmap.mapcontext.ViewPort; |
... | ... | |
55 | 56 |
* method. Some of these tools need to draw some objects in the map and they use |
56 | 57 |
* the MapControlDrawer class to do that. |
57 | 58 |
* </p> |
58 |
*
|
|
59 |
* |
|
59 | 60 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
60 | 61 |
*/ |
61 | 62 |
public interface MapControlDrawer extends PrimitivesDrawer { |
... | ... | |
63 | 64 |
/** |
64 | 65 |
* The <code>ViewPort</code> is used to transform the map |
65 | 66 |
* coordinates in the screen coordinates. |
66 |
*
|
|
67 |
* |
|
67 | 68 |
* @param viewPort |
68 | 69 |
* The <code>ViewPort</code> |
69 | 70 |
*/ |
... | ... | |
72 | 73 |
/** |
73 | 74 |
* It draws a <code>Geometry</code> on the map using the color |
74 | 75 |
* specified using the {@link #setColor(Color)} method. |
75 |
*
|
|
76 |
* |
|
76 | 77 |
* @param geometry |
77 | 78 |
* The <code>Geometry</code> to draw. |
78 | 79 |
*/ |
... | ... | |
81 | 82 |
/** |
82 | 83 |
* It draws a <code>Geometry</code> on the map using a concrete |
83 | 84 |
* symbol. |
84 |
*
|
|
85 |
* |
|
85 | 86 |
* @param geometry |
86 | 87 |
* The <code>Geometry</code> to draw. |
87 | 88 |
* @param symbol |
... | ... | |
90 | 91 |
public void draw(Geometry geometry, ISymbol symbol); |
91 | 92 |
|
92 | 93 |
/** |
94 |
* It draws a <code>Geometry</code> on the map using a concrete |
|
95 |
* symbol. |
|
96 |
* |
|
97 |
* @param geometry |
|
98 |
* The <code>Geometry</code> to draw. |
|
99 |
* @param symbol |
|
100 |
* The symbol used to draw the geometry. |
|
101 |
* @param feature |
|
102 |
* The feature used to draw the geometry. |
|
103 |
*/ |
|
104 |
public void draw(Geometry geometry, ISymbol symbol, Feature feature); |
|
105 |
|
|
106 |
|
|
107 |
/** |
|
93 | 108 |
* It draws the <code>Handler</code>'s that compose a geometry |
94 | 109 |
* on the map. |
95 |
*
|
|
110 |
* |
|
96 | 111 |
* @param handlers |
97 | 112 |
* An array of <code>Handler</code>'s. |
98 | 113 |
* @param at |
... | ... | |
106 | 121 |
|
107 | 122 |
/** |
108 | 123 |
* It draws a line using a concrete symbol. |
109 |
*
|
|
124 |
* |
|
110 | 125 |
* @param firstPoint |
111 | 126 |
* The first point of the line. |
112 | 127 |
* @param endPoint |
... | ... | |
118 | 133 |
|
119 | 134 |
/** |
120 | 135 |
* It draws an image on a map in a concrete position. |
121 |
*
|
|
136 |
* |
|
122 | 137 |
* @param img |
123 | 138 |
* The image to draw. |
124 | 139 |
* @param x |
... | ... | |
131 | 146 |
/** |
132 | 147 |
* It draws image, applying a transform from image space |
133 | 148 |
* into user space before drawing. |
134 |
*
|
|
149 |
* |
|
135 | 150 |
* @param img |
136 | 151 |
* The image to draw. |
137 | 152 |
* @param xform |
... | ... | |
141 | 156 |
|
142 | 157 |
/** |
143 | 158 |
* It draws a <code>Handler</code> on the map. |
144 |
*
|
|
159 |
* |
|
145 | 160 |
* @param handler |
146 | 161 |
* The <code>Handler</code> to draw. |
147 | 162 |
* @param at |
... | ... | |
159 | 174 |
* @param instance |
160 | 175 |
*/ |
161 | 176 |
public void setComposite(Composite instance); |
162 |
|
|
177 |
|
|
163 | 178 |
/** |
164 |
* Replaces the values of all preferences for the rendering algorithms with the specified hints. The existing
|
|
165 |
* values for all rendering hints are discarded and the new set of known hints and values are initialized
|
|
179 |
* Replaces the values of all preferences for the rendering algorithms with the specified hints. The existing |
|
180 |
* values for all rendering hints are discarded and the new set of known hints and values are initialized |
|
166 | 181 |
* from the specified Map object. Hint categories include controls for rendering quality and overall time/ |
167 |
* quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some
|
|
182 |
* quality trade-off in the rendering process. Refer to the RenderingHints class for definitions of some |
|
168 | 183 |
* common keys and values. |
169 | 184 |
* @param hints the rendering hints to be set |
170 | 185 |
*/ |
171 | 186 |
public void setRenderingHints(RenderingHints hints); |
172 |
|
|
187 |
|
|
173 | 188 |
/** |
174 | 189 |
* Sets the Stroke for the Graphics2D context. |
175 |
* @param stroke the Stroke object to be used to stroke a Shape during the rendering
|
|
190 |
* @param stroke the Stroke object to be used to stroke a Shape during the rendering |
|
176 | 191 |
*/ |
177 | 192 |
public void setStroke(Stroke stroke); |
178 |
|
|
193 |
|
|
179 | 194 |
/** |
180 | 195 |
* Cleans the graphics using the image of the MapControl |
181 | 196 |
* @param mapCtrl |
Also available in: Unified diff