Search in sources :

Example 16 with DateRange

use of org.jfree.data.time.DateRange in project seng438-a3-R41Ryan by seng438-winter-2022.

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)

Example 17 with DateRange

use of org.jfree.data.time.DateRange in project seng438-a3-R41Ryan by seng438-winter-2022.

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 18 with DateRange

use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.

the class PeriodAxisTest method test1932146.

/**
 * A test for bug 1932146.
 */
@Test
public void test1932146() {
    PeriodAxis axis = new PeriodAxis("TestAxis");
    axis.addChangeListener(this);
    this.lastEvent = null;
    axis.setRange(new DateRange(0L, 1000L));
    assertTrue(this.lastEvent != null);
}
Also used : DateRange(org.jfree.data.time.DateRange) Test(org.junit.Test)

Example 19 with DateRange

use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.

the class DateAxis method valueToJava2D.

/**
 * Translates the data value to the display coordinates (Java 2D User Space)
 * of the chart.
 *
 * @param value  the date to be plotted.
 * @param area  the rectangle (in Java2D space) where the data is to be
 *              plotted.
 * @param edge  the axis location.
 *
 * @return The coordinate corresponding to the supplied data value.
 */
@Override
public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) {
    value = this.timeline.toTimelineValue((long) value);
    DateRange range = (DateRange) getRange();
    double axisMin = this.timeline.toTimelineValue(range.getLowerMillis());
    double axisMax = this.timeline.toTimelineValue(range.getUpperMillis());
    double result = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        double minX = area.getX();
        double maxX = area.getMaxX();
        if (isInverted()) {
            result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX);
        } else {
            result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX);
        }
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        double minY = area.getMinY();
        double maxY = area.getMaxY();
        if (isInverted()) {
            result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY));
        } else {
            result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY));
        }
    }
    return result;
}
Also used : DateRange(org.jfree.data.time.DateRange)

Example 20 with DateRange

use of org.jfree.data.time.DateRange in project SIMVA-SoS by SESoS.

the class DateAxis method autoAdjustRange.

/**
 * Rescales the axis to ensure that all data is visible.
 */
@Override
protected void autoAdjustRange() {
    Plot plot = getPlot();
    if (plot == null) {
        // no plot, no data
        return;
    }
    if (plot instanceof ValueAxisPlot) {
        ValueAxisPlot vap = (ValueAxisPlot) plot;
        Range r = vap.getDataRange(this);
        if (r == null) {
            if (this.timeline instanceof SegmentedTimeline) {
                // Timeline hasn't method getStartTime()
                r = new DateRange(((SegmentedTimeline) this.timeline).getStartTime(), ((SegmentedTimeline) this.timeline).getStartTime() + 1);
            } else {
                r = new DateRange();
            }
        }
        long upper = this.timeline.toTimelineValue((long) r.getUpperBound());
        long lower;
        long fixedAutoRange = (long) getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        } else {
            lower = this.timeline.toTimelineValue((long) r.getLowerBound());
            double range = upper - lower;
            long minRange = (long) getAutoRangeMinimumSize();
            if (range < minRange) {
                long expand = (long) (minRange - range) / 2;
                upper = upper + expand;
                lower = lower - expand;
            }
            upper = upper + (long) (range * getUpperMargin());
            lower = lower - (long) (range * getLowerMargin());
        }
        upper = this.timeline.toMillisecond(upper);
        lower = this.timeline.toMillisecond(lower);
        DateRange dr = new DateRange(new Date(lower), new Date(upper));
        setRange(dr, false, false);
    }
}
Also used : DateRange(org.jfree.data.time.DateRange) Plot(org.jfree.chart.plot.Plot) ValueAxisPlot(org.jfree.chart.plot.ValueAxisPlot) ValueAxisPlot(org.jfree.chart.plot.ValueAxisPlot) 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