Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20965b1

Browse files
Initial version, added analysis/common
1 parent 89b8ba7 commit 20965b1

File tree

10 files changed

+1866
-0
lines changed

10 files changed

+1866
-0
lines changed

sysmlinjava/analysis/common/Axis.java

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package sysmlinjava.analysis.common;
2+
3+
import java.io.Serializable;
4+
import java.util.Optional;
5+
6+
/**
7+
* Axis definition for a numerical axis in a chart display, e.g. line, bar,
8+
* timing, etc.
9+
*
10+
* @author ModelerOne
11+
*
12+
*/
13+
public class Axis implements Serializable
14+
{
15+
/** Serializable ID*/private static final long serialVersionUID = 8854669832371302383L;
16+
17+
/**
18+
* Title of the axis, not including the parenthetical units portion
19+
*/
20+
public String title;
21+
/**
22+
* Parenthetical units portion of the title
23+
*/
24+
public String units;
25+
/**
26+
* Minimum value on the axis.
27+
*/
28+
public double minTicValue;
29+
/**
30+
* Maimum value on the axis. Chart will automatically determine max value from
31+
* data if value is not present
32+
*/
33+
public double maxTicValue;
34+
/**
35+
* Whether chart will automatically determine range of values on the axis from
36+
* data. Note this boolean is used (versus making the {@code min/maxTicValue}s
37+
* optional) to enable serialization, i.e. {@code Optional} is not serializable.
38+
*/
39+
public boolean autoRange;
40+
/**
41+
* Increment between major (numbered) tics on the axis
42+
*/
43+
public double majorTicValue;
44+
/**
45+
* Number of tics between the major tics.
46+
*/
47+
public int minorTicCount;
48+
49+
/**
50+
* Constructor
51+
*
52+
* @param title Title of the axis, not including the parenthetical units
53+
* portion
54+
* @param units Parenthetical units portion of the title
55+
* @param minTicValue Optional minimum value on the axis. Chart will
56+
* automatically determine min value from data if value is
57+
* not present.
58+
* @param maxTicValue Optional maximum value on the axis. Chart will
59+
* automatically determine max value from data if value is
60+
* not present.
61+
* @param majorTicValue Increment between major (numbered) tics on the axis
62+
* @param minorTicCount Number of tics between the major tics.
63+
*/
64+
public Axis(String title, String units, Optional<Double> minTicValue, Optional<Double> maxTicValue, double majorTicValue, int minorTicCount)
65+
{
66+
super();
67+
this.title = title;
68+
this.units = units;
69+
this.autoRange = false;
70+
if (minTicValue.isPresent())
71+
this.minTicValue = minTicValue.get();
72+
else
73+
{
74+
this.minTicValue = 0;
75+
this.autoRange = true;
76+
}
77+
if (maxTicValue.isPresent())
78+
this.maxTicValue = maxTicValue.get();
79+
else
80+
{
81+
this.maxTicValue = 100;
82+
this.autoRange = true;
83+
}
84+
this.majorTicValue = majorTicValue;
85+
this.minorTicCount = minorTicCount;
86+
}
87+
88+
@Override
89+
public String toString()
90+
{
91+
return String.format("Axis [title=%s, units=%s, minValue=%s, maxValue=%s, majorTicValue=%s, minorTicCount=%s]", title, units, minTicValue, maxTicValue, majorTicValue, minorTicCount);
92+
}
93+
94+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package sysmlinjava.analysis.common;
2+
3+
import java.io.Serializable;
4+
5+
/**
6+
* Axis definition for a numerical axis in a chart display, e.g. line, bar,
7+
* timing, etc.
8+
*
9+
* @author ModelerOne
10+
*
11+
*/
12+
public class AxisFixedRange implements Serializable
13+
{
14+
/** Serializable ID*/private static final long serialVersionUID = 8854669832371302383L;
15+
16+
/**
17+
* Title of the axis, not including the parenthetical units portion
18+
*/
19+
public String title;
20+
/**
21+
* Parenthetical units portion of the title
22+
*/
23+
public String units;
24+
/**
25+
* Minimum value on the axis
26+
*/
27+
public double minTicValue;
28+
/**
29+
* Maimum value on the axis
30+
*/
31+
public double maxTicValue;
32+
/**
33+
* Increment between major (numbered) tics on the axis
34+
*/
35+
public double majorTicValue;
36+
/**
37+
* Number of tics between the major tics.
38+
*/
39+
public int minorTicCount;
40+
41+
/**
42+
* Constructor
43+
*
44+
* @param title Title of the axis, not including the parenthetical units
45+
* portion
46+
* @param units Parenthetical units portion of the title
47+
* @param minTicValue Minimum value on the axis
48+
* @param maxTicValue Maximum value on the axis
49+
* @param majorTicValue Increment between major (numbered) tics on the axis
50+
* @param minorTicCount Number of tics between the major tics.
51+
*/
52+
public AxisFixedRange(String title, String units, double minTicValue, double maxTicValue, double majorTicValue, int minorTicCount)
53+
{
54+
super();
55+
this.title = title;
56+
this.units = units;
57+
this.minTicValue = minTicValue;
58+
this.maxTicValue = maxTicValue;
59+
this.majorTicValue = majorTicValue;
60+
this.minorTicCount = minorTicCount;
61+
}
62+
63+
@Override
64+
public String toString()
65+
{
66+
return String.format("Axis [title=%s, units=%s, minValue=%s, maxValue=%s, majorTicValue=%s, minorTicCount=%s]", title, units, minTicValue, maxTicValue, majorTicValue, minorTicCount);
67+
}
68+
69+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package sysmlinjava.analysis.common;
2+
3+
import java.io.Serializable;
4+
import java.util.List;
5+
import java.util.StringJoiner;
6+
7+
/**
8+
* Axis definition for a categorical axis in a chart display, e.g. bar chart.
9+
*
10+
* @author ModelerOne
11+
*
12+
*/
13+
public class CategoriesAxis implements Serializable
14+
{
15+
/** Serializable ID*/private static final long serialVersionUID = -2225302723021161670L;
16+
17+
/**
18+
* Title of the axis, which need not include any parenthetical "units" portion
19+
*/
20+
public String title;
21+
/**
22+
* List of the categories (string names) on the axis
23+
*/
24+
public List<String> categories;
25+
26+
/**
27+
* Consructor
28+
*
29+
* @param title title of the axis
30+
* @param categories list of categories on the axis
31+
*/
32+
public CategoriesAxis(String title, List<String> categories)
33+
{
34+
super();
35+
this.title = title;
36+
this.categories = categories;
37+
}
38+
39+
@Override
40+
public String toString()
41+
{
42+
StringJoiner joiner = new StringJoiner(", ");
43+
categories.forEach(state -> joiner.add(state));
44+
return String.format("CategoriesAxis [title=%s, categories=%s]", title, joiner.toString());
45+
}
46+
}

0 commit comments

Comments
 (0)