1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Jonathan Rajotte-Julien
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.tmf
.chart
.ui
.data
;
12 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
14 import java
.math
.BigDecimal
;
17 * BigDecimal based range representation
19 * @author Jonathan Rajotte-Julien
21 public class ChartRange
{
23 // ------------------------------------------------------------------------
25 // ------------------------------------------------------------------------
27 private BigDecimal fMinimum
;
28 private BigDecimal fMaximum
;
29 private BigDecimal fRange
;
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
39 fMinimum
= checkNotNull(BigDecimal
.ZERO
);
40 fMaximum
= checkNotNull(BigDecimal
.ONE
);
41 fRange
= checkNotNull(getMaximum().subtract(getMinimum()));
45 * Constructor with minimum and maximum values supplied.
48 * The minimum value of the range
50 * The maximum value of the range
52 public ChartRange(BigDecimal minimum
, BigDecimal maximum
) {
55 fRange
= checkNotNull(maximum
.subtract(minimum
));
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 * Accessor that returns the lower bound of the range.
65 * @return The minimum value of the range
67 public BigDecimal
getMinimum() {
72 * Accessor that returns the upper bound of the range.
74 * @return The maximum value of the range
76 public BigDecimal
getMaximum() {
81 * Accessor that returns the difference between the lower and the upper
82 * bounds of the range.
84 * @return The range delta
86 public BigDecimal
getDelta() {
91 * Method that checks if the delta is equal to zero.
93 * @return {@code true} if the delta is null, else {@code false}
95 public boolean isDeltaNull() {
96 return getDelta().compareTo(BigDecimal
.ZERO
) == 0;
99 // ------------------------------------------------------------------------
101 // ------------------------------------------------------------------------
104 * Mutator that sets the minimum value of the range.
107 * The new minimum value
109 public void setMinimum(BigDecimal minimum
) {
111 fRange
= checkNotNull(getMaximum().subtract(getMinimum()));
115 * Mutator that sets the maximum value of the range.
118 * The new maximum value
120 public void setMaximum(BigDecimal maximum
) {
122 fRange
= checkNotNull(getMaximum().subtract(getMinimum()));
125 // ------------------------------------------------------------------------
127 // ------------------------------------------------------------------------
130 * This method clamps the positive minimum value of this range down to zero.
131 * It returns the current object back with the minimum value modified.
133 * @return The current range map
135 public ChartRange
clamp() {
136 fMinimum
= fMinimum
.min(BigDecimal
.ZERO
);
This page took 0.034516 seconds and 5 git commands to generate.