]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/Point.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / com / infomatiq / jsi / Point.java
diff --git a/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/Point.java b/bundles/org.simantics.scenegraph/src/com/infomatiq/jsi/Point.java
new file mode 100644 (file)
index 0000000..929b831
--- /dev/null
@@ -0,0 +1,72 @@
+//   Point.java\r
+//   Java Spatial Index Library\r
+//   Copyright (C) 2002-2005 Infomatiq Limited.\r
+//  \r
+//  This library is free software; you can redistribute it and/or\r
+//  modify it under the terms of the GNU Lesser General Public\r
+//  License as published by the Free Software Foundation; either\r
+//  version 2.1 of the License, or (at your option) any later version.\r
+//  \r
+//  This library is distributed in the hope that it will be useful,\r
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+//  Lesser General Public License for more details.\r
+//  \r
+//  You should have received a copy of the GNU Lesser General Public\r
+//  License along with this library; if not, write to the Free Software\r
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
+\r
+package com.infomatiq.jsi;\r
+\r
+/**\r
+ * Currently hardcoded to 2 dimensions, but could be extended.\r
+ * \r
+ * @author  aled@sourceforge.net\r
+ * @version 1.0b8\r
+ */\r
+public class Point {\r
+  /**\r
+   * The (x, y) coordinates of the point.\r
+   */\r
+  public float x, y;\r
+  \r
+  /**\r
+   * Constructor.\r
+   * \r
+   * @param x The x coordinate of the point\r
+   * @param y The y coordinate of the point\r
+   */\r
+  public Point(float x, float y) {\r
+    this.x = x; \r
+    this.y = y;\r
+  }\r
+  \r
+  /**\r
+   * Copy from another point into this one\r
+   */\r
+  public void set(Point other) {\r
+    x = other.x;\r
+    y = other.y;\r
+  }\r
+  \r
+  /**\r
+   * Print as a string in format "(x, y)"\r
+   */\r
+  public String toString() {\r
+    return "(" + x + ", " + y + ")";\r
+  }\r
+  \r
+  /**\r
+   * @return X coordinate rounded to an int\r
+   */\r
+  public int xInt() {\r
+    return (int) Math.round(x);\r
+  }\r
+  \r
+  /**\r
+   * @return Y coordinate rounded to an int\r
+   */\r
+  public int yInt() {\r
+    return (int) Math.round(y);\r
+  }\r
+}\r