Skip to content
Snippets Groups Projects
Commit 379998eb authored by Maximilian Koenig's avatar Maximilian Koenig
Browse files

Removed White Shadow Bar Chart and fixes to confidence bars

parent ad815c49
No related branches found
No related tags found
No related merge requests found
......@@ -357,8 +357,10 @@ public class VisualizationController {
@Override
public void actionPerformed(ActionEvent e) {
transformDiagram(view.getConfidenceRadio().isSelected());
if (view.getConfidenceRadio() != null)
transformDiagram(view.getConfidenceRadio().isSelected());
else
transformDiagram(false);
}
};
......
......@@ -29,10 +29,17 @@ package tools.descartes.pavo.types;
import java.awt.Color;
import java.math.BigDecimal;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
......@@ -68,6 +75,9 @@ import tools.descartes.pavo.view.View;
*/
public class BarChart extends AbstractVisualizationType implements IVisualizationType {
double barwidth = 0.2;
JSpinner mySpinner;
public BarChart(ResultContainerPavo resultN) {
super(resultN);
}
......@@ -105,15 +115,11 @@ public class BarChart extends AbstractVisualizationType implements IVisualizatio
@Override
public JFreeChart visualize() {
ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
XYSeriesCollection dataset = new XYSeriesCollection();
XYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false);
XYBarRenderer.setDefaultShadowsVisible(false);
JFreeChart chart = ChartFactory.createXYBarChart("", this.getXDescription(), false, this.getYDescription(),
dataset);
NumberAxis domainAxis = new NumberAxis(this.getXDescription());
domainAxis.setAutoRangeIncludesZero(false);
NumberAxis valueAxis = new NumberAxis(this.getYDescription());
XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
for (AbstractQuantitativeResult r : this.getResult().getResults()) {
if (r instanceof ValueResultPavo) {
ValueMarker marker = new ValueMarker(((ValueResultPavo) r).getValue());
......@@ -121,8 +127,8 @@ public class BarChart extends AbstractVisualizationType implements IVisualizatio
marker.setLabel(((ValueResultPavo) r).getName());
marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
((XYPlot) chart.getPlot()).addRangeMarker(marker);
ValueAxis yAxis = plot.getRangeAxis();
((CategoryPlot) chart.getPlot()).addRangeMarker(marker);
ValueAxis yAxis = ((CategoryPlot) chart.getPlot()).getRangeAxis();
if (marker.getValue() > yAxis.getUpperBound())
yAxis.setRange(yAxis.getLowerBound(), marker.getValue() + 1);
} else if (r instanceof SeriesResultPavo) {
......@@ -135,9 +141,11 @@ public class BarChart extends AbstractVisualizationType implements IVisualizatio
dataset.addSeries(series1);
}
}
plot.setBackgroundPaint(Color.white);
plot.setRangeGridlinePaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.lightGray);
XYPlot plot = chart.getXYPlot();
plot.setRenderer(new ClusteredXYBarRenderer(barwidth, true));
XYBarRenderer.setDefaultShadowsVisible(false);
return chart;
}
......@@ -155,9 +163,37 @@ public class BarChart extends AbstractVisualizationType implements IVisualizatio
JPanel panel = new JPanel();
JRadioButton a = View.createConfidence(c.getActionListenerConfidence());
panel.add(a);
try {
if (c.getView().getConfidenceRadio().isSelected()) {
a.setSelected(true);
}
} catch (NullPointerException e) {
}
c.getView().addConfidence(a);
panel.add(View.createMinMaxMean(c.createActionListenerMin(), c.createActionListenerMax(),
c.createActionListenerMean()));
mySpinner = new JSpinner();
mySpinner.setModel(new SpinnerNumberModel(1 - barwidth, 0.1, 2, 0.1));
mySpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
barwidth = 1.0 - (double) mySpinner.getValue();
c.updateChart(visualize());
}
});
JPanel spinnerpanel = new JPanel();
spinnerpanel.add(new JLabel("Bar Width:"));
spinnerpanel.add(mySpinner);
panel.add(spinnerpanel);
return panel;
}
}
\ No newline at end of file
......@@ -30,6 +30,9 @@ import java.awt.Color;
import java.util.LinkedList;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
......@@ -37,10 +40,12 @@ import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset;
import tools.descartes.pavo.controller.VisualizationController;
import tools.descartes.pavo.result.AbstractQuantitativeResult;
import tools.descartes.pavo.result.ResultContainerPavo;
import tools.descartes.pavo.result.SeriesResultPavo;
import tools.descartes.pavo.util.Point;
import tools.descartes.pavo.view.View;
/**
* * Class to visualise the current result as BoxPlot if possible. Can visualise
......@@ -94,4 +99,12 @@ public class BoxPlot extends AbstractVisualizationType implements IVisualization
return true;
}
public JPanel getEditViewComponent(VisualizationController c) {
JPanel panel = new JPanel();
JRadioButton a = View.createConfidence(c.getActionListenerConfidence());
a.setEnabled(false);
panel.add(a);
return panel;
}
}
\ No newline at end of file
......@@ -164,6 +164,16 @@ public class LineChart extends AbstractVisualizationType implements IVisualizati
JPanel panel = new JPanel();
JRadioButton a = View.createConfidence(c.getActionListenerConfidence());
panel.add(a);
try {
if (c.getView().getConfidenceRadio().isSelected()) {
a.setSelected(true);
}
} catch (NullPointerException e) {
}
c.getView().addConfidence(a);
panel.add(View.createMinMaxMean(c.createActionListenerMin(), c.createActionListenerMax(),
c.createActionListenerMean()));
return panel;
......
......@@ -179,6 +179,10 @@ public class View {
this.buttonPanel.add(comp);
}
public void addConfidence(JRadioButton conf) {
this.confidenceRadio = conf;
}
/**
* Static Method to create a Panel containing RadioButtons for Minimum,
* maximum and mean markers including their action listener
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment