Example usage for org.jfree.chart.axis DateAxis setTickLabelFont

List of usage examples for org.jfree.chart.axis DateAxis setTickLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateAxis setTickLabelFont.

Prototype

public void setTickLabelFont(Font font) 

Source Link

Document

Sets the font for the tick labels and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:daylightchart.daylightchart.chart.DaylightChart.java

@SuppressWarnings("deprecation")
private void createMonthsAxis(final XYPlot plot) {
    final DateAxis axis = new DateAxis();
    axis.setTickMarkPosition(DateTickMarkPosition.START);
    axis.setLowerMargin(0.0f);//from  w ww .  jav a  2 s  .  c o  m
    axis.setUpperMargin(0.0f);
    axis.setTickLabelFont(ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12));
    axis.setDateFormatOverride(ChartConfiguration.monthsFormat);
    axis.setVerticalTickLabels(true);
    axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1), true, true);
    // Fix the axis range for all the months in the year
    final int dateYear = riseSetData.getYear() - 1900;
    axis.setRange(new Date(dateYear, 0, 1), new Date(dateYear, 11, 31));
    //
    plot.setDomainAxis(axis);
}

From source file:com.mothsoft.alexis.web.ChartServlet.java

private void doLineGraph(final HttpServletRequest request, final HttpServletResponse response,
        final String title, final String[] dataSetIds, final Integer width, final Integer height,
        final Integer numberOfSamples) throws ServletException, IOException {

    final DataSetService dataSetService = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext()).getBean(DataSetService.class);

    final OutputStream out = response.getOutputStream();
    response.setContentType("image/png");
    response.setHeader("Cache-Control", "max-age: 5; must-revalidate");

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();

    final DateAxis dateAxis = new DateAxis(title != null ? title : "Time");
    final DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1);
    final DateFormat chartFormatter = new SimpleDateFormat("ha");
    dateAxis.setDateFormatOverride(chartFormatter);
    dateAxis.setTickUnit(unit);/*from  w  w  w  .  j a  v a  2 s . c  om*/
    dateAxis.setLabelFont(DEFAULT_FONT);
    dateAxis.setTickLabelFont(DEFAULT_FONT);

    if (numberOfSamples > 12) {
        dateAxis.setTickLabelFont(
                new Font(DEFAULT_FONT.getFamily(), Font.PLAIN, (int) (DEFAULT_FONT.getSize() * .8)));
    }

    final NumberAxis yAxis = new NumberAxis("Activity");

    final StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);

    int colorCounter = 0;

    if (dataSetIds != null) {
        for (final String dataSetIdString : dataSetIds) {
            final Long dataSetId = Long.valueOf(dataSetIdString);
            final DataSet dataSet = dataSetService.get(dataSetId);

            // go back for numberOfSamples, but include current hour
            final Calendar calendar = new GregorianCalendar();
            calendar.add(Calendar.HOUR_OF_DAY, -1 * (numberOfSamples - 1));
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            final Timestamp startDate = new Timestamp(calendar.getTimeInMillis());

            calendar.add(Calendar.HOUR_OF_DAY, numberOfSamples);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MILLISECOND, 999);
            final Timestamp endDate = new Timestamp(calendar.getTimeInMillis());

            logger.debug(String.format("Generating chart for period: %s to %s", startDate.toString(),
                    endDate.toString()));

            final List<DataSetPoint> dataSetPoints = dataSetService
                    .findAndAggregatePointsGroupedByUnit(dataSetId, startDate, endDate, TimeUnits.HOUR);

            final boolean hasData = addSeries(seriesCollection, dataSet.getName(), dataSetPoints, startDate,
                    numberOfSamples, renderer);

            if (dataSet.isAggregate()) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.BLACK);
            } else if (hasData) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1,
                        PAINTS[colorCounter++ % PAINTS.length]);
            } else {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.LIGHT_GRAY);
            }
        }
    }

    final XYPlot plot = new XYPlot(seriesCollection, dateAxis, yAxis, renderer);

    // create the chart...
    final JFreeChart chart = new JFreeChart(plot);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    plot.setBackgroundPaint(new Color(253, 253, 253));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(DEFAULT_FONT);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0.00d);

    ChartUtilities.writeChartAsPNG(out, chart, width, height);
}

From source file:AtomPanel.java

private void initJFreeChart() {
    this.numOfStream = numOfStream;

    datasets = new TimeSeriesCollection();
    trend = new TimeSeriesCollection();
    projpcs = new TimeSeriesCollection();
    spe = new TimeSeriesCollection();

    for (int i = 0; i < MaxNumOfStream; i++) {
        //add streams
        TimeSeries timeseries = new TimeSeries("Stream " + i, Millisecond.class);
        datasets.addSeries(timeseries);/*ww  w. j  a v a  2 s . c  om*/
        timeseries.setHistoryCount(historyRange);
        //add trend variables
        TimeSeries trendSeries = new TimeSeries("Trend " + i, Millisecond.class);
        trend.addSeries(trendSeries);
        trendSeries.setHistoryCount(historyRange);
        //add proj onto PCs variables
        TimeSeries PC = new TimeSeries("Projpcs " + i, Millisecond.class);
        projpcs.addSeries(PC);
        PC.setHistoryCount(historyRange);
        //add spe streams
        TimeSeries speSeries = new TimeSeries("Spe " + i, Millisecond.class);
        spe.addSeries(speSeries);
        speSeries.setHistoryCount(historyRange);
    }
    combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Time"));
    //data stream  plot
    DateAxis domain = new DateAxis("Time");
    NumberAxis range = new NumberAxis("Streams");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setItemLabelsVisible(false);
    renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot = new XYPlot(datasets, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot);

    //Trend captured by pca
    DateAxis domain0 = new DateAxis("Time");
    NumberAxis range0 = new NumberAxis("PCA Trend");
    domain0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range0.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain0.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range0.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer0 = new DefaultXYItemRenderer();
    renderer0.setItemLabelsVisible(false);
    renderer0.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer0.setSeriesPaint(0, Color.blue);
    renderer0.setSeriesPaint(1, Color.red);
    renderer0.setSeriesPaint(2, Color.magenta);
    XYPlot plot0 = new XYPlot(trend, domain0, range0, renderer0);
    plot0.setBackgroundPaint(Color.lightGray);
    plot0.setDomainGridlinePaint(Color.white);
    plot0.setRangeGridlinePaint(Color.white);
    plot0.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain0.setAutoRange(true);
    domain0.setLowerMargin(0.0);
    domain0.setUpperMargin(0.0);
    domain0.setTickLabelsVisible(false);

    range0.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot0);

    //proj on PCs plot
    DateAxis domain1 = new DateAxis("Time");
    NumberAxis range1 = new NumberAxis("Proj on PCs");
    domain1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain1.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range1.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    XYItemRenderer renderer1 = new DefaultXYItemRenderer();
    renderer1.setItemLabelsVisible(false);
    renderer1.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);
    renderer1.setSeriesPaint(1, Color.red);
    renderer1.setSeriesPaint(2, Color.magenta);
    plot1 = new XYPlot(projpcs, domain1, range1, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);
    plot1.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain1.setAutoRange(true);
    domain1.setLowerMargin(0.0);
    domain1.setUpperMargin(0.0);
    domain1.setTickLabelsVisible(false);

    range1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot1);

    //spe  plot
    DateAxis domain2 = new DateAxis("Time");
    NumberAxis range2 = new NumberAxis("SPE");
    domain2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range2.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range2.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));

    XYItemRenderer renderer2 = new DefaultXYItemRenderer();
    renderer2.setItemLabelsVisible(false);
    renderer2.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    XYPlot plot2 = new XYPlot(spe, domain2, range2, renderer);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);
    plot2.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    domain2.setAutoRange(true);
    domain2.setLowerMargin(0.0);
    domain2.setUpperMargin(0.0);
    domain2.setTickLabelsVisible(true);

    range2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    combineddomainxyplot.add(plot2);

    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(historyRange); // 60 seconds
    JFreeChart chart;
    if (this.pcaType == AtomUtils.PCAType.pca)
        chart = new JFreeChart("CloudWatch-ATOM with Exact Data", new Font("SansSerif", Font.BOLD, 18),
                combineddomainxyplot, false);
    else if (this.pcaType == AtomUtils.PCAType.pcaTrack)
        chart = new JFreeChart("CloudWatch-ATOM with Fixed Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    else
        chart = new JFreeChart("CloudWatch-ATOM with Dynamic Tracking Threshold",
                new Font("SansSerif", Font.BOLD, 18), combineddomainxyplot, false);
    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    AtomPanel.this.add(chartPanel, BorderLayout.CENTER);
}

From source file:com.rapidminer.gui.plotter.charts.SeriesChartPlotter.java

@Override
protected void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {//from   www  .j  a v  a 2s . c o m
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    JFreeChart chart = createChart(this.dataset, createLegend);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // domain axis
    if (axis[INDEX] >= 0) {
        if (!dataTable.isNominal(axis[INDEX])) {
            if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
                DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
                domainAxis.setTimeZone(Tools.getPreferredTimeZone());
                chart.getXYPlot().setDomainAxis(domainAxis);
                if (getRangeForDimension(axis[INDEX]) != null) {
                    domainAxis.setRange(getRangeForDimension(axis[INDEX]));
                }
                domainAxis.setLabelFont(LABEL_FONT_BOLD);
                domainAxis.setTickLabelFont(LABEL_FONT);
                domainAxis.setVerticalTickLabels(isLabelRotating());
            }
        } else {
            LinkedHashSet<String> values = new LinkedHashSet<String>();
            for (DataTableRow row : dataTable) {
                String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
                if (stringValue.length() > 40) {
                    stringValue = stringValue.substring(0, 40);
                }
                values.add(stringValue);
            }
            ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
                    values.toArray(new String[values.size()]));
            categoryAxis.setLabelFont(LABEL_FONT_BOLD);
            categoryAxis.setTickLabelFont(LABEL_FONT);
            categoryAxis.setVerticalTickLabels(isLabelRotating());
            chart.getXYPlot().setDomainAxis(categoryAxis);
        }
    }

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:org.mwc.debrief.track_shift.views.BaseStackedDotsView.java

/**
 * method to create a working plot (to contain our data)
 * /*ww w .  j  a v a 2s . c  om*/
 * @return the chart, in it's own panel
 */
@SuppressWarnings("deprecation")
protected void createStackedPlot() {

    // first create the x (time) axis
    final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss");
    _df.setTimeZone(TimeZone.getTimeZone("GMT"));

    final DateAxis xAxis = new CachedTickDateAxis("");
    xAxis.setDateFormatOverride(_df);
    Font tickLabelFont = new Font("Courier", Font.PLAIN, 13);
    xAxis.setTickLabelFont(tickLabelFont);
    xAxis.setTickLabelPaint(Color.BLACK);

    xAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits());
    xAxis.setAutoTickUnitSelection(true);

    // create the special stepper plot
    _dotPlot = new XYPlot();
    NumberAxis errorAxis = new NumberAxis("Error (" + getUnits() + ")");
    Font axisLabelFont = new Font("Courier", Font.PLAIN, 16);
    errorAxis.setLabelFont(axisLabelFont);
    errorAxis.setTickLabelFont(tickLabelFont);
    _dotPlot.setRangeAxis(errorAxis);
    _dotPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    _dotPlot.setRenderer(new ColourStandardXYItemRenderer(null, null, _dotPlot));

    _dotPlot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    _dotPlot.setRangeGridlineStroke(new BasicStroke(2));
    _dotPlot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    _dotPlot.setDomainGridlineStroke(new BasicStroke(2));

    // now try to do add a zero marker on the error bar
    final Paint thePaint = Color.DARK_GRAY;
    final Stroke theStroke = new BasicStroke(3);
    final ValueMarker zeroMarker = new ValueMarker(0.0, thePaint, theStroke);
    _dotPlot.addRangeMarker(zeroMarker);

    _linePlot = new XYPlot();
    final NumberAxis absBrgAxis = new NumberAxis("Absolute (" + getUnits() + ")");
    absBrgAxis.setLabelFont(axisLabelFont);
    absBrgAxis.setTickLabelFont(tickLabelFont);
    _linePlot.setRangeAxis(absBrgAxis);
    absBrgAxis.setAutoRangeIncludesZero(false);
    _linePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    final DefaultXYItemRenderer lineRend = new ColourStandardXYItemRenderer(null, null, _linePlot);
    lineRend.setPaint(Color.DARK_GRAY);
    _linePlot.setRenderer(lineRend);

    _linePlot.setDomainCrosshairVisible(true);
    _linePlot.setRangeCrosshairVisible(true);
    _linePlot.setDomainCrosshairPaint(Color.GRAY);
    _linePlot.setRangeCrosshairPaint(Color.GRAY);
    _linePlot.setDomainCrosshairStroke(new BasicStroke(3.0f));
    _linePlot.setRangeCrosshairStroke(new BasicStroke(3.0f));

    _linePlot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    _linePlot.setRangeGridlineStroke(new BasicStroke(2));
    _linePlot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    _linePlot.setDomainGridlineStroke(new BasicStroke(2));

    // and the plot object to display the cross hair value
    final XYTextAnnotation annot = new XYTextAnnotation("-----", 2, 2);
    annot.setTextAnchor(TextAnchor.TOP_LEFT);

    Font annotationFont = new Font("Courier", Font.BOLD, 16);
    annot.setFont(annotationFont);
    annot.setPaint(Color.DARK_GRAY);
    annot.setBackgroundPaint(Color.white);
    _linePlot.addAnnotation(annot);

    // give them a high contrast backdrop
    _dotPlot.setBackgroundPaint(Color.white);
    _linePlot.setBackgroundPaint(Color.white);

    // set the y axes to autocalculate
    _dotPlot.getRangeAxis().setAutoRange(true);
    _linePlot.getRangeAxis().setAutoRange(true);

    _combined = new CombinedDomainXYPlot(xAxis);

    _combined.add(_linePlot);
    _combined.add(_dotPlot);

    _combined.setOrientation(PlotOrientation.HORIZONTAL);

    // put the plot into a chart
    _myChart = new JFreeChart(null, null, _combined, true);

    final LegendItemSource[] sources = { _linePlot };
    _myChart.getLegend().setSources(sources);

    _myChart.addProgressListener(new ChartProgressListener() {
        public void chartProgress(final ChartProgressEvent cpe) {
            if (cpe.getType() != ChartProgressEvent.DRAWING_FINISHED)
                return;

            // is hte line plot visible?
            if (!_showLinePlot.isChecked())
                return;

            // double-check our label is still in the right place
            final double xVal = _linePlot.getRangeAxis().getLowerBound();
            final double yVal = _linePlot.getDomainAxis().getUpperBound();
            boolean annotChanged = false;
            if (annot.getX() != yVal) {
                annot.setX(yVal);
                annotChanged = true;
            }
            if (annot.getY() != xVal) {
                annot.setY(xVal);
                annotChanged = true;
            }
            // and write the text
            final String numA = MWC.Utilities.TextFormatting.GeneralFormat
                    .formatOneDecimalPlace(_linePlot.getRangeCrosshairValue());
            final Date newDate = new Date((long) _linePlot.getDomainCrosshairValue());
            final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss");
            _df.setTimeZone(TimeZone.getTimeZone("GMT"));
            final String dateVal = _df.format(newDate);
            final String theMessage = " [" + dateVal + "," + numA + "]";
            if (!theMessage.equals(annot.getText())) {
                annot.setText(theMessage);
                annotChanged = true;
            }
            if (annotChanged) {
                _linePlot.removeAnnotation(annot);
                _linePlot.addAnnotation(annot);
            }
        }
    });

    // and insert into the panel
    _holder.setChart(_myChart);

    // do a little tidying to reflect the memento settings
    if (!_showLinePlot.isChecked())
        _combined.remove(_linePlot);
    if (!_showDotPlot.isChecked() && _showLinePlot.isChecked())
        _combined.remove(_dotPlot);
}

From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java

public TrackerTab(Program program) {
    super(program, TabsTracker.get().title(), Images.TOOL_TRACKER.getIcon(), true);

    filterDialog = new TrackerFilterDialog(program);

    jPopupMenu = new JPopupMenu();
    jPopupMenu.addPopupMenuListener(listener);

    JMenuItem jMenuItem;/*from  www  .  ja  v a 2  s  . c  o m*/
    jMenuItem = new JMenuItem(TabsTracker.get().edit(), Images.EDIT_EDIT.getIcon());
    jMenuItem.setActionCommand(TrackerAction.EDIT.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    jMenuItem = new JMenuItem(TabsTracker.get().delete(), Images.EDIT_DELETE.getIcon());
    jMenuItem.setActionCommand(TrackerAction.DELETE.name());
    jMenuItem.addActionListener(listener);
    jPopupMenu.add(jMenuItem);

    JMenuInfo.createDefault(jPopupMenu);

    jIskValue = new JMenuItem();
    jIskValue.setEnabled(false);
    jIskValue.setForeground(Color.BLACK);
    jIskValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jIskValue.setDisabledIcon(Images.TOOL_VALUES.getIcon());
    jPopupMenu.add(jIskValue);

    jDateValue = new JMenuItem();
    jDateValue.setEnabled(false);
    jDateValue.setForeground(Color.BLACK);
    jDateValue.setHorizontalAlignment(SwingConstants.RIGHT);
    jPopupMenu.add(jDateValue);

    jEditDialog = new JTrackerEditDialog(program);

    jSelectionDialog = new JSelectionDialog(program);

    JSeparator jDateSeparator = new JSeparator();

    jQuickDate = new JComboBox<QuickDate>(QuickDate.values());
    jQuickDate.setActionCommand(TrackerAction.QUICK_DATE.name());
    jQuickDate.addActionListener(listener);

    JLabel jFromLabel = new JLabel(TabsTracker.get().from());
    jFrom = createDateChooser();

    JLabel jToLabel = new JLabel(TabsTracker.get().to());
    jTo = createDateChooser();

    jAll = new JCheckBox(General.get().all());
    jAll.setSelected(true);
    jAll.setActionCommand(TrackerAction.ALL.name());
    jAll.addActionListener(listener);
    jAll.setFont(new Font(jAll.getFont().getName(), Font.ITALIC, jAll.getFont().getSize()));

    jTotal = new JCheckBox(TabsTracker.get().total());
    jTotal.setSelected(true);
    jTotal.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jTotal.addActionListener(listener);

    jWalletBalance = new JCheckBox(TabsTracker.get().walletBalance());
    jWalletBalance.setSelected(true);
    jWalletBalance.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jWalletBalance.addActionListener(listener);

    jWalletBalanceFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jWalletBalanceFilters.setActionCommand(TrackerAction.FILTER_WALLET_BALANCE.name());
    jWalletBalanceFilters.addActionListener(listener);

    jAssets = new JCheckBox(TabsTracker.get().assets());
    jAssets.setSelected(true);
    jAssets.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jAssets.addActionListener(listener);

    jAssetsFilters = new JButton(Images.LOC_INCLUDE.getIcon());
    jAssetsFilters.setActionCommand(TrackerAction.FILTER_ASSETS.name());
    jAssetsFilters.addActionListener(listener);

    jSellOrders = new JCheckBox(TabsTracker.get().sellOrders());
    jSellOrders.setSelected(true);
    jSellOrders.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jSellOrders.addActionListener(listener);

    jEscrows = new JCheckBox(TabsTracker.get().escrows());
    jEscrows.setSelected(true);
    jEscrows.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrows.addActionListener(listener);

    jEscrowsToCover = new JCheckBox(TabsTracker.get().escrowsToCover());
    jEscrowsToCover.setSelected(true);
    jEscrowsToCover.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jEscrowsToCover.addActionListener(listener);

    jManufacturing = new JCheckBox(TabsTracker.get().manufacturing());
    jManufacturing.setSelected(true);
    jManufacturing.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jManufacturing.addActionListener(listener);

    jContractCollateral = new JCheckBox(TabsTracker.get().contractCollateral());
    jContractCollateral.setSelected(true);
    jContractCollateral.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractCollateral.addActionListener(listener);

    jContractValue = new JCheckBox(TabsTracker.get().contractValue());
    jContractValue.setSelected(true);
    jContractValue.setActionCommand(TrackerAction.UPDATE_SHOWN.name());
    jContractValue.addActionListener(listener);

    JSeparator jOwnersSeparator = new JSeparator();

    jAllProfiles = new JCheckBox(TabsTracker.get().allProfiles());
    jAllProfiles.setActionCommand(TrackerAction.PROFILE.name());
    jAllProfiles.addActionListener(listener);

    jOwners = new JMultiSelectionList<String>();
    jOwners.getSelectionModel().addListSelectionListener(listener);
    JScrollPane jOwnersScroll = new JScrollPane(jOwners);

    JLabel jHelp = new JLabel(TabsTracker.get().help());
    jHelp.setIcon(Images.MISC_HELP.getIcon());

    JLabel jNoFilter = new JLabel(TabsTracker.get().helpLegacyData());
    jNoFilter.setIcon(new ShapeIcon(NO_FILTER));

    JLabel jFilter = new JLabel(TabsTracker.get().helpNewData());
    jFilter.setIcon(new ShapeIcon(FILTER_AND_DEFAULT));

    JDropDownButton jSettings = new JDropDownButton(Images.DIALOG_SETTINGS.getIcon());

    jIncludeZero = new JCheckBoxMenuItem(TabsTracker.get().includeZero());
    jIncludeZero.setSelected(true);
    jIncludeZero.setActionCommand(TrackerAction.INCLUDE_ZERO.name());
    jIncludeZero.addActionListener(listener);
    jSettings.add(jIncludeZero);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setDateFormatOverride(dateFormat);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setAutoTickUnitSelection(true);
    domainAxis.setAutoRange(true);
    domainAxis.setTickLabelFont(jFromLabel.getFont());

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRange(true);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    rangeAxis.setTickLabelFont(jFromLabel.getFont());

    //XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, new XYLineAndShapeRenderer(true, true));
    render = new MyRender();
    XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, render);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.getRenderer()
            .setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {2} ({1})", dateFormat, iskFormat));
    plot.setDomainCrosshairLockedOnData(true);
    plot.setDomainCrosshairStroke(new BasicStroke(1));
    plot.setDomainCrosshairPaint(Color.BLACK);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);

    jNextChart = new JFreeChart(plot);
    jNextChart.setAntiAlias(true);
    jNextChart.setBackgroundPaint(jPanel.getBackground());
    jNextChart.addProgressListener(null);
    jNextChart.getLegend().setItemFont(jFrom.getFont());

    jChartPanel = new ChartPanel(jNextChart);
    jChartPanel.addMouseListener(listener);
    jChartPanel.setDomainZoomable(false);
    jChartPanel.setRangeZoomable(false);
    jChartPanel.setPopupMenu(null);
    jChartPanel.addChartMouseListener(listener);
    jChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    jChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    jChartPanel.setMinimumDrawWidth(10);
    jChartPanel.setMinimumDrawHeight(10);

    int AssetsGapWidth = PANEL_WIDTH - jAssets.getPreferredSize().width
            - jAssetsFilters.getPreferredSize().width;
    if (AssetsGapWidth < 0) {
        AssetsGapWidth = 0;
    }
    int WalletGapWidth = PANEL_WIDTH - jWalletBalance.getPreferredSize().width
            - jWalletBalanceFilters.getPreferredSize().width;
    if (WalletGapWidth < 0) {
        WalletGapWidth = 0;
    }

    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(jHelp).addGap(20).addComponent(jNoFilter)
                    .addGap(20).addComponent(jFilter).addGap(20, 20, Integer.MAX_VALUE).addComponent(jSettings)
                    .addGap(6))
            .addComponent(jChartPanel)).addGroup(
                    layout.createParallelGroup().addComponent(jQuickDate, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFromLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH)
                                            .addComponent(jToLabel, LABEL_WIDTH, LABEL_WIDTH, LABEL_WIDTH))
                                    .addGap(0)
                                    .addGroup(layout.createParallelGroup()
                                            .addComponent(jFrom, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)
                                            .addComponent(jTo, PANEL_WIDTH - LABEL_WIDTH,
                                                    PANEL_WIDTH - LABEL_WIDTH, PANEL_WIDTH - LABEL_WIDTH)))
                            .addComponent(jDateSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jTotal, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addGroup(layout.createSequentialGroup().addComponent(jWalletBalance)
                                    .addGap(0, 0, WalletGapWidth).addComponent(jWalletBalanceFilters))
                            .addGroup(layout.createSequentialGroup().addComponent(jAssets)
                                    .addGap(0, 0, AssetsGapWidth).addComponent(jAssetsFilters))
                            .addComponent(jSellOrders, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrows, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jEscrowsToCover, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jManufacturing, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractCollateral, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jContractValue, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersSeparator, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jAllProfiles, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)
                            .addComponent(jOwnersScroll, PANEL_WIDTH, PANEL_WIDTH, PANEL_WIDTH)));
    layout.setVerticalGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup()
                    .addComponent(jHelp, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jNoFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jFilter, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jSettings, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight()))
                    .addComponent(jChartPanel))
            .addGroup(layout.createSequentialGroup()
                    .addComponent(jQuickDate, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jFromLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jFrom, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jToLabel, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jTo, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight()))
                    .addComponent(jDateSeparator, 3, 3, 3)
                    .addComponent(jAll, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jTotal, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jWalletBalance, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight())
                            .addComponent(jWalletBalanceFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addGroup(layout.createParallelGroup()
                            .addComponent(jAssets, Program.getButtonsHeight(), Program.getButtonsHeight(),
                                    Program.getButtonsHeight())
                            .addComponent(jAssetsFilters, Program.getButtonsHeight(),
                                    Program.getButtonsHeight(), Program.getButtonsHeight()))
                    .addComponent(jSellOrders, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrows, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jEscrowsToCover, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jManufacturing, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractCollateral, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jContractValue, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersSeparator, 3, 3, 3)
                    .addComponent(jAllProfiles, Program.getButtonsHeight(), Program.getButtonsHeight(),
                            Program.getButtonsHeight())
                    .addComponent(jOwnersScroll, 70, 70, Integer.MAX_VALUE)));
}

From source file:interfaces.InterfazPrincipal.java

private void botonGenerarReporteClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGenerarReporteClienteActionPerformed
    // TODO add your handling code here:
    try {//from   w w  w . j av  a  2  s . c  om
        if (clienteReporteClienteFechaFinal.getSelectedDate().getTime()
                .compareTo(clienteReporteClienteFechaInicial.getSelectedDate().getTime()) < 0) {
            JOptionPane.showMessageDialog(this, "La fecha final debe ser posterior al dia de inicio");
        } else {
            final ArrayList<Integer> listaIDFlujos = new ArrayList<>();
            final JDialog dialogoEditar = new JDialog();
            dialogoEditar.setTitle("Reporte cliente");
            dialogoEditar.setSize(350, 610);
            dialogoEditar.setResizable(false);

            JPanel panelDialogo = new JPanel();
            panelDialogo.setLayout(new GridBagLayout());

            GridBagConstraints c = new GridBagConstraints();
            //c.fill = GridBagConstraints.HORIZONTAL;

            JLabel ediitarTextoPrincipalDialogo = new JLabel("Informe cliente");
            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 1;
            c.insets = new Insets(10, 45, 10, 10);
            Font textoGrande = new Font("Arial", 1, 18);
            ediitarTextoPrincipalDialogo.setFont(textoGrande);
            panelDialogo.add(ediitarTextoPrincipalDialogo, c);

            final JTable tablaDialogo = new JTable();
            DefaultTableModel modeloTabla = new DefaultTableModel() {

                @Override
                public boolean isCellEditable(int row, int column) {
                    //all cells false
                    return false;
                }
            };
            ;

            modeloTabla.addColumn("Factura");
            modeloTabla.addColumn("Tipo Flujo");
            modeloTabla.addColumn("Fecha");
            modeloTabla.addColumn("Valor");

            //Llenar tabla
            ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura();
            ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura(
                    " where factura_id in (select factura_id from Factura where cliente_id = "
                            + String.valueOf(jTextFieldIdentificacionClienteReporte.getText())
                            + ") order by factura_id");
            // {"flujo_id","factura_id","tipo_flujo","fecha","valor"};
            ArrayList<Calendar> fechasFlujos = new ArrayList<>();

            for (int i = 0; i < flujosCliente.size(); i++) {
                String fila[] = new String[4];
                String[] objeto = flujosCliente.get(i);
                fila[0] = objeto[1];
                fila[1] = objeto[2];
                fila[2] = objeto[3];
                fila[3] = objeto[4];

                //Filtrar, mirar las fechas
                String[] partirEspacios = objeto[3].split("\\s");
                //El primer string es la fecha sin hora
                //Ahora esparamos por -
                String[] tomarAgeMesDia = partirEspacios[0].split("-");

                //Realizar filtro
                int ageConsulta = Integer.parseInt(tomarAgeMesDia[0]);
                int mesConsulta = Integer.parseInt(tomarAgeMesDia[1]);
                int diaConsulta = Integer.parseInt(tomarAgeMesDia[2]);

                //Obtenemos dias, mes y ao de la consulta
                //Inicial
                int anioInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.YEAR);
                int mesInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.MONTH) + 1;
                int diaInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.DAY_OF_MONTH);
                //Final
                int anioFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.YEAR);
                int mesFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.MONTH) + 1;
                int diaFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.DAY_OF_MONTH);

                //Construir fechas
                Calendar fechaDeLaBD = new GregorianCalendar(ageConsulta, mesConsulta, diaConsulta);
                //Set year, month, day)

                Calendar fechaInicialRango = new GregorianCalendar(anioInicial, mesInicial, diaInicial);
                Calendar fechaFinalRango = new GregorianCalendar(anioFinal, mesFinal, diaFinal);

                if (fechaDeLaBD.compareTo(fechaInicialRango) <= 0
                        && fechaDeLaBD.compareTo(fechaFinalRango) >= 0) {
                    fechasFlujos.add(fechaDeLaBD);
                    modeloTabla.addRow(fila);
                }

            }

            if (modeloTabla.getRowCount() > 0) {
                tablaDialogo.setModel(modeloTabla);
                tablaDialogo.getColumn("Factura").setMinWidth(80);
                tablaDialogo.getColumn("Tipo Flujo").setMinWidth(80);
                tablaDialogo.getColumn("Fecha").setMinWidth(90);
                tablaDialogo.getColumn("Valor").setMinWidth(80);
                tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                JScrollPane scroll = new JScrollPane(tablaDialogo);
                scroll.setPreferredSize(new Dimension(330, 150));

                c.gridx = 0;
                c.gridy = 1;
                c.gridwidth = 1;
                c.insets = new Insets(0, 0, 0, 0);
                panelDialogo.add(scroll, c);

                TimeSeries localTimeSeries = new TimeSeries("Compras del cliente en el periodo");

                Map listaAbonos = new HashMap();

                for (int i = 0; i < modeloTabla.getRowCount(); i++) {
                    listaIDFlujos.add(Integer.parseInt(flujosCliente.get(i)[0]));

                    if (modeloTabla.getValueAt(i, 1).equals("abono")) {
                        Calendar fechaFlujo = fechasFlujos.get(i);
                        double valor = Double.parseDouble(String.valueOf(modeloTabla.getValueAt(i, 3)));

                        int anoDato = fechaFlujo.get(Calendar.YEAR);
                        int mesDato = fechaFlujo.get(Calendar.MONTH) + 1;
                        int diaDato = fechaFlujo.get(Calendar.DAY_OF_MONTH);
                        Day FechaDato = new Day(diaDato, mesDato, anoDato);

                        if (listaAbonos.get(FechaDato) != null) {
                            double valorAbono = (double) listaAbonos.get(FechaDato);
                            listaAbonos.remove(FechaDato);
                            listaAbonos.put(FechaDato, valorAbono + valor);
                        } else {
                            listaAbonos.put(FechaDato, valor);

                        }

                    }

                }
                Double maximo = 0.0;
                Iterator iterator = listaAbonos.keySet().iterator();
                while (iterator.hasNext()) {
                    Day key = (Day) iterator.next();
                    Double value = (double) listaAbonos.get(key);
                    maximo = Math.max(maximo, value);
                    localTimeSeries.add(key, value);
                }

                //localTimeSeries.add();
                TimeSeriesCollection datos = new TimeSeriesCollection(localTimeSeries);

                JFreeChart chart = ChartFactory.createTimeSeriesChart("Compras del cliente en el periodo", // Title
                        "Tiempo", // x-axis Label
                        "Total ($)", // y-axis Label
                        datos, // Dataset
                        true, // Show Legend
                        true, // Use tooltips
                        false // Configure chart to generate URLs?
                );
                /*Altering the graph */
                XYPlot plot = (XYPlot) chart.getPlot();
                plot.setAxisOffset(new RectangleInsets(5.0, 10.0, 10.0, 5.0));
                plot.setDomainCrosshairVisible(true);
                plot.setRangeCrosshairVisible(true);

                XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
                renderer.setBaseShapesVisible(true);
                renderer.setBaseShapesFilled(true);

                NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
                numberAxis.setRange(new Range(0, maximo * 1.2));
                Font font = new Font("Dialog", Font.PLAIN, 9);
                numberAxis.setTickLabelFont(font);
                numberAxis.setLabelFont(font);

                DateAxis axis = (DateAxis) plot.getDomainAxis();
                axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy"));
                axis.setAutoTickUnitSelection(false);
                axis.setVerticalTickLabels(true);

                axis.setTickLabelFont(font);
                axis.setLabelFont(font);

                LegendTitle leyendaChart = chart.getLegend();
                leyendaChart.setItemFont(font);

                Font fontTitulo = new Font("Dialog", Font.BOLD, 12);
                TextTitle tituloChart = chart.getTitle();
                tituloChart.setFont(fontTitulo);

                ChartPanel CP = new ChartPanel(chart);
                Dimension D = new Dimension(330, 300);
                CP.setPreferredSize(D);
                CP.setVisible(true);
                c.gridx = 0;
                c.gridy = 2;
                c.gridwidth = 1;
                c.insets = new Insets(10, 0, 0, 0);
                panelDialogo.add(CP, c);

                c.gridx = 0;
                c.gridy = 3;
                c.gridwidth = 1;
                c.anchor = GridBagConstraints.WEST;
                c.insets = new Insets(10, 30, 0, 0);

                JButton botonCerrar = new JButton("Cerrar");
                botonCerrar.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dialogoEditar.dispose();
                    }
                });
                panelDialogo.add(botonCerrar, c);

                JButton botonGenerarPDF = new JButton("Guardar archivo");
                botonGenerarPDF.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente();
                        reporteFlujosCliente.guardarDocumentoDialogo(dialogoEditar, listaIDFlujos,
                                Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()),
                                clienteReporteClienteFechaInicial.getSelectedDate(),
                                clienteReporteClienteFechaFinal.getSelectedDate());

                    }
                });
                c.insets = new Insets(10, 100, 0, 0);

                panelDialogo.add(botonGenerarPDF, c);

                JButton botonImprimir = new JButton("Imprimir");
                botonImprimir.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente();
                        reporteFlujosCliente.imprimirFlujo(listaIDFlujos,
                                Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()),
                                clienteReporteClienteFechaInicial.getSelectedDate(),
                                clienteReporteClienteFechaFinal.getSelectedDate());

                    }
                });
                c.insets = new Insets(10, 230, 0, 0);

                panelDialogo.add(botonImprimir, c);
                dialogoEditar.add(panelDialogo);

                dialogoEditar.setVisible(true);

            } else {
                JOptionPane.showMessageDialog(this,
                        "El cliente no registra movimientos en el rango de fechas seleccionado");
            }

        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Debe seleccionar un da inicial y final de fechas");
    }

}