List of usage examples for org.jfree.chart.block BlockBorder NONE
BlockBorder NONE
To view the source code for org.jfree.chart.block BlockBorder NONE.
Click Source Link
From source file:net.nosleep.superanalyzer.analysis.views.YearView.java
private void createChart() { NumberAxis xAxis = new NumberAxis(Misc.getString("RELEASE_YEAR")); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(Misc.getString("SONG_COUNT")); yAxis.setAutoRangeIncludesZero(true); xAxis.setNumberFormatOverride(new DecimalFormat("0")); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(_dataset, xAxis, yAxis, renderer); // create and return the chart panel... _chart = new JFreeChart(Misc.getString("RELEASE_YEAR"), JFreeChart.DEFAULT_TITLE_FONT, plot, true); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); LegendTitle legend = _chart.getLegend(); legend.setFrame(BlockBorder.NONE); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("RELEASE_YEAR_TOOLTIP"))); XYToolTipGenerator generator = new StandardXYToolTipGenerator("{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(generator); ChartUtilities.applyCurrentTheme(_chart); // format the lines after applying the theme renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true);//w ww . ja v a 2 s. c om renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(1, new BasicStroke(2.0f)); renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); _chart.setPadding(new RectangleInsets(10, 10, 10, 10)); Misc.formatChart(plot); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void initialize() { final JFreeChart chart = chartNode.getChart(); final XYPlot plot = chart.getXYPlot(); // Do not set colors and strokes dynamically. They are instead provided // by the dataset and configured in configureRenderer() plot.setDrawingSupplier(null);/* w ww .ja v a 2 s . c o m*/ plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (m/z) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("m/z"); xAxis.setUpperMargin(0.03); xAxis.setLowerMargin(0.03); xAxis.setRangeType(RangeType.POSITIVE); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel("Intensity"); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setAutoRangeIncludesZero(true); // set the fixed number formats, because otherwise JFreeChart sometimes // shows exponent, sometimes it doesn't DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); xAxis.setNumberFormatOverride(mzFormat); DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); yAxis.setNumberFormatOverride(intensityFormat); chartTitle = chartNode.getChart().getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (MsSpectrumDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (MsSpectrumDataSet dataset : datasets) { int datasetIndex = plot.indexOf(dataset); XYItemRenderer renderer = plot.getRenderer(datasetIndex); renderer.setBaseItemLabelsVisible(newVal); } }); legendVisible.addListener((prop, oldVal, newVal) -> { legend.setVisible(newVal); }); }
From source file:com.rapidminer.gui.viewer.ROCChartPlotter.java
public void paintDeviationChart(Graphics graphics, int width, int height) { prepareData();/* www .ja v a2 s .c om*/ JFreeChart chart = createChart(this.dataset); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); } Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height); chart.draw((Graphics2D) graphics, drawRect); }
From source file:probe.com.view.body.quantcompare.PieChart.java
private String initPieChart(int width, int height, String title) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int x = 0; x < labels.length; x++) { dataset.setValue(labels[x], values[x]); }/* ww w. j a v a 2s. c om*/ PiePlot plot = new PiePlot(dataset); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0); plot.setLabelFont(new Font("Verdana", Font.BOLD, 10)); plot.setLabelGenerator(new PieSectionLabelGenerator() { @Override public String generateSectionLabel(PieDataset pd, Comparable cmprbl) { return valuesMap.get(cmprbl.toString()); } @Override public AttributedString generateAttributedSectionLabel(PieDataset pd, Comparable cmprbl) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelShadowPaint(null); plot.setLabelPaint(Color.WHITE); plot.setLabelOutlinePaint(null); plot.setBackgroundPaint(Color.WHITE); plot.setInteriorGap(0); plot.setShadowPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f)); plot.setInteriorGap(0.05); for (String label : labels) { plot.setSectionPaint(label, defaultKeyColorMap.get(label)); } JFreeChart chart = new JFreeChart(plot); // chart.setTitle(new TextTitle(title, new Font("Verdana", Font.BOLD, 13))); chart.setBorderPaint(null); chart.setBackgroundPaint(null); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setItemFont(new Font("Verdana", Font.PLAIN, 10)); String imgUrl = saveToFile(chart, width, height); return imgUrl; }
From source file:edu.cudenver.bios.chartsvc.resource.ScatterPlotResource.java
/** * Create a JFreeChart object from the chart specification. JFreechart provides * functionality to render 2D scatter plots as jpeg images * //from w w w . j av a2 s . c o m * @param chart chart specification object * @return JFreeChart object * @throws ResourceException */ private JFreeChart buildScatterPlot(Chart chart) throws ResourceException { ArrayList<LineStyle> lineStyleList = chart.getLineStyleList(); float dashedLength = 1.0f; float spaceLength = 1.0f; float thickness = 1.0f; // the first series is treated as the x values if (chart.getSeries() == null || chart.getSeries().size() <= 0) throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No data series specified"); // create the jfree chart series XYSeriesCollection chartData = new XYSeriesCollection(); // use a spline renderer to make the connecting lines smooth XYSplineRenderer rend = new XYSplineRenderer(); int seriesIdx = 0; for (Series series : chart.getSeries()) { XYSeries xySeries = new XYSeries(series.getLabel()); List<Double> xList = series.getXCoordinates(); List<Double> yList = series.getYCoordinates(); if (xList != null && yList != null && xList.size() == yList.size()) { for (int i = 0; i < xList.size(); i++) { xySeries.add(xList.get(i), yList.get(i)); } } if (seriesIdx >= 0 && seriesIdx < lineStyleList.size()) { LineStyle lineStyle = lineStyleList.get(seriesIdx); dashedLength = (float) lineStyle.getDashLength(); spaceLength = (float) lineStyle.getSpaceLength(); thickness = (float) lineStyle.getWidth(); } else { dashedLength = 1.0f; spaceLength = 1.0f; thickness = 1.0f; } // set the line style rend.setSeriesPaint(seriesIdx, Color.BLACK); if (seriesIdx >= 0) { /*rend.setSeriesStroke(seriesIdx, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {(float) seriesIdx, (float) 2*seriesIdx}, 0.0f));*/ rend.setSeriesStroke(seriesIdx, new BasicStroke(thickness, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { dashedLength, spaceLength }, 0.0f)); } // add the series to the data set chartData.addSeries(xySeries); seriesIdx++; } // turn off shapes displayed at each data point to make a smooth curve rend.setBaseShapesVisible(false); // Create the line chart NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRangeIncludesZero(false); if (chart.getXAxis() != null) { Axis xAxisSpec = chart.getXAxis(); xAxis.setLabel(xAxisSpec.getLabel()); if (!Double.isNaN(xAxisSpec.getRangeMin()) && !Double.isNaN(xAxisSpec.getRangeMax())) { xAxis.setRange(xAxisSpec.getRangeMin(), xAxisSpec.getRangeMax()); } } NumberAxis yAxis = new NumberAxis(); if (chart.getYAxis() != null) { Axis yAxisSpec = chart.getYAxis(); yAxis.setLabel(chart.getYAxis().getLabel()); if (!Double.isNaN(yAxisSpec.getRangeMin()) && !Double.isNaN(yAxisSpec.getRangeMax())) { xAxis.setRange(yAxisSpec.getRangeMin(), yAxisSpec.getRangeMax()); } } XYPlot plot = new XYPlot((XYDataset) chartData, xAxis, yAxis, rend); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); JFreeChart renderedChart = new JFreeChart(chart.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); renderedChart.setBackgroundPaint(Color.WHITE); if (chart.hasLegend()) { LegendTitle legend = new LegendTitle(plot, new ColumnArrangement(), new ColumnArrangement()); legend.setFrame(BlockBorder.NONE); legend.setPosition(RectangleEdge.BOTTOM); renderedChart.addLegend(legend); } return renderedChart; }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.interactivepiechartfilters.JfreeDivaPieChartFilter.java
private String initPieChart(int width, int height) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int x = 0; x < labels.length; x++) { dataset.setValue(labels[x], new Double(values[x])); }//from www .j a va 2 s . c o m plot = new PiePlot(dataset); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0); plot.setLabelFont(new Font("Verdana", Font.BOLD, 15)); plot.setLabelGenerator(new PieSectionLabelGenerator() { @Override public String generateSectionLabel(PieDataset pd, Comparable cmprbl) { return valuesMap.get(cmprbl.toString()); } @Override public AttributedString generateAttributedSectionLabel(PieDataset pd, Comparable cmprbl) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelShadowPaint(null); plot.setLabelPaint(Color.WHITE); plot.setLabelOutlinePaint(null); plot.setBackgroundPaint(Color.WHITE); plot.setInteriorGap(0); plot.setShadowPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f)); plot.setInteriorGap(0.05); for (String label : labels) { plot.setSectionPaint(label, defaultKeyColorMap.get(label)); } chart = new JFreeChart(plot); chart.setTitle( new TextTitle(Local_Filter_Manager.getFilterTitle(filter_Id), new Font("Verdana", Font.BOLD, 13))); chart.setBorderPaint(null); chart.setBackgroundPaint(null); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setItemFont(new Font("Verdana", Font.PLAIN, 12)); String imgUrl = saveToFile(chart, width, height); return imgUrl; }
From source file:com.rapidminer.template.gui.RoleRequirementSelector.java
private JFreeChart makeChart(ExampleSet exampleSet, Attribute att) { DefaultPieDataset pieDataset = new DefaultPieDataset(); if (att.isNominal()) { for (String val : att.getMapping().getValues()) { pieDataset.setValue(val, exampleSet.getStatistics(att, Statistics.COUNT, val)); }//from w ww . ja v a 2 s .com } JFreeChart chart = ChartFactory.createPieChart(null, pieDataset, true, false, false); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setFrame(BlockBorder.NONE); chart.setBackgroundImageAlpha(0.0f); chart.setBorderVisible(false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setShadowPaint(null); plot.setOutlineVisible(false); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); plot.setCircular(true); return chart; }
From source file:com.rapidminer.gui.plotter.charts.ParallelPlotter2.java
@Override public void updatePlotter() { prepareData();/*from w w w . j a v a 2 s.c o m*/ JFreeChart chart = createChart(this.dataset); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis SymbolAxis axis = null; if (this.dataTable.isSupportingColumnWeights()) { List<Double> weightList = new LinkedList<>(); for (int column = 0; column < dataTable.getNumberOfColumns(); column++) { if ((!dataTable.isSpecial(column)) && (column != colorColumn)) { weightList.add(this.dataTable.getColumnWeight(column)); } } double[] weights = new double[weightList.size()]; int index = 0; for (Double d : weightList) { weights[index++] = d; } axis = new WeightBasedSymbolAxis(null, domainAxisMap, weights); } else { axis = new SymbolAxis(null, domainAxisMap); } axis.setTickLabelFont(LABEL_FONT); axis.setLabelFont(LABEL_FONT_BOLD); // rotate labels if (isLabelRotating()) { axis.setTickLabelsVisible(true); axis.setVerticalTickLabels(true); } chart.getXYPlot().setDomainAxis(axis); // renderer final ColorizedLineAndShapeRenderer renderer = new ColorizedLineAndShapeRenderer(this.colorMap); plot.setRenderer(renderer); // legend settings if ((colorColumn >= 0) && (this.dataTable.isNominal(colorColumn))) { final LegendItemCollection legendItemCollection = new LegendItemCollection(); for (int i = 0; i < this.dataTable.getNumberOfValues(colorColumn); i++) { legendItemCollection.add(new LegendItem(this.dataTable.mapIndex(colorColumn, i), null, null, null, new Rectangle2D.Double(0, 0, 7, 7), getColorProvider() .getPointColor(i / (double) (this.dataTable.getNumberOfValues(colorColumn) - 1)), new BasicStroke(0.75f), Color.GRAY)); } chart.addLegend(new LegendTitle(new LegendItemSource() { @Override public LegendItemCollection getLegendItems() { return legendItemCollection; } })); LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } else if (colorColumn >= 0) { chart.addLegend(new LegendTitle(new LegendItemSource() { @Override public LegendItemCollection getLegendItems() { LegendItemCollection itemCollection = new LegendItemCollection(); itemCollection.add(new LegendItem("Dummy")); return itemCollection; } }) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, renderer.getMinColorValue(), renderer.getMaxColorValue()); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(renderer.getMinColorValue()); final String maxColorString = Tools.formatNumber(renderer.getMaxColorValue()); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7), dataTable.getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }); } // chart panel if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); }
From source file:com.rapidminer.gui.plotter.charts.AbstractBarChartPlotter.java
public void paintBarChart(Graphics graphics) { int categoryCount = prepareData(); String groupByName = groupByColumn >= 0 ? dataTable.getColumnName(groupByColumn) : null; String valueName = valueColumn >= 0 ? dataTable.getColumnName(valueColumn) : null; String maxClassesProperty = System.getProperty(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT); int maxClasses = 20; try {/*from ww w . j a v a2 s . c o m*/ if (maxClassesProperty != null) maxClasses = Integer.parseInt(maxClassesProperty); } catch (NumberFormatException e) { LogService.getGlobal().log( "Bar Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING); } boolean createLegend = categoryCount > 0 && categoryCount < maxClasses; if (categoryCount <= MAX_CATEGORIES) { JFreeChart chart = createChart(categoryDataSet, groupByName, valueName, createLegend); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); } Rectangle2D drawRect = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); chart.draw((Graphics2D) graphics, drawRect); } else { graphics.drawString("Too many columns (" + categoryCount + "), this chart is only able to plot up to " + MAX_CATEGORIES + " different categories", MARGIN, MARGIN); } }
From source file:ec.ui.view.DistributionView.java
private static JFreeChart createDistributionViewChart() { XYPlot plot = new XYPlot(); XYLineAndShapeRenderer dRenderer = new XYSplineRenderer(); dRenderer.setBaseShapesVisible(false); dRenderer.setAutoPopulateSeriesPaint(false); dRenderer.setAutoPopulateSeriesStroke(false); dRenderer.setBaseStroke(TsCharts.getStrongStroke(LinesThickness.Thin)); dRenderer.setDrawSeriesLineAsPath(true); // not sure if useful plot.setDataset(DISTRIBUTION_INDEX, Charts.emptyXYDataset()); plot.setRenderer(DISTRIBUTION_INDEX, dRenderer); XYBarRenderer hRenderer = new XYBarRenderer(); hRenderer.setShadowVisible(false);//from w w w .java 2 s . c o m hRenderer.setDrawBarOutline(true); hRenderer.setAutoPopulateSeriesPaint(false); hRenderer.setAutoPopulateSeriesOutlinePaint(false); hRenderer.setBaseSeriesVisibleInLegend(false); plot.setDataset(HISTOGRAM_INDEX, Charts.emptyXYDataset()); plot.setRenderer(HISTOGRAM_INDEX, hRenderer); NumberAxis domainAxis = new NumberAxis(); domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setDomainAxis(domainAxis); plot.setDomainGridlinesVisible(false); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); rangeAxis.setTickUnit(new NumberTickUnit(0.05)); rangeAxis.setNumberFormatOverride(new DecimalFormat("0.###")); plot.setRangeAxis(rangeAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); JFreeChart result = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); result.setPadding(TsCharts.CHART_PADDING); result.getTitle().setFont(TsCharts.CHART_TITLE_FONT); result.getLegend().setFrame(BlockBorder.NONE); result.getLegend().setBackgroundPaint(null); return result; }