Source Code Cross Referenced for PGpoint.java in  » Database-JDBC-Connection-Pool » postgresql » org » postgresql » geometric » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » postgresql » org.postgresql.geometric 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-------------------------------------------------------------------------
002:         *
003:         * Copyright (c) 2003-2005, PostgreSQL Global Development Group
004:         *
005:         * IDENTIFICATION
006:         *   $PostgreSQL: pgjdbc/org/postgresql/geometric/PGpoint.java,v 1.15 2007/07/16 15:02:53 jurka Exp $
007:         *
008:         *-------------------------------------------------------------------------
009:         */
010:        package org.postgresql.geometric;
011:
012:        import org.postgresql.util.GT;
013:        import org.postgresql.util.PGobject;
014:        import org.postgresql.util.PGtokenizer;
015:        import org.postgresql.util.PSQLException;
016:        import org.postgresql.util.PSQLState;
017:
018:        import java.awt.Point;
019:        import java.io.Serializable;
020:        import java.sql.SQLException;
021:
022:        /**
023:         * It maps to the point datatype in org.postgresql.
024:         *
025:         * This implements a version of java.awt.Point, except it uses double
026:         * to represent the coordinates.
027:         */
028:        public class PGpoint extends PGobject implements  Serializable,
029:                Cloneable {
030:            /**
031:             * The X coordinate of the point
032:             */
033:            public double x;
034:
035:            /**
036:             * The Y coordinate of the point
037:             */
038:            public double y;
039:
040:            /**
041:             * @param x coordinate
042:             * @param y coordinate
043:             */
044:            public PGpoint(double x, double y) {
045:                this ();
046:                this .x = x;
047:                this .y = y;
048:            }
049:
050:            /**
051:             * This is called mainly from the other geometric types, when a
052:             * point is embedded within their definition.
053:             *
054:             * @param value Definition of this point in PostgreSQL's syntax
055:             */
056:            public PGpoint(String value) throws SQLException {
057:                this ();
058:                setValue(value);
059:            }
060:
061:            /**
062:             * Required by the driver
063:             */
064:            public PGpoint() {
065:                setType("point");
066:            }
067:
068:            /**
069:             * @param s Definition of this point in PostgreSQL's syntax
070:             * @exception SQLException on conversion failure
071:             */
072:            public void setValue(String s) throws SQLException {
073:                PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
074:                try {
075:                    x = Double.valueOf(t.getToken(0)).doubleValue();
076:                    y = Double.valueOf(t.getToken(1)).doubleValue();
077:                } catch (NumberFormatException e) {
078:                    throw new PSQLException(GT.tr(
079:                            "Conversion to type {0} failed: {1}.",
080:                            new Object[] { type, s }),
081:                            PSQLState.DATA_TYPE_MISMATCH, e);
082:                }
083:            }
084:
085:            /**
086:             * @param obj Object to compare with
087:             * @return true if the two points are identical
088:             */
089:            public boolean equals(Object obj) {
090:                if (obj instanceof  PGpoint) {
091:                    PGpoint p = (PGpoint) obj;
092:                    return x == p.x && y == p.y;
093:                }
094:                return false;
095:            }
096:
097:            public int hashCode() {
098:                long v1 = Double.doubleToLongBits(x);
099:                long v2 = Double.doubleToLongBits(y);
100:                return (int) (v1 ^ v2 ^ (v1 >>> 32) ^ (v2 >>> 32));
101:            }
102:
103:            /**
104:             * @return the PGpoint in the syntax expected by org.postgresql
105:             */
106:            public String getValue() {
107:                return "(" + x + "," + y + ")";
108:            }
109:
110:            /**
111:             * Translate the point by the supplied amount.
112:             * @param x integer amount to add on the x axis
113:             * @param y integer amount to add on the y axis
114:             */
115:            public void translate(int x, int y) {
116:                translate((double) x, (double) y);
117:            }
118:
119:            /**
120:             * Translate the point by the supplied amount.
121:             * @param x double amount to add on the x axis
122:             * @param y double amount to add on the y axis
123:             */
124:            public void translate(double x, double y) {
125:                this .x += x;
126:                this .y += y;
127:            }
128:
129:            /**
130:             * Moves the point to the supplied coordinates.
131:             * @param x integer coordinate
132:             * @param y integer coordinate
133:             */
134:            public void move(int x, int y) {
135:                setLocation(x, y);
136:            }
137:
138:            /**
139:             * Moves the point to the supplied coordinates.
140:             * @param x double coordinate
141:             * @param y double coordinate
142:             */
143:            public void move(double x, double y) {
144:                this .x = x;
145:                this .y = y;
146:            }
147:
148:            /**
149:             * Moves the point to the supplied coordinates.
150:             * refer to java.awt.Point for description of this
151:             * @param x integer coordinate
152:             * @param y integer coordinate
153:             * @see java.awt.Point
154:             */
155:            public void setLocation(int x, int y) {
156:                move((double) x, (double) y);
157:            }
158:
159:            /**
160:             * Moves the point to the supplied java.awt.Point
161:             * refer to java.awt.Point for description of this
162:             * @param p Point to move to
163:             * @see java.awt.Point
164:             */
165:            public void setLocation(Point p) {
166:                setLocation(p.x, p.y);
167:            }
168:
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.