本文整理汇总了Java中org.jfree.data.time.RegularTimePeriod类的典型用法代码示例。如果您正苦于以下问题:Java RegularTimePeriod类的具体用法?Java RegularTimePeriod怎么用?Java RegularTimePeriod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RegularTimePeriod类属于org.jfree.data.time包,在下文中一共展示了RegularTimePeriod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerialization4
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Serialize a time seroes chart, restore it, and check for equality.
*/
@Test
public void testSerialization4() {
RegularTimePeriod t = new Day();
TimeSeries series = new TimeSeries("Series 1");
series.add(t, 36.4);
t = t.next();
series.add(t, 63.5);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
"Value", dataset);
JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
assertEquals(c1, c2);
}
示例2: testEquals
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Tests the equals method.
*/
public void testEquals() {
final TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
final TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
final boolean b1 = s1.equals(s2);
assertFalse("b1", b1);
s2.setName("Time Series 1");
final boolean b2 = s1.equals(s2);
assertTrue("b2", b2);
final RegularTimePeriod p1 = new Day();
final RegularTimePeriod p2 = p1.next();
s1.add(p1, 100.0);
s1.add(p2, 200.0);
final boolean b3 = s1.equals(s2);
assertFalse("b3", b3);
s2.add(p1, 100.0);
s2.add(p2, 200.0);
final boolean b4 = s1.equals(s2);
assertTrue("b4", b4);
}
示例3: createDataset
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Creates a sample dataset.
*
* @param name the dataset name.
* @param base the starting value.
* @param start the starting period.
* @param count the number of values to generate.
*
* @return The dataset.
*/
private static XYDataset createDataset(String name, double base,
RegularTimePeriod start, int count) {
TimeSeries series = new TimeSeries(name, start.getClass());
RegularTimePeriod period = start;
double value = base;
for (int i = 0; i < count; i++) {
series.add(period, value);
period = period.next();
value = value * (1 + (Math.random() - 0.495) / 10.0);
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
return dataset;
}
示例4: PeriodAxis
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Creates a new axis.
*
* @param label the axis label (<code>null</code> permitted).
* @param first the first time period in the axis range
* (<code>null</code> not permitted).
* @param last the last time period in the axis range
* (<code>null</code> not permitted).
* @param timeZone the time zone (<code>null</code> not permitted).
*/
public PeriodAxis(String label,
RegularTimePeriod first, RegularTimePeriod last,
TimeZone timeZone) {
super(label, null);
this.first = first;
this.last = last;
this.timeZone = timeZone;
this.calendar = Calendar.getInstance(timeZone);
this.autoRangeTimePeriodClass = first.getClass();
this.majorTickTimePeriodClass = first.getClass();
this.minorTickMarksVisible = false;
this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
this.majorTickTimePeriodClass);
setAutoRange(true);
this.labelInfo = new PeriodAxisLabelInfo[2];
this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class,
new SimpleDateFormat("MMM"));
this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class,
new SimpleDateFormat("yyyy"));
}
示例5: generateToolTip
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Generates a tool tip text item for a particular item within a series.
*
* @param data the dataset.
* @param series the series number (zero-based index).
* @param item the item number (zero-based index).
*
* @return The tool tip text (possibly <code>null</code>).
*/
public String generateToolTip(XYDataset data, int series, int item) {
String xStr, yStr;
if (data instanceof YisSymbolic) {
yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
}
else {
double y = data.getYValue(series, item);
yStr = Double.toString(round(y, 2));
}
if (data instanceof XisSymbolic) {
xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
}
else if (data instanceof TimeSeriesCollection) {
RegularTimePeriod p
= ((TimeSeriesCollection) data).getSeries(series)
.getTimePeriod(item);
xStr = p.toString();
}
else {
double x = data.getXValue(series, item);
xStr = Double.toString(round(x, 2));
}
return "X: " + xStr + ", Y: " + yStr;
}
示例6: createDataset
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Creates a sample dataset.
*
* @param name the dataset name.
* @param base the starting value.
* @param start the starting period.
* @param count the number of values to generate.
*
* @return The dataset.
*/
private static XYDataset createDataset(String name, double base,
RegularTimePeriod start, int count) {
TimeSeries series = new TimeSeries(name);
RegularTimePeriod period = start;
double value = base;
for (int i = 0; i < count; i++) {
series.add(period, value);
period = period.next();
value = value * (1 + (Math.random() - 0.495) / 10.0);
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
return dataset;
}
示例7: calculateDateForPosition
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* 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) {
ParamChecks.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;
}
示例8: calculateDateForPosition
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* 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;
}
示例9: testSerialization4
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Serialize a time seroes chart, restore it, and check for equality.
*/
@Test
public void testSerialization4() {
RegularTimePeriod t = new Day();
TimeSeries series = new TimeSeries("Series 1");
series.add(t, 36.4);
t = t.next();
series.add(t, 63.5);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series);
JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
"Value", dataset);
JFreeChart c2 = (JFreeChart) TestUtils.serialised(c1);
assertEquals(c1, c2);
}
示例10: getEntityHyperlink
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
@Override
public JRPrintHyperlink getEntityHyperlink(ChartEntity entity)
{
JRPrintHyperlink printHyperlink = null;
if (hasHyperlinks() && entity instanceof XYItemEntity)
{
XYItemEntity itemEntity = (XYItemEntity) entity;
TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset();
TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex());
Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey());
if (serieHyperlinks != null)
{
RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
printHyperlink = serieHyperlinks.get(timePeriod);
}
}
return printHyperlink;
}
示例11: nodeCompleted
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
public void nodeCompleted(Object parent) {
TimeSeriesCollectionBuilder tsc = null;
try {
if(parent != null && parent instanceof TimeSeriesCollectionBuilder)
tsc = (TimeSeriesCollectionBuilder)parent;
if(this.series == null) {
this.series = new TimeSeries(name, domain, range, Class.forName(timePeriodClass) );
this.setProperties(this.series, beanMap );
}
if(addValue != null) {
boolean notify = false;
if(addValue.containsKey(("notify")))
notify = Boolean.valueOf((String)addValue.get("notify"));
this.series.add((RegularTimePeriod)addValue.get("period"), ((Number)addValue.get("value")).doubleValue(), notify);
addValue = null;
}
if(tsc != null)
tsc.addSeries(this.series);
} catch (Throwable ex) {
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
示例12: getForecastData
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
public static TimeSeries getForecastData(TimeSeries observationData, int forcastperc) {
TimeSeries fcdataset = new TimeSeries("Time Series Forecast");
if (observationData.isEmpty() == true)
return fcdataset;
int size = observationData.getItemCount();
long fcsize = size + Math.round( (double)size * ((double)forcastperc/100)); // new data set
try {
fcdataset = observationData.createCopy(0,size-1);
for (int i=size; i < fcsize; i++) {
RegularTimePeriod nexttp = fcdataset.getNextTimePeriod();
fcdataset.add(nexttp,0.00D);
}
} catch (Exception e) {
System.out.println("Exception:" + e.getLocalizedMessage());
System.out.println("Could not create forecasted data sample");
return fcdataset;
}
return fcdataset;
}
示例13: output
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Outputs the given DataPoint to the current TimeSeries.
* @param dataPoint the DataPoint to output to the current TimeSeries.
*/
private void output( DataPoint dataPoint, String timeVariable )
throws InstantiationException, IllegalAccessException,
InvocationTargetException, InstantiationException
{
long timeValue = (long)dataPoint.getIndependentValue(timeVariable);
Object[] args = new Object[1];
args[0] = new Date( timeValue );
RegularTimePeriod period
= (RegularTimePeriod)timePeriodConstructor.newInstance(args);
double value = dataPoint.getDependentValue();
timeSeries.add( new TimeSeriesDataItem(period,value) );
}
示例14: calculateDateForPosition
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* 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;
}
示例15: PeriodAxis
import org.jfree.data.time.RegularTimePeriod; //导入依赖的package包/类
/**
* Creates a new axis.
*
* @param label the axis label (<code>null</code> permitted).
* @param first the first time period in the axis range
* (<code>null</code> not permitted).
* @param last the last time period in the axis range
* (<code>null</code> not permitted).
* @param timeZone the time zone (<code>null</code> not permitted).
*/
public PeriodAxis(String label,
RegularTimePeriod first, RegularTimePeriod last,
TimeZone timeZone) {
super(label, null);
this.first = first;
this.last = last;
this.timeZone = timeZone;
// FIXME: this calendar may need a locale as well
this.calendar = Calendar.getInstance(timeZone);
this.autoRangeTimePeriodClass = first.getClass();
this.majorTickTimePeriodClass = first.getClass();
this.minorTickMarksVisible = false;
this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
this.majorTickTimePeriodClass);
setAutoRange(true);
this.labelInfo = new PeriodAxisLabelInfo[2];
this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class,
new SimpleDateFormat("MMM"));
this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class,
new SimpleDateFormat("yyyy"));
}