use of org.magic.api.interfaces.MTGDashBoard in project MtgDesktopCompanion by nicho92.
the class HistoryPricesPanel method refresh.
private void refresh() {
TimeSeriesCollection dataset = new TimeSeriesCollection();
TimeSeries series1 = new TimeSeries(title);
if (showAll) {
for (MTGDashBoard d : MTGControler.getInstance().getDashBoards()) {
TimeSeries series = new TimeSeries(d.getName());
Map<Date, Double> mapTime;
try {
mapTime = d.getPriceVariation(mc, me);
if (mapTime != null) {
for (Entry<Date, Double> da : mapTime.entrySet()) series.add(new Day(da.getKey()), da.getValue().doubleValue());
dataset.addSeries(series);
}
} catch (IOException e) {
MTGLogger.printStackTrace(e);
}
}
} else {
for (Entry<Date, Double> d : map.entrySet()) series1.add(new Day(d.getKey()), d.getValue().doubleValue());
dataset.addSeries(series1);
}
JFreeChart chart = ChartFactory.createTimeSeriesChart("Price Variation", "Date", "Price", dataset, true, true, false);
if (showEdition)
try {
for (MagicEdition edition : MTGControler.getInstance().getEnabledProviders().loadEditions()) {
Date d = new SimpleDateFormat("yyyy-MM-dd hh:mm").parse(edition.getReleaseDate() + " 00:00");
TimeSeriesDataItem item = series1.getDataItem(new Day(d));
if (item != null) {
double x = item.getPeriod().getFirstMillisecond();
double y = item.getValue().doubleValue();
XYTextAnnotation annot = new XYTextAnnotation(edition.getId(), x, y);
annot.setToolTipText(edition.getSet());
XYPlot plot = (XYPlot) chart.getPlot();
plot.addAnnotation(annot);
}
}
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
pane.setChart(chart);
pane.addMouseWheelListener(mwe -> {
if (mwe.getWheelRotation() > 0) {
pane.zoomOutDomain(0.5, 0.5);
} else if (mwe.getWheelRotation() < 0) {
pane.zoomInDomain(1.5, 1.5);
}
});
this.add(pane, BorderLayout.CENTER);
chart.fireChartChanged();
}
use of org.magic.api.interfaces.MTGDashBoard in project MtgDesktopCompanion by nicho92.
the class SpeedConfigurator method save.
protected void save() {
for (MTGCardsProvider prov : MTGControler.getInstance().getListProviders()) {
prov.enable(false);
if (prov.getName().equals(cboProvider.getSelectedItem().toString()))
prov.enable(true);
MTGControler.getInstance().setProperty(prov, prov.isEnable());
}
for (MTGDao prov : MTGControler.getInstance().getDaoProviders()) {
prov.enable(false);
if (prov.getName().equals(cboDAOs.getSelectedItem().toString()))
prov.enable(true);
MTGControler.getInstance().setProperty(prov, prov.isEnable());
}
for (MTGPictureProvider prov : MTGControler.getInstance().getPicturesProviders()) {
prov.enable(false);
if (prov.getName().equals(cboPictures.getSelectedItem().toString()))
prov.enable(true);
MTGControler.getInstance().setProperty(prov, prov.isEnable());
}
for (MTGPicturesCache prov : MTGControler.getInstance().getListCaches()) {
prov.enable(false);
if (prov.getName().equals(cboCaches.getSelectedItem().toString()))
prov.enable(true);
MTGControler.getInstance().setProperty(prov, prov.isEnable());
}
for (MTGDashBoard prov : MTGControler.getInstance().getDashBoards()) {
prov.enable(false);
if (prov.getName().equals(cboDashboard.getSelectedItem().toString()))
prov.enable(true);
MTGControler.getInstance().setProperty(prov, prov.isEnable());
}
System.exit(0);
}
Aggregations