Search in sources :

Example 6 with DateRange

use of org.jfree.data.time.DateRange in project aspro by JMMC-OpenDev.

the class ObservabilityPanel method updateDateAxisBounds.

/**
 * Update the data axis range i.e. zoom on date range
 * @param lower lower value in milliseconds
 * @param upper upper value in milliseconds
 */
private void updateDateAxisBounds(final long lower, final long upper) {
    final BoundedDateAxis dateAxis = (BoundedDateAxis) this.xyPlot.getRangeAxis();
    // add a margin of 1 ms :
    dateAxis.setBounds(new DateRange(lower - 1l, upper + 1l));
    dateAxis.setRange(lower - 1l, upper + 1l);
}
Also used : DateRange(org.jfree.data.time.DateRange) BoundedDateAxis(fr.jmmc.oiexplorer.core.gui.chart.BoundedDateAxis)

Example 7 with DateRange

use of org.jfree.data.time.DateRange in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

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} 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} not permitted).
 *
 * @see #getMinimumDate()
 * @see #setMinimumDate(Date)
 */
public void setMaximumDate(Date maximumDate) {
    Args.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();
}
Also used : DateRange(org.jfree.data.time.DateRange) Date(java.util.Date)

Example 8 with DateRange

use of org.jfree.data.time.DateRange in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

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} (optional).
 *
 * @param range  the range ({@code null} 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) {
    Args.nullNotPermitted(range, "range");
    // conversion...
    if (!(range instanceof DateRange)) {
        range = new DateRange(range);
    }
    super.setRange(range, turnOffAutoRange, notify);
}
Also used : DateRange(org.jfree.data.time.DateRange)

Example 9 with DateRange

use of org.jfree.data.time.DateRange in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class DateAxis method getMinimumDate.

/**
 * Returns the earliest date visible on the axis.
 *
 * @return The date.
 *
 * @see #setMinimumDate(Date)
 * @see #getMaximumDate()
 */
public Date getMinimumDate() {
    Date result;
    Range range = getRange();
    if (range instanceof DateRange) {
        DateRange r = (DateRange) range;
        result = r.getLowerDate();
    } else {
        result = new Date((long) range.getLowerBound());
    }
    return result;
}
Also used : DateRange(org.jfree.data.time.DateRange) DateRange(org.jfree.data.time.DateRange) Range(org.jfree.data.Range) Date(java.util.Date)

Example 10 with DateRange

use of org.jfree.data.time.DateRange in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

the class DateAxis method getMaximumDate.

/**
 * Returns the latest date visible on the axis.
 *
 * @return The date.
 *
 * @see #setMaximumDate(Date)
 * @see #getMinimumDate()
 */
public Date getMaximumDate() {
    Date result;
    Range range = getRange();
    if (range instanceof DateRange) {
        DateRange r = (DateRange) range;
        result = r.getUpperDate();
    } else {
        result = new Date((long) range.getUpperBound());
    }
    return result;
}
Also used : DateRange(org.jfree.data.time.DateRange) DateRange(org.jfree.data.time.DateRange) Range(org.jfree.data.Range) Date(java.util.Date)

Aggregations

DateRange (org.jfree.data.time.DateRange)39 Date (java.util.Date)24 Range (org.jfree.data.Range)13 Font (java.awt.Font)7 FontMetrics (java.awt.FontMetrics)6 FontRenderContext (java.awt.font.FontRenderContext)6 LineMetrics (java.awt.font.LineMetrics)6 DateFormat (java.text.DateFormat)6 SimpleDateFormat (java.text.SimpleDateFormat)6 RectangleInsets (org.jfree.ui.RectangleInsets)4 Plot (org.jfree.chart.plot.Plot)3 ValueAxisPlot (org.jfree.chart.plot.ValueAxisPlot)3 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 RectangleInsets (org.jfree.chart.api.RectangleInsets)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 TransferStatus (com.tesshu.jpsonic.domain.TransferStatus)1 BoundedDateAxis (fr.jmmc.oiexplorer.core.gui.chart.BoundedDateAxis)1 BasicStroke (java.awt.BasicStroke)1