Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.spi / src / main / java / org / gvsig / vectorediting / lib / spi / DefaultDrawingStatus.java @ 4306

History | View | Annotate | Download (3.84 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 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 2
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
package org.gvsig.vectorediting.lib.spi;
26

    
27
import java.util.ArrayList;
28
import java.util.List;
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
31
import org.gvsig.vectorediting.lib.api.DrawingStatus;
32

    
33
public class DefaultDrawingStatus implements DrawingStatus {
34

    
35
    private final List<Geometry> geometries;
36
    private final List<Status> status;
37
    private String info;
38
    private ISymbol previewSymbol;
39

    
40
    private static class DefaultStatus implements Status{
41
        private final Geometry geometry;
42
        private final ISymbol symbol;
43
        private final String text;
44
        private final int type;
45

    
46
        DefaultStatus(Geometry geometry, ISymbol symbol, String text, int type){
47
            this.geometry = geometry;
48
            this.symbol = symbol;
49
            this.text = text;
50
            this.type = type;
51
        }
52

    
53
        @Override
54
        public Geometry getGeometry() {
55
            return geometry;
56
        }
57

    
58
        @Override
59
        public ISymbol getSymbol() {
60
            return symbol;
61
        }
62

    
63
        @Override
64
        public String getText() {
65
            return text;
66
        }
67

    
68
        @Override
69
        public int getType() {
70
            return type;
71
        }
72
        
73
    }
74

    
75
    public DefaultDrawingStatus() {
76
        geometries = new ArrayList<>();
77
        status = new ArrayList<>();
78

    
79
        info = null;
80
    }
81

    
82
//    public DefaultDrawingStatus(List<Geometry> geometries, String info) {
83
//        this.geometries = new ArrayList<Geometry>();
84
//        this.geometries.addAll(geometries);
85
//        this.info = info;
86
//    }
87

    
88
//    public void setGeometries(List<Geometry> geometries) {
89
//        this.geometries.addAll(geometries);
90
//    }
91

    
92
    @Override
93
    public List<Geometry> getGeometries() {
94
        return this.geometries;
95
    }
96
    
97
    public Geometry getGeometry() {
98
        for (Status st : status) {
99
            if(st.getType() == TYPE_GEOMETRY){
100
                return st.getGeometry();
101
            }
102
        }
103
        return null;
104
    }
105

    
106
    @Override
107
    public List<Status> getStatus() {
108
        return this.status;
109
    }
110

    
111
    public void setInfo(String info) {
112
        this.info = info;
113
    }
114

    
115
    @Override
116
    public String getInfo() {
117
        return this.info;
118
    }
119

    
120
    public void addGeometry(Geometry geometry) {
121
        geometries.add(geometry);
122
        status.add(new DefaultStatus(geometry,null,null,TYPE_BUILDING));
123
    }
124

    
125
    public void addStatus(Geometry geometry, ISymbol symbol, String text) {
126
        this.addStatus(geometry, symbol, text, TYPE_BUILDING);
127
    }
128

    
129
    public void addStatus(Geometry geometry, ISymbol symbol, String text, int type) {
130
        geometries.add(geometry);
131
        status.add(new DefaultStatus(geometry,symbol,text,type));
132
    }
133

    
134
    public ISymbol getPreviewSymbol() {
135
        return previewSymbol;
136
    }
137

    
138
    public void setPreviewSymbol(ISymbol previewSymbol) {
139
        this.previewSymbol = previewSymbol;
140
    }
141
    
142
}