Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1007 / extensions / extWMS / src / com / iver / cit / gvsig / fmap / layers / ComposedLayerWMS.java @ 12478

History | View | Annotate | Download (2.88 KB)

1 10934 jmvivo
/**
2 12348 jmvivo
 *
3 10934 jmvivo
 */
4
package com.iver.cit.gvsig.fmap.layers;
5
6
import java.awt.Graphics2D;
7
import java.awt.image.BufferedImage;
8
import java.util.Vector;
9
10 12348 jmvivo
import javax.print.attribute.PrintRequestAttributeSet;
11
12 11030 jmvivo
import com.iver.cit.gvsig.fmap.DriverException;
13 10934 jmvivo
import com.iver.cit.gvsig.fmap.ViewPort;
14
import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer;
15
import com.iver.utiles.swing.threads.Cancellable;
16
17
/**
18
 * Group WMS layers for make a single petition to the
19
 * server for all layers.
20 12348 jmvivo
 *
21 10934 jmvivo
 * It is posible only if almost all params are the same. For this
22 12348 jmvivo
 * comparasion, ComposedLayerWMS uses the method
23 10934 jmvivo
 * {@link com.iver.cit.gvsig.fmap.layers.FLyrWMS#isComposedLayerCompatible(com.iver.cit.gvsig.fmap.layers.FLayer)}
24 12348 jmvivo
 *
25
 *
26 10934 jmvivo
 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer
27
 * @see com.iver.cit.gvsig.fmap.layers.FLyrWMS
28
 */
29 11125 jmvivo
public class ComposedLayerWMS extends ComposedLayer {
30 10934 jmvivo
        private FLyrWMS layer=null;
31
32
        /* (non-Javadoc)
33
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#canAdd(com.iver.cit.gvsig.fmap.layers.FLayer)
34
         */
35
        public boolean canAdd(FLayer layer) {
36
                if (this.layer != null) {
37
                        return this.layer.isComposedLayerCompatible(layer);
38
                }
39
                return false;
40
        }
41
42
        /* (non-Javadoc)
43 11125 jmvivo
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#doAdd(com.iver.cit.gvsig.fmap.layers.FLayer)
44 10934 jmvivo
         */
45 11125 jmvivo
        protected void doAdd(FLayer layer) throws Exception {
46 10934 jmvivo
                FLyrWMS aLayer =(FLyrWMS)layer;
47
                if (this.layer == null) {
48
                        this.layer = new FLyrWMS();
49
                        this.layer.setXMLEntity(aLayer.getXMLEntity());
50
                        return;
51 12348 jmvivo
                }
52 10934 jmvivo
                this.layer.setLayerQuery( this.layer.getLayerQuery() + ","+ aLayer.getLayerQuery());
53
                Vector aStyles = aLayer.getStyles();
54 12348 jmvivo
55 10934 jmvivo
                if (aStyles != null) {
56
                        Vector myStyles = this.layer.getStyles();
57
                        if (myStyles == null) {
58
                                this.layer.setStyles(aStyles);
59
                        } else {
60
                                myStyles.addAll(aStyles);
61
                                this.layer.setStyles(myStyles);
62
                        }
63
                }
64 12348 jmvivo
65 10934 jmvivo
                //revisar el fullextend para ajustarlo a todas las capas
66
                this.layer.getFullExtent().add(aLayer.getFullExtent());
67
68
        }
69
70
        /* (non-Javadoc)
71 11125 jmvivo
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#doDraw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable, double)
72 10934 jmvivo
         */
73 11125 jmvivo
        protected void doDraw(BufferedImage image, Graphics2D g, ViewPort viewPort,
74 11030 jmvivo
                        Cancellable cancel, double scale) throws DriverException {
75 10934 jmvivo
                this.layer.draw(image,g,viewPort,cancel,scale);
76
        }
77
78 12348 jmvivo
        /* (non-Javadoc)
79
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#doPrint(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable, double, javax.print.attribute.PrintRequestAttributeSet)
80
         */
81
        protected void doPrint(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws DriverException {
82
                this.layer.print(g, viewPort, cancel, scale, properties);
83
84
        }
85
86 10934 jmvivo
}