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


Java DataSource类代码示例

本文整理汇总了Java中de.erichseifert.gral.data.DataSource的典型用法代码示例。如果您正苦于以下问题:Java DataSource类的具体用法?Java DataSource怎么用?Java DataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testReader

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testReader() throws IOException, ParseException {
	DataReader reader = DataReaderFactory.getInstance().get("image/png");
	DataSource data = reader.read(imageData);
	assertEquals(3, data.getColumnCount());
	assertEquals(4, data.getRowCount());

	double[] expected = new double[] {
		255.0,   0.0,   0.0,
		  0.0, 255.0,   0.0,
		  0.0,   0.0, 255.0,
		127.0, 127.0, 127.0
	};
	for (int i = 0; i < expected.length; i++) {
		int col = i % 3;
		int row = i / 3;
		double value = ((Number) data.get(col, row)).doubleValue();
		assertEquals(expected[i], value, DELTA);
	}
}
 
开发者ID:eseifert,项目名称:gral,代码行数:22,代码来源:ImageReaderTest.java

示例2: Histogram2D

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Initializes a new histogram with the specified data source and
 * subdivisions at the specified positions.
 * @param data Data source to be analyzed.
 * @param orientation Orientation in which the data should be sampled.
 * @param breaks Values of where a subdivision should occur.
 */
public Histogram2D(DataSource data, Orientation orientation,
				   Number[]... breaks) {
	this(data, orientation);
	int count = getData().getColumnCount();
	if (orientation == Orientation.HORIZONTAL) {
		count = getData().getRowCount();
	}
	if (breaks.length != count) {
		throw new IllegalArgumentException(MessageFormat.format(
			"Invalid number of breaks: got {0,number,integer}, expected {1,number,integer}.", //$NON-NLS-1$
			breaks.length, count));
	}
	Collections.addAll(this.breaks, breaks);
	dataUpdated(getData());
}
 
开发者ID:eseifert,项目名称:gral,代码行数:23,代码来源:Histogram2D.java

示例3: XYPlot

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Initializes a new instance object with the specified data sources and
 * reasonable default settings.
 * @param data Data to be displayed.
 */
public XYPlot(DataSource... data) {
	super();

	pointRenderersByDataSource = new HashMap<>(data.length);
	lineRenderersByDataSource = new HashMap<>(data.length);
	areaRenderersByDataSource = new HashMap<>(data.length);

	setPlotArea(new XYPlotArea2D(this));
	setLegend(new XYLegend(this));

	// Handle data sources after the renderer lists are initialized
	for (DataSource source : data) {
		add(source);
	}

	createDefaultAxes();
	autoscaleAxes();
	createDefaultAxisRenderers();

	// Listen for changes of the axis range
	for (String axisName : getAxesNames()) {
		getAxis(axisName).addAxisListener(this);
	}
}
 
开发者ID:eseifert,项目名称:gral,代码行数:30,代码来源:XYPlot.java

示例4: setPointRenderers

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Sets the {@code PointRenderer}s for a certain data source to the specified value.
 * @param s Data source.
 * @param pointRendererFirst First PointRenderer.
 * @param pointRenderers Remaining PointRenderers to be set.
 */
public void setPointRenderers(DataSource s, PointRenderer pointRendererFirst, PointRenderer... pointRenderers) {
	List<PointRenderer> pointRendererList = null;
	if (pointRendererFirst == null) {
		setPointRenderers(s, pointRendererList);
		return;
	}
	pointRendererList = new ArrayList<>(pointRenderers.length + 1);
	pointRendererList.add(pointRendererFirst);
	for (PointRenderer pointRenderer : pointRenderers) {
		if (pointRenderer == null) {
			throw new IllegalArgumentException("A PointRenderer for a DataSource cannot be null.");
		}
		pointRendererList.add(pointRenderer);
	}
	setPointRenderers(s, pointRendererList);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:23,代码来源:XYPlot.java

示例5: setLineRenderers

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Sets the {@code LineRenderer}s for a certain data source to the specified
 * value.
 * @param s Data source.
 * @param lineRendererFirst First {@code LineRenderer} to be set.
 * @param lineRenderers Remaining {@code LineRenderer}s to be set.
 */
public void setLineRenderers(DataSource s, LineRenderer lineRendererFirst, LineRenderer... lineRenderers) {
	List<LineRenderer> lineRendererList = null;
	if (lineRendererFirst == null) {
		setLineRenderers(s, lineRendererList);
		return;
	}
	lineRendererList = new ArrayList<>(lineRenderers.length + 1);
	lineRendererList.add(lineRendererFirst);
	for (LineRenderer lineRenderer : lineRenderers) {
		if (lineRenderer == null) {
			throw new IllegalArgumentException("A LineRenderer for a DataSource cannot be null.");
		}
		lineRendererList.add(lineRenderer);
	}
	setLineRenderers(s, lineRendererList);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:24,代码来源:XYPlot.java

示例6: PiePlot

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Initializes a new pie plot with the specified data source.
 * @param data Data to be displayed.
 */
public PiePlot(DataSource data) {
	super();

	center = new Point2D.Double(0.5, 0.5);
	radius = 1.0;
	start = 0.0;
	clockwise = true;

	pointRenderers = new HashMap<>();

	setPlotArea(new PiePlotArea2D(this));
	setLegend(new PiePlotLegend(this));

	add(data);

	createDefaultAxes();
	createDefaultAxisRenderers();

	dataUpdated(data);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:25,代码来源:PiePlot.java

示例7: RasterPlot

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Initializes a new box-and-whisker plot with the specified data source.
 * @param data Data to be displayed.
 */
public RasterPlot(DataSource data) {
	offset = new Point2D.Double();
	distance = new de.erichseifert.gral.graphics.Dimension2D.Double(1.0, 1.0);
	colors = new Grayscale();

	((XYPlotArea2D) getPlotArea()).setMajorGridX(false);
	((XYPlotArea2D) getPlotArea()).setMajorGridY(false);
	//getAxisRenderer(AXIS_X).setSetting(AxisRenderer.TICKS, false);
	//getAxisRenderer(AXIS_Y).setSetting(AxisRenderer.TICKS, false);
	getAxisRenderer(AXIS_X).setIntersection(-Double.MAX_VALUE);
	getAxisRenderer(AXIS_Y).setIntersection(-Double.MAX_VALUE);

	// Store data
	add(data);

	// Adjust axes to the data series
	autoscaleAxes();
}
 
开发者ID:eseifert,项目名称:gral,代码行数:23,代码来源:RasterPlot.java

示例8: setLegend

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
/**
 * Sets the legend to the specified value.
 * @param legend Legend to be set.
 */
protected void setLegend(Legend legend) {
	if (this.legend != null) {
		legendContainer.remove(this.legend);
		this.legend.clear();
		this.legend.setBaseFont(null);
	}
	this.legend = legend;
	if (this.legend != null) {
		this.legend.setBaseFont(font);
		Location constraints = getLegendLocation();
		legendContainer.add(legend, constraints);
		for (DataSource source : getVisibleData()) {
			legend.add(source);
		}
	}
}
 
开发者ID:eseifert,项目名称:gral,代码行数:21,代码来源:AbstractPlot.java

示例9: remove

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Override
public void remove(DataSource source) {
	super.remove(source);
	Set<Row> rows = new HashSet<>(components.keySet());
	for (Row row : rows) {
		if (row.getSource() != source) {
			continue;
		}
		Drawable item = components.remove(row);
		if (item != null) {
			remove(item);
		}
	}
	refresh();
	source.removeDataListener(this);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:17,代码来源:ValueLegend.java

示例10: testDataVisibility

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Test
public void testDataVisibility() {
	// get
	assertTrue(plot.isVisible(series1));
	assertTrue(plot.isVisible(series2));

	// set
	plot.setVisible(series1, false);
	assertFalse(plot.isVisible(series1));
	plot.setVisible(series1, true);
	assertTrue(plot.isVisible(series1));

	// get all
	List<DataSource> all = plot.getData();
	List<DataSource> visible = plot.getVisibleData();
	assertEquals(all.size(), visible.size());
	for (int i = 0; i < all.size(); i++) {
		assertEquals(all.get(i), visible.get(i));
	}
	plot.setVisible(series1, false);
	assertEquals(visible.size() - 1, plot.getVisibleData().size());
	assertEquals(all.get(1), plot.getVisibleData().get(0));
}
 
开发者ID:eseifert,项目名称:gral,代码行数:24,代码来源:PlotTest.java

示例11: testSeparator

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSeparator() throws IOException {
	InputStream input = new ByteArrayInputStream((
		"0;10.0;20\r\n" +
		"1;11.0;21\r\n" +
		"2;12.0;22\r\n"
	).getBytes());

	DataReader reader = DataReaderFactory.getInstance().get("text/csv");
	reader.setSetting(CSVReader.SEPARATOR_CHAR, ';');
	DataSource data = reader.read(input, Integer.class, Double.class, Double.class);

	assertEquals( 0,   data.get(0, 0));
	assertEquals( 1,   data.get(0, 1));
	assertEquals( 2,   data.get(0, 2));
	assertEquals(10.0, data.get(1, 0));
	assertEquals(11.0, data.get(1, 1));
	assertEquals(12.0, data.get(1, 2));
	assertEquals(20.0, data.get(2, 0));
	assertEquals(21.0, data.get(2, 1));
	assertEquals(22.0, data.get(2, 2));
}
 
开发者ID:eseifert,项目名称:gral,代码行数:24,代码来源:CSVReaderTest.java

示例12: testEmptyValues

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testEmptyValues() throws IOException, ParseException {
	InputStream input = new ByteArrayInputStream((
		"0,10.0,\r\n" +
		"1,,21\r\n" +
		",,3\r\n"
	).getBytes());
	DataReader reader = DataReaderFactory.getInstance().get("text/csv");
	DataSource data = reader.read(input, Integer.class, Double.class, Double.class);
	assertEquals( 0,   data.get(0, 0));
	assertEquals(10.0, data.get(1, 0));
	assertNull(        data.get(2, 0));
	assertEquals( 1,   data.get(0, 1));
	assertNull(        data.get(1, 1));
	assertEquals(21.0, data.get(2, 1));
	assertNull(        data.get(0, 2));
	assertNull(        data.get(1, 2));
	assertEquals( 3.0, data.get(2, 2));
}
 
开发者ID:eseifert,项目名称:gral,代码行数:21,代码来源:CSVReaderTest.java

示例13: testSerialization

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
	BoxPlot original = plot;
	BoxPlot deserialized = TestUtils.serializeAndDeserialize(original);

	assertEquals(original.getBackground(), deserialized.getBackground());
	assertEquals(original.getBorderStroke(), deserialized.getBorderStroke());
	assertEquals(original.getBorderColor(), deserialized.getBorderColor());
	assertEquals(original.isLegendVisible(), deserialized.isLegendVisible());
	assertEquals(original.getLegendLocation(), deserialized.getLegendLocation());
	assertEquals(original.getLegendDistance(), deserialized.getLegendDistance(), DELTA);

	List<DataSource> dataSourcesOriginal = original.getData();
	List<DataSource> dataSourcesDeserialized = deserialized.getData();
	assertEquals(dataSourcesOriginal.size(), dataSourcesDeserialized.size());
	for (int index = 0; index < dataSourcesOriginal.size(); index++) {
		List<PointRenderer> pointRenderersOriginal = original.getPointRenderers(
						dataSourcesOriginal.get(index));
		List<PointRenderer> pointRenderersDeserialized = deserialized.getPointRenderers(
						dataSourcesDeserialized.get(index));
		testPointRendererSerialization(pointRenderersOriginal, pointRenderersDeserialized);
	}
   }
 
开发者ID:eseifert,项目名称:gral,代码行数:24,代码来源:BoxPlotTest.java

示例14: formatFilledArea

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
private static void formatFilledArea(XYPlot plot, DataSource data, Color color) {
	PointRenderer point = new DefaultPointRenderer2D();
	point.setColor(color);
	plot.setPointRenderer(data, point);
	LineRenderer line = new DefaultLineRenderer2D();
	line.setColor(color);
	line.setGap(3.0);
	line.setGapRounded(true);
	plot.setLineRenderer(data, line);
	AreaRenderer area = new DefaultAreaRenderer2D();
	area.setColor(GraphicsUtils.deriveWithAlpha(color, 64));
	plot.setAreaRenderer(data, area);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:14,代码来源:AreaPlot.java

示例15: formatLineArea

import de.erichseifert.gral.data.DataSource; //导入依赖的package包/类
private static void formatLineArea(XYPlot plot, DataSource data, Color color) {
	PointRenderer point = new DefaultPointRenderer2D();
	point.setColor(color);
	plot.setPointRenderer(data, point);
	plot.setLineRenderer(data, null);
	AreaRenderer area = new LineAreaRenderer2D();
	area.setGap(3.0);
	area.setColor(color);
	plot.setAreaRenderer(data, area);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:11,代码来源:AreaPlot.java


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