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

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

Introduction

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

Prototype

public void setForegroundAlpha(float alpha) 

Source Link

Document

Sets the alpha-transparency for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:ro.nextreports.engine.chart.JFreeChartExporter.java

private JFreeChart createBubbleChart() throws QueryException {
    bubbleDataset = new DefaultXYZDataset();

    // x, y are inverted for jfree bubble chart!
    // that's why we use minX & maxX values to compute Tu (tickUnit)
    String chartTitle = replaceParameters(chart.getTitle().getTitle());
    chartTitle = StringUtil.getI18nString(chartTitle, I18nUtil.getLanguageByName(chart, language));
    String xLegend = StringUtil.getI18nString(replaceParameters(chart.getYLegend().getTitle()),
            I18nUtil.getLanguageByName(chart, language));
    String yLegend = StringUtil.getI18nString(replaceParameters(chart.getXLegend().getTitle()),
            I18nUtil.getLanguageByName(chart, language));
    JFreeChart jfreechart = ChartFactory.createBubbleChart(chartTitle, xLegend, // x-axis Label
            yLegend, // y-axis Label
            bubbleDataset, PlotOrientation.HORIZONTAL, true, true, false);

    // hide border
    jfreechart.setBorderVisible(false);/*w w  w  . j  a va 2s  .  c  o m*/

    // title
    setTitle(jfreechart);

    boolean showValues = (chart.getShowYValuesOnChart() == null) ? false : chart.getShowYValuesOnChart();

    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setForegroundAlpha(transparency);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();

    DecimalFormat decimalformat;
    DecimalFormat percentageFormat;
    if (chart.getYTooltipPattern() == null) {
        decimalformat = new DecimalFormat("#");
        percentageFormat = new DecimalFormat("0.00%");
    } else {
        decimalformat = new DecimalFormat(chart.getYTooltipPattern());
        percentageFormat = decimalformat;
    }

    if (showValues) {
        // increase a little bit the range axis to view all item label values over bars
        xyplot.getRangeAxis().setUpperMargin(0.2);
    }

    // grid axis visibility & colors 
    if ((chart.getXShowGrid() != null) && !chart.getXShowGrid()) {
        xyplot.setDomainGridlinesVisible(false);
    } else {
        if (chart.getXGridColor() != null) {
            xyplot.setDomainGridlinePaint(chart.getXGridColor());
        } else {
            xyplot.setDomainGridlinePaint(Color.BLACK);
        }
    }
    if ((chart.getYShowGrid() != null) && !chart.getYShowGrid()) {
        xyplot.setRangeGridlinesVisible(false);
    } else {
        if (chart.getYGridColor() != null) {
            xyplot.setRangeGridlinePaint(chart.getYGridColor());
        } else {
            xyplot.setRangeGridlinePaint(Color.BLACK);
        }
    }

    // chart background
    xyplot.setBackgroundPaint(chart.getBackground());

    // labels color
    xyplot.getDomainAxis().setTickLabelPaint(chart.getXColor());
    xyplot.getRangeAxis().setTickLabelPaint(chart.getYColor());

    // legend color
    xyplot.getDomainAxis().setLabelPaint(chart.getXLegend().getColor());
    xyplot.getRangeAxis().setLabelPaint(chart.getYLegend().getColor());

    // legend font
    xyplot.getDomainAxis().setLabelFont(chart.getXLegend().getFont());
    xyplot.getRangeAxis().setLabelFont(chart.getYLegend().getFont());

    // axis color
    xyplot.getDomainAxis().setAxisLinePaint(chart.getxAxisColor());
    xyplot.getRangeAxis().setAxisLinePaint(chart.getyAxisColor());

    // hide labels
    if ((chart.getXShowLabel() != null) && !chart.getXShowLabel()) {
        xyplot.getDomainAxis().setTickLabelsVisible(false);
        xyplot.getDomainAxis().setTickMarksVisible(false);
    }
    if ((chart.getYShowLabel() != null) && !chart.getYShowLabel()) {
        xyplot.getRangeAxis().setTickLabelsVisible(false);
        xyplot.getRangeAxis().setTickMarksVisible(false);
    }

    // label orientation
    ValueAxis domainAxis = xyplot.getDomainAxis();
    if (chart.getXorientation() == Chart.VERTICAL) {
        domainAxis.setLabelAngle(Math.PI / 2);
    } else if (chart.getXorientation() == Chart.DIAGONAL) {
        domainAxis.setLabelAngle(Math.PI / 4);
    } else if (chart.getXorientation() == Chart.HALF_DIAGONAL) {
        domainAxis.setLabelAngle(Math.PI / 8);
    }

    // labels fonts
    xyplot.getDomainAxis().setTickLabelFont(chart.getXLabelFont());
    xyplot.getRangeAxis().setTickLabelFont(chart.getYLabelFont());

    createChart(xyplot.getRangeAxis(), new Object[4]);

    double minX = Double.MAX_VALUE;
    double maxX = Double.MIN_VALUE;
    double minY = Double.MAX_VALUE;
    double maxY = Double.MIN_VALUE;
    double maxZ = Double.MIN_VALUE;
    for (String serie : bubbleData.keySet()) {
        XYZList xyzList = bubbleData.get(serie);
        List<Number> yList = xyzList.getyList();
        for (Number n : yList) {
            minY = Math.min(minY, n.doubleValue());
            maxY = Math.max(maxY, n.doubleValue());
        }
        List<Number> xList = xyzList.getxList();
        for (Number n : xList) {
            minX = Math.min(minX, n.doubleValue());
            maxX = Math.max(maxX, n.doubleValue());
        }
        List<Number> zList = xyzList.getzList();
        for (Number n : zList) {
            maxZ = Math.max(maxZ, n.doubleValue());
        }
    }

    double tu = Math.floor((maxX - minX) / 5 + 0.5d);
    NumberTickUnit rUnit = new NumberTickUnit(tu);
    ((NumberAxis) xyplot.getRangeAxis()).setTickUnit(rUnit);

    // make the bubble with text fit on X axis (which is shown vertically!)
    xyplot.getDomainAxis().setUpperMargin(0.2);
    xyplot.getDomainAxis().setLowerMargin(0.2);

    for (String serie : bubbleData.keySet()) {
        XYZList xyzList = bubbleData.get(serie);
        double[][] data = { getDoubleArray(xyzList.getyList()), getDoubleArray(xyzList.getxList()),
                getZDoubleArray(xyzList.getzList(), tu, maxZ) };
        bubbleDataset.addSeries(serie, data);
    }

    int series = bubbleData.keySet().size();
    for (int i = 0; i < series; i++) {
        xyitemrenderer.setSeriesPaint(i, chart.getForegrounds().get(i));
        if (showValues) {
            xyitemrenderer.setSeriesItemLabelsVisible(i, true);
            xyitemrenderer.setSeriesItemLabelGenerator(i,
                    new StandardXYItemLabelGenerator("{2}", decimalformat, percentageFormat));
        }
    }

    // show labels on bubbles
    xyitemrenderer.setBaseItemLabelsVisible(true);
    xyitemrenderer.setBaseItemLabelGenerator(new LegendXYItemLabelGenerator());
    return jfreechart;
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private byte[] generateTimeSeriesChart(String siteId, IntervalXYDataset dataset, int width, int height,
        boolean renderBar, float transparency, boolean itemLabelsVisible, boolean smallFontInDomainAxis,
        String timePeriod, Date firstDate, Date lastDate) {
    JFreeChart chart = null;/*from w ww  .  j a v  a2  s  . c o m*/
    if (!renderBar) {
        chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, true, false, false);
    } else {
        chart = ChartFactory.createXYBarChart(null, null, true, null, dataset, PlotOrientation.VERTICAL, true,
                false, false);
    }
    XYPlot plot = (XYPlot) chart.getPlot();

    // set transparency
    plot.setForegroundAlpha(transparency);

    // set background
    chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set antialias
    chart.setAntiAlias(true);

    // set domain axis font size
    if (smallFontInDomainAxis && !canUseNormalFontSize(width)) {
        plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    }

    // configure date display (localized) in domain axis
    Locale locale = msgs.getLocale();
    PeriodAxis periodaxis = new PeriodAxis(null);
    Class timePeriodClass = null;
    if (dataset instanceof TimeSeriesCollection) {
        TimeSeriesCollection tsc = (TimeSeriesCollection) dataset;
        if (tsc.getSeriesCount() > 0) {
            timePeriodClass = tsc.getSeries(0).getTimePeriodClass();
        } else {
            timePeriodClass = org.jfree.data.time.Day.class;
        }
        periodaxis.setAutoRangeTimePeriodClass(timePeriodClass);
    }
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = null;
    if (StatsManager.CHARTTIMESERIES_WEEKDAY.equals(timePeriod)) {
        aperiodaxislabelinfo = new PeriodAxisLabelInfo[2];
        aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
                new SimpleDateFormat("E", locale));
        aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
                new SimpleDateFormat("d", locale));
    } else if (StatsManager.CHARTTIMESERIES_DAY.equals(timePeriod)) {
        aperiodaxislabelinfo = new PeriodAxisLabelInfo[3];
        aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
                new SimpleDateFormat("d", locale));
        aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
                new SimpleDateFormat("MMM", locale));
        aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class,
                new SimpleDateFormat("yyyy", locale));
    } else if (StatsManager.CHARTTIMESERIES_MONTH.equals(timePeriod)) {
        aperiodaxislabelinfo = new PeriodAxisLabelInfo[2];
        aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class,
                new SimpleDateFormat("MMM", locale));
        aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class,
                new SimpleDateFormat("yyyy", locale));
    } else if (StatsManager.CHARTTIMESERIES_YEAR.equals(timePeriod)) {
        aperiodaxislabelinfo = new PeriodAxisLabelInfo[1];
        aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class,
                new SimpleDateFormat("yyyy", locale));
    }
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    // date range
    if (firstDate != null || lastDate != null) {
        periodaxis.setAutoRange(false);
        if (firstDate != null) {
            if (StatsManager.CHARTTIMESERIES_MONTH.equals(timePeriod)
                    || StatsManager.CHARTTIMESERIES_YEAR.equals(timePeriod)) {
                periodaxis.setFirst(new org.jfree.data.time.Month(firstDate));
            } else {
                periodaxis.setFirst(new org.jfree.data.time.Day(firstDate));
            }
        }
        if (lastDate != null) {
            if (StatsManager.CHARTTIMESERIES_MONTH.equals(timePeriod)
                    || StatsManager.CHARTTIMESERIES_YEAR.equals(timePeriod)) {
                periodaxis.setLast(new org.jfree.data.time.Month(lastDate));
            } else {
                periodaxis.setLast(new org.jfree.data.time.Day(lastDate));
            }
        }
    }
    periodaxis.setTickMarkOutsideLength(0.0F);
    plot.setDomainAxis(periodaxis);

    // set outline
    AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) plot.getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) renderer;
        r.setDrawSeriesLineAsPath(true);
        r.setShapesVisible(true);
        r.setShapesFilled(true);
    } else if (renderer instanceof XYBarRenderer) {
        //XYBarRenderer r = (XYBarRenderer) renderer;
        ClusteredXYBarRenderer r = new ClusteredXYBarRenderer();
        r.setDrawBarOutline(true);
        if (smallFontInDomainAxis && !canUseNormalFontSize(width))
            r.setMargin(0.05);
        else
            r.setMargin(0.10);
        plot.setRenderer(r);
        renderer = r;
    }

    // item labels
    if (itemLabelsVisible) {
        plot.getRangeAxis().setUpperMargin(0.2);
        renderer.setItemLabelGenerator(new XYItemLabelGenerator() {
            private static final long serialVersionUID = 1L;

            public String generateLabel(XYDataset dataset, int series, int item) {
                Number n = dataset.getY(series, item);
                if (n.doubleValue() != 0)
                    return n.toString();
                return "";
            }

        });
        renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        renderer.setItemLabelsVisible(true);
    }

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        LOG.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:CGgui.java

public CGgui() {
    //main window frame
    f.setResizable(false);/*from ww  w  .  java2 s.c  om*/
    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:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createXYZBubbleChart(String title, String xLabel, String yLabel, XYZDataset dataset) {
    JFreeChart chart = ChartFactory.createBubbleChart(title, xLabel, yLabel, dataset, orientation, true, true,
            false);/*from   ww  w  . jav a 2  s .  c  o m*/
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);
    //renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator());

    // increase the margins to account for the fact that the auto-range
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerMargin(0.15);
    domainAxis.setUpperMargin(0.15);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createXYAreaChart(String title, String xLabel, String yLabel, XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart(title, xLabel, yLabel, dataset, orientation, true, // legend
            true, // tool tips
            false // URLs
    );/*  w  w w.j a  v a 2  s. c  o  m*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    if (timeType.length() != 0) {
        setDateAxis(plot);
    } else {
        ValueAxis domainAxis = plot.getDomainAxis();
        domainAxis.setTickMarkPaint(Color.black);
        domainAxis.setLowerMargin(0.0);
        domainAxis.setUpperMargin(0.0);

        ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setTickMarkPaint(Color.black);
    }

    //XYItemRenderer renderer = plot.getRenderer();
    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    return chart;
}

From source file:logdruid.ui.chart.GraphPanel.java

public void load(JPanel panel_2) {
    startDateJSpinner = (JSpinner) panel_2.getComponent(2);
    endDateJSPinner = (JSpinner) panel_2.getComponent(3);
    // scrollPane.setV
    panel.removeAll();//w  ww  .ja v  a2 s  .  c  o m
    Dimension panelSize = this.getSize();
    add(scrollPane, BorderLayout.CENTER);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    // scrollPane.set trying to replace scroll where it was
    JCheckBox relativeCheckBox = (JCheckBox) panel_2.getComponent(5);
    estimatedTime = System.currentTimeMillis() - startTime;
    logger.info("gathering time: " + estimatedTime);
    startTime = System.currentTimeMillis();
    //   Map<Source, Map<String, MineResult>>
    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();
    int ite = 0;
    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {
        final Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        logger.debug("mineResultSet key/source: " + ((Source) pairs.getKey()).getSourceName());
        JCheckBox checkBox = (JCheckBox) panel_1.getComponent(ite++);
        logger.debug("checkbox: " + checkBox.getText() + ", " + checkBox.isSelected());
        if (checkBox.isSelected()) {

            Map mrArrayList = (Map<String, MineResult>) pairs.getValue();
            ArrayList<String> mineResultGroup = new ArrayList<String>();
            Set<String> mrss = mrArrayList.keySet();

            mineResultGroup.addAll(mrss);
            Collections.sort(mineResultGroup, new AlphanumComparator());
            Iterator mrArrayListIterator = mineResultGroup.iterator();
            while (mrArrayListIterator.hasNext()) {

                String key = (String) mrArrayListIterator.next();
                logger.debug(key);
                final MineResult mr = (MineResult) mrArrayList.get(key);
                Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
                Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
                // logger.info("mineResultSet hash size: "
                // +mr.getTimeseriesMap().size());
                // logger.info("mineResultSet hash content: " +
                // mr.getStatTimeseriesMap());
                logger.debug("mineResultSet mr.getStartDate(): " + mr.getStartDate()
                        + " mineResultSet mr.getEndDate(): " + mr.getEndDate());
                logger.debug("mineResultSet (Date)jsp.getValue(): " + (Date) startDateJSpinner.getValue());
                logger.debug("mineResultSet (Date)jsp2.getValue(): " + (Date) endDateJSPinner.getValue());
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {

                        ArrayList<String> mineResultGroup2 = new ArrayList<String>();
                        Set<String> mrss2 = statMap.keySet();
                        mineResultGroup2.addAll(mrss2);
                        Collections.sort(mineResultGroup2, new AlphanumComparator());
                        Iterator statMapIterator = mineResultGroup2.iterator();

                        //            Iterator statMapIterator = statMap.entrySet().iterator();
                        if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                            JPanel checkboxPanel = new JPanel(new WrapLayout());

                            checkboxPanel.setBackground(Color.white);

                            int count = 1;
                            chart = ChartFactory.createXYAreaChart(// Title
                                    mr.getSourceID() + " " + mr.getGroup(), // +
                                    null, // X-Axis
                                    // label
                                    null, // Y-Axis label
                                    null, // Dataset
                                    PlotOrientation.VERTICAL, false, // Show
                                    // legend
                                    true, // tooltips
                                    false // url
                            );
                            TextTitle my_Chart_title = new TextTitle(mr.getSourceID() + " " + mr.getGroup(),
                                    new Font("Verdana", Font.BOLD, 17));
                            chart.setTitle(my_Chart_title);
                            XYPlot plot = (XYPlot) chart.getPlot();
                            ValueAxis range = plot.getRangeAxis();
                            range.setVisible(false);

                            final DateAxis domainAxis1 = new DateAxis();
                            domainAxis1.setTickLabelsVisible(true);
                            // domainAxis1.setTickMarksVisible(true);

                            logger.debug("getRange: " + domainAxis1.getRange());
                            if (relativeCheckBox.isSelected()) {
                                domainAxis1.setRange((Date) startDateJSpinner.getValue(),
                                        (Date) endDateJSPinner.getValue());
                            } else {
                                Date startDate = mr.getStartDate();
                                Date endDate = mr.getEndDate();
                                if (mr.getStartDate().before((Date) startDateJSpinner.getValue())) {
                                    startDate = (Date) startDateJSpinner.getValue();
                                    logger.debug("setMinimumDate: " + (Date) startDateJSpinner.getValue());
                                }
                                if (mr.getEndDate().after((Date) endDateJSPinner.getValue())) {
                                    endDate = (Date) endDateJSPinner.getValue();
                                    logger.debug("setMaximumDate: " + (Date) endDateJSPinner.getValue());
                                }
                                if (startDate.before(endDate)) {
                                    domainAxis1.setRange(startDate, endDate);
                                }
                            }
                            XYToolTipGenerator tt1 = new XYToolTipGenerator() {
                                public String generateToolTip(XYDataset dataset, int series, int item) {
                                    StringBuffer sb = new StringBuffer();
                                    String htmlStr = "<html>";
                                    Number x;
                                    FastDateFormat sdf = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss");
                                    x = dataset.getX(series, item);
                                    sb.append(htmlStr);
                                    if (x != null) {
                                        sb.append("<p style='color:#000000;'>" + (sdf.format(x)) + "</p>");
                                        sb.append("<p style='color:#000000;'>"
                                                + dataset.getSeriesKey(series).toString() + ": "
                                                + form.format(dataset.getYValue(0, item)) + "</p>");
                                        if (mr.getFileLineForDate(new Date(x.longValue()),
                                                dataset.getSeriesKey(series).toString()) != null) {
                                            sb.append(
                                                    "<p style='color:#0000FF;'>"
                                                            + cd.sourceFileArrayListMap
                                                                    .get(pairs.getKey()).get(mr
                                                                            .getFileLineForDate(
                                                                                    new Date(x.longValue()),
                                                                                    dataset.getSeriesKey(series)
                                                                                            .toString())
                                                                            .getFileId())
                                                                    .getFile().getName()
                                                            + ":"
                                                            + mr.getFileLineForDate(new Date(x.longValue()),
                                                                    dataset.getSeriesKey(series).toString())
                                                                    .getLineNumber()
                                                            + "</p>");

                                        }
                                    }
                                    return sb.toString();
                                }
                            };

                            while (statMapIterator.hasNext()) {

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                String me = (String) statMapIterator.next();

                                ExtendedTimeSeries ts = (ExtendedTimeSeries) statMap.get(me);
                                // logger.info(((TimeSeries)
                                // me.getValue()).getMaxY());
                                if (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(ts.getTimeSeries());
                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me
                                        + " nb records: " + ((ExtendedTimeSeries) statMap.get(me))
                                                .getTimeSeries().getItemCount());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY()));
                                XYPlot plot1 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.toString());
                                axis4.setAutoRange(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(false);
                                plot1.setDomainCrosshairVisible(true);
                                plot1.setRangeCrosshairVisible(true);
                                axis4.setRange(new Range(
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY(),
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot1.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;
                                domainAxis.setLowerMargin(0.0);
                                domainAxis.setUpperMargin(0.0);
                                plot1.setDomainAxis(domainAxis);
                                plot1.setForegroundAlpha(0.5f);
                                plot1.setDataset(count, dataset);
                                plot1.mapDatasetToRangeAxis(count, count);
                                final XYAreaRenderer renderer = new XYAreaRenderer(); // XYAreaRenderer2
                                // also
                                // nice
                                if ((((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()
                                        - ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries()
                                                .getMinY()) > 0) {

                                    // renderer.setToolTipGenerator(new
                                    // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new
                                    // FastDateFormat("d-MMM-yyyy HH:mm:ss"),
                                    // new DecimalFormat("#,##0.00")));
                                }
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                plot1.setRenderer(count, renderer);
                                int hits = 0; // ts.getStat()[1]
                                int matchs = 0;
                                if (((ExtendedTimeSeries) statMap.get(me)).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) statMap.get(me)).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) statMap.get(me)).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.toString() + "(" + hits + ")", 0));
                                Boolean selected = true;
                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }
                            Iterator eventMapIterator = eventMap.entrySet().iterator();
                            while (eventMapIterator.hasNext()) {

                                //   HistogramDataset histoDataSet=new HistogramDataset();

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                Map.Entry me = (Map.Entry) eventMapIterator.next();
                                // if (dataset.getEndXValue(series, item))
                                if (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(((ExtendedTimeSeries) me.getValue()).getTimeSeries());

                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me.getKey()
                                        + " nb records: "
                                        + ((ExtendedTimeSeries) me.getValue()).getTimeSeries().getItemCount());
                                logger.debug("mineResultSet hash content: " + mr.getEventTimeseriesMap());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMinY()));
                                XYPlot plot2 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.getKey().toString());
                                axis4.setAutoRange(true);
                                // axis4.setInverted(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(true);

                                // axis4.setRange(new Range(((TimeSeries)
                                // axis4.setRange(new Range(((TimeSeries)
                                // me.getValue()).getMinY(), ((TimeSeries)
                                // me.getValue()).getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot2.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;

                                // domainAxis.setLowerMargin(0.001);
                                // domainAxis.setUpperMargin(0.0);
                                plot2.setDomainCrosshairVisible(true);
                                plot2.setRangeCrosshairVisible(true);
                                //plot2.setRangeCrosshairLockedOnData(true);
                                plot2.setDomainAxis(domainAxis);
                                plot2.setForegroundAlpha(0.5f);
                                plot2.setDataset(count, dataset);
                                plot2.mapDatasetToRangeAxis(count, count);
                                XYBarRenderer rend = new XYBarRenderer(); // XYErrorRenderer

                                rend.setShadowVisible(false);
                                rend.setDrawBarOutline(true);
                                Stroke stroke = new BasicStroke(5);
                                rend.setBaseStroke(stroke);
                                final XYItemRenderer renderer = rend;
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                // renderer.setItemLabelsVisible(true);
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                plot2.setRenderer(count, renderer);
                                int hits = 0;
                                int matchs = 0;

                                if (((ExtendedTimeSeries) me.getValue()).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) me.getValue()).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) me.getValue()).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.getKey().toString() + "(" + hits + ")", 0));

                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }

                            JPanel pan = new JPanel();

                            pan.setLayout(new BorderLayout());
                            pan.setPreferredSize(new Dimension(600,
                                    Integer.parseInt((String) Preferences.getPreference("chartSize"))));
                            // pan.setPreferredSize(panelSize);
                            panel.add(pan);
                            final ChartPanel cpanel = new ChartPanel(chart);
                            cpanel.setMinimumDrawWidth(0);
                            cpanel.setMinimumDrawHeight(0);
                            cpanel.setMaximumDrawWidth(1920);
                            cpanel.setMaximumDrawHeight(1200);
                            // cpanel.setInitialDelay(0);
                            cpanel.setDismissDelay(9999999);
                            cpanel.setInitialDelay(50);
                            cpanel.setReshowDelay(200);
                            cpanel.setPreferredSize(new Dimension(600, 350));
                            // cpanel.restoreAutoBounds(); fix the tooltip
                            // missing problem but then relative display is
                            // broken
                            panel.add(new JSeparator(SwingConstants.HORIZONTAL));
                            pan.add(cpanel, BorderLayout.CENTER);
                            // checkboxPanel.setPreferredSize(new Dimension(600,
                            // 0));
                            cpanel.addChartMouseListener(new ChartMouseListener() {

                                public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
                                    // chartmouseevent.getEntity().

                                    ChartEntity entity = chartmouseevent.getEntity();
                                    if (entity instanceof XYItemEntity) {
                                        XYItemEntity item = ((XYItemEntity) entity);
                                        if (item.getDataset() instanceof TimeSeriesCollection) {

                                            TimeSeriesCollection data = (TimeSeriesCollection) item
                                                    .getDataset();
                                            TimeSeries series = data.getSeries(item.getSeriesIndex());
                                            TimeSeriesDataItem dataitem = series.getDataItem(item.getItem());

                                            // logger.info(" Serie: "+series.getKey().toString()
                                            // +
                                            // " Period : "+dataitem.getPeriod().toString());
                                            // mr.getFileForDate(new Date
                                            // (x.longValue())
                                            ;
                                            int x = chartmouseevent.getTrigger().getX();
                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getEnd()));
                                            int y = chartmouseevent.getTrigger().getY();
                                            String myString = "";
                                            if (dataitem.getPeriod() != null) {
                                                logger.info(dataitem.getPeriod().getEnd());
                                                //                                    myString = mr.getFileForDate(dataitem.getPeriod().getEnd()).toString();
                                                String lineString = ""
                                                        + mr.getFileLineForDate(dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getLineNumber();
                                                String fileString = cd.sourceFileArrayListMap
                                                        .get(pairs.getKey())
                                                        .get(mr.getFileLineForDate(
                                                                dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getFileId())
                                                        .getFile().getAbsolutePath();
                                                String command = Preferences.getPreference("editorCommand");
                                                command = command.replace("$line", lineString);
                                                command = command.replace("$file", fileString);
                                                logger.info(command);
                                                Runtime rt = Runtime.getRuntime();
                                                try {
                                                    rt.exec(command);
                                                } catch (IOException e1) {
                                                    // TODO Auto-generated catch block
                                                    e1.printStackTrace();
                                                }
                                                StringSelection stringSelection = new StringSelection(
                                                        fileString);
                                                Clipboard clpbrd = Toolkit.getDefaultToolkit()
                                                        .getSystemClipboard();
                                                clpbrd.setContents(stringSelection, null);
                                                //      cpanel.getGraphics().drawString("file name copied", x - 5, y - 5);
                                                try {
                                                    Thread.sleep(500);
                                                } catch (InterruptedException e) {
                                                    // TODO Auto-generated catch
                                                    // block
                                                    e.printStackTrace();
                                                }
                                            }

                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getStart()));
                                        }
                                    }
                                }

                                public void chartMouseMoved(ChartMouseEvent e) {
                                }

                            });

                            pan.add(checkboxPanel, BorderLayout.SOUTH);

                        }
                    }
                } else {
                    logger.debug("mr dates null: " + mr.getGroup() + mr.getSourceID() + mr.getLogFiles());
                }
            }
        }
    }
    // Map=miner.mine(sourceFiles,repo);
    estimatedTime = System.currentTimeMillis() - startTime;

    revalidate();
    logger.info("display time: " + estimatedTime);
}

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

/**
 * Creates a sample chart./*from w  ww  .  j  a  v a 2s.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:probe.com.view.core.chart4j.VennDiagramPanel.java

/**
 * Update the plot.//from w w w.  jav  a 2 s.co m
 */
public void updatePlot() {

    //        plotPanel.removeAll();
    tooltipToDatasetMap = new HashMap<String, String>();

    DefaultXYZDataset xyzDataset = new DefaultXYZDataset();

    chart = ChartFactory.createBubbleChart(null, "X", "Y", xyzDataset, PlotOrientation.VERTICAL, false, true,
            false);
    XYPlot plot = chart.getXYPlot();

    if (currentVennDiagramType == VennDiagramType.ONE_WAY) {
        plot.getRangeAxis().setRange(0.86, 1.24);
        plot.getDomainAxis().setRange(0.85, 1.25);
    } else if (currentVennDiagramType == VennDiagramType.TWO_WAY) {
        plot.getRangeAxis().setRange(0.86, 1.24);
        plot.getDomainAxis().setRange(0.85, 1.25);
    } else if (currentVennDiagramType == VennDiagramType.THREE_WAY) {
        plot.getRangeAxis().setRange(0.86, 1.24);
        plot.getDomainAxis().setRange(0.85, 1.25);
    } else {
        plot.getRangeAxis().setRange(-0.04, 0.6);
        plot.getDomainAxis().setRange(-0.08, 0.7);
    }

    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);

    double radius = 0.1;
    Ellipse2D ellipse = new Ellipse2D.Double(1 - radius, 1 - radius, radius + radius, radius + radius);
    XYShapeAnnotation xyShapeAnnotation = new XYShapeAnnotation(ellipse, new BasicStroke(2f),
            new Color(140, 140, 140, 150), datasetAColor); // @TODO: make it possible set the line color and width?
    plot.addAnnotation(xyShapeAnnotation);

    if (currentVennDiagramType == VennDiagramType.TWO_WAY
            || currentVennDiagramType == VennDiagramType.THREE_WAY) {
        ellipse = new Ellipse2D.Double(1 - radius + 0.1, 1 - radius, radius + radius, radius + radius);
        xyShapeAnnotation = new XYShapeAnnotation(ellipse, new BasicStroke(2f), new Color(140, 140, 140, 150),
                datasetBColor);
        plot.addAnnotation(xyShapeAnnotation);
    }

    if (currentVennDiagramType == VennDiagramType.THREE_WAY) {
        ellipse = new Ellipse2D.Double(1 - radius + 0.05, 1 - radius + 0.1, radius + radius, radius + radius);
        xyShapeAnnotation = new XYShapeAnnotation(ellipse, new BasicStroke(2f), new Color(140, 140, 140, 150),
                datasetCColor);
        plot.addAnnotation(xyShapeAnnotation);
    }

    XYTextAnnotation anotation;

    if (currentVennDiagramType == VennDiagramType.ONE_WAY) {

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("a").size(), 1.0, 1.0);
        anotation.setToolTipText(groupNames.get("a"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "a");

        // legend
        if (showLegend) {
            anotation = new XYTextAnnotation(groupNames.get("a"), legendDatasetAThreeWay.getX(),
                    legendDatasetAThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
        }

    } else if (currentVennDiagramType == VennDiagramType.TWO_WAY) {

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("a").size(), 0.96, 1.0);
        anotation.setToolTipText(groupNames.get("a"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "a");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("b").size(), 1.14, 1.0);
        anotation.setToolTipText(groupNames.get("b"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "b");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ab").size(), 1.05, 1.0);
        anotation
                .setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ab");

        // legend
        if (showLegend) {
            anotation = new XYTextAnnotation(groupNames.get("a"), legendDatasetAThreeWay.getX(),
                    legendDatasetAThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("b"), legendDatasetBThreeWay.getX(),
                    legendDatasetBThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
        }

    } else if (currentVennDiagramType == VennDiagramType.THREE_WAY) {

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("a").size(), 0.96, 0.97);
        anotation.setToolTipText(groupNames.get("a"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "a");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("b").size(), 1.14, 0.97);
        anotation.setToolTipText(groupNames.get("b"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "b");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ab").size(), 1.05, 0.97);
        anotation
                .setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ab");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("c").size(), 1.05, 1.14);
        anotation.setToolTipText(groupNames.get("c"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "c");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ac").size(), 0.99, 1.065);
        anotation.setToolTipText(
                "<html>" + groupNames.get("a") + "  &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ac");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("bc").size(), 1.11, 1.065);
        anotation
                .setToolTipText("<html>" + groupNames.get("b") + " &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "bc");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("abc").size(), 1.05, 1.036);
        anotation.setToolTipText("<html>" + groupNames.get("a") + "  &#8745; " + groupNames.get("b")
                + " &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "abc");

        // legend
        if (showLegend) {
            anotation = new XYTextAnnotation(groupNames.get("a"), legendDatasetAThreeWay.getX(),
                    legendDatasetAThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("b"), legendDatasetBThreeWay.getX(),
                    legendDatasetBThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("c"), legendDatasetCThreeWay.getX(),
                    legendDatasetCThreeWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
        }

    } else if (currentVennDiagramType == VennDiagramType.FOUR_WAY) {

        XYBoxAnnotation anotation2 = new XYBoxAnnotation(0, 0, 0.2, 0.5, new BasicStroke(2), Color.LIGHT_GRAY,
                datasetAColor);
        plot.addAnnotation(anotation2);

        anotation2 = new XYBoxAnnotation(0.1, 0, 0.3, 0.4, new BasicStroke(2), Color.LIGHT_GRAY, datasetBColor);
        plot.addAnnotation(anotation2);

        anotation2 = new XYBoxAnnotation(0, 0.1, 0.4, 0.3, new BasicStroke(2), Color.LIGHT_GRAY, datasetCColor);
        plot.addAnnotation(anotation2);

        anotation2 = new XYBoxAnnotation(0, 0, 0.5, 0.2, new BasicStroke(2), Color.LIGHT_GRAY, datasetDColor);
        plot.addAnnotation(anotation2);

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("a").size(), 0.15, 0.45);
        anotation.setToolTipText(groupNames.get("a"));
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "a");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ab").size(), 0.15, 0.35);
        anotation
                .setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ab");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("abc").size(), 0.15, 0.25);
        anotation.setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b")
                + " &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "abc");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("abcd").size(), 0.15, 0.15);
        anotation.setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b")
                + " &#8745; " + groupNames.get("c") + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "abcd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("abd").size(), 0.15, 0.05);
        anotation.setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("b")
                + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "abd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ac").size(), 0.05, 0.25);
        anotation
                .setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ac");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("acd").size(), 0.05, 0.15);
        anotation.setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("c")
                + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "acd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("ad").size(), 0.05, 0.05);
        anotation
                .setToolTipText("<html>" + groupNames.get("a") + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "ad");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("b").size(), 0.25, 0.35);
        anotation.setToolTipText("<html>" + groupNames.get("b") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "b");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("bc").size(), 0.25, 0.25);
        anotation
                .setToolTipText("<html>" + groupNames.get("b") + " &#8745; " + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "bc");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("bcd").size(), 0.25, 0.15);
        anotation.setToolTipText("<html>" + groupNames.get("b") + " &#8745; " + groupNames.get("c")
                + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "bcd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("bd").size(), 0.25, 0.05);
        anotation
                .setToolTipText("<html>" + groupNames.get("b") + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "bd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("c").size(), 0.35, 0.25);
        anotation.setToolTipText("<html>" + groupNames.get("c") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "c");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("cd").size(), 0.35, 0.15);
        anotation
                .setToolTipText("<html>" + groupNames.get("c") + " &#8745; " + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "cd");

        anotation = new XYTextAnnotation("" + vennDiagramResults.get("d").size(), 0.45, 0.15);
        anotation.setToolTipText("<html>" + groupNames.get("d") + "</html>");
        anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeValues));
        plot.addAnnotation(anotation);
        tooltipToDatasetMap.put(anotation.getToolTipText(), "d");

        // legend
        if (showLegend) {
            anotation = new XYTextAnnotation(groupNames.get("a"), legendDatasetAFourWay.getX(),
                    legendDatasetAFourWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("b"), legendDatasetBFourWay.getX(),
                    legendDatasetBFourWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("c"), legendDatasetCFourWay.getX(),
                    legendDatasetCFourWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
            anotation = new XYTextAnnotation(groupNames.get("d"), legendDatasetDFourWay.getX(),
                    legendDatasetDFourWay.getY());
            anotation.setTextAnchor(TextAnchor.BASELINE_LEFT);
            anotation.setFont(new Font(anotation.getFont().getFontName(), Font.BOLD, fontSizeLegend));
            plot.addAnnotation(anotation);
        }
    }

    // set up the renderer
    XYBubbleRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    plot.setRenderer(renderer);

    // make all datapoints semitransparent
    plot.setForegroundAlpha(0.5f);

    // remove space before/after the domain axis
    plot.getDomainAxis().setUpperMargin(0);
    plot.getDomainAxis().setLowerMargin(0);

    plot.setRangeGridlinePaint(Color.black);

    // hide unwanted chart details
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    chart.getPlot().setOutlineVisible(false);

    // set background color
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setBackgroundPaint(Color.WHITE);
    chartPanel = new ChartPanel(chart);

    // disable the pop up menu
    chartPanel.setPopupMenu(null);

    chartPanel.setBackground(Color.WHITE);

    // add the plot to the chart
    //        plotPanel.add(chartPanel);
    //        plotPanel.revalidate();
    //        plotPanel.repaint();
    //
    //      this.add(plotPanel);
}

From source file:org.jfree.chart.ChartFactory.java

/**
 * Creates an area chart using an {@link XYDataset}.
 * <P>/*from  w w w . ja  v  a  2 s  .c o m*/
 * The chart object returned by this method uses an {@link XYPlot} instance
 * as the plot, with a {@link NumberAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as
 * the renderer.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param xAxisLabel  a label for the X-axis ({@code null} permitted).
 * @param yAxisLabel  a label for the Y-axis ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return An XY area chart.
 */
public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setForegroundAlpha(0.5f);

    XYToolTipGenerator tipGenerator = new StandardXYToolTipGenerator();
    plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, null));
    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}