01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.bpel.design.geometry;
21:
22: /**
23: *
24: * @author anjeleevich
25: */
26: public class FPoint {
27:
28: public final float x;
29: public final float y;
30:
31: public FPoint(double x, double y) {
32: this .x = (float) x;
33: this .y = (float) y;
34: }
35:
36: public double distance(FPoint point) {
37: if (equals(point))
38: return 0.0;
39: return distance(point.x, point.y);
40: }
41:
42: public FPoint move(double px, double py) {
43: return ((px == x) && (py == y)) ? this : new FPoint(x, y);
44: }
45:
46: public FPoint translate(double tx, double ty) {
47: return new FPoint(tx + x, ty + y);
48: }
49:
50: public double distance(double px, double py) {
51: px -= x;
52: py -= y;
53:
54: return Math.sqrt(px * px + py * py);
55: }
56:
57: public FPoint point(double t, FPoint p) {
58: if (((float) t == 0.0f) || equals(p)) {
59: return this ;
60: }
61:
62: if ((float) t == 1.0f) {
63: return p;
64: }
65:
66: return point(t, p.x, p.y);
67: }
68:
69: public FPoint rotate90() {
70: return new FPoint(-y, x);
71: }
72:
73: public FPoint point(double t, double px, double py) {
74: return new FPoint((double) x + t * (px - (double) x),
75: (double) y + t * (py - (double) y));
76: }
77:
78: public boolean equals(FPoint point) {
79: return (point == this)
80: || ((point.x == this.x) && (point.y == this.y));
81: }
82: }
|