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:com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.java
public void updatePlotter() { int categoryCount = prepareData(); String maxClassesProperty = ParameterService .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT); int maxClasses = 20; try {/*w w w .jav a 2s. co m*/ if (maxClassesProperty != null) { maxClasses = Integer.parseInt(maxClassesProperty); } } catch (NumberFormatException e) { // LogService.getGlobal().log("Pie Chart plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", // LogService.WARNING); LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.pie_chart_plotter_parsing_error"); } boolean createLegend = categoryCount > 0 && categoryCount < maxClasses; if (categoryCount <= MAX_CATEGORIES) { JFreeChart chart = createChart(pieDataSet, createLegend); // set the background color for the chart... chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setShadowPaint(new Color(104, 104, 104, 100)); int size = pieDataSet.getKeys().size(); for (int i = 0; i < size; i++) { Comparable<?> key = pieDataSet.getKey(i); plot.setSectionPaint(key, getColorProvider(true).getPointColor(i / (double) (size - 1))); boolean explode = false; for (String explosionGroup : explodingGroups) { if (key.toString().startsWith(explosionGroup) || explosionGroup.startsWith(key.toString())) { explode = true; break; } } if (explode) { plot.setExplodePercent(key, this.explodingAmount); } } plot.setLabelFont(LABEL_FONT); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); plot.setOutlinePaint(Color.WHITE); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } 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); } else { // LogService.getGlobal().logNote("Too many columns (" + categoryCount + // "), this chart is only able to plot up to " + MAX_CATEGORIES + // " different categories."); LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.charts.AbstractPieChartPlotter.too_many_columns", new Object[] { categoryCount, MAX_CATEGORIES }); } }
From source file:org.pentaho.chart.plugin.jfreechart.chart.JFreeChartGenerator.java
public JFreeChart createChart(ChartDocumentContext chartDocContext, ChartTableModel data) { JFreeChart chart = doCreateChart(chartDocContext, data); chart.setBackgroundPaint(getChartBackgroundColor(chartDocContext.getChartDocument())); Color chartBackgroundPaint = ColorFactory.getInstance() .getColor(chartDocContext.getChartDocument().getPlotElement(), BorderStyleKeys.BACKGROUND_COLOR); if (chartBackgroundPaint != null) { chart.getPlot().setBackgroundPaint(chartBackgroundPaint); }/* w ww. j a v a 2 s . c om*/ CSSNumericValue opacity = (CSSNumericValue) chartDocContext.getChartDocument().getPlotElement() .getLayoutStyle().getValue(ColorStyleKeys.OPACITY); if (opacity != null) { chart.getPlot().setForegroundAlpha((float) opacity.getValue()); } ChartElement rootElement = chartDocContext.getChartDocument().getRootElement(); ChartElement[] children = rootElement.findChildrenByName(ChartElement.TAG_NAME_TITLE); //$NON-NLS-1$ if (children != null && children.length > 0) { Font font = ChartUtils.getFont(children[0]); if (font != null) { chart.getTitle().setFont(font); } } if (getShowLegend(chartDocContext.getChartDocument())) { children = chartDocContext.getChartDocument().getRootElement() .findChildrenByName(ChartElement.TAG_NAME_LEGEND); //$NON-NLS-1$ if ((children != null) && (children.length > 0)) { ChartElement legendElement = children[0]; Font font = JFreeChartUtils.getFont(legendElement); if (font != null) { chart.getLegend().setItemFont(font); } CSSNumericValue value = (CSSNumericValue) legendElement.getLayoutStyle() .getValue(BorderStyleKeys.BORDER_TOP_WIDTH); if ((value == null) || (value.getValue() <= 0)) { chart.getLegend().setBorder(BlockBorder.NONE); } } } CSSValue borderWidth = rootElement.getLayoutStyle().getValue(BorderStyleKeys.BORDER_TOP_WIDTH); if ((borderWidth != null) && (borderWidth instanceof CSSNumericValue) && (((CSSNumericValue) borderWidth).getValue() > 0)) { chart.setBorderVisible(true); } else if ((borderWidth != null) && (borderWidth instanceof CSSStringValue)) { chart.setBorderVisible(true); } Color borderColor = ColorFactory.getInstance().getColor(rootElement, BorderStyleKeys.BORDER_TOP_COLOR); if (borderColor != null) { chart.setBorderPaint(borderColor); } Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; children = chartDocContext.getChartDocument().getRootElement() .findChildrenByName(ChartElement.TAG_NAME_RANGE_LABEL); //$NON-NLS-1$ if (children != null && children.length > 0) { Font font = ChartUtils.getFont(children[0]); if (font != null) { categoryPlot.getRangeAxis().setLabelFont(font); } } children = chartDocContext.getChartDocument().getRootElement() .findChildrenByName(ChartElement.TAG_NAME_DOMAIN_LABEL); //$NON-NLS-1$ if (children != null && children.length > 0) { Font font = ChartUtils.getFont(children[0]); if (font != null) { categoryPlot.getDomainAxis().setLabelFont(font); } } } return chart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createTopNBarChart(String yAxisLabel, CategoryDataset dataset) { JFreeChart jfreechart = ChartFactory.createBarChart(null, null, yAxisLabel, dataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = jfreechart.getCategoryPlot(); categoryplot.setBackgroundPaint(null); categoryplot.setOutlinePaint(null);//from ww w. java2 s.c o m categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); categoryplot.setRangePannable(true); categoryplot.setRangeGridlinesVisible(true); categoryplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setBarPainter(new StandardBarPainter()); barrenderer.setShadowVisible(false); barrenderer.setItemMargin(0.015); barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE); barrenderer.setSeriesPaint(1, UIConstants.INTEL_LIGHT_BLUE); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryMargin(0.15D); categoryaxis.setUpperMargin(0.02D); categoryaxis.setLowerMargin(0.02D); categoryaxis.setMaximumCategoryLabelWidthRatio(0.5F); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setRangeType(RangeType.POSITIVE); numberaxis.setStandardTickUnits(createLargeNumberTickUnits()); numberaxis.setUpperMargin(0.20000000000000001D); numberaxis.setLabelFont(UIConstants.H5_FONT); numberaxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0)); numberaxis.setTickMarksVisible(true); numberaxis.setTickLabelsVisible(true); LegendTitle legend = jfreechart.getLegend(); legend.setFrame(BlockBorder.NONE); legend.setItemFont(barrenderer.getBaseItemLabelFont().deriveFont(10.0f)); return jfreechart; }
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
/** * Create a chart-object using dataset object. This method takes a dataset object, e.g. a DialWidgetDefinition, * and creates and returns a JFreeChart object from it. * // w w w .j ava 2 s . c o m * @param dataset * The dataset * @param title * The title of the chart * @param units * The units of the chart value * @param width * The width of the image to create * @param height * The height of the image to create * @param logger * The logger to log any messages to * * @return JFreeChart the generated chart object */ public static JFreeChart getChart(final Dataset dataset, final String title, final String units, final int width, final int height, final ILogger logger) { JFreeChart chart = null; if (dataset instanceof DialWidgetDefinition) { chart = JFreeChartEngine.createDial((DialWidgetDefinition) dataset, title, units); } else if (dataset instanceof TimeSeriesCollectionChartDefinition) { chart = JFreeChartEngine.createTimeSeriesCollectionChart((TimeSeriesCollectionChartDefinition) dataset); } else if (dataset instanceof TimeTableXYDatasetChartDefinition) { chart = JFreeChartEngine.createStackedTimeSeriesChart((TimeTableXYDatasetChartDefinition) dataset); } else if (dataset instanceof XYSeriesCollectionChartDefinition) { chart = JFreeChartEngine.createXYSeriesCollectionChart((XYSeriesCollectionChartDefinition) dataset); } else if (dataset instanceof BarLineChartDefinition) { chart = JFreeChartEngine.createBarLineChart((BarLineChartDefinition) dataset); } else if (dataset instanceof CategoryDatasetChartDefinition) { chart = JFreeChartEngine.createCategoryDatasetChart((CategoryDatasetChartDefinition) dataset); } else if (dataset instanceof PieDatasetChartDefinition) { chart = JFreeChartEngine.createPieDatasetChart((PieDatasetChartDefinition) dataset); } else if (dataset instanceof XYZSeriesCollectionChartDefinition) { chart = JFreeChartEngine.createXYZSeriesCollectionChart((XYZSeriesCollectionChartDefinition) dataset); } if (chart == null) { logger.error(Messages.getInstance().getString("ChartEngine.ERROR_0002_COULD_NOT_CREATE_CHART")); //$NON-NLS-1$ } else { // TODO implement the ability to have "ImageTitle"s for subtitles ChartDefinition chartDefinition = (ChartDefinition) dataset; Iterator iter = chartDefinition.getSubtitles().iterator(); while (iter.hasNext()) { chart.addSubtitle(new TextTitle(iter.next().toString())); } chart.setBackgroundPaint(chartDefinition.getChartBackgroundPaint()); chart.setBackgroundImage(chartDefinition.getChartBackgroundImage()); chart.setBorderVisible(chartDefinition.isBorderVisible()); chart.setBorderPaint(chartDefinition.getBorderPaint()); if (chart.getTitle() != null) { chart.getTitle().setPosition(chartDefinition.getTitlePosition()); chart.getTitle().setFont(chartDefinition.getTitleFont()); } if (chartDefinition.getLegendFont() != null && chart.getLegend() != null) { chart.getLegend().setItemFont(chartDefinition.getLegendFont()); } if (!chartDefinition.isLegendBorderVisible() && chart.getLegend() != null) { chart.getLegend().setBorder(BlockBorder.NONE); } if (chartDefinition.getLegendPosition() != null && chart.getLegend() != null) { chart.getLegend().setPosition(chartDefinition.getLegendPosition()); } } return (chart); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setTitle(JFreeChart chart, String title, Font titleFont, Color foregroundColor, List<cfCHARTTITLEData> titles) throws cfmRunTimeException { if (titles.size() > 0) { // One or more CFCHARTTITLE tags were specified so use them to configure // the chart titles for (int i = 0; i < titles.size(); i++) { cfCHARTTITLEData data = titles.get(i); Font font = getFont(data.getFont(), data.getFontBold(), data.getFontItalic(), data.getFontSize()); TextTitle textTitle = new TextTitle(data.getTitle(), font); textTitle.setPaint(convertStringToColor(data.getLabelColor())); textTitle.setBackgroundPaint(convertStringToColor(data.getBackgroundColor())); String pos = data.getPosition(); if (pos.equals("top")) textTitle.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) textTitle.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) textTitle.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) textTitle.setPosition(RectangleEdge.RIGHT); if (!data.getShowBorder()) textTitle.setBorder(BlockBorder.NONE); else//from w w w. j a v a2 s. com textTitle.setBorder(new BlockBorder()); textTitle.setPadding(data.getPadding(), data.getPadding(), data.getPadding(), data.getPadding()); textTitle.setMargin(data.getMargin(), data.getMargin(), data.getMargin(), data.getMargin()); chart.addSubtitle(textTitle); } } else { // A CFCHARTTITLE tag was NOT specified so use the CFCHART attributes to // configure the chart title if (title == null) return; TextTitle textTitle = new TextTitle(title, titleFont); textTitle.setPaint(foregroundColor); // Add a border around the title to match CFMX 7 textTitle.setBorder(new BlockBorder()); textTitle.setPadding(10, 10, 10, 10); textTitle.setMargin(5, 5, 5, 5); chart.setTitle(textTitle); } }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setLegend(JFreeChart chart, boolean bShowLegend, Font font, Color foregroundColor, Color backgroundColor, cfCHARTLEGENDData legendData) throws cfmRunTimeException { LegendTitle legend = new LegendTitle(chart.getPlot()); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); // If a CFCHARTLEGEND tag was used then use it's attributes to configure the // legend//from w w w . j av a 2s .c o m if (legendData != null) { // A CFCHARTLEGEND tag is present so use its attributes to configure the // legend legend.setItemFont(getFont(legendData.getFont(), legendData.getFontBold(), legendData.getFontItalic(), legendData.getFontSize())); legend.setItemPaint(convertStringToColor(legendData.getLabelColor())); legend.setBackgroundPaint(convertStringToColor(legendData.getBackgroundColor())); String pos = legendData.getPosition(); if (pos.equals("top")) legend.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) legend.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) legend.setPosition(RectangleEdge.RIGHT); if (!legendData.getShowBorder()) legend.setBorder(BlockBorder.NONE); else legend.setBorder(new BlockBorder()); } else { // A CFCHARTLEGEND tag is NOT present so use the attributes from the // CFCHART tag to configure the legend if (!bShowLegend) return; legend.setItemFont(font); legend.setItemPaint(foregroundColor); legend.setBackgroundPaint(backgroundColor); // By default CFMX 7 places the legend at the top with no border legend.setPosition(RectangleEdge.TOP); legend.setBorder(BlockBorder.NONE); } // Add the legend to the chart chart.addSubtitle(legend); }