Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.operation / src / main / java / org / gvsig / fmap / geom / operation / AggregateDraw.java @ 40559

History | View | Annotate | Download (2.9 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2009 IVER T.I   {{Task}}
27
 */
28

    
29
/**
30
 *
31
 */
32
package org.gvsig.fmap.geom.operation;
33

    
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37
import org.gvsig.fmap.geom.Geometry.TYPES;
38
import org.gvsig.fmap.geom.aggregate.Aggregate;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

    
42
/**
43
 * @author Vicente Caballero Navarro
44
 *
45
 */
46
public class AggregateDraw extends GeometryOperation {
47
        
48
        public static final String NAME = "draw";
49
        public static int CODE = Integer.MIN_VALUE;
50

    
51
        final static private Logger logger = LoggerFactory
52
        .getLogger(AggregateDraw.class);
53

    
54
        /* (non-Javadoc)
55
         * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
56
         */
57
        public int getOperationIndex() {
58
                return CODE;
59
        }
60

    
61
        /* (non-Javadoc)
62
         * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
63
         */
64
        public Object invoke(Geometry geom, GeometryOperationContext ctx)
65
        throws GeometryOperationException {
66

    
67
                Aggregate aggregate = (Aggregate) geom;
68
                for (int i=0;i<aggregate.getPrimitivesNumber();i++){
69
                        Geometry prim = aggregate.getPrimitiveAt(i);
70
                        try {
71
                                prim.invokeOperation(CODE, ctx);
72
                        } catch (GeometryOperationNotSupportedException e) {
73
                                throw new GeometryOperationException(e);
74
                        }
75
                }
76
                return null;
77
        }
78

    
79
        public static void register() {
80
                GeometryManager geoMan = GeometryLocator.getGeometryManager();
81
                
82
                CODE = geoMan.getGeometryOperationCode(NAME);
83

    
84
                geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
85
                                TYPES.AGGREGATE);
86
                geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
87
                                TYPES.MULTIPOINT);
88
                geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
89
                                TYPES.MULTICURVE);
90
                geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
91
                                TYPES.MULTISURFACE);
92
                geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
93
                                TYPES.MULTISOLID);
94

    
95
        }
96

    
97
}