Java Code Examples for org.jfree.chart.axis.ValueAxis#setTickLabelFont()

The following examples show how to use org.jfree.chart.axis.ValueAxis#setTickLabelFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 2
Source File: ParallelPlotter2.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
private static 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, false,                     // include legend
				true,                      // tooltips
				false                      // urls
				);

		chart.setBackgroundPaint(Color.white);

		// get a reference to the plot for further customization...
		XYPlot plot = (XYPlot) chart.getPlot();
		plot.setBackgroundPaint(Color.WHITE);

		ValueAxis valueAxis = plot.getRangeAxis();
		valueAxis.setLabelFont(LABEL_FONT_BOLD);
		valueAxis.setTickLabelFont(LABEL_FONT);

		return chart;
	}
 
Example 3
Source File: StatisticChartStyling.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
static ValueAxis updateScalingOfAxis(boolean logScaled, ValueAxis oldAxis, final boolean autoRangeIncludesZero) {
    ValueAxis newAxis = oldAxis;
    if (logScaled) {
        if (!(oldAxis instanceof CustomLogarithmicAxis)) {
            final CustomLogarithmicAxis logarithmicAxis = createLogarithmicAxis(oldAxis.getLabel());
            logarithmicAxis.setAutoRange(oldAxis.isAutoRange());
            newAxis = logarithmicAxis;
        }
    } else {
        if (oldAxis instanceof CustomLogarithmicAxis) {
            final NumberAxis numberAxis = createNumberAxis(oldAxis.getLabel(), autoRangeIncludesZero);
            numberAxis.setAutoRange(oldAxis.isAutoRange());
            newAxis = numberAxis;
        }
    }
    newAxis.setLabelFont(oldAxis.getLabelFont());
    newAxis.setLabelPaint(oldAxis.getLabelPaint());
    newAxis.setTickLabelFont(oldAxis.getTickLabelFont());
    newAxis.setTickLabelPaint(oldAxis.getTickLabelPaint());
    return newAxis;
}
 
Example 4
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 5
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 6
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 7
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 8
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the attributes for this theme to a {@link ValueAxis}.
 *
 * @param axis  the axis (<code>null</code> not permitted).
 */
protected void applyToValueAxis(ValueAxis axis) {
    axis.setLabelFont(this.largeFont);
    axis.setLabelPaint(this.axisLabelPaint);
    axis.setTickLabelFont(this.regularFont);
    axis.setTickLabelPaint(this.tickLabelPaint);
    if (axis instanceof SymbolAxis) {
        applyToSymbolAxis((SymbolAxis) axis);
    }
    if (axis instanceof PeriodAxis) {
        applyToPeriodAxis((PeriodAxis) axis);
    }
}
 
Example 9
Source File: GsnChartJfreechart.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public JFreeChart createChart(Collection<Data> datas) {
    TimeSeries t1 = new TimeSeries("S1");
    Iterator<Data> iter = datas.iterator() ; 
    Data data ;
    while (iter.hasNext()) {
        data = iter.next();
        t1.addOrUpdate(RegularTimePeriod.createInstance(Millisecond.class, new Date((Long)data.getP2()), TimeZone.getDefault()), data.getValue());
    }
    XYDataset dataset = new TimeSeriesCollection(t1);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            null,
            null, 
            null, 
            dataset, 
            false,
            false, 
            false
    );
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);
    //
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data to Display");
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInsets(new RectangleInsets(5,14,0,5));
    //
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(ssdf);
    axis.setTickLabelFont(TICK_FONT);
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelFont(TICK_FONT);
    //
    return chart;
}
 
Example 10
Source File: DeviationChartPlotter.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private JFreeChart createChart(XYDataset dataset, boolean createLegend) {

		// create the chart...
		JFreeChart chart = ChartFactory.createXYLineChart(null,      // chart title
				null,                      // x axis label
				null,                      // y axis label
				dataset,                  // data
				PlotOrientation.VERTICAL, createLegend,                     // include legend
				true,                     // tooltips
				false                     // urls
				);

		chart.setBackgroundPaint(Color.white);

		// get a reference to the plot for further customization...
		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);

		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 {
			for (int i = 0; i < dataset.getSeriesCount(); i++) {
				renderer.setSeriesStroke(i, stroke);
				Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
				renderer.setSeriesPaint(i, color);
				renderer.setSeriesFillPaint(i, color);
			}
		}
		renderer.setAlpha(0.12f);

		plot.setRenderer(renderer);

		ValueAxis valueAxis = plot.getRangeAxis();
		valueAxis.setLabelFont(LABEL_FONT_BOLD);
		valueAxis.setTickLabelFont(LABEL_FONT);

		return chart;
	}
 
Example 11
Source File: SeriesChartPlotter.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void updatePlotter() {
	int categoryCount = prepareData();
	String maxClassesProperty = ParameterService
			.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
	int maxClasses = 20;
	try {
		if (maxClassesProperty != null) {
			maxClasses = Integer.parseInt(maxClassesProperty);
		}
	} catch (NumberFormatException e) {
		// LogService.getGlobal().log("Series 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.SeriesChartPlotter.parsing_property_error");
	}
	boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

	JFreeChart chart = createChart(this.dataset, createLegend);

	// set the background color for the chart...
	chart.setBackgroundPaint(Color.white);

	// domain axis
	if (axis[INDEX] >= 0) {
		if (!dataTable.isNominal(axis[INDEX])) {
			if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
				DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
				domainAxis.setTimeZone(Tools.getPreferredTimeZone());
				chart.getXYPlot().setDomainAxis(domainAxis);
				if (getRangeForDimension(axis[INDEX]) != null) {
					domainAxis.setRange(getRangeForDimension(axis[INDEX]));
				}
				domainAxis.setLabelFont(LABEL_FONT_BOLD);
				domainAxis.setTickLabelFont(LABEL_FONT);
				domainAxis.setVerticalTickLabels(isLabelRotating());
			}
		} else {
			LinkedHashSet<String> values = new LinkedHashSet<String>();
			for (DataTableRow row : dataTable) {
				String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
				if (stringValue.length() > 40) {
					stringValue = stringValue.substring(0, 40);
				}
				values.add(stringValue);
			}
			ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
					values.toArray(new String[values.size()]));
			categoryAxis.setLabelFont(LABEL_FONT_BOLD);
			categoryAxis.setTickLabelFont(LABEL_FONT);
			categoryAxis.setVerticalTickLabels(isLabelRotating());
			chart.getXYPlot().setDomainAxis(categoryAxis);
		}
	}

	// 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);
	}

	AbstractChartPanel panel = getPlotterPanel();
	if (panel == null) {
		panel = createPanel(chart);
	} else {
		panel.setChart(chart);
	}

	// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
	panel.getChartRenderingInfo().setEntityCollection(null);
}
 
Example 12
Source File: ROCChartPlotter.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
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
			);

	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;
}
 
Example 13
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 14
Source File: JThermometer.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 15
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 16
Source File: JThermometer.java    From opensim-gui with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 17
Source File: JThermometer.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 18
Source File: JThermometer.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 19
Source File: JThermometer.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}
 
Example 20
Source File: JThermometer.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets the tick label font.
 *
 * @param font  the font.
 */
public void setTickLabelFont(Font font) {
    ValueAxis axis = this.plot.getRangeAxis();
    axis.setTickLabelFont(font);
}