-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathXY.java
More file actions
135 lines (122 loc) · 3.21 KB
/
Copy pathXY.java
File metadata and controls
135 lines (122 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package sysmlinjava.analysis.common;
import java.io.Serializable;
import sysmlinjava.valuetypes.Point2D;
/**
* X and Y values for a point in a 2D cartesian coordinate system, i.e. x and y
* values on the X and Y axes. The directions and ranges of the x and y values
* is undefined. Use for analysis displays is as needed for the particular
* display. The {@code CoordinateTransform} class is provided to permit use of
* this XY coordinate system as a transform of another, e.g. {@code Point2D}
* coordinate system.
* <p>
* For example, a SysMLinJava model might use a typical cartesian coordinate
* system with some distance per x,y increment and the {@code [0,0]} point at
* the bottom left of the modeled space. An animated area display uses a pixel
* coordinate system with the pixel as the increment and the {@code 0,0} pixel
* at the upper left of the pixel space. The {@code CoordinateTransform} could
* be used to transform {@code Point2D} positions in the model to {@code XY}
* pixels in the display.
*
* @see sysmlinjava.analysis.common.CartesianCoordinateTransform
*
* @author ModelerOne
*
*/
public class XY implements Serializable
{
/** Serializable ID */
private static final long serialVersionUID = 6019714086065572412L;
/**
* x value for the point
*/
public double xValue;
/**
* y value for the point
*/
public double yValue;
/**
* Whether or not values are empty/not yet set
*/
public boolean isEmpty;
/**
* Constructor for empty values
*
*/
public XY()
{
super();
isEmpty = true;
}
/**
* Constructor
*
* @param xValue point's x axis value
* @param yValue point's y axis value
*/
public XY(double xValue, double yValue)
{
super();
this.xValue = xValue;
this.yValue = yValue;
isEmpty = false;
}
/**
* Constructor for copy of another instance
*
* @param copied instance whose values are to be copied to this
*/
public XY(XY copied)
{
super();
xValue = copied.xValue;
yValue = copied.yValue;
isEmpty = false;
}
/**
* Constructor for copy of Point2D instance
*
* @param copied point whose values are to be copied to this
*/
public XY(Point2D copied)
{
this(copied.xValue, copied.yValue);
}
/**
* Returns whether or not values are empty/not yet set
*
* @return true of x and y values are not yet set, false otherwise
*/
public boolean isEmpty()
{
return isEmpty;
}
/**
* Returns instance whose x and y values are this x and y values offset by
* specified delta values
*
* @param xDelta amount to change xValue by
* @param yDelta amount to change yValue by
* @return instance whose x and y values are this x and y values offset by
* specified delta values
*/
public XY offset(int xDelta, int yDelta)
{
return new XY(xValue + xDelta, yValue + yDelta);
}
/**
* Returns whether this instance is equal to (same {@code xValue}s and
* {@code yValue}s) specified other instance
*
* @param other instance to be compared with
* @return true if this instance is equal to other instance
*/
public boolean equals(XY other)
{
return xValue == other.xValue && yValue == other.yValue;
}
@Override
public String toString()
{
return String.format("XY [xValue=%s, yValue=%s]", xValue, yValue);
}
}