Package simtools.ui

Source Code of simtools.ui.TimePlotStatisticsDialog

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Claude Cazenave
*
* $Id: TimePlotStatisticsDialog.java,v 1.7 2008/03/28 11:36:02 ogor Exp $
*
* Changes
* -------
* 15 mai 2006  : Initial public release (CC);
*
*/
package simtools.ui;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import simtools.shapes.PlotShape;

public class TimePlotStatisticsDialog extends PlotInformationDialog{

  public static SimpleDateFormat dateTimeFormatter;
  static{
    dateTimeFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
  }
 
  public TimePlotStatisticsDialog(PlotShape ps){
    super(ps);
  }
 
  /**
   * @return JPanel containing statistics related to all curves
   */
  protected JPanel createCurveStatisticsPanel(){
    JPanel ret=new JPanel();
    ret.setLayout(new BoxLayout(ret,BoxLayout.Y_AXIS));

    // Fisrt set xmin and xmax
    upateGlobalStatistics();
   
    // Then set curves statistics
    curveStatisticsPanel = new  TimeCurveStatisticPanel[plotShape.getCurveNumber()];
    for(int i=0;i<curveStatisticsPanel.length;i++){
      curveStatisticsPanel[i] = new TimeCurveStatisticPanel(plotShape.getCurve(i),this);
      ret.add(curveStatisticsPanel[i]);
      plotShape.addListener(curveStatisticsPanel[i])// TODO why ?
    }
    ret.setBorder(BorderFactory.createTitledBorder(null,resources.getString("curvesStatistics"),TitledBorder.CENTER, TitledBorder.TOP, null));
    return ret;
  }

  protected void upateGlobalStatistics(){
      xmin = plotShape.getPrimaryXAxis().getMin();
      xmax = plotShape.getPrimaryXAxis().getMax();
      tfpxmin.setText("Min = " + dateTimeFormatter.format(new Date( (long)xmin)));
      tfpxmax.setText("Max = " + dateTimeFormatter.format(new Date( (long)xmax)));

      if(plotShape.getSecondaryXAxis() != null){
          double sxmin = plotShape.getSecondaryXAxis().getMin();
          double sxmax = plotShape.getSecondaryXAxis().getMax();
          tfsxmin.setText("Min = " +  dateTimeFormatter.format(new Date( (long)sxmin)));
          tfsxmax.setText("Max = " +  dateTimeFormatter.format(new Date( (long)sxmax)));
      }
  }
 
}
TOP

Related Classes of simtools.ui.TimePlotStatisticsDialog

TOP
Copyright © 2018 www.massapi.com. 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.