com.ebay.carad.os.vitalsigns.listeners
Class LineGraphImageCreationListener

java.lang.Object
  extended by com.ebay.carad.os.vitalsigns.listeners.AbstractReportingListener
      extended by com.ebay.carad.os.vitalsigns.listeners.LineGraphImageCreationListener
All Implemented Interfaces:
IReportingListener
Direct Known Subclasses:
HtmlGraphListener

public class LineGraphImageCreationListener
extends AbstractReportingListener
implements IReportingListener

Generates time series line graphs based on report data.

TODO : go over with fine tooth comb to make sure that it was not changed by port to OS - VS, especially since this is primary report output format

Version:
$Id$
Author:
Jeremy Thomerson, Jeremy Kraybill

Field Summary
private  long eightDaysAgo
           
private static long ERROR_MARGIN
           
private  long fiftySixWksAgo
           
private  long fiftyThreeWksAgo
           
private  long fiftyTwoWksAgo
           
private  long fiftyTwoWksAndDayAgo
           
private  long hundredFourWeeksAgo
           
private static org.apache.log4j.Logger LOGGER
           
private  long now
           
private  long oneDayAgo
           
private  long oneHourAgo
           
private  long oneMonthAgo
           
private  long oneMonthAndDayAgo
           
private  long oneMonthAndHourAgo
           
private  long oneMonthAndWeekAgo
           
private  long oneWeekAgo
           
private  long oneWeekAndHourAgo
           
private  long twoDaysAgo
           
private  long twoMonthsAgo
           
private  long twoWeeksAgo
           
private  java.lang.String yAxisLabel
           
 
Constructor Summary
LineGraphImageCreationListener()
           
 
Method Summary
private  void buildCharts(java.lang.String filebase, java.lang.String name, java.util.List data, java.util.List legend, boolean createMini)
          Creates a main and mini chart for a given data set, and saves them.
private  void buildDayChart(IDashboardReport report, java.lang.String chartBase, DataPoint[] data)
          Builds the day chart.
private  void buildHourChart(IDashboardReport report, java.lang.String chartBase, DataPoint[] data)
          Builds the hour chart.
private  void buildMonthChart(IDashboardReport report, java.lang.String chartBase, DataPoint[] data)
          Builds the month chart.
private  void buildWeekChart(IDashboardReport report, java.lang.String chartBase, DataPoint[] data)
          Builds the week chart.
private  void buildYearChart(IDashboardReport report, java.lang.String chartBase, DataPoint[] data)
          Builds the year chart.
static org.jfree.chart.JFreeChart createChart(java.lang.String yLabel, java.util.List sets, java.util.List legend, boolean showDetail)
          Basic chart creation method.
protected  void doAfterImagesCreated(float[] reportChanges, IDashboardReport report, IDashboardAgent agent)
           
private  float[] getDeltas(DataPoint[] data)
          Returns the week/month/year deltas for the given data set.
protected  java.lang.String getYAxisLabel()
          Returns the label of the graph's Y-axis.
private  DataPoint goBackTo(java.util.Iterator it, DataPoint current, long target)
          Takes an iterator over a list of Map objects, which have a key for LOGTIME, and go back until the current value of LOGTIME is less than or equal to the target given date.
protected  boolean includeDayChart(IDashboardReport rept)
          Returns whether this report builds a daily report.
protected  boolean includeHourChart(IDashboardReport rept)
          Returns whether this report builds an hourly report.
protected  boolean includeMonthChart(IDashboardReport rept)
          Returns whether this report builds a monthly report.
protected  boolean includeWeekChart(IDashboardReport rept)
          Returns whether this report builds a weekly report.
protected  boolean includeYearChart(IDashboardReport rept)
          Returns whether this report builds a yearly report.
 void reportRan(IDashboardAgent agent, IDashboardReport report)
           
private  void setTimes()
           
 void setYAxisLabel(java.lang.String label)
          Sets the label of the graph's Y-axis.
 
Methods inherited from class com.ebay.carad.os.vitalsigns.listeners.AbstractReportingListener
reportingComplete, reportingException, reportingPreStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ebay.carad.os.vitalsigns.listeners.IReportingListener
reportingComplete, reportingException, reportingPreStart
 

Field Detail

LOGGER

private static final org.apache.log4j.Logger LOGGER

yAxisLabel

private java.lang.String yAxisLabel

ERROR_MARGIN

private static final long ERROR_MARGIN
See Also:
Constant Field Values

now

private long now

oneHourAgo

private long oneHourAgo

oneDayAgo

private long oneDayAgo

twoDaysAgo

private long twoDaysAgo

oneWeekAgo

private long oneWeekAgo

oneWeekAndHourAgo

private long oneWeekAndHourAgo

eightDaysAgo

private long eightDaysAgo

twoWeeksAgo

private long twoWeeksAgo

oneMonthAgo

private long oneMonthAgo

oneMonthAndHourAgo

private long oneMonthAndHourAgo

oneMonthAndDayAgo

private long oneMonthAndDayAgo

oneMonthAndWeekAgo

private long oneMonthAndWeekAgo

twoMonthsAgo

private long twoMonthsAgo

fiftyTwoWksAgo

private long fiftyTwoWksAgo

fiftyTwoWksAndDayAgo

private long fiftyTwoWksAndDayAgo

fiftyThreeWksAgo

private long fiftyThreeWksAgo

fiftySixWksAgo

private long fiftySixWksAgo

hundredFourWeeksAgo

private long hundredFourWeeksAgo
Constructor Detail

LineGraphImageCreationListener

public LineGraphImageCreationListener()
Method Detail

getYAxisLabel

protected java.lang.String getYAxisLabel()
Returns the label of the graph's Y-axis.

Returns:
the label of the graph's Y-axis.

setYAxisLabel

public void setYAxisLabel(java.lang.String label)
Sets the label of the graph's Y-axis.

Parameters:
label - the label to use

setTimes

private void setTimes()

goBackTo

private DataPoint goBackTo(java.util.Iterator it,
                           DataPoint current,
                           long target)
Takes an iterator over a list of Map objects, which have a key for LOGTIME, and go back until the current value of LOGTIME is less than or equal to the target given date.

Parameters:
iterator - the Iterator to navigate back with
row - the current row
target - the date to stop when at or before
Returns:
the row

buildHourChart

private void buildHourChart(IDashboardReport report,
                            java.lang.String chartBase,
                            DataPoint[] data)
Builds the hour chart.

Parameters:
report - the report we are building for
chartBase - the base destination filename for saved files
data - the data to chart

buildDayChart

private void buildDayChart(IDashboardReport report,
                           java.lang.String chartBase,
                           DataPoint[] data)
Builds the day chart.

Parameters:
report - the report we are building for
chartBase - the base destination filename for saved files
data - the list of row data to chart

buildWeekChart

private void buildWeekChart(IDashboardReport report,
                            java.lang.String chartBase,
                            DataPoint[] data)
Builds the week chart.

Parameters:
report - the report we are building for
chartBase - the base destination filename for saved files
data - the list of row data to chart

buildMonthChart

private void buildMonthChart(IDashboardReport report,
                             java.lang.String chartBase,
                             DataPoint[] data)
Builds the month chart.

Parameters:
report - the report we are building for
chartBase - the base destination file name for saved files
data - the list of row data to chart

buildYearChart

private void buildYearChart(IDashboardReport report,
                            java.lang.String chartBase,
                            DataPoint[] data)
Builds the year chart.

Parameters:
report - the report we are building for
chartBase - the base destination filename for saved files
data - the list of row data to chart

getDeltas

private float[] getDeltas(DataPoint[] data)
Returns the week/month/year deltas for the given data set.

Parameters:
data - the list of row data to chart
Returns:
a float array with percentage deltas for each timeframe (week/month/year)

buildCharts

private void buildCharts(java.lang.String filebase,
                         java.lang.String name,
                         java.util.List data,
                         java.util.List legend,
                         boolean createMini)
Creates a main and mini chart for a given data set, and saves them.

Parameters:
filebase - the base file name for the charts, to which "-" + name will be appended.
name - the name of the chart for saving purposes, like "month" or "year"
data - the list of row data to chart
legend - the legend for the chart (a list of strings)

includeHourChart

protected boolean includeHourChart(IDashboardReport rept)
Returns whether this report builds an hourly report.

Returns:
true to display a last-hour report

includeDayChart

protected boolean includeDayChart(IDashboardReport rept)
Returns whether this report builds a daily report.

Returns:
true to display a last-day report

includeWeekChart

protected boolean includeWeekChart(IDashboardReport rept)
Returns whether this report builds a weekly report.

Returns:
true to display a last-week report

includeMonthChart

protected boolean includeMonthChart(IDashboardReport rept)
Returns whether this report builds a monthly report.

Returns:
true to display a last-month report

includeYearChart

protected boolean includeYearChart(IDashboardReport rept)
Returns whether this report builds a yearly report.

Returns:
true to display a last-year report

createChart

public static org.jfree.chart.JFreeChart createChart(java.lang.String yLabel,
                                                     java.util.List sets,
                                                     java.util.List legend,
                                                     boolean showDetail)
Basic chart creation method. Sets up an empty time-series chart, colors, etc.

Parameters:
yLabel - the label for the Y-axis
sets - a list of lists -- each one a list of Map objects, mapping LOGTIME and DATA to millisecond time and data columns, respectively. Each list becomes a series in the graph.
legend - an array of labels for the data series (a list of strings)
showDetail - if true, shows both the legend and the Y-axis label, and multi series; otherwise just shows no labels and first series.
Returns:
a chart

reportRan

public void reportRan(IDashboardAgent agent,
                      IDashboardReport report)
Specified by:
reportRan in interface IReportingListener
Overrides:
reportRan in class AbstractReportingListener

doAfterImagesCreated

protected void doAfterImagesCreated(float[] reportChanges,
                                    IDashboardReport report,
                                    IDashboardAgent agent)


Copyright © 2004-2009. All Rights Reserved.