use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.
the class DateAxis method setMinimumDate.
/**
* Sets the minimum date visible on the axis and sends an
* {@link AxisChangeEvent} to all registered listeners. If
* <code>date</code> is on or after the current maximum date for
* the axis, the maximum date will be shifted to preserve the current
* length of the axis.
*
* @param date the date (<code>null</code> not permitted).
*
* @see #getMinimumDate()
* @see #setMaximumDate(Date)
*/
public void setMinimumDate(Date date) {
ParamChecks.nullNotPermitted(date, "date");
// check the new minimum date relative to the current maximum date
Date maxDate = getMaximumDate();
long maxMillis = maxDate.getTime();
long newMinMillis = date.getTime();
if (maxMillis <= newMinMillis) {
Date oldMin = getMinimumDate();
long length = maxMillis - oldMin.getTime();
maxDate = new Date(newMinMillis + length);
}
setRange(new DateRange(date, maxDate), true, false);
fireChangeEvent();
}
use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.
the class DateAxis method java2DToValue.
/**
* Translates a Java2D coordinate into the corresponding data value. To
* perform this translation, you need to know the area used for plotting
* data, and which edge the axis is located on.
*
* @param java2DValue the coordinate in Java2D space.
* @param area the rectangle (in Java2D space) where the data is to be
* plotted.
* @param edge the axis location.
*
* @return A data value.
*/
@Override
public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) {
DateRange range = (DateRange) getRange();
double axisMin = this.timeline.toTimelineValue(range.getLowerMillis());
double axisMax = this.timeline.toTimelineValue(range.getUpperMillis());
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getMaxX();
} else if (RectangleEdge.isLeftOrRight(edge)) {
min = area.getMaxY();
max = area.getY();
}
double result;
if (isInverted()) {
result = axisMax - ((java2DValue - min) / (max - min) * (axisMax - axisMin));
} else {
result = axisMin + ((java2DValue - min) / (max - min) * (axisMax - axisMin));
}
return this.timeline.toMillisecond((long) result);
}
use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.
the class DateAxis method zoomRange.
/**
* Zooms in on the current range (zoom-in stops once the axis length
* reaches the equivalent of one millisecond).
*
* @param lowerPercent the new lower bound.
* @param upperPercent the new upper bound.
*/
@Override
public void zoomRange(double lowerPercent, double upperPercent) {
double start = this.timeline.toTimelineValue((long) getRange().getLowerBound());
double end = this.timeline.toTimelineValue((long) getRange().getUpperBound());
double length = end - start;
Range adjusted;
long adjStart, adjEnd;
if (isInverted()) {
adjStart = (long) (start + (length * (1 - upperPercent)));
adjEnd = (long) (start + (length * (1 - lowerPercent)));
} else {
adjStart = (long) (start + length * lowerPercent);
adjEnd = (long) (start + length * upperPercent);
}
// so we apply this instead:
if (adjEnd <= adjStart) {
adjEnd = adjStart + 1L;
}
adjusted = new DateRange(this.timeline.toMillisecond(adjStart), this.timeline.toMillisecond(adjEnd));
setRange(adjusted);
}
use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.
the class DateAxis method setRange.
/**
* Sets the range for the axis, if requested, sends an
* {@link AxisChangeEvent} to all registered listeners. As a side-effect,
* the auto-range flag is set to <code>false</code> (optional).
*
* @param range the range (<code>null</code> not permitted).
* @param turnOffAutoRange a flag that controls whether or not the auto
* range is turned off.
* @param notify a flag that controls whether or not listeners are
* notified.
*/
@Override
public void setRange(Range range, boolean turnOffAutoRange, boolean notify) {
ParamChecks.nullNotPermitted(range, "range");
// conversion...
if (!(range instanceof DateRange)) {
range = new DateRange(range);
}
super.setRange(range, turnOffAutoRange, notify);
}
use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.
the class DateAxis method setMaximumDate.
/**
* Sets the maximum date visible on the axis and sends an
* {@link AxisChangeEvent} to all registered listeners. If
* <code>maximumDate</code> is on or before the current minimum date for
* the axis, the minimum date will be shifted to preserve the current
* length of the axis.
*
* @param maximumDate the date (<code>null</code> not permitted).
*
* @see #getMinimumDate()
* @see #setMinimumDate(Date)
*/
public void setMaximumDate(Date maximumDate) {
ParamChecks.nullNotPermitted(maximumDate, "maximumDate");
// check the new maximum date relative to the current minimum date
Date minDate = getMinimumDate();
long minMillis = minDate.getTime();
long newMaxMillis = maximumDate.getTime();
if (minMillis >= newMaxMillis) {
Date oldMax = getMaximumDate();
long length = oldMax.getTime() - minMillis;
minDate = new Date(newMaxMillis - length);
}
setRange(new DateRange(minDate, maximumDate), true, false);
fireChangeEvent();
}
Aggregations