Revision 35778 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java
MapContext.java | ||
---|---|---|
1115 | 1115 |
*/ |
1116 | 1116 |
System.gc(); |
1117 | 1117 |
} |
1118 |
|
|
1119 |
|
|
1120 |
|
|
1121 |
/** |
|
1122 |
* <p>Draws this map if its {@link ViewPort ViewPort} has an extent defined:<br> |
|
1123 |
* <ol> |
|
1124 |
* <li>Selects only the layers that have to be drawn: {@linkplain #prepareDrawing(BufferedImage, Graphics2D, double)}. |
|
1125 |
* <li>Sets quality: antialiasing by text and images, and quality rendering. |
|
1126 |
* <li>Draws the layers. |
|
1127 |
* <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW</code>. |
|
1128 |
* <li>Draws the graphic layer. |
|
1129 |
* <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW</code>. |
|
1130 |
* <li>Invokes the garbage collector and memory clean. |
|
1131 |
* </ol></p> |
|
1132 |
* |
|
1133 |
* @param image buffer used sometimes instead <code>g</code> to accelerate the draw. For example, if two points are as closed that can't be distinguished, draws only one. |
|
1134 |
* @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform |
|
1135 |
* @param cancel shared object that determines if this layer can continue being drawn |
|
1136 |
* @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}. |
|
1137 |
* @throws ReadDriverException if fails reading with the driver. |
|
1138 |
*/ |
|
1139 |
public void draw(BufferedImage image, Graphics2D g, Cancellable cancel, |
|
1140 |
double scale, double _dpi) throws ReadDriverException { |
|
1141 |
if (viewPort.getExtent() == null) { |
|
1142 |
// System.err.println("viewPort.getExtent() = null"); |
|
1143 |
return; |
|
1144 |
} |
|
1145 |
System.out.println("Viewport despues: " + viewPort.toString()); |
|
1146 |
/* |
|
1147 |
* if ((viewPort.getImageWidth() <=0) || (viewPort.getImageHeight() <= |
|
1148 |
* 0)) { return; } |
|
1149 |
*/ |
|
1118 | 1150 |
|
1151 |
// prepareDrawing(image, g, scale); |
|
1152 |
|
|
1153 |
// M�s c�lidad al texto |
|
1154 |
RenderingHints renderHints = new RenderingHints( |
|
1155 |
RenderingHints.KEY_ANTIALIASING, |
|
1156 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
1157 |
renderHints.put(RenderingHints.KEY_RENDERING, |
|
1158 |
RenderingHints.VALUE_RENDER_QUALITY); |
|
1159 |
renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, |
|
1160 |
RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
|
1161 |
g.setRenderingHints(renderHints); |
|
1162 |
|
|
1163 |
long t1 = System.currentTimeMillis(); |
|
1164 |
// layers.draw(image, g, viewPort, cancel, scale); |
|
1165 |
|
|
1166 |
this.getMapContextDrawer().draw(this.layers, image, g, cancel, scale, _dpi); |
|
1167 |
|
|
1168 |
LayerDrawEvent beforeTracLayerEvent = new LayerDrawEvent(tracLayer, |
|
1169 |
g, viewPort, LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW); |
|
1170 |
fireLayerDrawingEvent(beforeTracLayerEvent); |
|
1171 |
tracLayer.draw(image, g, viewPort, cancel, scale); |
|
1172 |
LayerDrawEvent afterTracLayerEvent = new LayerDrawEvent(tracLayer, |
|
1173 |
g, viewPort, LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW); |
|
1174 |
fireLayerDrawingEvent(afterTracLayerEvent); |
|
1175 |
|
|
1176 |
//layers.setDirty(false); |
|
1177 |
long t2 = System.currentTimeMillis(); |
|
1178 |
System.err.println("Tiempo de dibujado:" + (t2 - t1) + |
|
1179 |
" mseg. Memoria libre:" + Runtime.getRuntime().freeMemory() / 1024 + " KB"); |
|
1180 |
/* |
|
1181 |
* g.setColor(Color.BLUE); GeneralPath shpR = new |
|
1182 |
* GeneralPath(viewPort.getExtent()); |
|
1183 |
* shpR.transform(viewPort.getAffineTransform()); g.draw(shpR); |
|
1184 |
*/ |
|
1185 |
System.gc(); |
|
1186 |
} |
|
1187 |
|
|
1119 | 1188 |
/** |
1120 | 1189 |
* <p>Draws only the internal graphic layer using the information of the {@link ViewPort ViewPort} of this map.</p> |
1121 | 1190 |
* |
... | ... | |
1164 | 1233 |
}, scale); |
1165 | 1234 |
} |
1166 | 1235 |
|
1236 |
|
|
1167 | 1237 |
/** |
1238 |
* <p>Like {@linkplain MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)}, but creating |
|
1239 |
* the task as cancellable.</p> |
|
1240 |
* |
|
1241 |
* @param image buffer used sometimes instead <code>g</code> to accelerate the draw. For example, if two points are as closed that can't be distinguished, draws only one. |
|
1242 |
* @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform |
|
1243 |
* @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}. |
|
1244 |
* |
|
1245 |
* @throws ReadDriverException if the driver fails reading. |
|
1246 |
* |
|
1247 |
* @see #draw(BufferedImage, Graphics2D, Cancellable, double) |
|
1248 |
*/ |
|
1249 |
public void draw(BufferedImage image, Graphics2D g, double scale, double _dpi) |
|
1250 |
throws ReadDriverException { |
|
1251 |
// layers.setDirty(true); |
|
1252 |
draw(image, g, new Cancellable() { |
|
1253 |
/** |
|
1254 |
* @see com.iver.utiles.swing.threads.Cancellable#isCanceled() |
|
1255 |
*/ |
|
1256 |
public boolean isCanceled() { |
|
1257 |
return false; |
|
1258 |
} |
|
1259 |
|
|
1260 |
public void setCanceled(boolean canceled) { |
|
1261 |
// TODO Auto-generated method stub |
|
1262 |
|
|
1263 |
} |
|
1264 |
}, scale, _dpi); |
|
1265 |
} |
|
1266 |
|
|
1267 |
|
|
1268 |
/** |
|
1168 | 1269 |
* <p>Gets the {@link ViewPort ViewPort} associated to this map.</p> |
1169 | 1270 |
* |
1170 | 1271 |
* @return the view port |
Also available in: Unified diff