Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / cad / tools / split / SplitEdge.java @ 40557

History | View | Annotate | Download (3.69 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
/* Spatial Operations & Editing Tools for uDig
25
 * 
26
 * Axios Engineering under a funding contract with: 
27
 *      Diputación Foral de Gipuzkoa, Ordenación Territorial 
28
 *
29
 *      http://b5m.gipuzkoa.net
30
 *      http://www.axios.es 
31
 *
32
 * (C) 2006, Diputación Foral de Gipuzkoa, Ordenación Territorial (DFG-OT). 
33
 * DFG-OT agrees to licence under Lesser General Public License (LGPL).
34
 * 
35
 * You can redistribute it and/or modify it under the terms of the 
36
 * GNU Lesser General Public License as published by the Free Software 
37
 * Foundation; version 2.1 of the License.
38
 *
39
 * This library is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
42
 * Lesser General Public License for more details.
43
 */
44
package org.gvsig.editing.gui.cad.tools.split;
45

    
46
import com.vividsolutions.jts.geom.Coordinate;
47
import com.vividsolutions.jts.geom.Location;
48
import com.vividsolutions.jts.geomgraph.Edge;
49
import com.vividsolutions.jts.geomgraph.Label;
50
import com.vividsolutions.jts.geomgraph.Position;
51

    
52
/**
53
 * A custom edge class that knows if its an edge from the shell of the polygin being splitted, one
54
 * of its holes or the splitting line, by inspecing its label.
55
 * 
56
 * @author Gabriel Roldán, Axios Engineering
57
 * @author Mauricio Pazos, Axios Engineering
58
 * @since 1.1.0
59
 */
60
final class SplitEdge extends Edge {
61
    SplitEdge( Coordinate[] pts, Label label ) {
62
        super(pts, label);
63
    }
64

    
65
    private int[] getLabelLocations() {
66
        int[] locations = new int[3];
67
        Label label = getLabel();
68
        locations[Position.ON] = label.getLocation(0, Position.ON);
69
        locations[Position.LEFT] = label.getLocation(0, Position.LEFT);
70
        locations[Position.RIGHT] = label.getLocation(0, Position.RIGHT);
71
        return locations;
72
    }
73

    
74
    public boolean isShellEdge() {
75
        int[] loc = getLabelLocations();
76
        return (loc[Position.LEFT] == Location.EXTERIOR && loc[Position.RIGHT] == Location.INTERIOR);
77
    }
78

    
79
    public boolean isHoleEdge() {
80
        int[] loc = getLabelLocations();
81
        return (loc[Position.LEFT] == Location.INTERIOR && loc[Position.RIGHT] == Location.EXTERIOR);
82
    }
83

    
84
    public boolean isInteriorEdge() {
85
        int[] loc = getLabelLocations();
86
        return (loc[Position.LEFT] == Location.INTERIOR && loc[Position.RIGHT] == Location.INTERIOR);
87
    }
88

    
89
    public String toString() {
90
        StringBuffer sb = new StringBuffer("Edge[label=");
91
        sb.append(getLabel()).append(", ");
92
        Coordinate[] coords = getCoordinates();
93
        for( int i = 0; i < coords.length; i++ ) {
94
            sb.append(coords[i].x).append(",").append(coords[i].y).append(" ");
95
        }
96
        sb.append("]");
97
        return sb.toString();
98
    }
99
}