use of org.jfree.chart.ChartPanel in project MtgDesktopCompanion by nicho92.
the class RarityRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Rarity repartition", // data
getRarityRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("Uncommon", Color.GRAY);
plot.setSectionPaint("Common", Color.WHITE);
plot.setSectionPaint("Rare", Color.YELLOW);
plot.setSectionPaint("Mythic Rare", Color.ORANGE);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
}
use of org.jfree.chart.ChartPanel in project MtgDesktopCompanion by nicho92.
the class TypeRepartitionPanel method refresh.
private void refresh() {
this.removeAll();
JFreeChart chart = ChartFactory.createPieChart3D(// chart title
"Type repartition", // data
getTypeRepartitionDataSet(), // include legend
false, true, true);
pane = new ChartPanel(chart);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionPaint("B", Color.BLACK);
plot.setSectionPaint("W", Color.WHITE);
plot.setSectionPaint("U", Color.BLUE);
plot.setSectionPaint("G", Color.GREEN);
plot.setSectionPaint("R", Color.RED);
plot.setSectionPaint("multi", Color.YELLOW);
plot.setSectionPaint("uncolor", Color.GRAY);
PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
plot.setLabelGenerator(generator);
this.add(pane, BorderLayout.CENTER);
}
use of org.jfree.chart.ChartPanel in project mylizzie by aerisnju.
the class WinrateHistogramDialog method initCustomComponents.
private void initCustomComponents() {
WinrateHistogramTableModel winrateHistogramTableModel = new WinrateHistogramTableModel();
tableWinrateHistory.setModel(winrateHistogramTableModel);
XYSeries blackSeries = new XYSeries("Black");
XYSeries whiteSeries = new XYSeries("White");
XYSeries standardSeries = new XYSeries("50%");
for (int i = 0; i <= 50; ++i) {
standardSeries.add(i, 50);
}
dataSet = new XYSeriesCollection();
dataSet.addSeries(blackSeries);
dataSet.addSeries(whiteSeries);
dataSet.addSeries(standardSeries);
JFreeChart chart = ChartFactory.createXYLineChart(// chart title
"", // x axis label
"", // y axis label
"Win%", // data
dataSet, PlotOrientation.VERTICAL, // include legend
true, // tooltips
true, // urls
false);
chart.setBackgroundPaint(Color.WHITE);
// get a reference to the plot for further customisation...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
NumberAxis range = (NumberAxis) plot.getRangeAxis();
range.setRange(0.0, 100.0);
histogramChartPanel = new ChartPanel(chart);
panelWinrateHistogram.add(histogramChartPanel);
winrateHistogramTableModel.setRefreshObserver(new Consumer<WinrateHistogramTableModel>() {
private long lastRefreshTime = System.currentTimeMillis();
@Override
public void accept(WinrateHistogramTableModel model) {
long currentTime = System.currentTimeMillis();
if (currentTime - lastRefreshTime < 500L) {
return;
}
lastRefreshTime = currentTime;
blackSeries.clear();
whiteSeries.clear();
standardSeries.clear();
for (int i = 0; i < model.getHistogramEntryList().size(); ++i) {
WinrateHistogramEntry entry = model.getHistogramEntryList().get(i);
standardSeries.add(entry.getMoveNumber(), 50);
if (checkBoxHistogramShowBlack.isSelected()) {
blackSeries.add(entry.getMoveNumber(), entry.getBlackWinrate());
}
if (checkBoxHistogramShowWhite.isSelected()) {
whiteSeries.add(entry.getMoveNumber(), entry.getWhiteWinrate());
}
}
if (model.getHistogramEntryList().size() < 50) {
for (int i = model.getHistogramEntryList().size() - 1; i <= 50; ++i) {
standardSeries.add(i, 50);
}
}
histogramChartPanel.repaint();
}
});
if (Lizzie.optionSetting.getWinrateHistogramWindowWidth() >= 10 && Lizzie.optionSetting.getWinrateHistogramWindowHeight() >= 10) {
setPreferredSize(new Dimension(Lizzie.optionSetting.getWinrateHistogramWindowWidth(), Lizzie.optionSetting.getWinrateHistogramWindowHeight()));
}
splitPaneHistogram.setDividerLocation(0.3);
pack();
histogramChartPanel.setPreferredSize(new Dimension(panelWinrateHistogram.getWidth(), panelWinrateHistogram.getHeight()));
histogramChartPanel.setSize(panelWinrateHistogram.getWidth(), panelWinrateHistogram.getHeight());
pack();
}
use of org.jfree.chart.ChartPanel in project FRC2018 by first95.
the class AdjustedTalonTester method runVoltageTest.
public void runVoltageTest() {
// Create dataset
XYDataset dataset = new XYSeriesCollection();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
int seriesNum = 0;
for (double throttle = -1.0; throttle <= 1.0; throttle += 0.25) {
// Prime the UUT with normal voltages for a while
double voltage = 13;
for (int i = 0; i < AdjustedTalon.NUM_RECENT_SAMPLES; ++i) {
pdp.setVoltage(13);
uut.set(ControlMode.PercentOutput, 0.0);
}
XYSeries series = new XYSeries("Throttle at " + throttle, false);
for (; voltage >= 5.0; voltage -= 0.01) {
pdp.setVoltage(voltage);
uut.set(ControlMode.PercentOutput, throttle);
series.add(voltage, lastCommandedThrottle);
}
((XYSeriesCollection) dataset).addSeries(series);
renderer.setSeriesLinesVisible(seriesNum, true);
renderer.setSeriesShapesVisible(seriesNum, false);
seriesNum++;
}
// Create chart
JFreeChart chart = ChartFactory.createScatterPlot("Adjusted throttle vs battery voltage", "voltage", "Adjusted throttle", dataset);
// Changes background color
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(new Color(200, 200, 200));
plot.setRenderer(renderer);
// Create Panel
ChartPanel panel = new ChartPanel(chart);
setContentPane(panel);
}
use of org.jfree.chart.ChartPanel in project ta4j by ta4j.
the class IndicatorsToChart method displayChart.
/**
* Displays a chart in a frame.
* @param chart the chart to be displayed
*/
private static void displayChart(JFreeChart chart) {
// Chart panel
ChartPanel panel = new ChartPanel(chart);
panel.setFillZoomRectangle(true);
panel.setMouseWheelEnabled(true);
panel.setPreferredSize(new java.awt.Dimension(500, 270));
// Application frame
ApplicationFrame frame = new ApplicationFrame("Ta4j example - Indicators to chart");
frame.setContentPane(panel);
frame.pack();
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
Aggregations