Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / handler / AbstractHandler.java @ 40559

History | View | Annotate | Download (2.6 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
package org.gvsig.fmap.geom.handler;
25

    
26
import java.awt.geom.Point2D;
27

    
28

    
29

    
30
/**
31
 * This class expands the <code>Handler</code> interface adding support for selection, and
32
 *  identifying a handler of a geometry.
33
 * 
34
 * @see Handler
35
 *
36
 * @author Vicente Caballero Navarro
37
 */
38
public abstract class AbstractHandler implements Handler {
39
        /**
40
         * Identifies each handler of a geometry.
41
         */
42
        protected int index;
43
        /**
44
         * Position of this handler.
45
         * 
46
         * @see #getPoint()
47
         * @see Handler#set(double, double)
48
         * @see Handler#move(double, double)
49
         */
50
        protected Point2D point;
51
        /**
52
         * True when the handler is selected.
53
         * 
54
         * @see #select
55
         * @see #isSelected()
56
         */
57
        private boolean select=false;
58
        /*
59
         * (non-Javadoc)
60
         * @see com.iver.cit.gvsig.fmap.core.Handler#getPoint()
61
         */
62
        public Point2D getPoint() {
63
                return point;
64
        }
65
        /**
66
         * Sets the state of the handler. <code>True</code> if is selected, <code>false</code> if it's not.
67
         * 
68
         * @param b <code>true</code> if the handler is selected, <code>false</code>  otherwise
69
         * 
70
         * @see #isSelected()
71
         */
72
        public void select(boolean b) {
73
                select=b;
74
        }
75
        /**
76
         * Returns the state of the handler. <code>True</code> if is selected, <code>false</code> if it's not.
77
         * 
78
         * @return <code>true</code> if the handler is selected,<code>false</code> otherwise 
79
         * 
80
         * @see #select(boolean)
81
         */
82
        public boolean isSelected(){
83
                return select;
84
        }
85
        /*
86
         * (non-Javadoc)
87
         * @see com.iver.cit.gvsig.fmap.core.Handler#equalsPoint(java.lang.Object)
88
         */
89
        public boolean equalsPoint(Object obj) {
90
                Point2D p1=this.getPoint();
91
                Point2D p2=((Handler)obj).getPoint();
92
                if (p1.getX()==p2.getX() && p1.getY()==p2.getY()) {
93
                        return true;
94
                }
95
                return false;
96
        }
97
}