Revision 36203 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java

View differences:

MapContext.java
1117 1117
		System.gc();
1118 1118
	}
1119 1119
	
1120
	
1121
	
1122 1120
	/**
1123
	 * <p>Draws this map if its {@link ViewPort ViewPort} has an extent defined:<br>
1124
	 * <ol>
1125
	 * <li>Selects only the layers that have to be drawn: {@linkplain #prepareDrawing(BufferedImage, Graphics2D, double)}.
1126
	 * <li>Sets quality: antialiasing by text and images, and quality rendering.
1127
	 * <li>Draws the layers.
1128
	 * <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW</code>.
1129
	 * <li>Draws the graphic layer.
1130
	 * <li>Fires a <code>LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW</code>.
1131
	 * <li>Invokes the garbage collector and memory clean.
1132
	 * </ol></p>
1133
	 *
1134
	 * @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.
1135
	 * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
1136
	 * @param cancel shared object that determines if this layer can continue being drawn
1137
	 * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}.
1138
	 * @throws ReadDriverException if fails reading with the driver.
1139
	 */
1140
	public void draw(BufferedImage image, Graphics2D g, Cancellable cancel,
1141
			double scale, double _dpi) throws ReadDriverException {
1142
		if (viewPort.getExtent() == null) {
1143
			// System.err.println("viewPort.getExtent() = null");
1144
			return;
1145
		}
1146
		System.out.println("Viewport despues: " + viewPort.toString());
1147
		/*
1148
		 * if ((viewPort.getImageWidth() <=0) || (viewPort.getImageHeight() <=
1149
		 * 0)) { return; }
1150
		 */
1151

  
1152
//		prepareDrawing(image, g, scale);
1153

  
1154
		// M�s c�lidad al texto
1155
		RenderingHints renderHints = new RenderingHints(
1156
				RenderingHints.KEY_ANTIALIASING,
1157
				RenderingHints.VALUE_ANTIALIAS_ON);
1158
		renderHints.put(RenderingHints.KEY_RENDERING,
1159
				RenderingHints.VALUE_RENDER_QUALITY);
1160
		renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
1161
				RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
1162
		g.setRenderingHints(renderHints);
1163

  
1164
		long t1 = System.currentTimeMillis();
1165
//		layers.draw(image, g, viewPort, cancel, scale);
1166

  
1167
		this.getMapContextDrawer().draw(this.layers, image, g, cancel, scale, _dpi);
1168

  
1169
		LayerDrawEvent beforeTracLayerEvent = new LayerDrawEvent(tracLayer,
1170
				g, viewPort, LayerDrawEvent.GRAPHICLAYER_BEFORE_DRAW);
1171
		fireLayerDrawingEvent(beforeTracLayerEvent);
1172
		tracLayer.draw(image, g, viewPort, cancel, scale);
1173
		LayerDrawEvent afterTracLayerEvent = new LayerDrawEvent(tracLayer,
1174
				g, viewPort, LayerDrawEvent.GRAPHICLAYER_AFTER_DRAW);
1175
		fireLayerDrawingEvent(afterTracLayerEvent);
1176

  
1177
		//layers.setDirty(false);
1178
		long t2 = System.currentTimeMillis();
1179
		System.err.println("Tiempo de dibujado:" + (t2 - t1) +
1180
				" mseg. Memoria libre:" + Runtime.getRuntime().freeMemory() / 1024  + " KB");
1181
		/*
1182
		 * g.setColor(Color.BLUE); GeneralPath shpR = new
1183
		 * GeneralPath(viewPort.getExtent());
1184
		 * shpR.transform(viewPort.getAffineTransform()); g.draw(shpR);
1185
		 */
1186
		System.gc();
1187
	}
1188

  
1189
	/**
1190 1121
	 * <p>Draws only the internal graphic layer using the information of the {@link ViewPort ViewPort} of this map.</p>
1191 1122
	 *
1192 1123
	 * @param image image used to accelerate the screen draw
......
1234 1165
		}, scale);
1235 1166
	}
1236 1167

  
1237
	
1238
	/**
1239
	 * <p>Like {@linkplain MapContext#draw(BufferedImage, Graphics2D, Cancellable, double)}, but creating
1240
	 *  the task as cancellable.</p>
1241
	 *
1242
	 * @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.
1243
	 * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
1244
	 * @param scale the scale of the view. Must be between {@linkplain FLayer#getMinScale()} and {@linkplain FLayer#getMaxScale()}.
1245
	 *
1246
	 * @throws ReadDriverException if the driver fails reading.
1247
	 *
1248
	 * @see #draw(BufferedImage, Graphics2D, Cancellable, double)
1249
	 */
1250
	public void draw(BufferedImage image, Graphics2D g, double scale, double _dpi)
1251
			throws ReadDriverException {
1252
//		layers.setDirty(true);
1253
		draw(image, g, new Cancellable() {
1254
			/**
1255
			 * @see com.iver.utiles.swing.threads.Cancellable#isCanceled()
1256
			 */
1257
			public boolean isCanceled() {
1258
				return false;
1259
			}
1260 1168

  
1261
			public void setCanceled(boolean canceled) {
1262
				// TODO Auto-generated method stub
1263

  
1264
			}
1265
		}, scale, _dpi);
1266
	}
1267
	
1268
	
1269 1169
	/**
1270 1170
	 * <p>Gets the {@link ViewPort ViewPort} associated to this map.</p>
1271 1171
	 *

Also available in: Unified diff