Search in sources :

Example 6 with XYPlot

use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.

the class DatabaseDashboardViewPart method loadDatabaseChart.

/**
	 * Load an instance of ChartCompositePart stand for database monitor info
	 *
	 * @param parent an instance of Composite
	 */
private void loadDatabaseChart(Composite parent) {
    dbStatComp = new Composite(parent, SWT.NULL);
    dbStatComp.setLayout(new GridLayout());
    dbStatComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group dbGrp = new Group(dbStatComp, SWT.NONE);
    dbGrp.setText(Messages.dbDatabaseStatusSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    dbGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    dbGrp.setLayoutData(gridData);
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = convertMapKey(dbStatDumpData.getDiagStatusResultMap());
    dbStatChartPart = new ChartCompositePart(dbGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = dbStatChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
    }
    dbStatChartPart.loadContent();
    JFreeChart chart = (JFreeChart) dbStatChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) dbStatChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(false);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 7 with XYPlot

use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.

the class DatabaseDashboardViewPart method fireChartSetting.

/**
	 * This method is responsible for preparing data for ChartSettingDlg and
	 * dealing with the results of chartSettingDlg
	 *
	 */
private void fireChartSetting() {
    ChartSettingDlg chartSettingDlg = new ChartSettingDlg(composite.getShell());
    chartSettingDlg.setHasTitlSetting(false);
    chartSettingDlg.setHasHistoryPath(true);
    chartSettingDlg.setHasAxisSetting(false);
    chartSettingDlg.setHasChartSelection(true);
    // plot appearance
    XYPlot dbStatplot = dbStatChartPart.getChart().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);
    // series
    chartSettingDlg.setSettingMap(dbStatChartPart.getSettingMap());
    // history path
    chartSettingDlg.setHistoryPath(historyPath);
    chartSettingDlg.setHistoryFileName(historyFileName);
    // 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();
        JFreeChart delayBarChart = delayChart.getBarChart();
        Plot delayBarPlot = delayBarChart.getPlot();
        XYPlot delaySeriesPlot = (XYPlot) delayChart.getSeriesChart().getPlot();
        JFreeChart countBarChart = countChart.getBarChart();
        Plot countBarPlot = countBarChart.getPlot();
        XYPlot countSeriesPlot = (XYPlot) countChart.getSeriesChart().getPlot();
        // history path
        String newHistoryPath = chartSettingDlg.getHistoryPath();
        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);
        //delayChart
        delayBarPlot.setBackgroundPaint(bgColor);
        delayBarChart.setBackgroundPaint(bgColor);
        delaySeriesPlot.setBackgroundPaint(bgColor);
        //countChart;
        countBarPlot.setBackgroundPaint(bgColor);
        countBarChart.setBackgroundPaint(bgColor);
        countSeriesPlot.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);
        //delayChart
        delaySeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //countChart;
        countSeriesPlot.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);
        //delayChart
        delaySeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //countChart;
        countSeriesPlot.setRangeGridlinePaint(rangeGridColor);
        dbStatChartPart.setSettingMap(chartSettingDlg.getSettingMap());
        dbStatChartPart.updateSettingSeries();
        //chart Selection
        fireChartSelection(chartSettingDlg.getChartSelectionLst());
    }
}
Also used : ChartSettingDlg(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg) XYPlot(org.jfree.chart.plot.XYPlot) XYPlot(org.jfree.chart.plot.XYPlot) Plot(org.jfree.chart.plot.Plot) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) JFreeChart(org.jfree.chart.JFreeChart)

Example 8 with XYPlot

use of org.jfree.chart.plot.XYPlot in project cubrid-manager by CUBRID.

the class HostDashboardHistoryViewPart method loadBrokerChart.

/**
	 * Load an instance of ChartCompositePart stand for broker monitor info
	 *
	 * @param parent the instance of Composite
	 */
private void loadBrokerChart(Composite parent) {
    brokerComp = new Composite(parent, SWT.NULL);
    brokerComp.setLayout(new GridLayout());
    brokerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group brokerGrp = new Group(brokerComp, SWT.NONE);
    brokerGrp.setText(Messages.hostBrokerSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    brokerGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    brokerGrp.setLayoutData(gridData);
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    brokerChartPart = new ChartCompositePart(brokerGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = brokerChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.BROKER);
    }
    brokerChartPart.loadContent();
    JFreeChart chart = (JFreeChart) brokerChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) brokerChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 9 with XYPlot

use of org.jfree.chart.plot.XYPlot in project qpid-broker-j by apache.

the class ChartProductionTest method assertChartTitlesAndWriteToFile.

private void assertChartTitlesAndWriteToFile(ChartBuilder builder) {
    JFreeChart chart = builder.buildChart(_chartingDefinition);
    assertEquals(TEST_CHARTTITLE, chart.getTitle().getText());
    assertEquals(TEST_CHARTSUBTITLE, ((ShortTextTitle) chart.getSubtitle(1)).getText());
    assertEquals(TEST_SERIESLEGEND, chart.getPlot().getLegendItems().get(0).getLabel());
    if (chart.getPlot() instanceof XYPlot) {
        assertEquals(1, chart.getXYPlot().getDatasetCount());
    } else {
        assertEquals(1, chart.getCategoryPlot().getDatasetCount());
    }
    _writer.writeChartToFileSystem(chart, _chartingDefinition);
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) JFreeChart(org.jfree.chart.JFreeChart)

Example 10 with XYPlot

use of org.jfree.chart.plot.XYPlot in project jgnash by ccavanaugh.

the class MonthlyAccountBalanceChart method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(Account a) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a);
    DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    // if (a.getTransactionCount() > 0) {
    Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
    Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
    dateAxis.setRange(start, end);
    // }
    NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    XYBarRenderer renderer = new XYBarRenderer(0.2);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

XYPlot (org.jfree.chart.plot.XYPlot)160 JFreeChart (org.jfree.chart.JFreeChart)98 NumberAxis (org.jfree.chart.axis.NumberAxis)49 Color (java.awt.Color)43 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)35 ValueAxis (org.jfree.chart.axis.ValueAxis)34 DateAxis (org.jfree.chart.axis.DateAxis)33 XYDataset (org.jfree.data.xy.XYDataset)30 SimpleDateFormat (java.text.SimpleDateFormat)22 XYSeries (org.jfree.data.xy.XYSeries)22 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)21 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)21 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)18 BasicStroke (java.awt.BasicStroke)16 Font (java.awt.Font)16 ChartPanel (org.jfree.chart.ChartPanel)16 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)16 DecimalFormat (java.text.DecimalFormat)13 Map (java.util.Map)13 LegendTitle (org.jfree.chart.title.LegendTitle)13