List of usage examples for org.jfree.chart.renderer.xy XYBubbleRenderer XYBubbleRenderer
public XYBubbleRenderer(int scaleType)
From source file:org.jfree.chart.demo.BubbleChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { JFreeChart jfreechart = ChartFactory.createBubbleChart("Bubble Chart Demo 2", "X", "Y", xyzdataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setRenderer(new XYBubbleRenderer(0)); xyplot.setForegroundAlpha(0.65F);/*from w w w. j av a 2 s . com*/ XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.blue); xyitemrenderer.setBaseItemLabelGenerator(new BubbleXYItemLabelGenerator()); xyitemrenderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); xyitemrenderer.setBaseItemLabelsVisible(true); xyitemrenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setRange(0.0D, 10D); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setRange(0.0D, 10D); return jfreechart; }
From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java
protected void buildChart() { DefaultXYZDataset dataset = new DefaultXYZDataset(); chart = ChartFactory.createBubbleChart("Untitled Chart", "Untitled X Axis", "Untitled Y Axis", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setAntiAlias(true);/* ww w .j a v a2 s . c o m*/ chartPanel = buildChartPanel(chart); setChartPanel(chartPanel); // most irritating: you can't change the scale type once you've // constructed the renderer. :-( chart.getXYPlot().setRenderer(new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_DOMAIN_AXIS)); // this must come last because the chart must exist for us to set its dataset setSeriesDataset(dataset); }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * Creates a bubble chart with default settings. The chart is composed of an {@link XYPlot}, with a {@link NumberAxis} for the * domain axis, a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} to draw the data items. * /* w w w . j a v a 2s. co m*/ * This method is copied from * {@link org.jfree.chart.ChartFactory#createBubbleChart(String, String, String, XYZDataset, PlotOrientation, boolean, boolean, boolean)} * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the orientation (horizontal or vertical) (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bubble chart. */ public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException(Messages.getString("TopChartFactory.argument")); //$NON-NLS-1$ } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS) { @Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // return straight away if the item is not visible if (!getItemVisible(series, item)) { return; } PlotOrientation orientation = plot.getOrientation(); // get the data point... double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = Double.NaN; if (dataset instanceof XYZDataset) { XYZDataset xyzData = (XYZDataset) dataset; z = xyzData.getZValue(series, item); } if (!Double.isNaN(z)) { RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, domainAxisLocation); double transY = rangeAxis.valueToJava2D(y, dataArea, rangeAxisLocation); double transDomain = 0.0; double transRange = 0.0; double zero; // MOD scorreia +2L avoid points: minimal size of circle must be 1 // z = z * transX + 1; // ADD xqliu 2009-07-06 bug 8035 double zSize = getBubbleSize(z); // calculate the multiple of bubble's default size z = 0; // use bubble's default size // ~ switch (getScaleType()) { case SCALE_ON_DOMAIN_AXIS: zero = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero; transRange = transDomain; break; case SCALE_ON_RANGE_AXIS: zero = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transRange = zero - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); transDomain = transRange; break; default: double zero1 = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero1; transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); } transDomain = Math.abs(transDomain); transRange = Math.abs(transRange); // MODSCA 2008-11-27 enlarge ellipse by diag% of the total diagonal double diag = Math.sqrt(dataArea.getHeight() * dataArea.getHeight() + dataArea.getWidth() * dataArea.getWidth()); transDomain += diag / 100; transRange += diag / 100; Ellipse2D circle = null; // ADD xqliu 2009-07-06 bug 8035 transDomain *= zSize; transRange *= zSize; // ~ if (orientation == PlotOrientation.VERTICAL) { circle = new Ellipse2D.Double(transX - transDomain / 2.0, transY - transRange / 2.0, transDomain, transRange); } else if (orientation == PlotOrientation.HORIZONTAL) { circle = new Ellipse2D.Double(transY - transRange / 2.0, transX - transDomain / 2.0, transRange, transDomain); } g2.setPaint(getItemPaint(series, item)); g2.fill(circle); g2.setStroke(getItemOutlineStroke(series, item)); g2.setPaint(getItemOutlinePaint(series, item)); g2.draw(circle); if (isItemLabelVisible(series, item)) { if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, series, item, transX, transY, false); } else if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, series, item, transY, transX, false); } } // add an entity if this info is being collected EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); if (entities != null && circle.intersects(dataArea)) { addEntity(entities, circle, dataset, series, item, circle.getCenterX(), circle.getCenterY()); } } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } } /** * DOC xqliu : calculate the size of bubble. for bug 8035 2009-07-06. * * @param z multiple of bubble's default size * @return */ private double getBubbleSize(double z) { if (z > 0 && z <= 10) { return 2; } else if (z > 10 && z <= 100) { return 3; } else if (z > 100) { return 4; } return 1; } }; if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java
private void updateChart(SimpleFeatureCollection features, String xField, String yField, String sizeField) { // 1. Create a single plot containing both the scatter and line XYPlot plot = new XYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainPannable(false);/* w w w .java 2 s . co m*/ plot.setRangePannable(false); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setForegroundAlpha(0.75f); // 2. Setup Scatter plot // Create the bubble chart data, renderer, and axis int fontStyle = java.awt.Font.BOLD; FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0]; NumberAxis xPlotAxis = new NumberAxis(xField); // Independent variable xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); NumberAxis yPlotAxis = new NumberAxis(yField); // Dependent variable yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); XYItemRenderer plotRenderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); plotRenderer.setSeriesPaint(0, java.awt.Color.ORANGE); // dot plotRenderer.setBaseItemLabelGenerator(new BubbleXYItemLabelGenerator()); plotRenderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); plotRenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // Set the bubble chart data, renderer, and axis into plot plot.setDataset(0, getBubbleChartData(features, xField, yField, sizeField)); xPlotAxis.setAutoRangeIncludesZero(false); xPlotAxis.setAutoRange(false); double differUpper = minMaxVisitor.getMaxX() - minMaxVisitor.getAverageX(); double differLower = minMaxVisitor.getAverageX() - minMaxVisitor.getMinX(); double gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { xPlotAxis.setRange(minMaxVisitor.getMinX() - gap, minMaxVisitor.getMaxX()); } else { xPlotAxis.setRange(minMaxVisitor.getMinX(), minMaxVisitor.getMaxX() + gap); } yPlotAxis.setAutoRangeIncludesZero(false); yPlotAxis.setAutoRange(false); differUpper = minMaxVisitor.getMaxY() - minMaxVisitor.getAverageY(); differLower = minMaxVisitor.getAverageY() - minMaxVisitor.getMinY(); gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { yPlotAxis.setRange(minMaxVisitor.getMinY() - gap, minMaxVisitor.getMaxY()); } else { yPlotAxis.setRange(minMaxVisitor.getMinY(), minMaxVisitor.getMaxY() + gap); } plot.setRenderer(0, plotRenderer); plot.setDomainAxis(0, xPlotAxis); plot.setRangeAxis(0, yPlotAxis); // Map the scatter to the first Domain and first Range plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); // 3. Setup line // Create the line data, renderer, and axis XYItemRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); // Lines only lineRenderer.setSeriesPaint(0, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(1, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(2, java.awt.Color.GRAY); // Set the line data, renderer, and axis into plot NumberAxis xLineAxis = new NumberAxis(EMPTY); xLineAxis.setTickMarksVisible(false); xLineAxis.setTickLabelsVisible(false); NumberAxis yLineAxis = new NumberAxis(EMPTY); yLineAxis.setTickMarksVisible(false); yLineAxis.setTickLabelsVisible(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); // AverageY XYSeries horizontal = new XYSeries("AverageY"); //$NON-NLS-1$ horizontal.add(xPlotAxis.getRange().getLowerBound(), minMaxVisitor.getAverageY()); horizontal.add(xPlotAxis.getRange().getUpperBound(), minMaxVisitor.getAverageY()); lineDataset.addSeries(horizontal); // AverageX XYSeries vertical = new XYSeries("AverageX"); //$NON-NLS-1$ vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getLowerBound()); vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getUpperBound()); lineDataset.addSeries(vertical); plot.setDataset(1, lineDataset); plot.setRenderer(1, lineRenderer); plot.setDomainAxis(1, xLineAxis); plot.setRangeAxis(1, yLineAxis); // Map the line to the second Domain and second Range plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); // 4. Setup Selection NumberAxis xSelectionAxis = new NumberAxis(EMPTY); xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false); NumberAxis ySelectionAxis = new NumberAxis(EMPTY); ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false); XYItemRenderer selectionRenderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot selectionRenderer.setSeriesOutlinePaint(0, java.awt.Color.RED); plot.setDataset(2, new DefaultXYZDataset2()); plot.setRenderer(2, selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2, ySelectionAxis); // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2, 0); plot.mapDatasetToRangeAxis(2, 0); // 5. Finally, Create the chart with the plot and a legend java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20); JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite.setChart(chart); chartComposite.forceRedraw(); }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createBubbleChart(XYZDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); // A renderer that draws a circle at each data point with a diameter that is // determined by the z-value in the dataset (the renderer requires the dataset // to be an instance of {@link XYZDataset}. XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); }//w w w . j ava2 s .c o m if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart("Bubble Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:probe.com.view.core.chart4j.VennDiagramPanel.java
/** * Update the plot./*from w w w . j a v a 2 s .c o 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") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + groupNames.get("b") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + groupNames.get("b") + " ∩ " + 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") + " ∩ " + groupNames.get("b") + " ∩ " + groupNames.get("c") + " ∩ " + 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") + " ∩ " + groupNames.get("b") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + groupNames.get("c") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + groupNames.get("c") + " ∩ " + 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") + " ∩ " + 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") + " ∩ " + 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:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRBubblePlot) getPlot()).getXAxisLabelExpression()), (String) evaluateExpression(((JRBubblePlot) getPlot()).getYAxisLabelExpression()), (XYZDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot) getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer(scaleType); xyPlot.setRenderer(bubbleRenderer);//from w w w . j ava 2s. c o m // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), false, (Comparable) evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), true, (Comparable) evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRBubblePlot) getPlot()).getXAxisLabelExpression()), (String) evaluateExpression(((JRBubblePlot) getPlot()).getYAxisLabelExpression()), (XYZDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot) getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer(scaleType); xyPlot.setRenderer(bubbleRenderer);// w ww . j a va 2s . c o m // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBubblePlot) getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRBubblePlot) getPlot()).getYAxisLabelExpression()), (XYZDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);/*from w w w . j a va2 s. c o m*/ configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot) getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer(scaleType); xyPlot.setRenderer(bubbleRenderer); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), false, (Comparable<?>) evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), true, (Comparable<?>) evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createBubbleChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createBubbleChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRBubblePlot) getPlot()).getXAxisLabelExpression()), evaluateTextExpression(((JRBubblePlot) getPlot()).getYAxisLabelExpression()), (XYZDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);// w w w .java 2s. c o m configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRBubblePlot bubblePlot = (JRBubblePlot) getPlot(); int scaleType = bubblePlot.getScaleTypeValue() == null ? ScaleTypeEnum.ON_RANGE_AXIS.getValue() : bubblePlot.getScaleTypeValue().getValue(); XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer(scaleType); xyPlot.setRenderer(bubbleRenderer); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisVerticalTickLabels(), bubblePlot.getOwnXAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(bubblePlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bubblePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisVerticalTickLabels(), bubblePlot.getOwnYAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(bubblePlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(bubblePlot.getRangeAxisMaxValueExpression())); return jfreeChart; }