Example usage for org.jfree.chart.plot XYPlot setDomainCrosshairVisible

List of usage examples for org.jfree.chart.plot XYPlot setDomainCrosshairVisible

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setDomainCrosshairVisible.

Prototype

public void setDomainCrosshairVisible(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the domain crosshair is visible and, if the flag changes, sends a PlotChangeEvent to all registered listeners.

Usage

From source file:CGgui.java

public CGgui() {
    //main window frame
    f.setResizable(false);//from ww  w . ja va2  s  .c o m
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(fCenter, BorderLayout.CENTER);
    f.getContentPane().add(fEast, BorderLayout.EAST);

    //menu
    mnuFile.add(mnuLoad);
    mnuLoad.add(mnuItemOpenFasta);
    mnuLoad.add(mnuItemOpenBed);
    mnuFile.add(mnuSaveData);
    mnuSaveData.add(mnuItemSavePositions);
    mnuSaveData.add(mnuItemSaveClusters);

    //mnuFile.add(mnuItemOpenDataFile);
    mnuFile.add(mnuSaveCharts);
    mnuSaveCharts.add(mnuItemSaveChrt);
    mnuSaveCharts.add(mnuItemSaveMinChrt);
    mnuSaveCharts.add(mnuItemSaveClusterChrt);
    mnuSaveCharts.add(mnuItemSaveGrayChrt);
    mnuSaveCharts.add(mnuItemSaveGrayMinChrt);
    mnuSaveCharts.add(mnuItemSaveGrayClusterChrt);
    mnuFile.add(mnuItemClearData);
    mnuFile.add(mnuItemQuit);
    mnuEdit.add(mnuItemChartProps);
    mnuEdit.add(mnuItemMinimaProps);
    mnuEdit.add(mnuItemClusterProps);
    mnuEdit.add(mnuItemFindMin);
    mnuEdit.add(mnuItemSetAxes);
    mnuEdit.add(mnuItemShowGrid);
    //   mnuHelp.add(mnuItemMan);
    //   mnuHelp.add(mnuItemAbout);
    mb.add(mnuFile);
    mb.add(mnuEdit);
    //   mb.add(mnuHelp);
    f.setJMenuBar(mb);

    //progressbar
    jprogressbar.setVisible(false);
    jprogressbar.setBorderPainted(false);
    f.getContentPane().add(jprogressbar, BorderLayout.SOUTH);

    //chart area
    //histogram
    ChartArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    chart = ChartFactory.createXYAreaChart("Fragment Length Histogram", "Fragment Length (l)", "Frequency f(l)",
            histogramdataset, PlotOrientation.VERTICAL, true, true, false);
    chart.addSubtitle(0, new TextTitle("n = " + CurrCG));
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setForegroundAlpha(0.85F);
    xyplot.setDomainCrosshairVisible(false);
    chartpanel = new ChartPanel(chart);
    ChartArea.add("Fragment Length", chartpanel);

    //minima
    minchart = ChartFactory.createXYLineChart("Local Minima", "Fragment Length (l)",
            "Number of Matches per Fragment", minimadataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot minxyplot = (XYPlot) minchart.getPlot();
    minxyplot.setForegroundAlpha(0.85F);
    minchartpanel = new ChartPanel(minchart);
    ChartArea.add("Minima", minchartpanel);

    //optimization
    clusterchart = ChartFactory.createScatterPlot("Average Cluster Size vs. Maximum Fragment Length",
            "Number (n) of Matches per Fragment",
            "Number of Overlapping Fragments per Cluster/Max Fragment Length", clusterdataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot clusterplot = (XYPlot) clusterchart.getPlot();
    clusterplot.setForegroundAlpha(0.85F);
    clusterchartpanel = new ChartPanel(clusterchart);
    ChartArea.add("Optimization", clusterchartpanel);

    //text area
    SeqText.setLineWrap(true);
    SeqText.setWrapStyleWord(true);
    SeqText.setEditable(false);
    jScrollPane.setBorder(BorderFactory
            .createCompoundBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Debug"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)), jScrollPane.getBorder()));
    textPanel.add(jScrollPane);
    //this next line is a hack to fix the ScrollPane size when the chart is scrolled
    jScrollPane.setPreferredSize(jScrollPane.getPreferredSize());
    //auto scroll to added text
    SeqText.setAutoscrolls(true);
    jScrollPane.setAutoscrolls(true);

    //center panel layout
    GroupLayout centerlayout = new GroupLayout(fCenter);
    fCenter.setLayout(centerlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h1 = centerlayout.createSequentialGroup();
    SequentialGroup v1 = centerlayout.createSequentialGroup();
    ////grouping
    h1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea).addComponent(textPanel));
    centerlayout.setHorizontalGroup(h1);
    ////more grouping
    v1.addGroup(centerlayout.createParallelGroup().addComponent(ChartArea));
    v1.addGroup(centerlayout.createParallelGroup().addComponent(textPanel));
    centerlayout.setVerticalGroup(v1);

    //CG Panel (search settings panel)
    CGPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Search Settings"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            CGPanel.getBorder()));
    //set subpanel1 layout
    GroupLayout CGsublayout1 = new GroupLayout(CGsubPanel1);
    CGsubPanel1.setLayout(CGsublayout1);
    ////Create a sequential and a parallel groups
    SequentialGroup h4 = CGsublayout1.createSequentialGroup();
    SequentialGroup v4 = CGsublayout1.createSequentialGroup();
    ////grouping
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternLabel).addComponent(minCGsLabel)
            .addComponent(maxCGsLabel).addComponent(CGstepLabel).addComponent(smoothCheckBox)
            .addComponent(CGApplyButton).addComponent(CGsetCurrLabel));
    h4.addGroup(CGsublayout1.createParallelGroup().addComponent(searchPatternText).addComponent(minCGsText)
            .addComponent(maxCGsText).addComponent(CGstepText).addComponent(smoothText)
            .addComponent(CGResetButton).addComponent(CGcurrText));
    CGsublayout1.setHorizontalGroup(h4);
    ////more grouping
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(searchPatternLabel).addComponent(searchPatternText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minCGsLabel)
            .addComponent(minCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxCGsLabel)
            .addComponent(maxCGsText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGstepLabel)
            .addComponent(CGstepText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(smoothCheckBox)
            .addComponent(smoothText));
    v4.addContainerGap(5, 5);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGApplyButton)
            .addComponent(CGResetButton));
    v4.addContainerGap(15, 15);
    v4.addGroup(CGsublayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(CGsetCurrLabel)
            .addComponent(CGcurrText));
    CGsublayout1.setVerticalGroup(v4);

    //set subpanel2 layout
    GroupLayout CGsublayout2 = new GroupLayout(CGsubPanel2);
    CGsubPanel2.setLayout(CGsublayout2);
    ////Create a sequential and a parallel groups
    SequentialGroup hSettingsSub2 = CGsublayout2.createSequentialGroup();
    SequentialGroup vSettingsSub2 = CGsublayout2.createSequentialGroup();

    ////horizontal grouping
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrLabel));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGcurrText));
    hSettingsSub2.addContainerGap(25, 25);
    hSettingsSub2.addGroup(CGsublayout2.createParallelGroup().addComponent(CGsetCurrButton));
    CGsublayout2.setHorizontalGroup(hSettingsSub2);
    ////vertical grouping
    vSettingsSub2.addGroup(CGsublayout2.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CGsetCurrLabel).addComponent(CGcurrText).addComponent(CGsetCurrButton));
    CGsublayout2.setVerticalGroup(vSettingsSub2);

    //set overall layout (subpanel3)
    GroupLayout CGsublayout3 = new GroupLayout(CGsubPanel3);
    CGsubPanel3.setLayout(CGsublayout3);
    ////Create a sequential and a parallel groups
    SequentialGroup h5 = CGsublayout3.createSequentialGroup();
    SequentialGroup v5 = CGsublayout3.createSequentialGroup();
    ////grouping
    h5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox).addComponent(CGsubPanel1)
            .addComponent(CGsubPanel2));
    CGsublayout3.setHorizontalGroup(h5);
    ////more grouping
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(caseCheckBox));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel1));
    v5.addContainerGap(5, 5);
    v5.addGroup(CGsublayout3.createParallelGroup().addComponent(CGsubPanel2));
    CGsublayout3.setVerticalGroup(v5);
    //add to resizable container
    CGPanel.add(CGsubPanel3);
    //button and slider listeners
    CGApplyButton.addActionListener(new ListenCGApplyButton());
    CGResetButton.addActionListener(new ListenCGResetButton());
    CGsetCurrButton.addActionListener(new ListenCGsetCurrButton());
    CGcurrText.addActionListener(new ListenCGsetCurrButton());

    //minimum area
    findminPanel.setVisible(true);
    findminPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Find Minimum"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            findminPanel.getBorder()));
    GroupLayout minlayout = new GroupLayout(findminPanel);
    findminPanel.setLayout(minlayout);

    ////Create a sequential and a parallel groups
    SequentialGroup h2 = minlayout.createSequentialGroup();
    SequentialGroup v2 = minlayout.createSequentialGroup();

    ////group find minimum and find all buttons
    SequentialGroup hFindMinButtons = minlayout.createSequentialGroup();
    SequentialGroup vFindMinButtons = minlayout.createSequentialGroup();
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcButton));
    hFindMinButtons.addGroup(minlayout.createParallelGroup().addComponent(CalcAllButton));
    vFindMinButtons.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(CalcButton).addComponent(CalcAllButton));
    ////general grouping
    h2.addGroup(minlayout.createParallelGroup().addComponent(minLabel).addComponent(maxLabel)
            .addComponent(ClearButton));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minText).addComponent(maxText)
            .addGroup(hFindMinButtons));
    h2.addContainerGap(5, 5);
    h2.addGroup(minlayout.createParallelGroup().addComponent(minGrabButton).addComponent(maxGrabButton)
            .addComponent(CancelButton));
    minlayout.setHorizontalGroup(h2);
    ////more grouping
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(minLabel)
            .addComponent(minText).addComponent(minGrabButton));
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxLabel)
            .addComponent(maxText).addComponent(maxGrabButton));
    v2.addContainerGap(5, 5);
    v2.addContainerGap(5, 5);
    v2.addGroup(minlayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(ClearButton)
            .addGroup(vFindMinButtons).addComponent(CancelButton));
    minlayout.setVerticalGroup(v2);
    //add button listeners
    ClearButton.addActionListener(new ListenClearButton());
    CalcButton.addActionListener(new ListenCalcButton());
    CalcAllButton.addActionListener(new ListenCalcAllButton());
    CancelButton.addActionListener(new ListenCancelButton());
    minGrabButton.addActionListener(new ListenminGrabButton());
    maxGrabButton.addActionListener(new ListenmaxGrabButton());

    //axes panel
    mnuItemSetAxes.setState(false);
    setaxesPanel.setVisible(false);
    setaxesPanel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Set Domain"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            setaxesPanel.getBorder()));
    GroupLayout setaxeslayout = new GroupLayout(setaxesPanel);
    setaxesPanel.setLayout(setaxeslayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h6 = setaxeslayout.createSequentialGroup();
    SequentialGroup v6 = setaxeslayout.createSequentialGroup();
    ////grouping
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainLabel).addComponent(maxdomainLabel)
            .addComponent(SetDomainButton));
    h6.addContainerGap(5, 5);
    h6.addGroup(setaxeslayout.createParallelGroup().addComponent(mindomainText).addComponent(maxdomainText)
            .addComponent(ResetDomainButton));
    setaxeslayout.setHorizontalGroup(h6);
    ////more grouping
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(mindomainLabel)
            .addComponent(mindomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(maxdomainLabel)
            .addComponent(maxdomainText));
    v6.addContainerGap(5, 5);
    v6.addGroup(setaxeslayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(SetDomainButton)
            .addComponent(ResetDomainButton));
    setaxeslayout.setVerticalGroup(v6);
    //add button listeners
    SetDomainButton.addActionListener(new ListenSetDomainButton());
    ResetDomainButton.addActionListener(new ListenResetDomainButton());

    //east panel layout
    GroupLayout eastlayout = new GroupLayout(fEast);
    fEast.setLayout(eastlayout);
    ////Create a sequential and a parallel groups
    SequentialGroup h3 = eastlayout.createSequentialGroup();
    SequentialGroup v3 = eastlayout.createSequentialGroup();
    ////grouping
    h3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel).addComponent(findminPanel)
            .addComponent(setaxesPanel));
    eastlayout.setHorizontalGroup(h3);
    ////more grouping
    v3.addGroup(eastlayout.createParallelGroup().addComponent(CGPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(findminPanel));
    v3.addGroup(eastlayout.createParallelGroup().addComponent(setaxesPanel));
    eastlayout.setVerticalGroup(v3);

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemQuit.addActionListener(new ListenMenuQuit());

    //listen for exit signals
    f.addWindowListener(new ListenCloseWdw());
    mnuItemClearData.addActionListener(new ListenClearData());

    //listen for open signal
    mnuItemOpenFasta.addActionListener(new ListenMenuOpenFasta());

    //listen for open signal
    mnuItemOpenBed.addActionListener(new ListenMenuOpenBed());

    //listen for save position signal
    mnuItemSavePositions.addActionListener(new ListenMenuSavePositions());

    //listen for save cluster signal
    mnuItemSaveClusters.addActionListener(new ListenMenuSaveClusters());

    //listen for save histogram chart signal
    mnuItemSaveChrt.addActionListener(new ListenMenuSaveChrt());

    //listen for save chart signal
    mnuItemSaveMinChrt.addActionListener(new ListenMenuSaveMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveClusterChrt.addActionListener(new ListenMenuSaveClusterChrt());

    //listen for save histogram chart in grayscale signal;
    mnuItemSaveGrayChrt.addActionListener(new ListenMenuSaveGrayChrt());

    //listen for save chart signal
    mnuItemSaveGrayMinChrt.addActionListener(new ListenMenuSaveGrayMinChrt());

    //listen for save cluster chart signal
    mnuItemSaveGrayClusterChrt.addActionListener(new ListenMenuSaveGrayClusterChrt());

    //listen for edit histogram properties signal
    mnuItemChartProps.addActionListener(new ListenMenuChartProps());

    //listen for edit minima chart properties signal
    mnuItemMinimaProps.addActionListener(new ListenMenuMinimaProps());

    //listen for edit optimization chart properties signal
    mnuItemClusterProps.addActionListener(new ListenMenuClusterProps());

    //listen for find minimum signal
    mnuItemFindMin.addActionListener(new ListenMenuFindMin());

    //listen for find minimum signal
    mnuItemSetAxes.addActionListener(new ListenMenuSetAxes());

    //listen for show gridlines
    mnuItemShowGrid.addActionListener(new ListenMenuShowGrid());

    //other menu items

    //garbage collect
    //System.gc();
}

From source file:CGgui.java

public void clearData() {
    //global variables reset
    MIN = Double.MAX_VALUE;/* w w w .j a  v a 2s  .  c om*/
    MAX = 0;
    BINS = 10000;
    key = "";
    regLine = null;

    //clear min settings
    minText.setText("");
    maxText.setText("");
    smoothText.setText("");
    fragmentMap.clear();

    //new data sets
    lengthHist = null;
    histogramdataset = new XYSeriesCollection();
    minimadataset = new CategoryTableXYDataset();
    clusterdataset = new CategoryTableXYDataset();

    //chart area reset
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setDataset(new XYSeriesCollection());
    chartpanel.restoreAutoBounds();

    XYPlot minxyplot = (XYPlot) minchart.getPlot();
    minxyplot.setDataset(0, minimadataset);
    minxyplot.setDataset(1, new DefaultXYDataset());
    minchart.clearSubtitles();
    minchartpanel.restoreAutoBounds();

    XYPlot clusterxyplot = (XYPlot) clusterchart.getPlot();
    clusterxyplot.setDataset(clusterdataset);
    clusterchartpanel.restoreAutoBounds();

    //remove marker
    if (intervalmarker != null) {
        xyplot = (XYPlot) chart.getPlot();
        xyplot.removeDomainMarker(intervalmarker, Layer.BACKGROUND);
        intervalmarker = null;
    }

    //remove crosshair
    xyplot.setDomainCrosshairVisible(false);

    //clear text
    minText.setText(null);
    maxText.setText(null);
    smoothText.setText(null);

    //f.pack();
    //System.gc();
}

From source file:org.ramadda.geodata.cdmdata.PointDatabaseTypeHandler.java

/**
 * _more_/*from w  ww  .ja  va2s .c  o m*/
 *
 *
 * @param request _more_
 * @param entry _more_
 * @param dataset _more_
 *
 * @return _more_
 */
private static JFreeChart createChart(Request request, Entry entry, XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            request.getString(ARG_POINT_TIMESERIES_TITLE, entry.getName()), // title
            "Date", // x-axis label
            "", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);
    ValueAxis rangeAxis = new NumberAxis("");
    rangeAxis.setVisible(false);
    XYPlot plot = (XYPlot) chart.getPlot();
    if (request.get("gray", false)) {
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
    } else {
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.lightGray);
        plot.setRangeGridlinePaint(Color.lightGray);
    }
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeAxis(0, rangeAxis, false);

    XYItemRenderer r = plot.getRenderer();
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;

}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.AdvancedXY_PlotPanel.java

private void initChart(XY_PlotPanel pPanel) {
    this.plotPanel = pPanel;
    this.chartPanel = pPanel.getChartPanel();
    if (pPanel instanceof SimpleXY_PlotPanel) {
        this.setTitle(((SimpleXY_PlotPanel) pPanel).getTitle());
    }//from  ww  w . ja  va2s . c o m

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();

    // how many data sets will there be (may not exist yet, cause swing worker may still be constructing them)
    int numRows = 2; // enough for counts, and delta counts
    if ((XY_PlotType.ADV_PORT_UTIL_PLUS.equals(getType())))
        numRows = 4;
    boolean includeExtra = numRows > MAX_DATASETS / 2 ? true : false;

    int rowSize = includeExtra ? MAX_DS_SIZE : MAX_DS_SIZE / 2 + 19; // extra for padding
    NumDataSets = numRows;

    // build the table model from the data sets, then build the table and slider

    // see "chartProgress()" method
    chart.addProgressListener(this);

    this.chartPanel.setPreferredSize(new java.awt.Dimension(750, 300));
    this.chartPanel.setDomainZoomable(true);
    this.chartPanel.setRangeZoomable(true);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    this.chartPanel.setBorder(border);
    add(this.chartPanel);

    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setPreferredSize(new Dimension(400, rowSize));
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));

    this.model = new XY_PlotTableModel(numRows);

    // initialize the model, and table, here
    //    this.model.setValueAt("name", 0, 1);
    this.model.setValueAt(new Double("0.00"), 0, 1);
    this.model.setValueAt(new Double("0.00"), 0, 2);
    //    this.model.setValueAt("units", 0, 3);
    JTable table = new JTable(this.model);

    // the columns are name, time, value, units.  both name and units are strings
    // so need special renderers for time and value

    TableCellRenderer renderer1 = new DateCellRenderer(new SimpleDateFormat("HH:mm:ss"));
    TableCellRenderer renderer2 = new NumberCellRenderer();
    table.getColumnModel().getColumn(1).setCellRenderer(renderer1);
    table.getColumnModel().getColumn(2).setCellRenderer(renderer2);
    JScrollPane scroller = new JScrollPane(table);
    dashboard.add(scroller);

    this.slider = new JSlider(0, 100, 10);
    this.slider.addChangeListener(this);
    dashboard.add(this.slider, BorderLayout.SOUTH);
    add(dashboard, BorderLayout.SOUTH);

    //     XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainCrosshairLockedOnData(true);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(true);
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Sets the Cross hair value./*from w w  w . j  a  v a 2  s .com*/
 */
private void setCrossHair(double crossHairValue) {
    // set the cross hair values of plot and sub-plots
    Plot mainplot = advancedGraph.getPlot();
    if (mainplot instanceof CombinedDomainXYPlot) {
        CombinedDomainXYPlot combinedPlot = (CombinedDomainXYPlot) mainplot;
        List<?> plots = combinedPlot.getSubplots();
        for (Object p : plots) {
            if (p instanceof XYPlot) {
                XYPlot subPlot = (XYPlot) p;
                subPlot.setDomainCrosshairLockedOnData(false);
                subPlot.setDomainCrosshairValue(crossHairValue);
                subPlot.setDomainCrosshairVisible(true);
            }
        }
        combinedPlot.setDomainCrosshairLockedOnData(false);
        combinedPlot.setDomainCrosshairValue(crossHairValue, true);
        combinedPlot.setDomainCrosshairVisible(true);
    }

    handlePanel.setHandlePosition(getHandleCoordinate());
}

From source file:org.webcat.grader.graphs.StackedAreaChart.java

@Override
protected JFreeChart generateChart(WCChartTheme chartTheme) {
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, xAxisLabel(), yAxisLabel(), tableXYDataset(),
            orientation(), true, false, false);

    XYPlot plot = chart.getXYPlot();

    long diff = (long) tableXYDataset().getXValue(0, tableXYDataset().getItemCount() - 1)
            - (long) tableXYDataset().getXValue(0, 0);

    GregorianCalendar calDiff = new GregorianCalendar();
    calDiff.setTime(new NSTimestamp(diff));

    // Set the time axis
    PeriodAxis axis = new PeriodAxis(null); // ( "Date" );
    PeriodAxisLabelInfo labelinfo[] = new PeriodAxisLabelInfo[2];

    if (calDiff.get(Calendar.DAY_OF_YEAR) > 1) {
        axis.setTimeZone(TimeZone.getTimeZone(user().timeZoneName()));
        axis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class);
        axis.setMajorTickTimePeriodClass(org.jfree.data.time.Week.class);

        labelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);

        labelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);
    } else {/*from   w  ww.j a  va  2  s .  co m*/
        axis.setAutoRangeTimePeriodClass(org.jfree.data.time.Hour.class);

        labelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("ha"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);

        labelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM-d"),
                PeriodAxisLabelInfo.DEFAULT_INSETS, chartTheme.smallFont(), chartTheme.textColor(), true,
                PeriodAxisLabelInfo.DEFAULT_DIVIDER_STROKE, PeriodAxisLabelInfo.DEFAULT_DIVIDER_PAINT);
    }

    axis.setLabelInfo(labelinfo);
    plot.setDomainAxis(axis);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    NumberTickUnit tickUnit = new NumberTickUnit(5);
    rangeAxis.setTickUnit(tickUnit);

    XYAreaRenderer2 renderer = (XYAreaRenderer2) plot.getRenderer();
    renderer.setOutline(true);
    renderer.setAutoPopulateSeriesOutlinePaint(true);

    plot.setDomainMinorGridlinesVisible(false);
    plot.setRangeMinorGridlinesVisible(false);

    if (markValue != null) {
        plot.setDomainCrosshairVisible(true);
        plot.setDomainCrosshairValue(markValue.doubleValue());
        plot.setDomainCrosshairPaint(Color.red);
        plot.setDomainCrosshairStroke(MARKER_STROKE);
    }

    chart.getLegend().setBorder(0, 0, 0, 0);

    return chart;
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private JFreeChart createInterruptChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Interrupt Chart", "Time", "Count", dataset,
            true, true, false);/*from  www.  j  av  a 2s.  c o m*/

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    // plot.setOutlinePaint(null);
    plot.setBackgroundPaint(Color.black);
    plot.setDomainGridlinePaint(Color.green);
    plot.setRangeGridlinePaint(Color.green);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(false);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("s.SS"));
    return chart;
}

From source file:com.afunms.system.manage.equipManager.java

/**
 * Creates a sample chart./* w  ww.j  a v  a  2  s.  c o m*/
 * 
 * @return a sample chart.
 */
private JFreeChart createChart() {
    final XYDataset direction = createDirectionDataset(600);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", direction,
            true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.setRangeCrosshairVisible(true);
    plot.setDomainCrosshairVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.darkGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(new Color(139, 69, 19));
    XYLineAndShapeRenderer render0 = (XYLineAndShapeRenderer) plot.getRenderer(0);
    render0.setSeriesPaint(0, Color.BLUE);

    XYAreaRenderer xyarearenderer = new XYAreaRenderer();
    xyarearenderer.setSeriesPaint(1, Color.GREEN); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);

    // configure the range axis to display directions...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    final TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(180.0, new CompassFormat()));
    units.add(new NumberTickUnit(90.0, new CompassFormat()));
    units.add(new NumberTickUnit(45.0, new CompassFormat()));
    units.add(new NumberTickUnit(22.5, new CompassFormat()));
    rangeAxis.setStandardTickUnits(units);

    // add the wind force with a secondary dataset/renderer/axis
    plot.setRangeAxis(rangeAxis);
    final XYItemRenderer renderer2 = new XYAreaRenderer();
    final ValueAxis axis2 = new NumberAxis("");
    axis2.setRange(0.0, 12.0);
    xyarearenderer.setSeriesPaint(1, new Color(0, 204, 0)); // 
    xyarearenderer.setSeriesFillPaint(1, Color.GREEN);
    xyarearenderer.setPaint(Color.GREEN);
    plot.setDataset(1, createForceDataset(600));
    plot.setRenderer(1, xyarearenderer);
    plot.setRangeAxis(1, axis2);
    plot.mapDatasetToRangeAxis(1, 1);

    return chart;
}

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  a v a2  s  .  c o m
        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");
    }

}

From source file:gov.llnl.lustre.lwatch.PlotFrame2.java

/**
 * Define the JFreeChart chart.//  w w  w  . j a  v  a  2s. c o  m
 *
 * @param dataset dataset to be plotted in the chart.
 */

public JFreeChart createChart(XYDataset dataset) {

    // Load data for settings from last "Refresh" time
    String[] selectedRows = lastRefreshPlotParams.getCategories();
    String[] selectedVars = lastRefreshPlotParams.getVariables();
    String[] selectedCurves = lastRefreshPlotParams.getCurves();

    int savedGranularity = granularity;
    granularity = lastRefreshPlotParams.getGranularity();

    boolean showLegend = true;
    //if (((isAnAggPlot) && (nColsSelected * nCurvesSelected > 8)) ||
    //(nRowsSelected * nColsSelected * nCurvesSelected > 8))
    //showLegend = false;
    if (((isAnAggPlot) && (selectedVars.length * selectedCurves.length > 8))
            || (selectedRows.length * selectedVars.length * selectedCurves.length > 8))
        showLegend = false;

    //if (fromRefresh && (nRowsSelected > 0 && nColsSelected > 0 && nCurvesSelected > 0) &&
    //(!noVarSelected)) {
    if (fromRefresh && (selectedRows.length > 0 && selectedVars.length > 0 && selectedCurves.length > 0)
            && (!noVarSelected)) {
        //Debug.out("nRowsSelected = " + nRowsSelected +
        //"   nColsSelected = " + nColsSelected +
        //"   nCurvesSelected = " + nCurvesSelected);

        pD = new PlotDescriptor();
    }

    chart = ChartFactory.createTimeSeriesChart(fsName + " - " + type + " data", // title
            "Date", // x-axis label
            yAxisLabel, // y-axis label
            dataset, // data
            showLegend, // create legend
            false, // generate tooltips
            false // generate URLs
    );

    chart.setBackgroundPaint(Color.black); //white);  // Border color
    chart.setBorderVisible(true);
    TextTitle tTitle = chart.getTitle();
    tTitle.setPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.black); //lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    // Check need for logorihmic axis
    if (useLogRangeAxis) {
        LogarithmicAxis rangeAxis2 = new LogarithmicAxis(yAxisLabel);
        plot.setRangeAxis(0, rangeAxis2);
    }

    // Default axis annotation is in black. So if the chart background
    // Paint was set to black above, we need to set axis labels, 
    // tick labels and tick marks to be a contrasting color.
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setTickMarkPaint(Color.white);
    plot.getRangeAxis().setLabelPaint(Color.white);
    plot.getRangeAxis().setTickLabelPaint(Color.white);
    plot.getRangeAxis().setTickMarkPaint(Color.white);

    // Grab the colors from the legend.
    //int nCurves = nRowsSelected * nColsSelected * nCurvesSelected;
    int nCurves = selectedRows.length * selectedVars.length * selectedCurves.length;
    if (localDebug) {
        Debug.out("selectedRows.length, selectedVars.length, selectedCurves.length = " + selectedRows.length
                + ", " + selectedVars.length + ", " + selectedCurves.length);
        Debug.out("Dimension legendColors to size = " + nCurves);
    }
    legendColors = new Color[nCurves];
    LegendItemCollection lic = plot.getLegendItems();
    for (int i = 0; i < lic.getItemCount(); i++) {
        LegendItem li = lic.get(i);
        legendColors[i] = (Color) li.getLinePaint();
        //if (localDebug)
        //Debug.out("Line Paint for legend " + i + " = " +
        //legendColors[i]);
    }

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(showIcons); // Controls icons at data pts.
        renderer.setBaseShapesFilled(false);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    if (granularity == Database.HOUR)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH")); //("dd-MMM-yy"));
    else if (granularity == Database.DAY)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.WEEK)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.MONTH)
        axis.setDateFormatOverride(new SimpleDateFormat("MM/yy")); //("dd-MMM-yy"));
    else if (granularity == Database.YEAR)
        axis.setDateFormatOverride(new SimpleDateFormat("yyyy HH:mm")); //("dd-MMM-yy"));
    else // granualrity == Database.RAW or HEARTBEAT
        axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH:mm:ss")); //("dd-MMM-yy"));

    // Reset granularity;
    granularity = savedGranularity;

    return chart;

}