Search in sources :

Example 46 with JFreeChart

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

the class VolumeInformationEditor method createChart.

/**
	 *
	 * Create jfreechart
	 *
	 * @param dataset DefaultPieDataset
	 * @return JFreeChart
	 */
private static JFreeChart createChart(DefaultPieDataset dataset) {
    JFreeChart chart = // chart
    ChartFactory.createPieChart3D(// chart
    "", // data
    dataset, // include legend
    true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new java.awt.Font("SansSerif", java.awt.Font.PLAIN, 12));
    plot.setDirection(Rotation.ANTICLOCKWISE);
    plot.setCircular(false);
    plot.setLabelLinkMargin(0.0);
    plot.setLabelGap(0.0);
    plot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    plot.setOutlinePaint(ChartColor.VERY_DARK_BLUE);
    plot.setLabelGenerator(null);
    plot.setLabelLinksVisible(false);
    plot.setLegendLabelGenerator(new org.jfree.chart.labels.StandardPieSectionLabelGenerator("{0}:{1} Mbyte", new DecimalFormat("0.00"), new DecimalFormat("0.00")));
    plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}={1}Mbyte {2}", new DecimalFormat("0.00"), new DecimalFormat("0.00%")));
    // plot.setSectionPaint("", SWTResourceManager.getColor(230, 230, 230));
    Color[] colors = { new Color(235, 139, 82), new Color(119, 119, 253) };
    PieRenderer renderer = new PieRenderer(colors);
    renderer.setColor(plot, dataset);
    return chart;
}
Also used : PiePlot3D(org.jfree.chart.plot.PiePlot3D) StandardPieToolTipGenerator(org.jfree.chart.labels.StandardPieToolTipGenerator) DecimalFormat(java.text.DecimalFormat) Color(java.awt.Color) ChartColor(org.jfree.chart.ChartColor) PieRenderer(com.cubrid.cubridmanager.ui.cubrid.database.control.PieRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 47 with JFreeChart

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

the class VolumeFolderInfoEditor method createChart.

/**
	 *
	 * Creates a chart.
	 *
	 * @param dataset DefaultPieDataset
	 * @param dbSpaceInfo DbSpaceInfo
	 * @return jFreeChart
	 */
private static JFreeChart createChart(DefaultPieDataset dataset, DbSpaceInfo dbSpaceInfo) {
    JFreeChart chart = ChartFactory.createPieChart3D(// chart
    dbSpaceInfo.getSpacename() + " Chart", // data
    dataset, // include legend
    true, true, false);
    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new java.awt.Font("SansSerif", java.awt.Font.PLAIN, 12));
    plot.setDirection(Rotation.ANTICLOCKWISE);
    plot.setCircular(false);
    plot.setLabelLinkMargin(0.0);
    plot.setLabelGap(0.0);
    plot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    plot.setOutlinePaint(ChartColor.VERY_DARK_BLUE);
    plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0}={1} pages {2}", new DecimalFormat("00.0"), new DecimalFormat("0.00%")));
    // plot.setSectionPaint("", SWTResourceManager.getColor(230, 230, 230));
    Color[] colors = { new Color(235, 139, 82), new Color(119, 119, 253) };
    PieRenderer renderer = new PieRenderer(colors);
    renderer.setColor(plot, dataset);
    return chart;
}
Also used : PiePlot3D(org.jfree.chart.plot.PiePlot3D) StandardPieToolTipGenerator(org.jfree.chart.labels.StandardPieToolTipGenerator) DecimalFormat(java.text.DecimalFormat) Color(java.awt.Color) ChartColor(org.jfree.chart.ChartColor) PieRenderer(com.cubrid.cubridmanager.ui.cubrid.database.control.PieRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 48 with JFreeChart

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

the class DbDashboardHistoryViewPart 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(true);
    xyplot.getRangeAxis().setVisible(true);
    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) TreeMap(java.util.TreeMap)

Example 49 with JFreeChart

use of org.jfree.chart.JFreeChart 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 50 with JFreeChart

use of org.jfree.chart.JFreeChart 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)

Aggregations

JFreeChart (org.jfree.chart.JFreeChart)178 XYPlot (org.jfree.chart.plot.XYPlot)40 NumberAxis (org.jfree.chart.axis.NumberAxis)26 Color (java.awt.Color)22 DateAxis (org.jfree.chart.axis.DateAxis)21 DecimalFormat (java.text.DecimalFormat)18 ChartPanel (org.jfree.chart.ChartPanel)17 XYSeries (org.jfree.data.xy.XYSeries)17 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)17 RectangleInsets (org.jfree.ui.RectangleInsets)17 NumberFormat (java.text.NumberFormat)16 CategoryAxis (org.jfree.chart.axis.CategoryAxis)16 CategoryPlot (org.jfree.chart.plot.CategoryPlot)16 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)13 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)13 HashMap (java.util.HashMap)12 ValueAxis (org.jfree.chart.axis.ValueAxis)12 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)11 CategoryDataset (org.jfree.data.category.CategoryDataset)11 Paint (java.awt.Paint)10