Search in sources :

Example 11 with XYPlot

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

the class MonthlyAccountBalanceChartCompare method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a, a2);
    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") + "-" + a.getCurrencyNode().getSymbol());
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title;
    if (jcb_compare.isSelected()) {
        title = a.getPathName() + " vs " + a2.getPathName();
    } else {
        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) ClusteredXYBarRenderer(org.jfree.chart.renderer.xy.ClusteredXYBarRenderer) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart)

Example 12 with XYPlot

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

the class RunningAccountBalanceChart 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);
    LocalDate start = DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate());
    LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
    dateAxis.setRange(DateUtils.asDate(start), DateUtils.asDate(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.EndMonthBalance") + " - " + 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) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 13 with XYPlot

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

the class SecurityHighLowChart method createHighLowChart.

private static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, AbstractXYDataset data, boolean legend) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    HighLowRenderer renderer = new HighLowRenderer();
    renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
    XYPlot plot = new XYPlot(data, timeAxis, valueAxis, renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) HighLowItemLabelGenerator(org.jfree.chart.labels.HighLowItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) HighLowRenderer(org.jfree.chart.renderer.xy.HighLowRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 14 with XYPlot

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

the class HostDashboardViewPart 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 cpuSeriesPlot = cpuChart.getSeriesChart().getXYPlot();
    String plotBgColor = trimPaintColor(cpuSeriesPlot.getBackgroundPaint().toString());
    String plotDomainGridColor = trimPaintColor(cpuSeriesPlot.getDomainGridlinePaint().toString());
    String plotRangGridColor = trimPaintColor(cpuSeriesPlot.getRangeGridlinePaint().toString());
    chartSettingDlg.setPlotBgColor(plotBgColor);
    chartSettingDlg.setPlotDomainGridColor(plotDomainGridColor);
    chartSettingDlg.setPlotRangGridColor(plotRangGridColor);
    // series
    if (brokerChartPart == null) {
        chartSettingDlg.setHasSeriesItemSetting(false);
    } else {
        chartSettingDlg.setHasSeriesItemSetting(true);
        chartSettingDlg.setSettingMap(brokerChartPart.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();
        JFreeChart memoryBarChart = memoryChart.getBarChart();
        Plot memoryBarPlot = memoryBarChart.getPlot();
        XYPlot memorySeriesPlot = (XYPlot) memoryChart.getSeriesChart().getPlot();
        JFreeChart iowaitBarChart = iowaitChart.getBarChart();
        Plot iowaitBarPlot = iowaitBarChart.getPlot();
        XYPlot iowaitSeriesPlot = (XYPlot) iowaitChart.getSeriesChart().getPlot();
        // history path
        String newHistoryPath = chartSettingDlg.getHistoryPath();
        isChangedHistoryPath = historyPath.equals(newHistoryPath) ? false : true;
        if (isChangedHistoryPath) {
            historyPath = newHistoryPath;
            historyFileHelp.setChangedHistoryPath(true);
            historyFileHelp.setHistoryPath(historyPath);
        }
        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);
        //cpu chart
        cpuBarChart.setBackgroundPaint(bgColor);
        cpuBarPlot.setBackgroundPaint(bgColor);
        cpuSeriesPlot.setBackgroundPaint(bgColor);
        //memoryChart
        memoryBarPlot.setBackgroundPaint(bgColor);
        memoryBarChart.setBackgroundPaint(bgColor);
        memorySeriesPlot.setBackgroundPaint(bgColor);
        //iowaitChart
        iowaitBarPlot.setBackgroundPaint(bgColor);
        iowaitBarChart.setBackgroundPaint(bgColor);
        iowaitSeriesPlot.setBackgroundPaint(bgColor);
        //DomainGridColor
        //broker Chart
        red = getColorElem(plotDomainGridColor, 0);
        green = getColorElem(plotDomainGridColor, 1);
        blue = getColorElem(plotDomainGridColor, 2);
        Color domainGridlineColor = new Color(red, green, blue);
        //cpu chart
        cpuSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //memoryChart
        memorySeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //delayChart
        iowaitSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //RangeGridColor
        red = getColorElem(plotRangGridColor, 0);
        green = getColorElem(plotRangGridColor, 1);
        blue = getColorElem(plotRangGridColor, 2);
        Color rangeGridColor = new Color(red, green, blue);
        //cpu chart
        cpuSeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //memoryChart
        memorySeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //delayChart
        iowaitSeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //broker Chart;
        if (brokerChartPart != null) {
            XYPlot brokerPlot = brokerChartPart.getChart().getXYPlot();
            brokerPlot.setBackgroundPaint(bgColor);
            brokerPlot.setDomainGridlinePaint(domainGridlineColor);
            brokerPlot.setRangeGridlinePaint(rangeGridColor);
            brokerChartPart.setSettingMap(chartSettingDlg.getSettingMap());
            brokerChartPart.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 15 with XYPlot

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

the class BrokerStatusHistoryViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 * 
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    final HistoryComposite historyComposite = new HistoryComposite();
    historyComposite.loadTimeSelection(composite);
    Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    ICubridNode selection = getCubridNode();
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    chartPart = new ChartCompositePart(composite, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = chartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
    }
    chartPart.setChartTitle(Messages.brokerHistoryChartTtl);
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    chartPart.setHistoryFileName(historyFileName);
    IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
    String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
    chartPart.setHistoryPath(sHistoryPath);
    chartPart.loadContent();
    chartPart.addChartMouseListener();
    makeActions();
    historyComposite.getQueryBtn().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent ex) {
            String date = historyComposite.getDate();
            String fromTime = historyComposite.getFromTime();
            String toTime = historyComposite.getToTime();
            // check date/fromTime/toTime
            boolean timeOrder = historyComposite.checkTime(date, fromTime, toTime);
            if (!timeOrder) {
                CommonUITool.openErrorBox(Messages.errBrokerHistorySettingTime);
                return;
            }
            String[] ymd = date.split("-");
            int year = Integer.valueOf(ymd[0]);
            int month = Integer.valueOf(ymd[1]);
            int day = Integer.valueOf(ymd[2]);
            String[] fromHms = fromTime.split(":");
            int fromHour = Integer.valueOf(fromHms[0]);
            int fromMinute = Integer.valueOf(fromHms[1]);
            int fromSecond = Integer.valueOf(fromHms[2]);
            Calendar calFrom = Calendar.getInstance();
            calFrom.set(year, month, day, fromHour, fromMinute, fromSecond);
            final long millisFrom = calFrom.getTimeInMillis();
            String[] toHms = toTime.split(":");
            int toHour = Integer.valueOf(toHms[0]);
            int toMinute = Integer.valueOf(toHms[1]);
            int toSecond = Integer.valueOf(toHms[2]);
            Calendar calTo = Calendar.getInstance();
            calTo.set(year, month, day, toHour, toMinute, toSecond);
            final long millisTo = calTo.getTimeInMillis();
            XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
            plot.getDomainAxis().setRange(millisFrom, millisTo);
            final CounterFile countFile = chartPart.openHistoryFile();
            if (countFile == null) {
                return;
            }
            final List<String> types = new ArrayList<String>();
            for (BrokerDiagEnum enumeration : BrokerDiagEnum.values()) {
                String type = enumeration.getName();
                types.add(type);
            }
            chartPart.executeQueryWithBusyCursor(countFile, types, millisFrom, millisTo);
            try {
                countFile.close();
            } catch (IOException e1) {
                LOGGER.error(e1.getMessage());
            }
        }

        public void widgetSelected(SelectionEvent ex) {
            widgetDefaultSelected(ex);
        }
    });
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Label(org.eclipse.swt.widgets.Label) BrokerDiagEnum(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagEnum) GridLayout(org.eclipse.swt.layout.GridLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) Calendar(java.util.Calendar) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IOException(java.io.IOException) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) XYPlot(org.jfree.chart.plot.XYPlot) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) GridData(org.eclipse.swt.layout.GridData) Map(java.util.Map) TreeMap(java.util.TreeMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

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