List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setBaseItemLabelFont
public void setBaseItemLabelFont(Font font);
From source file:classpackage.ChartGalaxy.java
private static JFreeChart createChart(final XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("MDS Galaxy", "X", "Y", createDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator()); renderer.setBaseItemLabelPaint(Color.WHITE);//label renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseItemLabelFont(renderer.getBaseItemLabelFont().deriveFont(15f)); renderer.setBaseItemLabelsVisible(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); //set false para linhas no grafico xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeGridlinesVisible(false); xyPlot.setRangeMinorGridlinesVisible(false); xyPlot.setRangeCrosshairVisible(false); xyPlot.setRangeCrosshairLockedOnData(false); xyPlot.setRangeZeroBaselineVisible(false); xyPlot.setBackgroundPaint(Color.BLACK); double size = 40.0; double delta = size / 2.0; Shape shape = new Rectangle2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape);/*from w ww . ja v a 2 s . com*/ renderer.setSeriesPaint(0, transparent); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(-0.1, 0.1); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(-0.1, 0.1); range.setTickUnit(new NumberTickUnit(0.1)); return jfreechart; }
From source file:org.talend.dataprofiler.chart.ChartDecorator.java
/** * DOC bZhou Comment method "decorateXYPlot". * /*from ww w. j av a2s .c o m*/ * @param chart */ private static void decorateXYPlot(JFreeChart chart) { Font font = null; XYPlot plot = chart.getXYPlot(); XYItemRenderer render = plot.getRenderer(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis valueAxis = plot.getRangeAxis(); font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE);//$NON-NLS-1$ render.setBaseItemLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$ domainAxis.setLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$ valueAxis.setLabelFont(font); font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE);//$NON-NLS-1$ domainAxis.setTickLabelFont(font); valueAxis.setTickLabelFont(font); setLegendFont(chart); font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$ TextTitle title = chart.getTitle(); if (title != null) { title.setFont(font); } font = null; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
private static void decorateCategoryPlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot();//from w ww. j av a2 s .co m XYItemRenderer render = plot.getRenderer(); ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis valueAxis = plot.getRangeAxis(); Font font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE); //$NON-NLS-1$ render.setBaseItemLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$ domainAxis.setLabelFont(font); font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE); //$NON-NLS-1$ valueAxis.setLabelFont(font); font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE); //$NON-NLS-1$ domainAxis.setTickLabelFont(font); valueAxis.setTickLabelFont(font); font = new Font("Tahoma", Font.PLAIN, BASE_LEGEND_LABEL_SIZE); //$NON-NLS-1$ LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(font); } font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE); //$NON-NLS-1$ TextTitle title = chart.getTitle(); if (title != null) { title.setFont(font); } font = null; if (render instanceof BarRenderer) { int rowCount = chart.getCategoryPlot().getDataset().getRowCount(); domainAxis.setUpperMargin(0.1); // domainAxis.setMaximumCategoryLabelLines(10); ((BarRenderer) render).setItemMargin(-0.40 * rowCount); } // set color int rowCount = chart.getXYPlot().getDataset().getSeriesCount(); for (int i = 0; i < rowCount; i++) { plot.getRenderer().setSeriesPaint(i, Color.RED); } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final XYPlot plot = chart.getXYPlot(); final XYItemRenderer renderer = plot.getRenderer(); if (StringUtils.isEmpty(getTooltipFormula()) == false) { renderer.setBaseToolTipGenerator(new FormulaXYZTooltipGenerator(getRuntime(), getTooltipFormula())); }//from w w w . j av a 2 s . c o m if (StringUtils.isEmpty(getUrlFormula()) == false) { renderer.setURLGenerator(new FormulaXYZURLGenerator(getRuntime(), getUrlFormula())); } renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseItemLabelsVisible(Boolean.TRUE.equals(getItemsLabelVisible())); if (getItemLabelFont() != null) { renderer.setBaseItemLabelFont(getItemLabelFont()); } plot.setOrientation(computePlotOrientation()); // May be an axis that supports dates final ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { final NumberAxis numberAxis = (NumberAxis) domainAxis; numberAxis.setAutoRangeIncludesZero(isDomainIncludesZero()); numberAxis.setAutoRangeStickyZero(isDomainStickyZero()); if (getDomainPeriodCount() > 0) { if (getDomainTickFormat() != null) { numberAxis.setTickUnit(new NumberTickUnit(getDomainPeriodCount(), getDomainTickFormat())); } else if (getDomainTickFormatString() != null) { final FastDecimalFormat formatter = new FastDecimalFormat(getDomainTickFormatString(), getResourceBundleFactory().getLocale()); numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount(), formatter)); } else { numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount())); } } else { if (getDomainTickFormat() != null) { numberAxis.setNumberFormatOverride(getDomainTickFormat()); } else if (getDomainTickFormatString() != null) { final DecimalFormat formatter = new DecimalFormat(getDomainTickFormatString(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setNumberFormatOverride(formatter); } } } else if (domainAxis instanceof DateAxis) { final DateAxis numberAxis = (DateAxis) domainAxis; if (getDomainPeriodCount() > 0 && getDomainTimePeriod() != null) { if (getDomainTickFormatString() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getDomainTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount(), formatter)); } else { numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount())); } } } if (domainAxis != null) { domainAxis.setLabel(getDomainTitle()); if (getDomainTitleFont() != null) { domainAxis.setLabelFont(getDomainTitleFont()); } domainAxis.setVerticalTickLabels(isDomainVerticalTickLabels()); if (getDomainTickFont() != null) { domainAxis.setTickLabelFont(getDomainTickFont()); } final int level = getRuntime().getProcessingContext().getCompatibilityLevel(); if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) { if (getDomainMinimum() != 0) { domainAxis.setLowerBound(getDomainMinimum()); } if (getDomainMaximum() != 1) { domainAxis.setUpperBound(getDomainMaximum()); } if (getDomainMinimum() == 0 && getDomainMaximum() == 0) { domainAxis.setLowerBound(0); domainAxis.setUpperBound(1); domainAxis.setAutoRange(true); } } else { domainAxis.setLowerBound(getDomainMinimum()); domainAxis.setUpperBound(getDomainMaximum()); domainAxis.setAutoRange(isDomainAxisAutoRange()); } } final ValueAxis rangeAxis = plot.getRangeAxis(); if (rangeAxis instanceof NumberAxis) { final NumberAxis numberAxis = (NumberAxis) rangeAxis; numberAxis.setAutoRangeIncludesZero(isRangeIncludesZero()); numberAxis.setAutoRangeStickyZero(isRangeStickyZero()); if (getRangePeriodCount() > 0) { if (getRangeTickFormat() != null) { numberAxis.setTickUnit(new NumberTickUnit(getRangePeriodCount(), getRangeTickFormat())); } else if (getRangeTickFormatString() != null) { final FastDecimalFormat formatter = new FastDecimalFormat(getRangeTickFormatString(), getResourceBundleFactory().getLocale()); numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount(), formatter)); } else { numberAxis.setTickUnit(new FastNumberTickUnit(getRangePeriodCount())); } } else { if (getRangeTickFormat() != null) { numberAxis.setNumberFormatOverride(getRangeTickFormat()); } else if (getRangeTickFormatString() != null) { final DecimalFormat formatter = new DecimalFormat(getRangeTickFormatString(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setNumberFormatOverride(formatter); standardTickUnitsApplyFormat(numberAxis, formatter); } } } else if (rangeAxis instanceof DateAxis) { final DateAxis numberAxis = (DateAxis) rangeAxis; if (getRangePeriodCount() > 0 && getRangeTimePeriod() != null) { if (getRangeTickFormatString() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()), (int) getRangePeriodCount(), formatter)); } else { numberAxis.setTickUnit( new DateTickUnit(getDateUnitAsInt(getRangeTimePeriod()), (int) getRangePeriodCount())); } } else { if (getRangeTickFormatString() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setDateFormatOverride(formatter); } } } if (rangeAxis != null) { rangeAxis.setLabel(getRangeTitle()); if (getRangeTitleFont() != null) { rangeAxis.setLabelFont(getRangeTitleFont()); } if (getRangeTickFont() != null) { rangeAxis.setTickLabelFont(getRangeTickFont()); } final int level = getRuntime().getProcessingContext().getCompatibilityLevel(); if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) { if (getRangeMinimum() != 0) { rangeAxis.setLowerBound(getRangeMinimum()); } if (getRangeMaximum() != 1) { rangeAxis.setUpperBound(getRangeMaximum()); } if (getRangeMinimum() == 0 && getRangeMaximum() == 0) { rangeAxis.setLowerBound(0); rangeAxis.setUpperBound(1); rangeAxis.setAutoRange(true); } } else { rangeAxis.setLowerBound(getRangeMinimum()); rangeAxis.setUpperBound(getRangeMaximum()); rangeAxis.setAutoRange(isRangeAxisAutoRange()); } } final String[] colors = getSeriesColor(); for (int i = 0; i < colors.length; i++) { renderer.setSeriesPaint(i, parseColorFromString(colors[i])); } }