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:org.jfree.fx.demo.FXGraphics2DDemo1.java
/** * Creates a chart./*from w w w. j a v a 2 s . c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", // title null, // x-axis label "US cents/lb", // y-axis label dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:org.n52.io.measurement.img.ChartIoHandler.java
private BufferedImage createImage() { int width = getChartStyleDefinitions().getWidth(); int height = getChartStyleDefinitions().getHeight(); BufferedImage chartImage = new BufferedImage(width, height, TYPE_INT_RGB); Graphics2D chartGraphics = chartImage.createGraphics(); chartGraphics.fillRect(0, 0, width, height); chartGraphics.setColor(WHITE);// w w w . j a v a2s .c om chart.setTextAntiAlias(true); chart.setAntiAlias(true); if (chart.getLegend() != null) { chart.getLegend().setFrame(BlockBorder.NONE); } chart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height)); return chartImage; }
From source file:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java
protected JFreeChart createChart(XYDataset dataset, String name) { String title = name;/* www . j a v a 2 s . c o m*/ JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "f", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); if (isMetric) { plot.getRangeAxis().setRange(0.0, 1.01); } plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return xyLineChart; }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private BufferedImage createImage() { IoParameters parameters = getParameters(); int width = parameters.getWidth(); int height = parameters.getHeight(); BufferedImage chartImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D chartGraphics = chartImage.createGraphics(); chartGraphics.fillRect(0, 0, width, height); chartGraphics.setColor(Color.WHITE); jFreeChart.setTextAntiAlias(true);/* w ww .ja va2 s. c om*/ jFreeChart.setAntiAlias(true); if (jFreeChart.getLegend() != null) { jFreeChart.getLegend().setFrame(BlockBorder.NONE); } jFreeChart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height)); return chartImage; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression.java
protected void configureSubChart(final JFreeChart chart) { final TextTitle chartTitle = chart.getTitle(); if (chartTitle != null) { if (getPieTitleFont() != null) { chartTitle.setFont(getPieTitleFont()); } else {//from w ww .ja v a 2s. co m final Font titleFont = Font.decode(getTitleFont()); chartTitle.setFont(titleFont); } } if (isAntiAlias() == false) { chart.setAntiAlias(false); } final LegendTitle chLegend = chart.getLegend(); if (chLegend != null) { final RectangleEdge loc = translateEdge(getLegendLocation().toLowerCase()); if (loc != null) { chLegend.setPosition(loc); } if (getLegendFont() != null) { chLegend.setItemFont(Font.decode(getLegendFont())); } if (!isDrawLegendBorder()) { chLegend.setBorder(BlockBorder.NONE); } if (getLegendBackgroundColor() != null) { chLegend.setBackgroundPaint(getLegendBackgroundColor()); } if (getLegendTextColor() != null) { chLegend.setItemPaint(getLegendTextColor()); } } final Plot plot = chart.getPlot(); plot.setNoDataMessageFont(Font.decode(getLabelFont())); final String pieNoData = getPieNoDataMessage(); if (pieNoData != null) { plot.setNoDataMessage(pieNoData); } else { final String message = getNoDataMessage(); if (message != null) { plot.setNoDataMessage(message); } } }
From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java
@FXML 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);//from w w w . j a v a 2 s . c om 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.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("Retention time (min)"); 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); chartTitle.setText("Chromatogram"); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (ChromatogramPlotDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (ChromatogramPlotDataSet 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
private JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*w w w .ja v a 2 s .c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD); valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD); domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else if (dataset.getSeriesCount() == 2) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); renderer.setSeriesStroke(1, stroke); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesFillPaint(1, Color.BLUE); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); plot.setRenderer(renderer); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(PlotterAdapter.LABEL_FONT); } return chart; }
From source file:com.rapidminer.gui.plotter.DistributionPlotter.java
public void paintComponent(Graphics graphics, int width, int height) { preparePlots();/* www .j a v a2s. co m*/ if (plot) { JFreeChart chart = null; try { if (!Double.isNaN(model.getUpperBound(plotColumn))) { chart = createNumericalChart(); } else { chart = createNominalChart(); } } catch (Exception e) { // do nothing - just do not draw the chart } if (chart != null) { // 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:net.sf.mzmine.modules.visualization.tic.TICPlot.java
public TICPlot(final ActionListener listener) { super(null, true); // Initialize. visualizer = listener;/*from ww w. j a va2s .c o m*/ labelsVisible = 1; havePeakLabels = false; numOfDataSets = 0; numOfPeaks = 0; showSpectrumRequest = false; // Set cursor. setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // Y-axis label. final String yAxisLabel; if (listener instanceof TICVisualizerWindow) { yAxisLabel = ((TICVisualizerWindow) listener).getPlotType() == PlotType.BASEPEAK ? "Base peak intensity" : "Total ion intensity"; } else { yAxisLabel = "Base peak intensity"; } // Initialize the chart by default time series chart from factory. final JFreeChart chart = ChartFactory.createXYLineChart("", // title "Retention time", // x-axis label yAxisLabel, // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); setChart(chart); // Title. chartTitle = chart.getTitle(); chartTitle.setFont(TITLE_FONT); chartTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); // Subtitle. chartSubTitle = new TextTitle(); chartSubTitle.setFont(SUBTITLE_FONT); chartSubTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); chart.addSubtitle(chartSubTitle); // Disable maximum size (we don't want scaling). setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // Legend constructed by ChartFactory. final LegendTitle legend = chart.getLegend(); legend.setItemFont(LEGEND_FONT); legend.setFrame(BlockBorder.NONE); // Set the plot properties. plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(AXIS_OFFSET); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // Set grid properties. plot.setDomainGridlinePaint(GRID_COLOR); plot.setRangeGridlinePaint(GRID_COLOR); // Set cross-hair (selection) properties. if (listener instanceof TICVisualizerWindow) { plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(CROSS_HAIR_COLOR); plot.setRangeCrosshairPaint(CROSS_HAIR_COLOR); plot.setDomainCrosshairStroke(CROSS_HAIR_STROKE); plot.setRangeCrosshairStroke(CROSS_HAIR_STROKE); } // Set the x-axis (retention time) properties. final NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat()); xAxis.setUpperMargin(AXIS_MARGINS); xAxis.setLowerMargin(AXIS_MARGINS); // Set the y-axis (intensity) properties. final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat()); // Set default renderer properties. defaultRenderer = new TICPlotRenderer(); defaultRenderer.setBaseShapesFilled(true); defaultRenderer.setDrawOutlines(false); defaultRenderer.setUseFillPaint(true); defaultRenderer.setBaseItemLabelPaint(LABEL_COLOR); // Set label generator final XYItemLabelGenerator labelGenerator = new TICItemLabelGenerator(this); defaultRenderer.setBaseItemLabelGenerator(labelGenerator); defaultRenderer.setBaseItemLabelsVisible(true); // Set toolTipGenerator final XYToolTipGenerator toolTipGenerator = new TICToolTipGenerator(); defaultRenderer.setBaseToolTipGenerator(toolTipGenerator); // Set focus state to receive key events. setFocusable(true); // Register key handlers. GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("LEFT"), listener, "MOVE_CURSOR_LEFT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("RIGHT"), listener, "MOVE_CURSOR_RIGHT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), listener, "SHOW_SPECTRUM"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('+'), this, "ZOOM_IN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('-'), this, "ZOOM_OUT"); // Add items to popup menu. final JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); if (listener instanceof TICVisualizerWindow) { popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); popupMenu.add(new AddFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new RemoveFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); } GUIUtils.addMenuItem(popupMenu, "Toggle showing peak values", this, "SHOW_ANNOTATIONS"); GUIUtils.addMenuItem(popupMenu, "Toggle showing data points", this, "SHOW_DATA_POINTS"); if (listener instanceof TICVisualizerWindow) { popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Show spectrum of selected scan", listener, "SHOW_SPECTRUM"); } popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Set axes range", this, "SETUP_AXES"); if (listener instanceof TICVisualizerWindow) { GUIUtils.addMenuItem(popupMenu, "Set same range to all windows", this, "SET_SAME_RANGE"); } }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutput.java
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); initRenderer(scope);/* w w w .j av a2s. com*/ final Plot plot = chart.getPlot(); chart.setBorderVisible(false); plot.setOutlineVisible(false); chart.setTitle(this.getName()); chart.getTitle().setVisible(true); chart.getTitle().setFont(getTitleFont()); if (!this.getTitleVisible(scope)) { chart.getTitle().setVisible(false); } if (textColor != null) { chart.getTitle().setPaint(textColor); } if (backgroundColor == null) { plot.setBackgroundPaint(null); chart.setBackgroundPaint(null); chart.setBorderPaint(null); if (chart.getLegend() != null) { chart.getLegend().setBackgroundPaint(null); } } else { final Color bg = backgroundColor; chart.setBackgroundPaint(bg); plot.setBackgroundPaint(bg); chart.setBorderPaint(bg); if (chart.getLegend() != null) { chart.getLegend().setBackgroundPaint(bg); } } if (chart.getLegend() != null) { chart.getLegend().setItemFont(getLegendFont()); chart.getLegend().setFrame(BlockBorder.NONE); if (textColor != null) { chart.getLegend().setItemPaint(textColor); } } chart.addProgressListener(this); }