Package org.jfree.data.time

Examples of org.jfree.data.time.TimeSeriesDataItem


    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        TimeSeriesDataItem item1 = new TimeSeriesDataItem(
            new Day(23, 9, 2001), 99.7
        );
        TimeSeriesDataItem item2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(item1);
View Full Code Here


        firstPass = false;
      }
      Date keyDate = getValidDate( rowData[1] );
      RegularTimePeriod regularTimePeriod =
          RegularTimePeriod.createInstance( timePeriodClass, keyDate, RegularTimePeriod.DEFAULT_TIME_ZONE );
      TimeSeriesDataItem timeSeriesDataItem =
          new TimeSeriesDataItem( regularTimePeriod, ( (Number) rowData[2] ).doubleValue() );
      if ( wrkSeries != null ) {
        wrkSeries.add( timeSeriesDataItem );
      }
      rowData = data.next();
    }
View Full Code Here

    while ( rowData != null ) {
      String seriesName = (String) rowData[0];
      TimeSeries wrkSeries = new TimeSeries( seriesName, timePeriodClass );
      for ( int column = 1; column < rowData.length - 1; column = column + 2 ) {
        Date keyDate = getValidDate( rowData[column] );
        TimeSeriesDataItem timeSeriesDataItem =
            new TimeSeriesDataItem( RegularTimePeriod.createInstance( timePeriodClass, keyDate,
                RegularTimePeriod.DEFAULT_TIME_ZONE ), ( (Number) rowData[column + 1] ).doubleValue() );
        wrkSeries.add( timeSeriesDataItem );
      }
      addSeries( wrkSeries );
      rowData = data.next();
View Full Code Here

            // if it is the first year and th ecurrent month is previous than the first month
            if(currentYearS.equalsIgnoreCase(yearsDefined.first()) && i<firstMonth.getMonth()){
              // continue
            }
            else{
              TimeSeriesDataItem item = timeSeries.getDataItem(currentMonth);
              if(item != null && item.getValue() != null) {
                double v = item.getValue().doubleValue();
                double result = 0;
                if(mainTarget != null) {
                  result = (v >= mainTarget.doubleValue())?WIN:LOSE;
                } else if(mainBaseline != null) {
                  result = (v > mainBaseline.doubleValue())?LOSE:WIN;
View Full Code Here

      for (Iterator iterator = yearsDefined.iterator(); iterator.hasNext();) {
        String currentYearS = (String) iterator.next();
        int currentYear=Integer.valueOf(currentYearS).intValue();
        // get the last in l
        for(int i = 1; i < 13; i++) {
          TimeSeriesDataItem item = timeSeries.getDataItem(new Month(i, currentYear));
          if(item == null || item.getValue() == null) {
            //timeSeries.addOrUpdate(new Month(i, currentYear), null);
          } else {
            lastIndexMonth = i;
          }
        }
View Full Code Here

    rangeAxis.setVisible(false);

    plot.getRenderer().setSeriesPaint(0, Color.BLACK);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
      public boolean getItemShapeVisible(int _series, int item) {
        TimeSeriesDataItem tsdi=timeSeries.getDataItem(item);
        if(tsdi==null)return false;
        Month period=(Month)tsdi.getPeriod();
        int currMonth=period.getMonth();
        int currYear=period.getYearValue();
        int lastMonthFilled=lastMonth.getMonth();
        int lastYearFilled=lastMonth.getYearValue();
        boolean isLast=false;
View Full Code Here

    logger.debug("IN");
    Color colorToReturn=null;

    try{
      final int last = lastIndexMonth;
      TimeSeriesDataItem item = timeSeries.getDataItem(new Month(last, Integer.valueOf(lastYear).intValue()));     
      if(item==null || item.getValue()==null){
        return Color.WHITE; 
      }
      Double currentValue=(Double)item.getValue();
      // get the color of the last element
      TreeSet<Double> orderedThresholds=new TreeSet<Double>(thresholds.keySet());
      Double thresholdGiveColor=null;   
      // if dealing with targets, begin from first target and go to on till the current value is major
      if(useTargets){
View Full Code Here

      return new DatasetMap();
    }
   
    // Set the first and the last periods

    TimeSeriesDataItem item1=timeSeries.getDataItem(0);
    firstMonth=(Month)item1.getPeriod();
    TimeSeriesDataItem item2=timeSeries.getDataItem(timeSeries.getItemCount()-1);
    lastMonth=(Month)item2.getPeriod();
    lastYear=yearsDefined.last();

    DatasetMap datasets=new DatasetMap();
    logger.debug("OUT");
    return datasets;
View Full Code Here

    String month=columnKey.substring(0,separator);
    String year=columnKey.substring(separator+1);
    Number value=dataset.getValue(row, column);     // value put in dataset (- 0.5 or 0.5)

    Month currentMonth=new Month(Integer.valueOf(month),Integer.valueOf(year));   // value for that month
    TimeSeriesDataItem item = timeSeries.getDataItem(currentMonth);

    if(nullValues.contains(columnKey)){
      return background;
    }
    // If no item is retrieved means that no value was specified for that month in that year
    if(item==null || item.getValue()==null){
      return background;
    }

    Double currentValue=(Double)item.getValue();

    TreeSet<Double> orderedThresholds=new TreeSet<Double>(thresholds.keySet());

    Double thresholdGiveColor=null;   
    // if dealing with targets, begin from first target and go to on till the current value is major
View Full Code Here

                throw new DataConversionException("Incorrect Key type. Required: Date or Calendar. Currently defined: " + key.getClass());

            if (value != null && !(value instanceof Number))
                throw new DataConversionException("Incorrect Value type for Key = " + key + ". Required: Number. Currently defined: " + value.getClass().getName());
            else {
                TimeSeriesDataItem item = new TimeSeriesDataItem(period, (Number) value);
                tSeries.add(item);
            }
        }
        if (tSeries.getItemCount() == 0) tSeries = null;
View Full Code Here

TOP

Related Classes of org.jfree.data.time.TimeSeriesDataItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.