当前位置: 首页>>代码示例>>Java>>正文


Java DiscreteLineRenderer2D.setGap方法代码示例

本文整理汇总了Java中de.erichseifert.gral.plots.lines.DiscreteLineRenderer2D.setGap方法的典型用法代码示例。如果您正苦于以下问题:Java DiscreteLineRenderer2D.setGap方法的具体用法?Java DiscreteLineRenderer2D.setGap怎么用?Java DiscreteLineRenderer2D.setGap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在de.erichseifert.gral.plots.lines.DiscreteLineRenderer2D的用法示例。


在下文中一共展示了DiscreteLineRenderer2D.setGap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SimpleXYPlot

import de.erichseifert.gral.plots.lines.DiscreteLineRenderer2D; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleXYPlot() {
	// Generate data
	DataTable data = new DataTable(Double.class, Double.class, Double.class,
			Double.class, Double.class, Double.class);
	for (double x = 1.0; x <= 400.0; x *= 1.5) {
		double x2 = x/5.0;
		data.add(x2, -Math.sqrt(x2) + 5.0,  5.0*Math.log10(x2),
			random.nextDouble() + 1.0, random.nextDouble() + 0.5, 1.0 + 2.0*random.nextDouble());
	}

	// Create data series
	DataSeries seriesLog = new DataSeries(data, 0, 2, 3, 4);
	DataSeries seriesLin = new DataSeries(data, 0, 1, 5);

	// Create new xy-plot
	XYPlot plot = new XYPlot(seriesLog, seriesLin);

	// Format plot
	plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));
	plot.setBackground(Color.WHITE);
	plot.getTitle().setText(getDescription());

	// Format plot area
	plot.getPlotArea().setBackground(new RadialGradientPaint(
		new Point2D.Double(0.5, 0.5),
		0.75f,
		new float[] { 0.6f, 0.8f, 1.0f },
		new Color[] { new Color(0, 0, 0, 0), new Color(0, 0, 0, 32), new Color(0, 0, 0, 128) }
	));
	plot.getPlotArea().setBorderStroke(null);

	// Format axes
	AxisRenderer axisRendererX = new LogarithmicRenderer2D();
	AxisRenderer axisRendererY = plot.getAxisRenderer(XYPlot.AXIS_Y);
	axisRendererX.setLabel(new Label("Logarithmic axis"));
	plot.setAxisRenderer(XYPlot.AXIS_X, axisRendererX);
	// Custom tick labels
	Map<Double, String> labels = new HashMap<>();
	labels.put(2.0, "Two");
	labels.put(1.5, "OnePointFive");
	axisRendererX.setCustomTicks(labels);
	// Custom stroke for the x-axis
	BasicStroke stroke = new BasicStroke(2f);
	axisRendererX.setShapeStroke(stroke);
	Label linearAxisLabel = new Label("Linear axis");
	linearAxisLabel.setRotation(90);
	axisRendererY.setLabel(linearAxisLabel);
	// Change intersection point of Y axis
	axisRendererY.setIntersection(1.0);
	// Change tick spacing
	axisRendererX.setTickSpacing(2.0);

	// Format rendering of data points
	PointRenderer sizeablePointRenderer = new SizeablePointRenderer();
	sizeablePointRenderer.setColor(GraphicsUtils.deriveDarker(COLOR1));
	plot.setPointRenderers(seriesLin, sizeablePointRenderer);
	PointRenderer defaultPointRenderer = new DefaultPointRenderer2D();
	defaultPointRenderer.setColor(GraphicsUtils.deriveDarker(COLOR2));
	defaultPointRenderer.setErrorVisible(true);
	defaultPointRenderer.setErrorColor(COLOR2);
	plot.setPointRenderers(seriesLog, defaultPointRenderer);

	// Format data lines
	DiscreteLineRenderer2D discreteRenderer = new DiscreteLineRenderer2D();
	discreteRenderer.setColor(COLOR1);
	discreteRenderer.setStroke(new BasicStroke(
			3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
			10.0f, new float[] {3f, 6f}, 0.0f));
	plot.setLineRenderers(seriesLin, discreteRenderer);
	// Custom gaps for points
	discreteRenderer.setGap(2.0);
	discreteRenderer.setGapRounded(true);
	// Custom ascending
	discreteRenderer.setAscentDirection(Orientation.VERTICAL);
	discreteRenderer.setAscendingPoint(0.5);

	// Add plot to Swing component
	add(new InteractivePanel(plot), BorderLayout.CENTER);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:81,代码来源:SimpleXYPlot.java

示例2: SimpleXYPlot

import de.erichseifert.gral.plots.lines.DiscreteLineRenderer2D; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleXYPlot() {
	// Generate data
	DataTable data = new DataTable(Double.class, Double.class, Double.class,
			Double.class, Double.class, Double.class);
	for (double x = 1.0; x <= 400.0; x *= 1.5) {
		double x2 = x/5.0;
		data.add(x2, -Math.sqrt(x2) + 5.0,  5.0*Math.log10(x2),
			random.nextDouble() + 1.0, random.nextDouble() + 0.5, 1.0 + 2.0*random.nextDouble());
	}

	// Create data series
	DataSeries seriesLog = new DataSeries(data, 0, 2, 3, 4);
	DataSeries seriesLin = new DataSeries(data, 0, 1, 5);

	// Create new xy-plot
	XYPlot plot = new XYPlot(seriesLog, seriesLin);

	// Format plot
	plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));
	plot.setBackground(Color.WHITE);
	plot.getTitle().setText(getDescription());

	// Format plot area
	plot.getPlotArea().setBackground(new RadialGradientPaint(
		new Point2D.Double(0.5, 0.5),
		0.75f,
		new float[] { 0.6f, 0.8f, 1.0f },
		new Color[] { new Color(0, 0, 0, 0), new Color(0, 0, 0, 32), new Color(0, 0, 0, 128) }
	));
	plot.getPlotArea().setBorderStroke(null);

	// Format axes
	AxisRenderer axisRendererX = new LogarithmicRenderer2D();
	AxisRenderer axisRendererY = plot.getAxisRenderer(XYPlot.AXIS_Y);
	axisRendererX.setLabel("Logarithmic axis");
	plot.setAxisRenderer(XYPlot.AXIS_X, axisRendererX);
	// Custom tick labels
	Map<Double, String> labels = new HashMap<Double, String>();
	labels.put(2.0, "Two");
	labels.put(1.5, "OnePointFive");
	axisRendererX.setCustomTicks(labels);
	// Custom stroke for the x-axis
	BasicStroke stroke = new BasicStroke(2f);
	axisRendererX.setShapeStroke(stroke);
	axisRendererY.setLabel("Linear axis");
	// Change intersection point of Y axis
	axisRendererY.setIntersection(1.0);
	// Change tick spacing
	axisRendererX.setTickSpacing(2.0);

	// Format rendering of data points
	PointRenderer sizeablePointRenderer = new SizeablePointRenderer();
	sizeablePointRenderer.setColor(GraphicsUtils.deriveDarker(COLOR1));
	plot.setPointRenderer(seriesLin, sizeablePointRenderer);
	PointRenderer defaultPointRenderer = new DefaultPointRenderer2D();
	defaultPointRenderer.setColor(GraphicsUtils.deriveDarker(COLOR2));
	defaultPointRenderer.setErrorVisible(true);
	defaultPointRenderer.setErrorColor(COLOR2);
	plot.setPointRenderer(seriesLog, defaultPointRenderer);

	// Format data lines
	DiscreteLineRenderer2D discreteRenderer = new DiscreteLineRenderer2D();
	discreteRenderer.setColor(COLOR1);
	discreteRenderer.setStroke(new BasicStroke(
		3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
		10.0f, new float[] {3f, 6f}, 0.0f));
	plot.setLineRenderer(seriesLin, discreteRenderer);
	// Custom gaps for points
	discreteRenderer.setGap(2.0);
	discreteRenderer.setGapRounded(true);
	// Custom ascending
	discreteRenderer.setAscentDirection(Orientation.VERTICAL);
	discreteRenderer.setAscendingPoint(0.5);

	// Add plot to Swing component
	add(new InteractivePanel(plot), BorderLayout.CENTER);
}
 
开发者ID:arahusky,项目名称:performance_javadoc,代码行数:79,代码来源:SimpleXYPlot.java


注:本文中的de.erichseifert.gral.plots.lines.DiscreteLineRenderer2D.setGap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。