summaryrefslogtreecommitdiff
path: root/java/src/org/singinst/uf/model/ScalarSchema.java
blob: fbb9c305255400aa244cbf7c1a882aa71ca10c9d (plain)
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
package org.singinst.uf.model;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.singinst.uf.math.MathUtil;
import org.singinst.uf.presenter.LineBounded;
import org.singinst.uf.presenter.LineBounds;

public class ScalarSchema implements SummarySource, LineBounded {
	private final String prefix;
	private final String suffix;

	private final Node node;
	private final String idString;
	private final LineBounds bounds;
	private final String unit;
	private final List<ConclusionReportGenerator> conclusionReportGenerators = new ArrayList<ConclusionReportGenerator>();
	private boolean visibleAxis = true;
	private boolean visibleProperty = true;

	private final LineBounds boundsConstraint;
	
	public ScalarSchema(Node node, String idString, LineBounds bounds, String unit, String prefix, String suffix, LineBounds boundsConstraint, boolean visibleProperty) {
		this.node = node;
		this.idString = idString;
		this.bounds = bounds;
		this.unit = unit;
		this.prefix = prefix;
		this.suffix = suffix;
		this.boundsConstraint = boundsConstraint;
		this.visibleProperty = visibleProperty;
	}
	
	public String getPrefix() {
		return prefix;
	}
	
	public String getSuffix() {
		return suffix;
	}

	public String getKey() {
		return node.getIdString() + "." + idString;
	}
	
	@Override
	public String toString() {
		return getKey();
	}

	public List<ScalarValueHolder> getScalarValues() {
		return Collections.singletonList(getScalarValueHolder());
	}
	public ScalarValueHolder getScalarValueHolder() {
		return ScalarValueHolder.findById(this);
	}
	public List<ConclusionReportGenerator> getConclusionGenerators() {
		return conclusionReportGenerators;
	}
	public LineBounds getLineBounds() {
		return getBounds();
	}
	public LineBounds getBounds() {
		return bounds;
	}
	public boolean isVisibleAxis() {
		return visibleAxis;
	}
	public boolean displayProperty() {
		return visibleProperty;
	}
	public void setVisibleAxis(boolean visibleAxis) {
		this.visibleAxis = visibleAxis;
	}
	public Collection<NodeMetadata> getDependencies() {
		return node.getDependencies();
	}
	
	public static int getMaxDecimalDigits() {
		return 4;
	}

	public String getUnit() {
		return unit;
	}

	public LineBounds getBoundsConstraint() {
		return boundsConstraint;
	}

	public Object monte() {
		return MathUtil.RANDOM.nextFloat() * 100 < getScalarValueHolder().getValue();
	}
}