Revision 9013

View differences:

branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/ShpStrategy.java
48 48
import java.util.BitSet;
49 49
import java.util.List;
50 50

  
51
import javax.print.attribute.PrintRequestAttributeSet;
52

  
51 53
import org.apache.log4j.Logger;
52 54
import org.cresques.cts.ICoordTrans;
53 55
import org.geotools.resources.geometry.XRectangle2D;
......
58 60
import com.iver.cit.gvsig.fmap.core.FShape;
59 61
import com.iver.cit.gvsig.fmap.core.IGeometry;
60 62
import com.iver.cit.gvsig.fmap.core.ISymbol;
61
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
62 63
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
63 64
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
64 65
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
......
74 75
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer;
75 76
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo;
76 77
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
77
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
78 78
import com.iver.utiles.swing.threads.Cancellable;
79 79
import com.iver.utiles.swing.threads.CancellableMonitorable;
80 80
import com.vividsolutions.jts.geom.Geometry;
......
348 348
	 *
349 349
	 * @throws DriverException
350 350
	 */
351
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel)
351
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, PrintRequestAttributeSet printProperties)
352 352
			throws DriverException {
353 353
		// super.draw(null, g, viewPort, cancel); // Quiero ejecutar el draw del
354 354
		// padre, que es el que va sin acelaraci?n!!
......
407 407

  
408 408
				if (XRectangle2D.intersectInclusive(extent, bounds)) {
409 409
					ISymbol symbol = l.getSymbol(i);
410

  
411 410
					if (bitSet.get(i)) {
412 411
						symbol = symbol.getSymbolForSelection();
413 412
					}
......
425 424
							geom = geom.cloneGeometry();
426 425
						geom.reProject(ct);
427 426
					}
427

  
428
					symbol.setPrintingProperties(printProperties);
428 429
					geom.draw(g, viewPort, symbol);
430
					symbol.setPrintingProperties(null);
431

  
429 432
				}
430 433
			}
431 434

  
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/Strategy.java
46 46
import java.awt.image.BufferedImage;
47 47
import java.util.BitSet;
48 48

  
49
import javax.print.attribute.PrintRequestAttributeSet;
50

  
49 51
import com.iver.cit.gvsig.fmap.DriverException;
50 52
import com.iver.cit.gvsig.fmap.ViewPort;
51 53
import com.iver.cit.gvsig.fmap.core.IGeometry;
......
84 86
	 *
85 87
	 * @throws DriverException
86 88
	 */
87
	void print(Graphics2D g, ViewPort viewPort, Cancellable cancel)
89
	void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, PrintRequestAttributeSet properties)
88 90
		throws DriverException;
89 91

  
90
	
92

  
91 93
	/**
92 94
	 * Similar to next one, but allows cancelations.
93 95
	 * @param visitor
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/DefaultStrategy.java
47 47
import java.awt.image.BufferedImage;
48 48
import java.util.BitSet;
49 49

  
50
import javax.print.attribute.PrintRequestAttributeSet;
51

  
50 52
import org.apache.log4j.Logger;
51 53
import org.cresques.cts.ICoordTrans;
52 54

  
......
302 304
	/* (non-Javadoc)
303 305
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
304 306
	 */
305
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel)
307
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, PrintRequestAttributeSet properties)
306 308
		throws DriverException {
307 309
		draw(null, g, viewPort, cancel); // Quiero ejecutar el draw del padre, que es el que va sin acelaraci?n!!
308 310
	}
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/ISymbol.java
45 45
import java.awt.Shape;
46 46
import java.awt.geom.AffineTransform;
47 47

  
48
import javax.print.attribute.PrintRequestAttributeSet;
49

  
48 50
import com.iver.utiles.IPersistance;
49 51
import com.iver.utiles.XMLEntity;
50 52

  
......
127 129
	 */
128 130
	void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r);
129 131

  
132
	void setPrintingProperties(PrintRequestAttributeSet printProperties);
130 133

  
134

  
131 135
}
132 136

  
133 137

  
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FSymbol.java
62 62
import java.net.URI;
63 63
import java.net.URISyntaxException;
64 64
import java.util.StringTokenizer;
65

  
66
import javax.print.attribute.PrintRequestAttributeSet;
67
import javax.print.attribute.standard.PrinterResolution;
65 68
import javax.swing.ImageIcon;
66 69

  
67 70
import com.iver.cit.gvsig.fmap.core.FShape;
......
128 131
	private String m_Descrip;
129 132
	public Color m_BackColor;
130 133
	public Paint m_BackFill;
134
	private PrintRequestAttributeSet properties;
131 135

  
132 136
    /**
133 137
     * Converts the comma-delimited string into a List of trimmed strings.
......
1230 1234
	}
1231 1235

  
1232 1236
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
1233
		FGraphicUtilities.DrawShape(g, affineTransform, shp, this);
1237
		if (properties==null)
1238
			FGraphicUtilities.DrawShape(g, affineTransform, shp, this);
1239
		else {
1240
			PrinterResolution resolution=(PrinterResolution)properties.get(PrinterResolution.class);
1241
			int DPI=resolution.getFeedResolution(PrinterResolution.DPI);
1242
			int strokeValue=0;
1243
				BasicStroke stroke=(BasicStroke)this.getStroke();
1244
				if (stroke != null) {
1245
					strokeValue=(int)stroke.getLineWidth();
1246
					double d=strokeValue*DPI/72;
1247
					this.setStroke(new BasicStroke((int)d));
1248
				}
1249
			FGraphicUtilities.DrawShape(g, affineTransform, shp, this);
1250
			this.setStroke(new BasicStroke(strokeValue));
1251
		}
1234 1252
	}
1235 1253

  
1236 1254
	/* (non-Javadoc)
......
1260 1278

  
1261 1279
	}
1262 1280

  
1281
	public void setPrintingProperties(PrintRequestAttributeSet properties) {
1282
		this.properties=properties;
1283

  
1284
	}
1285

  
1263 1286
}
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayers.java
52 52
import java.util.List;
53 53
import java.util.Vector;
54 54

  
55
import javax.print.attribute.PrintRequestAttributeSet;
55 56
import javax.swing.ImageIcon;
56 57

  
57 58
import org.apache.log4j.Logger;
......
307 308
			public boolean evaluate(FLayer layer) {
308 309
				return layer.isVisible();
309 310
			}
310
			
311

  
311 312
		};
312 313

  
313 314
		while (iter.hasNext()) {
314
			array.add(iter.nextLayer());			
315
			array.add(iter.nextLayer());
315 316
		}
316 317

  
317 318
		return (FLayer[]) array.toArray(new FLayer[0]);
......
512 513
	 * 		com.iver.cit.gvsig.fmap.ViewPort,
513 514
	 * 		com.iver.utiles.swing.threads.Cancellable)
514 515
	 */
515
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
516
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
516 517
		throws DriverException {
517 518

  
518 519
        // TODO: A la hora de imprimir, isWithinScale falla, porque est?
......
521 522

  
522 523
		for (Iterator iter = layers.iterator(); iter.hasNext();) {
523 524
			FLayer lyr = (FLayer) iter.next();
524
			lyr.print(g, viewPort, cancel,scale);
525
			lyr.print(g, viewPort, cancel, scale, properties);
525 526

  
526 527
		}
527 528
		 if (getVirtualLayers() != null) {
528
            getVirtualLayers().print( g, viewPort, cancel,scale);
529
            getVirtualLayers().print( g, viewPort, cancel, scale, properties);
529 530
        }
530 531
	}
531 532

  
......
889 890
		ArrayList ret = new ArrayList();
890 891
		LayersIterator it = new LayersIterator(this) {
891 892

  
892
			public boolean evaluate(FLayer layer) {				
893
			public boolean evaluate(FLayer layer) {
893 894
				return layer.isActive();
894 895
			}
895
			 
896

  
896 897
		};
897
			
898

  
898 899
		while (it.hasNext())
899 900
		{
900 901
			ret.add(it.next());
......
957 958
				InfoByPoint queryable_layer = (InfoByPoint) layer;
958 959
				aux = queryable_layer.getInfo(p, tolerance, null);
959 960
				if (!(queryable_layer instanceof FLayers)){
960
					for(int j = 0; j < aux.length; j++){					
961
					for(int j = 0; j < aux.length; j++){
961 962
						items.add(aux[j]);
962 963
					}
963 964
				}
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrAnnotation.java
10 10
import java.io.IOException;
11 11
import java.util.ArrayList;
12 12

  
13
import javax.print.attribute.PrintRequestAttributeSet;
14

  
13 15
import org.cresques.cts.ICoordTrans;
14 16
import org.cresques.cts.IProjection;
15 17

  
......
164 166
	 *      com.iver.utiles.swing.threads.Cancellable)
165 167
	 */
166 168
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
167
			double scale) throws DriverException {
169
			double scale, PrintRequestAttributeSet properties) throws DriverException {
168 170
		if (isVisible() && isWithinScale(scale)) {
169 171
			Strategy strategy = StrategyManager.getStrategy(this);
170
			strategy.print(g, viewPort, cancel);
172
			strategy.print(g, viewPort, cancel, properties);
171 173
		}
172 174
	}
173 175

  
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/GraphicLayer.java
49 49
import java.util.ArrayList;
50 50
import java.util.Collection;
51 51

  
52
import javax.print.attribute.PrintRequestAttributeSet;
53

  
52 54
import org.cresques.cts.ICoordTrans;
53 55

  
54 56
import com.iver.cit.gvsig.fmap.DriverException;
......
115 117
    /* (non-Javadoc)
116 118
     * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable, double)
117 119
     */
118
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException {
120
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws DriverException {
119 121
        if (isVisible() && isWithinScale(scale)){
120 122
            drawGraphics(null, g, viewPort, cancel);
121 123
            }
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrText.java
50 50
import java.awt.image.BufferedImage;
51 51
import java.util.ArrayList;
52 52

  
53
import javax.print.attribute.PrintRequestAttributeSet;
54

  
53 55
import org.cresques.cts.ICoordTrans;
54 56

  
55 57
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
......
404 406
     *      com.iver.cit.gvsig.fmap.operations.Cancellable)
405 407
     */
406 408
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
407
            double scale) throws DriverException {
409
            double scale, PrintRequestAttributeSet properties) throws DriverException {
408 410
        if (isVisible() && isWithinScale(scale)) {
409 411
            drawLabels(null, g, viewPort, cancel);
410 412
        }
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrRaster.java
54 54
import java.lang.reflect.InvocationTargetException;
55 55
import java.util.ArrayList;
56 56

  
57
import javax.print.attribute.PrintRequestAttributeSet;
57 58
import javax.swing.ImageIcon;
58 59

  
59 60
import org.cresques.cts.IProjection;
......
94 95
	private double 						posXWC = 0, posYWC = 0;
95 96
	private int 						r = 0, g = 0, b = 0;
96 97
	private boolean						removeRasterFlag = true;
97
			
98

  
98 99
	/**
99 100
	 * Devuelve el RasterAdapter de la capa.
100 101
	 *
......
114 115
			load();
115 116
		} catch (DriverIOException e) {
116 117
			e.printStackTrace();
117
		}*/			
118
		}*/
118 119
	}
119
	
120

  
120 121
	/**
121 122
	 * Inserta el RasterAdapter.
122 123
	 *
......
134 135
	public RasterFilterStack getFilterStack(){
135 136
		return source.getFilterStack();
136 137
	}
137
	
138

  
138 139
	/**
139 140
	 * Asignar el estado del raster
140 141
	 * @param status
......
142 143
	public void setStatus(StatusRasterInterface status){
143 144
		this.status = status;
144 145
	}
145
	
146

  
146 147
	/**
147 148
	 * Asigna la pila de filtros aplicada al raster
148 149
	 * @return
149 150
	 */
150 151
	public void setFilterStack(RasterFilterStack stack){
151
		source.setFilterStack(stack);		
152
		source.setFilterStack(stack);
152 153
	}
153
	
154

  
154 155
	/**
155 156
	 * Obtiene el estado del raster
156 157
	 * @return
......
158 159
	public StatusRasterInterface getStatus(){
159 160
		return this.status;
160 161
	}
161
	
162

  
162 163
	/**
163 164
	 * Asigna la posici?n en la que se ha hecho click al mostrar
164 165
	 * informaci?n del raster.
......
169 170
		this.posX = x;
170 171
		this.posY = y;
171 172
	}
172
	
173

  
173 174
	/**
174
	 * Asigna la posici?n en coordenadas del mundo real en la que se ha 
175
	 * Asigna la posici?n en coordenadas del mundo real en la que se ha
175 176
	 * hecho click al mostrar informaci?n del raster.
176 177
	 * @param x	Posici?n en X
177 178
	 * @param y	Posici?n en Y
......
180 181
		this.posXWC = x;
181 182
		this.posYWC = y;
182 183
	}
183
	
184

  
184 185
	/**
185
	 * Asigna RGB en la posici?n en la que se ha 
186
	 * Asigna RGB en la posici?n en la que se ha
186 187
	 * hecho click al mostrar informaci?n del raster.
187 188
	 * @param r	valor de rojo
188 189
	 * @param g	valor de verde
......
193 194
		this.g = g;
194 195
		this.b = b;
195 196
	}
196
	
197

  
197 198
	/*
198 199
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#load()
199 200
	 */
......
209 210
	 */
210 211
	public void draw(BufferedImage image, Graphics2D g, ViewPort vp,
211 212
		Cancellable cancel,double scale) throws DriverException {
212
		if (isWithinScale(scale)){	
213
		if (isWithinScale(scale)){
213 214
		try {
214 215
			if(status!=null && firstLoad){
215 216
				if(mustTileDraw){
......
228 229
						}
229 230
					}
230 231
				}else
231
					((RasterFileAdapter) source).draw(image, g, vp, cancel);	
232
					((RasterFileAdapter) source).draw(image, g, vp, cancel);
232 233
				status.applyStatus(this);
233 234
				firstLoad = false;
234 235
			}
235
		
236

  
236 237
			if(mustTileDraw){
237 238
				Point2D p = vp.getOffset();
238 239
				Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), vp.getImageWidth(), vp.getImageHeight());
......
249 250
				}
250 251
			}else
251 252
				((RasterFileAdapter) source).draw(image, g, vp, cancel);
252
									
253

  
253 254
		} catch (DriverIOException e) {
254 255
			throw new DriverException(e);
255 256
		}
......
276 277
			}
277 278
		}
278 279
	}
279
	
280

  
280 281
	public void setTransparency(int trans) {
281 282
		super.setTransparency(trans);
282 283
		((RasterFileAdapter) source).setTransparency(trans);
......
288 289
	public int getTransparency() {
289 290
		return ((RasterFileAdapter) source).getTransparency();
290 291
	}
291
	
292

  
292 293
	/*
293 294
	 * @see com.iver.cit.gvsig.fmap.layers.LayerOperations#getFullExtent()
294 295
	 */
......
305 306
	public int[] getPixel(double wcx, double wcy){
306 307
		return ((RasterFileAdapter) source).getPixel(wcx, wcy);
307 308
	}
308
	
309

  
309 310
	public double getMaxX(){
310 311
		try {
311 312
			return this.getFullExtent().getMaxX();
......
313 314
			return 0D;
314 315
		}
315 316
	}
316
	
317

  
317 318
	public double getMaxY(){
318 319
		try {
319 320
			return this.getFullExtent().getMaxY();
......
321 322
			return 0D;
322 323
		}
323 324
	}
324
	
325

  
325 326
	public double getMinX(){
326 327
		try {
327 328
			return this.getFullExtent().getMinX();
......
329 330
			return 0D;
330 331
		}
331 332
	}
332
	
333

  
333 334
	public double getMinY(){
334 335
		try {
335 336
			return this.getFullExtent().getMinY();
......
337 338
			return 0D;
338 339
		}
339 340
	}
340
	
341

  
341 342
	public double getHeight(){
342 343
		try {
343 344
			return this.getFullExtent().getHeight();
......
345 346
			return 0D;
346 347
		}
347 348
	}
348
	
349

  
349 350
	public double getWidth(){
350 351
		try {
351 352
			return this.getFullExtent().getWidth();
......
354 355
		}
355 356
	}
356 357

  
357
	
358

  
358 359
	/* (non-Javadoc)
359 360
	 * @deprecated. See String getInfo(Point p) throws DriverException
360 361
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(java.awt.Point)
......
383 384
		//System.out.println(data);
384 385
		return data;
385 386
	}
386
	
387

  
387 388
	public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) throws DriverException {
388
		
389

  
389 390
		Point2D pReal = getMapContext().getViewPort().toMapPoint(p);
390 391
		Point2D px = null;
391
		if(	pReal.getX() > this.getMinX() && 
392
			pReal.getX() < this.getMaxX() && 
393
			pReal.getY() > this.getMinY() && 
392
		if(	pReal.getX() > this.getMinX() &&
393
			pReal.getX() < this.getMaxX() &&
394
			pReal.getY() > this.getMinY() &&
394 395
			pReal.getY() < this.getMaxY()){
395 396
			ArrayList attr = source.getAttributes();
396 397
			int w = 0, h = 0;
......
400 401
					w = ((Integer)a[1]).intValue();
401 402
				if(a[0].toString().equals("Height"))
402 403
					h = ((Integer)a[1]).intValue();
403
			}	
404
			}
404 405
			px = new Point2D.Double();
405 406
			px.setLocation( ((pReal.getX() - this.getMinX()) * w) / getWidth(),
406 407
							((this.getMaxY() - pReal.getY()) * h) / getHeight());
407 408
		}
408
			
409

  
409 410
		int[] rgb = this.getPixel(pReal.getX(), pReal.getY());
410
				
411
		StringXMLItem[] item = new StringXMLItem[1]; 
411

  
412
		StringXMLItem[] item = new StringXMLItem[1];
412 413
		String data = "<file:"+normalizeAsXMLTag(getName())+">\n";
413 414

  
414 415
		data += "  <raster\n";
......
435 436
		data += "\"\n";
436 437
		data += "  />\n";
437 438
		data += "</file:"+normalizeAsXMLTag(getName())+">\n";
438
		
439
		item[0] = new StringXMLItem(data, this); 
439

  
440
		item[0] = new StringXMLItem(data, this);
440 441
		return item;
441
		
442
	}	
443
	
442

  
443
	}
444

  
444 445
	/**
445 446
	 * Filters a string for being suitable as XML Tag, erasing
446 447
	 * all not alphabetic or numeric characters.
......
458 459
	public ArrayList getAttributes() {
459 460
		return source.getAttributes();
460 461
	}
461
	
462

  
462 463
	/**
463 464
	 * @throws XMLException
464 465
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties()
465 466
	 */
466 467
	public XMLEntity getXMLEntity() throws XMLException {
467 468
		XMLEntity xml = super.getXMLEntity();
468
	
469

  
469 470
		if (source instanceof RasterFileAdapter) {
470 471
			xml.putProperty("file", ((RasterFileAdapter) source).getFile());
471 472
		}
472
	
473

  
473 474
		xml.putProperty("driverName", getSource().getDriver().getName());
474
		
475

  
475 476
		//Si no hay ning?n Status aplicamos el StatusLayerRaster que se usa por defecto
476 477
		if(status == null)
477 478
			status = new StatusLayerRaster();
478
		
479

  
479 480
		status.getXMLEntity(xml, true, this);
480
		
481
	
481

  
482

  
482 483
		return xml;
483 484
	}
484
	
485

  
485 486
	public void setXMLEntity03(XMLEntity xml)
486 487
	throws XMLException {
487 488
		super.setXMLEntity(xml);
......
498 499
			throw new XMLException(e);
499 500
		}
500 501
	}
501
	
502

  
502 503
	public void setXMLEntity(XMLEntity xml)
503 504
	throws XMLException {
504 505
		super.setXMLEntity(xml);
......
511 512
			setSource(adapter);
512 513
			// Para notificar al adapter-driver cual es la proyecci?n.
513 514
			setProjection(super.getProjection());
514
			
515

  
515 516
			//Inicializamos la clase a la que se usa por defecto para
516 517
			//compatibilidad con proyectos antiguos
517 518
			String claseStr = StatusLayerRaster.defaultClass;
......
521 522
			if(status!=null)
522 523
				status.setXMLEntity(xml, this);
523 524
			else{
524
				
525
				//Cuando cargamos un proyecto 
526
				
525

  
526
				//Cuando cargamos un proyecto
527

  
527 528
				if(claseStr!=null && !claseStr.equals("")){
528 529
					try{
529 530
						Class clase = Class.forName(claseStr);
......
541 542
						exc.printStackTrace();
542 543
					}catch(InvocationTargetException exc){
543 544
						exc.printStackTrace();
544
					}					
545
					}
545 546
				}
546 547
			}
547 548
			firstLoad = true;
548
			
549
			
549

  
550

  
550 551
		} catch (DriverLoadException e) {
551 552
			throw new XMLException(e);
552 553
		}
......
555 556
	/* (non-Javadoc)
556 557
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
557 558
	 */
558
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
559
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet propeties)
559 560
		throws DriverException {
560
		
561
		if (isVisible() && isWithinScale(scale)){	
561

  
562
		if (isVisible() && isWithinScale(scale)){
562 563
		isPrinting = true;
563 564
		if (!mustTilePrint) {
564 565
			draw(null, g, viewPort, cancel,scale);
......
569 570
	        // del BufferedImage ni caso, cuando se imprime viene con null
570 571
			Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, g.getClipRect());
571 572
			tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
572
			
573

  
573 574
			//Si es la primera lectura salvamos los valores de m?ximo y m?nimo para la aplicaci?n
574 575
			//de realce si la imagen es de 16 bits.
575
			
576

  
576 577
			RasterStats stats = getSource().getFilterStack().getStats();
577 578
			if(stats != null)
578
				stats.history.add(stats.new History(getName(), stats.minBandValue, stats.maxBandValue, stats.secondMinBandValue, stats.secondMaxBandValue));	
579
					
580
			
579
				stats.history.add(stats.new History(getName(), stats.minBandValue, stats.maxBandValue, stats.secondMinBandValue, stats.secondMaxBandValue));
580

  
581

  
581 582
			for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) {
582 583
	    		// Parte que dibuja
583 584
	    		try {
......
588 589
					e.printStackTrace();
589 590
				}
590 591
	        }
591
			
592

  
592 593
			if(stats != null){
593 594
				getSource().getFilterStack().getStats().history.clear();
594 595
				stats = getSource().getFilterStack().getStats();
595 596
			}
596
						
597

  
597 598
		}
598 599
	    isPrinting = false;
599 600
		}
600 601
	}
601 602

  
602 603
	public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
603
		throws DriverException {		
604
		throws DriverException {
604 605
	        // Para no pedir imagenes demasiado grandes, vamos
605 606
	        // a hacer lo mismo que hace EcwFile: chunkear.
606 607
	        // Llamamos a drawView con cuadraditos m?s peque?os
607 608
	        // del BufferedImage ni caso, cuando se imprime viene con null
608
		
609

  
609 610
	        int numW, numH;
610 611
	        int stepX, stepY;
611 612
	        int xProv, yProv, wProv, hProv;
612 613
	        double xProvD, yProvD, wProvD, hProvD;
613
	        int A = 1500; 
614
	        int A = 1500;
614 615
	        int H = 1500;
615 616
	        int altoAux, anchoAux;
616
	        
617

  
617 618
	        AffineTransform mat = (AffineTransform) viewPort.getAffineTransform().clone();
618
	        
619

  
619 620
	        // Vamos a hacerlo en trozos de AxH
620 621
	        Rectangle r = g.getClipRect();
621 622
	        numW = (int) (r.width) / A;
622
	        numH = (int) (r.height) / H;	        
623
	        
624
	        
623
	        numH = (int) (r.height) / H;
624

  
625

  
625 626
	        double[] srcPts = new double[8];
626 627
	        double[] dstPts= new double[8];
627 628

  
628 629
        	yProv = (int) r.y;
629 630
	        for (stepY=0; stepY < numH+1; stepY++)
630 631
	        {
631
        		if ((yProv + H) > r.getMaxY()) 
632
        		if ((yProv + H) > r.getMaxY())
632 633
        			altoAux = (int) r.getMaxY() - yProv;
633 634
        		else
634 635
        			altoAux = H;
635
	        		        	
636

  
636 637
        		xProv = (int) r.x;
637
	        	for (stepX=0; stepX < numW+1; stepX++)	        		
638
	        	{        		
639
		    		if ((xProv + A) > r.getMaxX()) 
638
	        	for (stepX=0; stepX < numW+1; stepX++)
639
	        	{
640
		    		if ((xProv + A) > r.getMaxX())
640 641
		    			anchoAux = (int) r.getMaxX() - xProv;
641 642
		    		else
642 643
		    			anchoAux = A;
643
	        		
644

  
644 645
	        		Rectangle newRect = new Rectangle(xProv, yProv, anchoAux, altoAux);
645
	        		
646

  
646 647
	        		// Parte que dibuja
647 648
	        		srcPts[0] = xProv;
648 649
	        		srcPts[1] = yProv;
......
652 653
	        		srcPts[5] = yProv + altoAux+1;
653 654
	        		srcPts[6] = xProv;
654 655
	        		srcPts[7] = yProv + altoAux+1;
655
	        		
656

  
656 657
	        		try {
657 658
						mat.inverseTransform(srcPts, 0, dstPts, 0, 4);
658 659
		        		Rectangle2D.Double rectCuadricula = new Rectangle2D.Double(
659 660
		        				dstPts[0], dstPts[1],
660
								dstPts[2] - dstPts[0], dstPts[5]-dstPts[3]); 
661
								dstPts[2] - dstPts[0], dstPts[5]-dstPts[3]);
661 662
		        		Extent extent = new Extent(rectCuadricula);
662
		        		
663

  
663 664
		        		Dimension tam = new Dimension(anchoAux+1, altoAux+1);
664 665
		        		ViewPort vp = viewPort.cloneViewPort();
665 666
		        		vp.setImageSize(tam);
......
668 669
		        		// ViewPortData vp = new ViewPortData(getProjection(), extent, tam);
669 670
		        		// vp.setMat(mat);
670 671
		        		// rasterList.draw(g2, vp);
671
		        				        		
672

  
672 673
		        		/*System.out.println("FLyrRaster.print(): fila "+stepX+" de "
673
		        		        + numW + " , col "+stepY+" de " + numH + 
674
		        		        + numW + " , col "+stepY+" de " + numH +
674 675
		        		        "\n, Extent = "+vp.getExtent() + " imageSize: "
675 676
		        		        + tam);*/
676 677
		        		draw(null, g, vp, cancel,scale);
677
						
678

  
678 679
					} catch (NoninvertibleTransformException e) {
679 680
						// TODO Auto-generated catch block
680 681
						e.printStackTrace();
681 682
					}
682 683
	        		// Fin parte que dibuja
683
					xProv = xProv + A;	
684
	        	}	        	
684
					xProv = xProv + A;
685
	        	}
685 686
	        	yProv = yProv + H;
686
	        }  
687
		
687
	        }
688

  
688 689
	}
689
	
690

  
690 691
	/**
691 692
	 * A?ade un fichero a la capa raster
692 693
	 * @param fileName Nombre del fichero
......
694 695
	public void addFiles(String fileName){
695 696
		((RasterFileAdapter) source).addFile(fileName);
696 697
	}
697
	
698

  
698 699
	/**
699 700
	 * Elimina un fichero a la capa raster
700 701
	 * @param fileName Nombre del fichero
......
702 703
	public void delFile(String fileName){
703 704
		((RasterFileAdapter) source).delFile(fileName);
704 705
	}
705
	
706

  
706 707
	/* (non-Javadoc)
707 708
	 * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setBand(int, int)
708 709
	 */
709 710
	public void setBand(int flag, int nBand) {
710 711
		this.getSource().setBand(flag, nBand);
711 712
	}
712
	
713

  
713 714
	/**
714 715
	 * Borra de la lista de listeners el que se pasa como par?metro.
715 716
	 *
......
722 723
			/*try{
723 724
				((RasterFileAdapter) source).stop();
724 725
			}catch(DriverIOException exc){
725
				
726

  
726 727
			}*/
727 728
			this.setRemoveRasterFlag(true);
728 729
		}
729 730
		return super.layerListeners.remove(o);
730 731
	}
731
	
732

  
732 733
	/**
733 734
	 * @return Returns the removeRasterFlag.
734 735
	 */
735 736
	public boolean isRemoveRasterFlag() {
736 737
		return removeRasterFlag;
737 738
	}
738
	
739

  
739 740
	/**
740 741
	 * Asigna el valor del flag que dice si destruimos la memoria del raster
741 742
	 * al eliminarlo del TOC o  no.
......
744 745
	public void setRemoveRasterFlag(boolean removeRasterFlag) {
745 746
		this.removeRasterFlag = removeRasterFlag;
746 747
	}
747
	
748
	public ImageIcon getTocImageIcon() {			
748

  
749
	public ImageIcon getTocImageIcon() {
749 750
		return new ImageIcon(MapControl.class.getResource("images/icolayerRaster.PNG"));
750 751
	}
751
	
752

  
752 753
	/*
753 754
	 *  (non-Javadoc)
754 755
	 * @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getTileSize()
755 756
	 */
756 757
	public int[] getTileSize() {
757
		int[] size = {maxTileDrawWidth, maxTileDrawHeight}; 
758
		int[] size = {maxTileDrawWidth, maxTileDrawHeight};
758 759
		return size;
759 760
	}
760 761

  
......
765 766
	public boolean isTiled() {
766 767
		return mustTileDraw;
767 768
	}
768
	
769

  
769 770
	/**
770 771
	 * Obtiene el flag que dice si la imagen est? o no georreferenciada
771 772
	 * @return true si est? georreferenciada y false si no lo est?.
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayer.java
45 45
import java.awt.image.BufferedImage;
46 46
import java.util.List;
47 47

  
48
import javax.print.attribute.PrintRequestAttributeSet;
48 49
import javax.swing.ImageIcon;
49 50

  
50 51
import org.cresques.cts.ICoordTrans;
......
199 200
	 *
200 201
	 * @throws DriverException
201 202
	 */
202
	void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
203
	void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
203 204
		throws DriverException;
204 205

  
205 206
	/**
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrGT2_old.java
52 52
import java.awt.image.BufferedImage;
53 53
import java.io.IOException;
54 54

  
55
import javax.print.attribute.PrintRequestAttributeSet;
56

  
55 57
import org.geotools.data.FeatureSource;
56 58
import org.geotools.map.DefaultMapContext;
57 59
import org.geotools.map.MapContext;
......
140 142
	/**
141 143
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable)
142 144
	 */
143
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) throws DriverException {
145
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale, PrintRequestAttributeSet properties) throws DriverException {
144 146
	}
145 147

  
146 148
}
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrGT2.java
49 49
import java.io.IOException;
50 50
import java.util.NoSuchElementException;
51 51

  
52
import javax.print.attribute.PrintRequestAttributeSet;
53

  
52 54
import org.geotools.data.DataStore;
53 55
import org.geotools.data.DefaultQuery;
54 56
import org.geotools.data.DefaultTransaction;
......
167 169
    }
168 170

  
169 171
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
170
            double scale) throws DriverException {
172
            double scale, PrintRequestAttributeSet properties) throws DriverException {
171 173
        // TODO Auto-generated method stub
172 174

  
173 175
    }
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java
50 50
import java.io.File;
51 51
import java.io.IOException;
52 52

  
53
import javax.print.attribute.PrintRequestAttributeSet;
54

  
53 55
import org.apache.log4j.Logger;
54 56
import org.cresques.cts.ICoordTrans;
55 57

  
......
384 386
	 *      com.iver.utiles.swing.threads.Cancellable)
385 387
	 */
386 388
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
387
			double scale) throws DriverException {
389
			double scale, PrintRequestAttributeSet properties) throws DriverException {
388 390
		if (isVisible() && isWithinScale(scale)) {
389 391
			Strategy strategy = StrategyManager.getStrategy(this);
390 392

  
391
			strategy.print(g, viewPort, cancel);
393
			strategy.print(g, viewPort, cancel, properties);
392 394

  
393 395
			if (getLayerText() != null) {
394 396
				getLayerText().draw(null, g, viewPort, cancel, scale);
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java
50 50
import java.util.List;
51 51
import java.util.prefs.Preferences;
52 52

  
53
import javax.print.attribute.PrintRequestAttributeSet;
54

  
53 55
import org.cresques.cts.ICoordTrans;
54 56
import org.cresques.cts.IProjection;
55 57
import org.cresques.geo.Projected;
......
291 293
	 *
292 294
	 * @throws DriverException
293 295
	 */
294
	public void print(Graphics2D g, double scale) throws DriverException {
296
	public void print(Graphics2D g, double scale, PrintRequestAttributeSet properties) throws DriverException {
295 297
		RenderingHints renderHints = new RenderingHints(
296 298
				RenderingHints.KEY_ANTIALIASING,
297 299
				RenderingHints.VALUE_ANTIALIAS_ON);
......
309 311

  
310 312
			}
311 313
		};
312
		layers.print(g, viewPort, cancel, scale);
314
		layers.print(g, viewPort, cancel, scale, properties);
313 315
		tracLayer.draw(null, g, viewPort, cancel, scale);
314 316
	}
315 317

  
......
741 743
		if (viewPort != null)
742 744
			viewPort.addViewPortListener(eventBuffer);
743 745
	}
744
	
746

  
745 747
	/**
746 748
	 * Sets the given zoom extent to the viewport.
747 749
	 *
......
1023 1025
		// truco
1024 1026
		if (getLayers().getLayersCount() > 0)
1025 1027
			getLayers().moveTo(0,0);
1026
		
1028

  
1027 1029
	}
1028 1030

  
1029 1031
}
branches/v10/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrGeoRaster.java
30 30
import java.io.InputStreamReader;
31 31
import java.util.ArrayList;
32 32

  
33
import javax.print.attribute.PrintRequestAttributeSet;
34

  
33 35
import org.cresques.io.data.RasterMetaFileTags;
34 36
import org.cresques.px.Extent;
35 37

  
......
148 150
	 * transformaci?n del viewPort.
149 151
	 */
150 152
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
151
		double scale)throws DriverException {
152
		super.print(g, this.toImageCoord(viewPort), cancel, scale);
153
		double scale, PrintRequestAttributeSet properties)throws DriverException {
154
		super.print(g, this.toImageCoord(viewPort), cancel, scale, properties);
153 155
	}
154 156

  
155 157
	/**
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/fmap/layers/FLyrWCS.java
60 60
import java.util.Hashtable;
61 61
import java.util.Map;
62 62

  
63
import javax.print.attribute.PrintRequestAttributeSet;
64

  
63 65
import org.cresques.filter.RasterFilterStack;
64 66
import org.cresques.filter.RasterFilterStackManager;
65 67
import org.cresques.geo.ViewPortData;
......
796 798
		rasterFile.close();
797 799
	}
798 800

  
799
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws DriverException {
801
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws DriverException {
800 802
		draw(null, g, viewPort, cancel, scale);
801 803
	}
802 804

  
branches/v10/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
66 66
import java.util.Vector;
67 67

  
68 68
import javax.imageio.ImageIO;
69
import javax.print.attribute.PrintRequestAttributeSet;
69 70
import javax.swing.ImageIcon;
70 71
import javax.swing.JOptionPane;
71 72

  
......
1068 1069
	 * 		com.iver.cit.gvsig.fmap.ViewPort,
1069 1070
	 * 		com.iver.cit.gvsig.fmap.operations.Cancellable)
1070 1071
	 */
1071
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
1072
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
1072 1073
		throws DriverException {
1073 1074
		if (isVisible() && isWithinScale(scale)){
1074 1075
		isPrinting = true;
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/FPanelLegendLabels.java
164 164
		getJComboBoxTextField().getModel().setSelectedItem(m_Renderer.getLabelField());
165 165
        getJComboBoxHeightField().getModel().setSelectedItem(m_Renderer.getLabelHeightField());
166 166
        getJComboBoxRotationField().getModel().setSelectedItem(m_Renderer.getLabelRotationField());
167
		setFSymbol((FSymbol) r.getDefaultSymbol());
168 167

  
168
        if (r.getDefaultSymbol() instanceof FSymbol)
169
        	setFSymbol((FSymbol) r.getDefaultSymbol());
170

  
169 171
		if (m_Renderer.getLabelField() != null)
170 172
			getJCheckBox().setSelected(true);
171 173
		else
......
619 621
					getJComboBoxHeightField().setEnabled(!b);
620 622
					getJRadioButton().setEnabled(b);
621 623
					getJRadioButton1().setEnabled(b);
624
					getJComboBoxHeightField().setSelectedItem(NULL_COMBO_ITEM);
622 625
				}
623 626

  
624 627
			});
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameView.java
68 68
import com.iver.cit.gvsig.fmap.layers.LegendListener;
69 69
import com.iver.cit.gvsig.fmap.layers.XMLException;
70 70
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
71
import com.iver.cit.gvsig.gui.layout.Attributes;
71 72
import com.iver.cit.gvsig.gui.layout.Layout;
72 73
import com.iver.cit.gvsig.project.Project;
73 74
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
......
481 482
                (int) r.height));
482 483

  
483 484
        try {
484
            this.getMapContext().print(g, getScale());
485
        	this.getMapContext().print(g, getScale(),layout.getAtributes().toPrintAttributes());
485 486
        } catch (com.iver.cit.gvsig.fmap.DriverException e) {
486 487
            NotificationManager.addError(e.getMessage(), e);
487 488
        }
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Attributes.java
53 53

  
54 54
import javax.print.attribute.HashPrintRequestAttributeSet;
55 55
import javax.print.attribute.PrintRequestAttributeSet;
56
import javax.print.attribute.ResolutionSyntax;
56 57
import javax.print.attribute.standard.Copies;
57 58
import javax.print.attribute.standard.Fidelity;
58 59
import javax.print.attribute.standard.Media;
......
60 61
import javax.print.attribute.standard.MediaSizeName;
61 62
import javax.print.attribute.standard.OrientationRequested;
62 63
import javax.print.attribute.standard.PrintQuality;
64
import javax.print.attribute.standard.PrinterResolution;
63 65
import javax.print.attribute.standard.Sides;
64 66

  
65 67
import com.iver.andami.PluginServices;
......
367 369

  
368 370
		//resul.add(MediaSize.Other.PERSONAL_ENVELOPE);
369 371
		//attributes.add(m_resolution);
372
		resul.add(new PrinterResolution(DPI,DPI,PrinterResolution.DPI));
370 373
		return resul;
371 374
	}
372 375

  
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Layout.java
84 84
import javax.swing.JPanel;
85 85
import javax.swing.filechooser.FileFilter;
86 86

  
87
import org.apache.log4j.Logger;
88

  
89 87
import com.iver.andami.PluginServices;
90 88
import com.iver.andami.messages.NotificationManager;
91 89
import com.iver.andami.ui.mdiManager.IWindowListener;
......
152 150
 */
153 151
public class Layout extends JPanel implements SingletonWindow, ViewPortListener,
154 152
		IWindowListener, CommandListener {
155
	private static Logger logger = Logger.getLogger(Layout.class.getName());
153
	//private static Logger logger = Logger.getLogger(Layout.class.getName());
156 154

  
157 155
	public static final int ZOOM_MAS = 1;
158 156

  
......
528 526

  
529 527
		// TODO Esto es para ver el rect?ngulo que representa el folio en la
530 528
		// impresi?n.
531
		g2.drawRect(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
529
		// g2.drawRect(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
532 530
		// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
533 531
	}
534 532

  
......
574 572

  
575 573
		switch (status) {
576 574
		case ZOOM_MAS:
577
			logger.debug("zoom mas");
575
			//logger.debug("zoom mas");
578 576
			layoutDraw.drawRectangle((Graphics2D) g);
579 577

  
580 578
			g.drawImage(img, 0, 0, this);
......
592 590
			break;
593 591

  
594 592
		case RECTANGLE:
595
			logger.debug("rectangle");
593
			//logger.debug("rectangle");
596 594
			layoutDraw.drawRectangle((Graphics2D) g);
597 595

  
598 596
			g.drawImage(img, 0, 0, this);
......
616 614
			break;
617 615

  
618 616
		case PAN:
619
			logger.debug("pan");
617
			//logger.debug("pan");
620 618

  
621 619
			rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x);
622 620
			rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y);
......
635 633

  
636 634
		case VIEW_PAN:
637 635

  
638
			logger.debug("View pan");
636
			//logger.debug("View pan");
639 637
			layoutDraw.drawRectangle((Graphics2D) g);
640 638

  
641 639
			for (int i = 0; i < getFFrames().length; i++) {
......
679 677
			break;
680 678

  
681 679
		case SELECT:
682
			logger.debug("select");
680
			//logger.debug("select");
683 681
			layoutDraw.drawRectangle((Graphics2D) g);
684 682

  
685 683
			g.drawImage(img, 0, 0, this);
......
730 728

  
731 729
			break;
732 730
		case GRAPHICS:
733
			logger.debug("graphics");
731
			//logger.debug("graphics");
734 732
			layoutDraw.drawRectangle((Graphics2D) g);
735 733
			g.drawImage(img, 0, 0, this);
736 734
			g.setClip(rClip);
......
751 749
			break;
752 750

  
753 751
		case DESACTUALIZADO:
754
			logger.debug("desactualizado");
752
			//logger.debug("desactualizado");
755 753
			img = new BufferedImage(getWidth(), getHeight(),
756 754
					BufferedImage.TYPE_INT_ARGB);
757 755
			imgRuler = new BufferedImage(getWidth(), getHeight(),

Also available in: Unified diff