01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: * (C) 2002, Refractions Reserach Inc.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation;
10: * version 2.1 of the License.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.graph.structure.line;
18:
19: import org.geotools.graph.structure.opt.OptDirectedNode;
20:
21: import com.vividsolutions.jts.geom.Coordinate;
22:
23: /**
24: * Optimized implementation of XYNode extended from OptDirectedNode. Instead of
25: * storing an underlying coordinate object, only a set of (x,y) values are
26: * stored eliminating the storage of additional oordinate dimensions.
27: *
28: * @see org.geotools.graph.structure.opt.OptDirectedNode
29: *
30: * @author Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
31: *
32: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/graph/src/main/java/org/geotools/graph/structure/line/OptDirectedXYNode.java $
33: */
34: public class OptDirectedXYNode extends OptDirectedNode implements
35: XYNode {
36:
37: /** x value of coordinate **/
38: private double m_x;
39:
40: /** y value of coordinate **/
41: private double m_y;
42:
43: /**
44: * This method creates a new Coordinate object upon each call.
45: *
46: * @see XYNode#getCoordinate()
47: */
48: public Coordinate getCoordinate() {
49: return (new Coordinate(m_x, m_y));
50: }
51:
52: /**
53: * This method strips only the x and y ordinates from the Coordinate object
54: * and stores them.
55: *
56: * @see XYNode#setCoordinate(Coordinate)
57: */
58: public void setCoordinate(Coordinate c) {
59: m_x = c.x;
60: m_y = c.y;
61: }
62: }
|