-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathComplex.java
More file actions
95 lines (88 loc) · 2.65 KB
/
Copy pathComplex.java
File metadata and controls
95 lines (88 loc) · 2.65 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
package sysmlinjava.valuetypes;
import sysmlinjava.annotations.Attribute;
import sysmlinjava.units.SysMLinJavaUnits;
/**
* SysMLinJava's representation of the value type for complex values, i.e. two
* (real and imaginary) values of {@code double} type.
* <p>
* This representation of the complex number type is for a generic complex
* number as used in SysML. Hence the use of two Java {@code
* double}s for its value. This SysML complex number is not the same as two java
* float, double, Float or Double types as SysML does not discriminate between
* bit-lengths of real or floating- point numeric types as does the Java
* language.
* <p>
* <b>Note:</b> as an {@code observableValueType} this value type can be
* "observed" by other objects. {@code ValueObserver}s call the {@code
* addValueObserver()} operation to be notiified (called-back) by the {@code
* Complex} object of any change in its value. This notification will only occur
* if and when the {@code Complex} {@code value} is changed by a call to the
* {@code
* setValue()} operation. So, while the {@code Complex value} is publicly
* accessible and can be changed by direct assignment, the {@code setValue()}
* operation must be used if {@code ValueObserver}s are to be notified of the
* change.
*
* @author ModelerOne
*
*/
public class Complex extends SysMLValueType
{
/**
* Attribute for the real part of the complex variable
*/
@Attribute
public double valueReal;
/**
* Attribute for the "imaginary" part of the complex variable
*/
@Attribute
public double valueImaginary;
/**
* Constructor
*
* @param valueReal initial value for the real part
* @param valueImaginary initial value of the imaginary part
*/
public Complex(double valueReal, double valueImaginary)
{
super();
this.valueReal = valueReal;
this.valueImaginary = valueImaginary;
}
/**
* Sets the value of the complex variable
*
* @param valueReal set value for the real part
* @param valueImaginary set value of the imaginary part
*/
public void setValues(double valueReal, double valueImaginary)
{
this.valueReal = valueReal;
this.valueImaginary = valueImaginary;
notifyValueChangeObservers();
}
/**
* Returns the real part of the complex variable
*
* @return real part
*/
public double getValueReal()
{
return valueReal;
}
/**
* Returns the imaginary part of the complex variable
*
* @return imaginary part
*/
public double getValueImaginary()
{
return valueImaginary;
}
@Override
protected void createUnits()
{
units = SysMLinJavaUnits.Numeric;
}
}