/** * Returns the x-value for a time period. * * @param period the period. * * @return The x-value. */ private long getX(RegularTimePeriod period) { switch (this.position) { case (START) : return period.getFirstMillisecond(this.workingCalendar); case (MIDDLE) : return period.getMiddleMillisecond(this.workingCalendar); case (END) : return period.getLastMillisecond(this.workingCalendar); default: return period.getMiddleMillisecond(this.workingCalendar); } }
/** * Returns the x-value for a time period. * * @param period the period. * * @return The x-value. */ private long getX(RegularTimePeriod period) { switch (this.position) { case (START) : return period.getFirstMillisecond(this.workingCalendar); case (MIDDLE) : return period.getMiddleMillisecond(this.workingCalendar); case (END) : return period.getLastMillisecond(this.workingCalendar); default: return period.getMiddleMillisecond(this.workingCalendar); } }
/** * Returns a {@link java.util.Date} corresponding to the specified position * within a {@link RegularTimePeriod}. * * @param period the period. * @param position the position (<code>null</code> not permitted). * * @return A date. */ private Date calculateDateForPosition(RegularTimePeriod period, DateTickMarkPosition position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } Date result = null; if (position == DateTickMarkPosition.START) { result = new Date(period.getFirstMillisecond()); } else if (position == DateTickMarkPosition.MIDDLE) { result = new Date(period.getMiddleMillisecond()); } else if (position == DateTickMarkPosition.END) { result = new Date(period.getLastMillisecond()); } return result; }
/** * Returns a {@link java.util.Date} corresponding to the specified position * within a {@link RegularTimePeriod}. * * @param period the period. * @param position the position ({@code null} not permitted). * * @return A date. */ private Date calculateDateForPosition(RegularTimePeriod period, DateTickMarkPosition position) { Args.nullNotPermitted(period, "period"); Date result = null; if (position == DateTickMarkPosition.START) { result = new Date(period.getFirstMillisecond()); } else if (position == DateTickMarkPosition.MIDDLE) { result = new Date(period.getMiddleMillisecond()); } else if (position == DateTickMarkPosition.END) { result = new Date(period.getLastMillisecond()); } return result; }
/** * Returns the x-value for a time period. * * @param period the time period ({@code null} not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(); } return result; }
/** * Returns the x-value for a time period. * * @param period the time period (<code>null</code> not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(this.workingCalendar); } return result; }
/** * Returns the x-value for a time period. * * @param period the time period ({@code null} not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(this.workingCalendar); } return result; }
/** * Returns the x-value for a time period. * * @param period the time period (<code>null</code> not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(); } return result; }
/** * Builds a DataPoint from the given TimeSeriesDataItem. The name used for * the independent, time variable can be changed using the setTimeVariable * method. * @param dataItem the TimeSeriesDataItem from which the values are to be * read and used to construct a new DataPoint. * @return a DataPoint object with values as specified by the given * TimeSeriesDataItem. */ private DataPoint build( TimeSeriesDataItem dataItem ) { DataPoint dataPoint = new Observation( dataItem.getValue().doubleValue() ); // Get time value (at middle of time period) double timeValue = dataItem.getPeriod().getMiddleMillisecond(); // Store time value as independent variable dataPoint.setIndependentValue( getVariableName(0), timeValue ); return dataPoint; } }
/** * Builds a DataPoint from the given TimeSeriesDataItem. The name used for * the independent, time variable can be changed using the setTimeVariable * method. * @param dataItem the TimeSeriesDataItem from which the values are to be * read and used to construct a new DataPoint. * @return a DataPoint object with values as specified by the given * TimeSeriesDataItem. */ private DataPoint build( TimeSeriesDataItem dataItem ) { DataPoint dataPoint = new Observation( dataItem.getValue().doubleValue() ); // Get time value (at middle of time period) double timeValue = dataItem.getPeriod().getMiddleMillisecond(); // Store time value as independent variable dataPoint.setIndependentValue( getVariableName(0), timeValue ); return dataPoint; } }
/** * Returns the millisecond (relative to the epoch) corresponding to the * specified {@code anchor} using the supplied {@code calendar} * (which incorporates a time zone). * * @param anchor the anchor ({@code null} not permitted). * @param calendar the calendar ({@code null} not permitted). * * @return Milliseconds since the epoch. * * @since 1.0.18 */ public long getMillisecond(TimePeriodAnchor anchor, Calendar calendar) { if (anchor.equals(TimePeriodAnchor.START)) { return getFirstMillisecond(calendar); } else if (anchor.equals(TimePeriodAnchor.MIDDLE)) { return getMiddleMillisecond(calendar); } else if (anchor.equals(TimePeriodAnchor.END)) { return getLastMillisecond(calendar); } else { throw new IllegalStateException("Unrecognised anchor: " + anchor); } }
DateFormat df = this.labelInfo[band].getDateFormat(); df.setTimeZone(this.timeZone); String label1 = df.format(new Date(p1.getMiddleMillisecond())); String label2 = df.format(new Date(p2.getMiddleMillisecond())); Rectangle2D b1 = TextUtils.getTextBounds(label1, g2, g2.getFontMetrics()); float x = (float) valueToJava2D(p.getMiddleMillisecond(), dataArea, edge); String label = df.format(new Date(p.getMiddleMillisecond())); long first = p.getFirstMillisecond(); long last = p.getLastMillisecond();
new Date(axisMax), this.timeZone, this.locale); String label1 = this.labelInfo[band].getDateFormat().format( new Date(p1.getMiddleMillisecond())); String label2 = this.labelInfo[band].getDateFormat().format( new Date(p2.getMiddleMillisecond())); Rectangle2D b1 = TextUtilities.getTextBounds(label1, g2, g2.getFontMetrics()); float x = (float) valueToJava2D(p.getMiddleMillisecond(), dataArea, edge); DateFormat df = this.labelInfo[band].getDateFormat(); String label = df.format(new Date(p.getMiddleMillisecond())); long first = p.getFirstMillisecond(); long last = p.getLastMillisecond();