offline and non-graphical charts production

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@76682 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2013-06-03 11:11:01 +00:00
parent 43033513df
commit 2fcab8df54
10 changed files with 473 additions and 195 deletions

View File

@ -114,14 +114,36 @@ public class GaussianDistributionGraph extends GenericStandaloneGraph {
return jfreechart;
}
public static JFreeChart createStaticChart(Dataset dataset, double mean, double variance) {
String label = "mean:"+mean+" variance:"+variance;
if (label.length()>30)
label = label.substring(0,30)+"...";
JFreeChart jfreechart = ChartFactory.createXYLineChart("", label, "", (XYSeriesCollection)dataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot xyplot = (XYPlot)jfreechart.getPlot();
xyplot.setDomainZeroBaselineVisible(true);
xyplot.setRangeZeroBaselineVisible(true);
xyplot.setDomainPannable(true);
xyplot.setRangePannable(true);
ValueAxis valueaxis = xyplot.getDomainAxis();
valueaxis.setLowerMargin(0.0D);
valueaxis.setUpperMargin(0.0D);
XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer();
xylineandshaperenderer.setDrawSeriesLineAsPath(true);
xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.5F));
return jfreechart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new GaussianDistributionGraph(title);
}
double mean;
double variance;
public double mean;
public double variance;
@Override
protected Dataset convert2Dataset(GraphData st) {

View File

@ -123,6 +123,24 @@ public class HistogramGraph extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
JFreeChart chart = ChartFactory.createBarChart("Histogram Chart", "", "", (DefaultCategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(Color.white);
CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
categoryplot.setBackgroundPaint(new Color(238, 238, 255));
categoryplot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
CategoryAxis categoryaxis = categoryplot.getDomainAxis();
categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
LegendTitle legendtitle = new LegendTitle(categoryplot.getRenderer(0));
legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
return chart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new HistogramGraph(title);

View File

@ -145,6 +145,43 @@ public class LineGraph extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset, String title) {
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(
title, // chart title
"", // domain axis label
"", // range axis label
(DefaultCategoryDataset)dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
// plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainCrosshairVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setRenderer(new LineAndShapeRenderer(true,true));
//deprecated
/*
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setFillPaint(Color.white);
*/
return chart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new LineGraph(title);

View File

@ -111,6 +111,23 @@ public class NumericSeriesGraph extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
NumberAxis numberaxis = new NumberAxis("X");
numberaxis.setAutoRangeIncludesZero(true);
NumberAxis numberaxis1 = new NumberAxis("Y");
numberaxis1.setAutoRangeIncludesZero(true);
XYSplineRenderer xysplinerenderer = new XYSplineRenderer();
XYPlot xyplot = new XYPlot((XYDataset) dataset, numberaxis, numberaxis1, xysplinerenderer);
xyplot.setBackgroundPaint(Color.lightGray);
xyplot.setDomainGridlinePaint(Color.white);
xyplot.setRangeGridlinePaint(Color.white);
xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
JFreeChart chart = new JFreeChart("Numeric Series", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true);
return chart;
}
@Override
protected Dataset convert2Dataset(GraphData st) {

View File

@ -102,6 +102,17 @@ public class PieGraph extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
JFreeChart chart = ChartFactory.createMultiplePieChart(
"Multiple Pie Chart", // chart title
(DefaultCategoryDataset)dataset, // dataset
TableOrder.BY_ROW,
true, // include legend
true,
false
);
return chart;
}
protected Dataset convert2DatasetOld(GraphData st) {

View File

@ -54,7 +54,14 @@ public class RadarGraph extends GenericStandaloneGraph{
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
SpiderWebPlot plot = new SpiderWebPlot((DefaultCategoryDataset)dataset);
JFreeChart chart = new JFreeChart(plot);
return chart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new RadarGraph(title);

View File

@ -123,6 +123,33 @@ public class ScatterGraphGeneric extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(
"", // chart title
"", // domain axis label
"", // range axis label
(DefaultCategoryDataset)dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainCrosshairVisible(true);
plot.setDomainGridlinesVisible(false);
plot.setRangeCrosshairVisible(true);
plot.setRenderer(new LineAndShapeRenderer(false,true));
return chart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new ScatterGraphGeneric(title);

View File

@ -106,6 +106,40 @@ public class ScatterGraphNumeric extends GenericStandaloneGraph {
return jfreechart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
JFreeChart jfreechart = ChartFactory.createScatterPlot("", "", "", (XYDataset)dataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot xyplot = (XYPlot)jfreechart.getPlot();
xyplot.setNoDataMessage("NO DATA");
xyplot.setDomainPannable(true);
xyplot.setRangePannable(true);
xyplot.setDomainZeroBaselineVisible(true);
xyplot.setRangeZeroBaselineVisible(true);
xyplot.setDomainGridlineStroke(new BasicStroke(0.0F));
xyplot.setDomainMinorGridlineStroke(new BasicStroke(0.0F));
xyplot.setDomainGridlinePaint(Color.blue);
xyplot.setRangeGridlineStroke(new BasicStroke(0.0F));
xyplot.setRangeMinorGridlineStroke(new BasicStroke(0.0F));
xyplot.setRangeGridlinePaint(Color.blue);
xyplot.setDomainMinorGridlinesVisible(true);
xyplot.setRangeMinorGridlinesVisible(true);
XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer();
xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black);
xylineandshaperenderer.setUseOutlinePaint(true);
NumberAxis numberaxis = (NumberAxis)xyplot.getDomainAxis();
numberaxis.setAutoRangeIncludesZero(false);
numberaxis.setTickMarkInsideLength(2.0F);
numberaxis.setTickMarkOutsideLength(2.0F);
numberaxis.setMinorTickCount(2);
numberaxis.setMinorTickMarksVisible(true);
NumberAxis numberaxis1 = (NumberAxis)xyplot.getRangeAxis();
numberaxis1.setTickMarkInsideLength(2.0F);
numberaxis1.setTickMarkOutsideLength(2.0F);
numberaxis1.setMinorTickCount(2);
numberaxis1.setMinorTickMarksVisible(true);
return jfreechart;
}
@Override
protected Dataset convert2Dataset(GraphData st) {

View File

@ -136,6 +136,44 @@ public class TimeSeriesGraph extends GenericStandaloneGraph {
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset, String timeSeriesStringFormat) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Time Series", // title
"", // x-axis label
"", // y-axis label
(XYDataset)dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
renderer.setDrawSeriesLineAsPath(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat(timeSeriesStringFormat));
return chart;
}
@Override
protected Dataset convert2Dataset(GraphData st) {

View File

@ -79,215 +79,282 @@ public class TransectLineGraph extends GenericStandaloneGraph {
}
protected Dataset generateDataset() {
// row keys...
String series1 = "First";
String series2 = "Second";
String series3 = "Third";
// row keys...
String series1 = "First";
String series2 = "Second";
String series3 = "Third";
// column keys...
String type1 = "Type 1";
String type2 = "Type 2";
String type3 = "Type 3";
String type4 = "Type 4";
String type5 = "Type 5";
String type6 = "Type 6";
String type7 = "Type 7";
String type8 = "Type 8";
// column keys...
String type1 = "Type 1";
String type2 = "Type 2";
String type3 = "Type 3";
String type4 = "Type 4";
String type5 = "Type 5";
String type6 = "Type 6";
String type7 = "Type 7";
String type8 = "Type 8";
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, series1, type1);
dataset.addValue(4.0, series1, type2);
dataset.addValue(3.0, series1, type3);
dataset.addValue(5.0, series1, type4);
dataset.addValue(5.0, series1, type5);
dataset.addValue(7.0, series1, type6);
dataset.addValue(7.0, series1, type7);
dataset.addValue(8.0, series1, type8);
dataset.addValue(1.0, series1, type1);
dataset.addValue(4.0, series1, type2);
dataset.addValue(3.0, series1, type3);
dataset.addValue(5.0, series1, type4);
dataset.addValue(5.0, series1, type5);
dataset.addValue(7.0, series1, type6);
dataset.addValue(7.0, series1, type7);
dataset.addValue(8.0, series1, type8);
dataset.addValue(5.0, series2, type1);
dataset.addValue(7.0, series2, type2);
dataset.addValue(6.0, series2, type3);
dataset.addValue(8.0, series2, type4);
dataset.addValue(4.0, series2, type5);
dataset.addValue(4.0, series2, type6);
dataset.addValue(2.0, series2, type7);
dataset.addValue(1.0, series2, type8);
dataset.addValue(5.0, series2, type1);
dataset.addValue(7.0, series2, type2);
dataset.addValue(6.0, series2, type3);
dataset.addValue(8.0, series2, type4);
dataset.addValue(4.0, series2, type5);
dataset.addValue(4.0, series2, type6);
dataset.addValue(2.0, series2, type7);
dataset.addValue(1.0, series2, type8);
dataset.addValue(4.0, series3, type1);
dataset.addValue(3.0, series3, type2);
dataset.addValue(2.0, series3, type3);
dataset.addValue(3.0, series3, type4);
dataset.addValue(6.0, series3, type5);
dataset.addValue(3.0, series3, type6);
dataset.addValue(4.0, series3, type7);
dataset.addValue(3.0, series3, type8);
return dataset;
dataset.addValue(4.0, series3, type1);
dataset.addValue(3.0, series3, type2);
dataset.addValue(2.0, series3, type3);
dataset.addValue(3.0, series3, type4);
dataset.addValue(6.0, series3, type5);
dataset.addValue(3.0, series3, type6);
dataset.addValue(4.0, series3, type7);
dataset.addValue(3.0, series3, type8);
return dataset;
}
protected JFreeChart createChart(Dataset dataset) {
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset0 = (DefaultCategoryDataset)dataset;
ArrayList<Integer> relevantindexes = new ArrayList<Integer>();
for (Object row:dataset0.getRowKeys()){
int spikescounter=0;
int pointscounter=0;
int allcounter=0;
int mincolumns = 0;
int maxcolumns = dataset0.getColumnCount()-1;
int medcolumns = (maxcolumns)/2;
for (Object column:dataset0.getColumnKeys()){
// System.out.println("row "+row+" column "+column );
double value = dataset0.getValue((String)row, (String)column).doubleValue();
String xlab = (String) column;
String annotation ="";
String x1lab = xlab;
int commaindex = xlab.indexOf(";");
if (commaindex>0){
annotation = xlab.substring(commaindex+1);
x1lab = xlab.substring(0,commaindex);
dataset2.addValue(value, (String)row, ""+(allcounter+1)+": "+annotation);
spikescounter++;
relevantindexes.add(allcounter);
}
else{
if ((allcounter==mincolumns)||(allcounter==maxcolumns)||(allcounter==medcolumns))
relevantindexes.add(allcounter);
dataset2.addValue(value, (String)row, ""+(allcounter+1)+"");
pointscounter++;
}
allcounter++;
dataset1.addValue(value, (String)row, x1lab);
}
}
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(
" ", // chart title
"", // domain axis label
"", // range axis label
(DefaultCategoryDataset)dataset1, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset0 = (DefaultCategoryDataset) dataset;
ArrayList<Integer> relevantindexes = new ArrayList<Integer>();
for (Object row : dataset0.getRowKeys()) {
int spikescounter = 0;
int pointscounter = 0;
int allcounter = 0;
int mincolumns = 0;
int maxcolumns = dataset0.getColumnCount() - 1;
int medcolumns = (maxcolumns) / 2;
for (Object column : dataset0.getColumnKeys()) {
// System.out.println("row "+row+" column "+column );
double value = dataset0.getValue((String) row, (String) column).doubleValue();
String xlab = (String) column;
String annotation = "";
String x1lab = xlab;
int commaindex = xlab.indexOf(";");
if (commaindex > 0) {
annotation = xlab.substring(commaindex + 1);
x1lab = xlab.substring(0, commaindex);
dataset2.addValue(value, (String) row, "" + (allcounter + 1) + ": " + annotation);
spikescounter++;
relevantindexes.add(allcounter);
}
else {
if ((allcounter == mincolumns) || (allcounter == maxcolumns) || (allcounter == medcolumns))
relevantindexes.add(allcounter);
dataset2.addValue(value, (String) row, "" + (allcounter + 1) + "");
pointscounter++;
}
allcounter++;
dataset1.addValue(value, (String) row, x1lab);
}
}
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(" ", // chart title
"", // domain axis label
"", // range axis label
(DefaultCategoryDataset) dataset1, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
chart.setTitle(new TextTitle(" ", new Font("sansserif", Font.BOLD, 60)));
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainCrosshairVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setRangeCrosshairVisible(true);
// plot.setRenderer(new LineAndShapeRenderer(true,true));
plot.setRenderer(new LineAndShapeRenderer(true,false));
plot.setAxisOffset(new RectangleInsets(1D, 1D, 1D, 1D));
plot.setDomainAxis(0,new CustomXAxis("",dataset1,relevantindexes));
CategoryAxis categoryaxis1 = plot.getDomainAxis(0);
categoryaxis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(0, 0);
plot.setDataset(1, (DefaultCategoryDataset)dataset2);
plot.setDomainAxis(1,new CustomXAxis("",dataset2,relevantindexes));
CategoryAxis categoryaxis2 = plot.getDomainAxis(1);
categoryaxis2.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(1, 1);
plot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT);
// categoryaxis2.setLabelInsets(new RectangleInsets(100, 100, 100, 100));
// categoryaxis2.setLowerMargin(0.05D);
// categoryaxis2.setUpperMargin(1D);
// plot.mapDatasetToRangeAxis(1, 1);
//deprecated
/*
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setFillPaint(Color.white);
*/
// rangeAxis.setStandardTickUnits(ValueAxis);
// rangeAxis.setAutoRangeIncludesZero(false);
// rangeAxis.setUpperMargin(0.12);
chart.setPadding(new RectangleInsets(30, 30, 90, 90));
big=true;
chart.getPlot().setBackgroundPaint(Color.white);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainCrosshairVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setRangeCrosshairVisible(true);
// plot.setRenderer(new LineAndShapeRenderer(true,true));
plot.setRenderer(new LineAndShapeRenderer(true, false));
plot.setAxisOffset(new RectangleInsets(1D, 1D, 1D, 1D));
plot.setDomainAxis(0, new CustomXAxis("", dataset1, relevantindexes));
CategoryAxis categoryaxis1 = plot.getDomainAxis(0);
categoryaxis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(0, 0);
plot.setDataset(1, (DefaultCategoryDataset) dataset2);
plot.setDomainAxis(1, new CustomXAxis("", dataset2, relevantindexes));
CategoryAxis categoryaxis2 = plot.getDomainAxis(1);
categoryaxis2.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(1, 1);
plot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT);
// categoryaxis2.setLabelInsets(new RectangleInsets(100, 100, 100, 100));
// categoryaxis2.setLowerMargin(0.05D);
// categoryaxis2.setUpperMargin(1D);
// plot.mapDatasetToRangeAxis(1, 1);
// deprecated
/*
* LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.white);
*/
// rangeAxis.setStandardTickUnits(ValueAxis);
// rangeAxis.setAutoRangeIncludesZero(false);
// rangeAxis.setUpperMargin(0.12);
chart.setPadding(new RectangleInsets(30, 30, 90, 90));
big = true;
chart.getPlot().setBackgroundPaint(Color.white);
return chart;
}
public static JFreeChart createStaticChart(Dataset dataset) {
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset0 = (DefaultCategoryDataset) dataset;
ArrayList<Integer> relevantindexes = new ArrayList<Integer>();
for (Object row : dataset0.getRowKeys()) {
int spikescounter = 0;
int pointscounter = 0;
int allcounter = 0;
int mincolumns = 0;
int maxcolumns = dataset0.getColumnCount() - 1;
int medcolumns = (maxcolumns) / 2;
for (Object column : dataset0.getColumnKeys()) {
// System.out.println("row "+row+" column "+column );
double value = dataset0.getValue((String) row, (String) column).doubleValue();
String xlab = (String) column;
String annotation = "";
String x1lab = xlab;
int commaindex = xlab.indexOf(";");
if (commaindex > 0) {
annotation = xlab.substring(commaindex + 1);
x1lab = xlab.substring(0, commaindex);
dataset2.addValue(value, (String) row, "" + (allcounter + 1) + ": " + annotation);
spikescounter++;
relevantindexes.add(allcounter);
}
else {
if ((allcounter == mincolumns) || (allcounter == maxcolumns) || (allcounter == medcolumns))
relevantindexes.add(allcounter);
dataset2.addValue(value, (String) row, "" + (allcounter + 1) + "");
pointscounter++;
}
allcounter++;
dataset1.addValue(value, (String) row, x1lab);
}
}
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(" ", // chart title
"", // domain axis label
"", // range axis label
(DefaultCategoryDataset) dataset1, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
chart.setTitle(new TextTitle(" ", new Font("sansserif", Font.BOLD, 60)));
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setDomainCrosshairVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setRenderer(new LineAndShapeRenderer(true, false));
plot.setAxisOffset(new RectangleInsets(1D, 1D, 1D, 1D));
plot.setDomainAxis(0, new CustomXAxis("", dataset1, relevantindexes));
CategoryAxis categoryaxis1 = plot.getDomainAxis(0);
categoryaxis1.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(0, 0);
plot.setDataset(1, (DefaultCategoryDataset) dataset2);
plot.setDomainAxis(1, new CustomXAxis("", dataset2, relevantindexes));
CategoryAxis categoryaxis2 = plot.getDomainAxis(1);
categoryaxis2.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
plot.mapDatasetToDomainAxis(1, 1);
plot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT);
chart.setPadding(new RectangleInsets(30, 30, 90, 90));
chart.getPlot().setBackgroundPaint(Color.white);
return chart;
}
@Override
protected GenericStandaloneGraph getInstance(String title) {
return new TransectLineGraph(title);
}
static class CustomXAxis extends CategoryAxis
{
static class CustomXAxis extends CategoryAxis {
DefaultCategoryDataset dataset;
List<Integer> samplingindexes;
public java.util.List refreshTicks(Graphics2D graphics2d, AxisState axisstate, Rectangle2D rectangle2d, RectangleEdge rectangleedge)
{
ArrayList arraylist = new ArrayList();
int size = dataset.getColumnCount();
for (int i=0;i<size;i++){
TextBlock tb = new TextBlock();
if (MathFunctions.isIn(samplingindexes, i)){
String xlab = (String)dataset.getColumnKeys().get(i);
// xlab = xlab.substring(xlab.indexOf(":")+1);
tb.addLine(new TextLine(xlab,new Font("sansserif", Font.BOLD, 8)));
}
else{
tb.addLine(new TextLine(""));
}
arraylist.add(new CategoryTick("p"+i, tb , TextBlockAnchor.CENTER_RIGHT,TextAnchor.CENTER_RIGHT, 0));
}
return arraylist;
}
public CustomXAxis(String s,DefaultCategoryDataset d,List<Integer> indexes)
{
super(s);
dataset = d;
samplingindexes = indexes;
}
}
DefaultCategoryDataset dataset;
List<Integer> samplingindexes;
public java.util.List refreshTicks(Graphics2D graphics2d, AxisState axisstate, Rectangle2D rectangle2d, RectangleEdge rectangleedge) {
ArrayList arraylist = new ArrayList();
int size = dataset.getColumnCount();
for (int i = 0; i < size; i++) {
TextBlock tb = new TextBlock();
if (MathFunctions.isIn(samplingindexes, i)) {
String xlab = (String) dataset.getColumnKeys().get(i);
// xlab = xlab.substring(xlab.indexOf(":")+1);
tb.addLine(new TextLine(xlab, new Font("sansserif", Font.BOLD, 8)));
} else {
tb.addLine(new TextLine(""));
}
arraylist.add(new CategoryTick("p" + i, tb, TextBlockAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0));
}
return arraylist;
}
public CustomXAxis(String s, DefaultCategoryDataset d, List<Integer> indexes) {
super(s);
dataset = d;
samplingindexes = indexes;
}
}
}