@Test public void scaleTimestamp1() { TimeScale linearScale = TimeScales.linearAbsoluteScale(); Instant start = Instant.now(); TimeInterval timeInterval = TimeInterval.between(start, start.plus(Duration.ofSeconds(8))); assertThat(linearScale.scaleTimestamp(start, timeInterval, 1.0, 100.0), equalTo(1.0)); assertThat(linearScale.scaleTimestamp(start.plus(Duration.ofSeconds(2)), timeInterval, 1.0, 100.0), equalTo(25.75)); assertThat(linearScale.scaleTimestamp(start.plus(Duration.ofSeconds(4)), timeInterval, 1.0, 100.0), equalTo(50.5)); assertThat(linearScale.scaleTimestamp(start.plus(Duration.ofSeconds(8)), timeInterval, 1.0, 100.0), equalTo(100.0)); }
@Override public double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue) { double fromStart = timeInterval.getStart().until(value, ChronoUnit.SECONDS); double range = timeInterval.getStart().until(timeInterval.getEnd(), ChronoUnit.SECONDS); double newRange = newMaxValue - newMinValue; return newMinValue + (fromStart) / range * newRange; }
LinearAbsoluteTimeScale implements TimeScale { @Override public double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue) { double fromStart = timeInterval.getStart().until(value, ChronoUnit.SECONDS); double range = timeInterval.getStart().until(timeInterval.getEnd(), ChronoUnit.SECONDS); double newRange = newMaxValue - newMinValue; return newMinValue + (fromStart) / range * newRange; } }
LinearAbsoluteTimeScale implements TimeScale { @Override public double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue) { double fromStart = timeInterval.getStart().until(value, ChronoUnit.SECONDS); double range = timeInterval.getStart().until(timeInterval.getEnd(), ChronoUnit.SECONDS); double newRange = newMaxValue - newMinValue; return newMinValue + (fromStart) / range * newRange; }  }
LinearAbsoluteTimeScale implements TimeScale { @Override public double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue) { double fromStart = timeInterval.getStart().until(value, ChronoUnit.SECONDS); double range = timeInterval.getStart().until(timeInterval.getEnd(), ChronoUnit.SECONDS); double newRange = newMaxValue - newMinValue; return newMinValue + (fromStart) / range * newRange; }  @Override double scaleNormalizedTime(double value, double newMinValue, double newMaxValue); @Override double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue); @Override TimeAxis references(TimeInterval range, int minRefs, int maxRefs); }
LinearAbsoluteTimeScale implements TimeScale { @Override public double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue) { double fromStart = timeInterval.getStart().until(value, ChronoUnit.SECONDS); double range = timeInterval.getStart().until(timeInterval.getEnd(), ChronoUnit.SECONDS); double newRange = newMaxValue - newMinValue; return newMinValue + (fromStart) / range * newRange; }  @Override double scaleNormalizedTime(double value, double newMinValue, double newMaxValue); @Override double scaleTimestamp(Instant value, TimeInterval timeInterval, double newMinValue, double newMaxValue); @Override TimeAxis references(TimeInterval range, int minRefs, int maxRefs);  }