use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.
the class MonitorStatisticChart method createChart.
public JFreeChart createChart() {
final Color backGroundColor = Color.WHITE;
//final Color backGroundColor = new Color(0xF0F0F0);
XYDataset dataset = createDataset();
final int seriesCount = dataset.getSeriesCount();
chart = ChartFactory.createTimeSeriesChart(chartTitle, timeAxisLabel, valueAxisLabel, dataset, true, true, false);
chart.setBackgroundPaint(backGroundColor);
if (!isHasValidData) {
int red = composite.getBackground().getRed();
int green = composite.getBackground().getGreen();
int blue = composite.getBackground().getBlue();
chart.setBackgroundPaint(new Color(red, green, blue));
chart.setBackgroundImageAlpha(0.0f);
}
XYPlot plot = (XYPlot) chart.getPlot();
if (!isHasValidData) {
setNoDataPlot(plot);
} else {
setDataPlot(plot);
chart.getLegend().setBackgroundPaint(Color.white);
}
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
for (int i = 0; i < seriesCount; i++) {
renderer.setSeriesPaint(i, colorAr[i % colorAr.length]);
}
return chart;
}
use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.
the class ChartCompositePart method createPlotUnit.
/**
* Create plot unit which show the data changing.
*
* @param parent the parent composite
*/
public void createPlotUnit(Composite parent) {
chart = createChart();
int red = parent.getBackground().getRed();
int green = parent.getBackground().getGreen();
int blue = parent.getBackground().getBlue();
chart.setBackgroundPaint(new Color(red, green, blue));
chartComposite = new ChartComposite(parent, SWT.NONE, chart, false, true, false, false, false);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
chartComposite.setLayout(fillLayout);
chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
if (null != monInstaceData) {
TextTitle title = chart.getTitle();
XYPlot plot = chart.getXYPlot();
// title
String ttlBgColor = monInstaceData.getTitleBgColor();
String ttlFontName = monInstaceData.getTitleFontName();
int ttlFontSize = monInstaceData.getTitleFontSize();
String ttlFontColor = monInstaceData.getTitleFontColor();
// plot
String plotBgColor = monInstaceData.getPlotBgColor();
String plotDomainGridColor = monInstaceData.getPlotDomainGridColor();
String plotRangGridColor = monInstaceData.getPlotRangGridColor();
String plotDateAxisColor = monInstaceData.getPlotDateAxisColor();
String plotNumberAxisColor = monInstaceData.getPlotNumberAxisColor();
// history path
historyPath = monInstaceData.getHistoryPath();
isChangedHistoryPath = true;
if (ttlBgColor != null) {
red = getColorElem(ttlBgColor, 0);
green = getColorElem(ttlBgColor, 1);
blue = getColorElem(ttlBgColor, 2);
title.setBackgroundPaint(new Color(red, green, blue));
}
if (!"".equals(ttlFontName)) {
Font titleFont = new Font(ttlFontName, 0, ttlFontSize);
title.setFont(titleFont);
}
red = getColorElem(ttlFontColor, 0);
green = getColorElem(ttlFontColor, 1);
blue = getColorElem(ttlFontColor, 2);
title.setPaint(new Color(red, green, blue));
red = getColorElem(plotBgColor, 0);
green = getColorElem(plotBgColor, 1);
blue = getColorElem(plotBgColor, 2);
plot.setBackgroundPaint(new Color(red, green, blue));
red = getColorElem(plotDomainGridColor, 0);
green = getColorElem(plotDomainGridColor, 1);
blue = getColorElem(plotDomainGridColor, 2);
plot.setDomainGridlinePaint(new Color(red, green, blue));
red = getColorElem(plotRangGridColor, 0);
green = getColorElem(plotRangGridColor, 1);
blue = getColorElem(plotRangGridColor, 2);
plot.setRangeGridlinePaint(new Color(red, green, blue));
red = getColorElem(plotDateAxisColor, 0);
green = getColorElem(plotDateAxisColor, 1);
blue = getColorElem(plotDateAxisColor, 2);
plot.getRangeAxis().setAxisLinePaint(new Color(red, green, blue));
red = getColorElem(plotNumberAxisColor, 0);
green = getColorElem(plotNumberAxisColor, 1);
blue = getColorElem(plotNumberAxisColor, 2);
plot.getDomainAxis().setAxisLinePaint(new Color(red, green, blue));
}
}
use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.
the class DbSystemMonitorCompositePart method fireChartSetting.
/**
* This method is responsible for preparing data for ChartSettingDlg and
* dealing with the results of chartSettingDlg
*
*/
public void fireChartSetting() {
ChartSettingDlg chartSettingDlg = new ChartSettingDlg(composite.getShell());
chartSettingDlg.setHasTitlSetting(false);
chartSettingDlg.setHasHistoryPath(true);
chartSettingDlg.setHasAxisSetting(false);
chartSettingDlg.setHasSeriesItemSetting(false);
chartSettingDlg.setHasChartSelection(true);
// plot appearance
XYPlot dbStatplot = cpuChart.getSeriesChart().getXYPlot();
String plotBgColor = trimPaintColor(dbStatplot.getBackgroundPaint().toString());
String plotDomainGridColor = trimPaintColor(dbStatplot.getDomainGridlinePaint().toString());
String plotRangGridColor = trimPaintColor(dbStatplot.getRangeGridlinePaint().toString());
chartSettingDlg.setPlotBgColor(plotBgColor);
chartSettingDlg.setPlotDomainGridColor(plotDomainGridColor);
chartSettingDlg.setPlotRangGridColor(plotRangGridColor);
//history setting
chartSettingDlg.setHistoryFileName(historyFileName);
chartSettingDlg.setHistoryPath(historyPath);
// chart selection
chartSettingDlg.setChartSelectionLst(getSelectedCharts());
if (chartSettingDlg.open() == Dialog.OK) {
// plot appearance
plotBgColor = chartSettingDlg.getPlotBgColor();
plotDomainGridColor = chartSettingDlg.getPlotDomainGridColor();
plotRangGridColor = chartSettingDlg.getPlotRangGridColor();
JFreeChart cpuBarChart = cpuChart.getBarChart();
Plot cpuBarPlot = cpuBarChart.getPlot();
XYPlot cpuSeriesPlot = (XYPlot) cpuChart.getSeriesChart().getPlot();
JFreeChart memoryBarChart = memoryChart.getBarChart();
Plot memoryBarPlot = memoryBarChart.getPlot();
XYPlot memorySeriesPlot = (XYPlot) memoryChart.getSeriesChart().getPlot();
// history path
String newHistoryPath = chartSettingDlg.getHistoryPath();
boolean isChangedHistoryPath = historyPath.equals(newHistoryPath) ? false : true;
if (isChangedHistoryPath) {
historyPath = newHistoryPath;
historyFileHelp.setHistoryPath(historyPath);
historyFileHelp.setChangedHistoryPath(true);
}
int red = 0;
int green = 0;
int blue = 0;
//background
red = getColorElem(plotBgColor, 0);
green = getColorElem(plotBgColor, 1);
blue = getColorElem(plotBgColor, 2);
Color bgColor = new Color(red, green, blue);
dbStatplot.setBackgroundPaint(bgColor);
//cpu chart
cpuBarChart.setBackgroundPaint(bgColor);
cpuBarPlot.setBackgroundPaint(bgColor);
cpuSeriesPlot.setBackgroundPaint(bgColor);
//memoryChart
memoryBarPlot.setBackgroundPaint(bgColor);
memoryBarChart.setBackgroundPaint(bgColor);
memorySeriesPlot.setBackgroundPaint(bgColor);
//DomainGridColor
//db Chart
red = getColorElem(plotDomainGridColor, 0);
green = getColorElem(plotDomainGridColor, 1);
blue = getColorElem(plotDomainGridColor, 2);
Color domainGridlineColor = new Color(red, green, blue);
dbStatplot.setDomainGridlinePaint(domainGridlineColor);
//cpu chart
cpuSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
//memoryChart
memorySeriesPlot.setDomainGridlinePaint(domainGridlineColor);
//RangeGridColor
red = getColorElem(plotRangGridColor, 0);
green = getColorElem(plotRangGridColor, 1);
blue = getColorElem(plotRangGridColor, 2);
Color rangeGridColor = new Color(red, green, blue);
dbStatplot.setRangeGridlinePaint(rangeGridColor);
//cpu chart
cpuSeriesPlot.setRangeGridlinePaint(rangeGridColor);
//memoryChart
memorySeriesPlot.setRangeGridlinePaint(rangeGridColor);
//chart Selection
fireChartSelection(chartSettingDlg.getChartSelectionLst());
}
}
use of org.jfree.chart.plot.XYPlot in project processdash by dtuma.
the class ScheduleBalancingDialog method addChartToPanel.
private void addChartToPanel(JPanel panel, int gridY) {
// create a dataset for displaying schedule data
chartData = new ChartData();
updateChart();
// customize a renderer for displaying schedules
XYBarRenderer renderer = new XYBarRenderer();
renderer.setUseYInterval(true);
renderer.setBaseToolTipGenerator(chartData);
renderer.setDrawBarOutline(true);
// use an inverted, unadorned numeric Y-axis
NumberAxis yAxis = new NumberAxis();
yAxis.setInverted(true);
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setUpperMargin(0);
// use a Date-based X-axis
DateAxis xAxis = new DateAxis();
// create an XY plot to display the data
XYPlot plot = new XYPlot(chartData, xAxis, yAxis, renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
plot.setRangeGridlinesVisible(false);
plot.setNoDataMessage(TaskScheduleDialog.resources.getString("Chart.No_Data_Message"));
// create a chart and a chart panel
JFreeChart chart = new JFreeChart(plot);
chart.removeLegend();
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setInitialDelay(50);
chartPanel.setDismissDelay(60000);
chartPanel.setMinimumDrawHeight(40);
chartPanel.setMinimumDrawWidth(40);
chartPanel.setMaximumDrawHeight(3000);
chartPanel.setMaximumDrawWidth(3000);
chartPanel.setPreferredSize(new Dimension(300, gridY * 25));
// add the chart to the dialog content pane
GridBagConstraints c = new GridBagConstraints();
c.gridy = gridY;
c.gridwidth = 4;
c.weightx = 2;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 0, 0, 0);
panel.add(chartPanel, c);
// colors with the schedule rows so they can act as a legend
for (int i = scheduleRows.size(); i-- > 0; ) {
ScheduleTableRow oneRow = scheduleRows.get(i);
oneRow.addColoredIcon(renderer.lookupSeriesPaint(i));
}
}
use of org.jfree.chart.plot.XYPlot in project processdash by dtuma.
the class EstErrorScatterChart method createChart.
@Override
public JFreeChart createChart() {
JFreeChart chart = super.createChart();
// set minimum/maximum bounds on the two axes
XYPlot xyPlot = chart.getXYPlot();
double cutoff = getPercentParam("cut", 100, 200, 5000);
xyPlot.setDomainAxis(truncAxis(xyPlot.getDomainAxis(), cutoff));
xyPlot.setRangeAxis(truncAxis(xyPlot.getRangeAxis(), cutoff));
xyPlot.setRenderer(new TruncatedItemRenderer(xyPlot.getRenderer()));
// add a box illustrating the target range
if (data.numRows() > 0) {
double box = getPercentParam("pct", 0, 50, 100);
xyPlot.addAnnotation(new XYBoxAnnotation(-box, -box, box, box));
xyPlot.addAnnotation(new XYLineAnnotation(-box, 0, box, 0));
xyPlot.addAnnotation(new XYLineAnnotation(0, -box, 0, box));
}
return chart;
}
Aggregations