root/tools/routingservice/trunk/src/jp/co/orkney/restlet/util/Point.java

Revision 164, 2.6 KB (checked in by anton, 3 years ago)

Distance limitation added

Line 
1package jp.co.orkney.restlet.util;
2
3/**
4 * Copyright (c) 2008 Orkney, Inc. <http://www.orkney.co.jp/>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (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, see <http://www.gnu.org/licenses/>.
18 */
19 
20import java.math.BigDecimal;
21
22
23/**
24 * <b>Point is a class which represents a point.</b>
25 * <p>
26 * Point object is characterized by the following information:
27 * <ul>
28 * <li>Two coordinates: X and Y</li>
29 * </ul>
30 * </p>
31 *
32 * @author Matthieu Bilbille - Orkney Inc.
33 * @version 1.0
34 */
35public class Point
36{
37        private BigDecimal x;
38        private BigDecimal y;
39       
40        /**
41         * Constructor Point.
42         * <p>
43         * Creates a new point with X and Y initialized at 0
44         * </p>
45         */
46        public Point()
47        {
48                x = new BigDecimal(0);
49                y = new BigDecimal(0);
50        }
51        /**
52         * Constructor Point.
53         * <p>
54         * Creates a new point with the specified X and Y values.
55         * </p>
56         * @param x X value
57         * @param y Y value
58         */
59        public Point(BigDecimal x, BigDecimal y)
60        {
61                this.x = x;
62                this.y = y;
63        }
64       
65        /**
66         * Gets the X value of the point
67         *
68         * @return this point's X value
69         */
70        public BigDecimal getX()
71        {
72                return x;
73        }
74       
75        /**
76         * Makes an addition between X value and the specified integer, and gets the result
77         * @param value value to add
78         * @return result of this addition
79         */
80        public BigDecimal getX(float value)
81        {
82                return x.add(new BigDecimal(value));
83        }
84       
85        /**
86         * Gets the Y value of the point
87         *
88         * @return this point's Y value
89         */
90        public BigDecimal getY()
91        {
92                return y;
93        }
94       
95        /**
96         * Makes an addition between Y value and the specified integer, and gets the result
97         * @param value value to add
98         * @return result of this addition
99         */
100        public BigDecimal getY(float value)
101        {
102                return y.add(new BigDecimal(value));
103        }
104       
105        /**
106         * Sets the X value of the point to the specified bigdecimal.
107         *
108         * @param x
109         *            the bigdecimal that is to be this point's X value
110         */
111        public void setX(BigDecimal x)
112        {
113                this.x = x;
114        }
115       
116        /**
117         * Sets the Y value of the point to the specified bigdecimal.
118         *
119         * @param y
120         *            the bigdecimal that is to be this point's Y value
121         */
122        public void setY(BigDecimal y)
123        {
124                this.y = y;
125        }
126       
127}
Note: See TracBrowser for help on using the browser.