de.uka.ipd.sdq.ByCounter.reporting
Class ChartResultWriter

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.reporting.ChartResultWriter
All Implemented Interfaces:
ICountingResultWriter

public class ChartResultWriter
extends java.lang.Object
implements ICountingResultWriter

Utility for exporting JFreeChart objects as .pdf files. Uses itext.

Since:
0.1
Version:
1.2
Author:
Michael Kuperberg (?), Martin Krogmann (?)

Field Summary
static int FILETYPE_JPG
          Filetypes for chart files: jpg
static int FILETYPE_PDF
          Filetypes for chart files: pdf
static int FILETYPE_PNG
          Filetypes for chart files: png
 
Constructor Summary
ChartResultWriter(java.lang.String chartDir, java.lang.String chartName)
           
 
Method Summary
 org.jfree.chart.JFreeChart createAndSaveChart(long datasetTimestampForSavingChart, org.jfree.data.category.DefaultCategoryDataset dataset, boolean savePNGchart, boolean savePDFchart, int chartXsize, int chartYsize, java.lang.String qualifyingMethodName, java.lang.String pathForChartSaving)
          TODO
 java.lang.String getChartDir()
           
 java.lang.String getChartName()
           
static void saveChartAsPDF(java.io.File file, org.jfree.chart.JFreeChart chart, int width, int height, com.lowagie.text.pdf.FontMapper mapper)
          Save a JFreeChart to a File as a .pdf.
 void setChartDir(java.lang.String chartDir)
           
 void setChartName(java.lang.String chartName)
           
static void writeChartAsPDF(java.io.OutputStream out, org.jfree.chart.JFreeChart chart, int width, int height, com.lowagie.text.pdf.FontMapper mapper)
          Writes a JFreeChart object to a OutputStream.
 long writeResultToFile(CountingResult cr, boolean usePrevTimestamp, long prevTimestampToUse)
          (non-Javadoc)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILETYPE_JPG

public static final int FILETYPE_JPG
Filetypes for chart files: jpg

See Also:
Constant Field Values

FILETYPE_PDF

public static final int FILETYPE_PDF
Filetypes for chart files: pdf

See Also:
Constant Field Values

FILETYPE_PNG

public static final int FILETYPE_PNG
Filetypes for chart files: png

See Also:
Constant Field Values
Constructor Detail

ChartResultWriter

public ChartResultWriter(java.lang.String chartDir,
                         java.lang.String chartName)
Parameters:
chartDir - The directory in which charts are saved.
chartName - The filename for the chart.
Method Detail

saveChartAsPDF

public static void saveChartAsPDF(java.io.File file,
                                  org.jfree.chart.JFreeChart chart,
                                  int width,
                                  int height,
                                  com.lowagie.text.pdf.FontMapper mapper)
                           throws java.io.IOException
Save a JFreeChart to a File as a .pdf. From JFreeChart Developer guide.

Parameters:
file - File to write to.
chart - JFreeChart object to draw.
width - Width of the object.
height - Height of the object.
mapper - Fontmapper to interface with itext. (Try DefaultFontMapper).
Throws:
java.io.IOException - Thrown when errors happen while writing.

writeChartAsPDF

public static void writeChartAsPDF(java.io.OutputStream out,
                                   org.jfree.chart.JFreeChart chart,
                                   int width,
                                   int height,
                                   com.lowagie.text.pdf.FontMapper mapper)
                            throws java.io.IOException
Writes a JFreeChart object to a OutputStream. From JFreeChart Developer guide.

Parameters:
out - Output stream.
chart - Chart to write.
width - Width of the graphic.
height - Height of the graphic.
mapper - Fontmapper to interface with itext.
Throws:
java.io.IOException - Is thrown by the OutputStream.

createAndSaveChart

public org.jfree.chart.JFreeChart createAndSaveChart(long datasetTimestampForSavingChart,
                                                     org.jfree.data.category.DefaultCategoryDataset dataset,
                                                     boolean savePNGchart,
                                                     boolean savePDFchart,
                                                     int chartXsize,
                                                     int chartYsize,
                                                     java.lang.String qualifyingMethodName,
                                                     java.lang.String pathForChartSaving)
TODO

Parameters:
datasetTimestampForSavingChart -
dataset -
savePNGchart -
savePDFchart -
chartXsize -
chartYsize -
qualifyingMethodName -
pathForChartSaving -
Returns:
The JFreeChart created using the specified parameters.

getChartDir

public java.lang.String getChartDir()
Returns:
the chartDir

getChartName

public java.lang.String getChartName()
Returns:
the chartName

setChartDir

public void setChartDir(java.lang.String chartDir)
Parameters:
chartDir - the chartDir to set

setChartName

public void setChartName(java.lang.String chartName)
Parameters:
chartName - the chartName to set

writeResultToFile

public long writeResultToFile(CountingResult cr,
                              boolean usePrevTimestamp,
                              long prevTimestampToUse)
(non-Javadoc)

Specified by:
writeResultToFile in interface ICountingResultWriter
Parameters:
cr - CountingResult to write
usePrevTimestamp - TODO explain
Returns:
timestamp that is part of the file name (if usePrevTimestamp==false, the returned timestamp is internally generated by this method)
See Also:
ICountingResultWriter.writeResultToFile(de.uka.ipd.sdq.ByCounter.execution.CountingResult, boolean, long)