本文整理汇总了Java中de.erichseifert.gral.data.DataTable.add方法的典型用法代码示例。如果您正苦于以下问题:Java DataTable.add方法的具体用法?Java DataTable.add怎么用?Java DataTable.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.erichseifert.gral.data.DataTable
的用法示例。
在下文中一共展示了DataTable.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SineGraph
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
public SineGraph() throws FileNotFoundException, IOException {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1600, 1400);
DataTable data = new DataTable(Double.class, Double.class);
for (double x = -5.0; x <= 5.0; x+=0.25) {
double y = 5.0*Math.sin(x);
data.add(x, y);
}
XYPlot plot = new XYPlot(data);
getContentPane().add(new InteractivePanel(plot));
LineRenderer lines = new DefaultLineRenderer2D();
plot.setLineRenderer(data, lines);
Color color = new Color(0.0f, 0.0f, 0.0f);
plot.getPointRenderer(data).setColor(color);
plot.getLineRenderer(data).setColor(color);
}
示例2: ScatterPlot
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public ScatterPlot() {
// Generate 100,000 data points
DataTable data = new DataTable(Double.class, Double.class);
for (int i = 0; i <= SAMPLE_COUNT; i++) {
data.add(random.nextGaussian()*2.0, random.nextGaussian()*2.0);
}
// Create a new xy-plot
XYPlot plot = new XYPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));
plot.getTitle().setText(getDescription());
// Format points
plot.getPointRenderer(data).setColor(COLOR1);
// Add plot to Swing component
add(new InteractivePanel(plot), BorderLayout.CENTER);
}
示例3: setUpBeforeClass
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public static void setUpBeforeClass() {
dataEmpty = new DataTable(Double.class, Double.class, Double.class);
dataEmpty.add(0.0, 0.0, 0.0); // 0
dataEmpty.add(0.0, 0.0, 0.0); // 1
dataEmpty.add(0.0, 0.0, 0.0); // 2
dataHorizontal = new DataTable(Double.class, Double.class, Double.class);
dataHorizontal.add(0.0, 0.0, 0.0); // 0
dataHorizontal.add(1.0, 1.0, 1.0); // 1
dataHorizontal.add(0.0, 0.0, 0.0); // 2
dataVertical = new DataTable(Double.class, Double.class, Double.class);
dataVertical.add(0.0, 1.0, 0.0); // 0
dataVertical.add(0.0, 1.0, 0.0); // 1
dataVertical.add(0.0, 1.0, 0.0); // 2
dataDiagonal = new DataTable(Double.class, Double.class, Double.class);
dataDiagonal.add(1.0, 0.0, 0.0); // 0
dataDiagonal.add(0.0, 1.0, 0.0); // 1
dataDiagonal.add(0.0, 0.0, 1.0); // 2
}
示例4: setUpBeforeClass
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public static void setUpBeforeClass() {
table = new DataTable(Integer.class, Integer.class, Integer.class);
table.add(1, 3, 5); // 0
table.add(2, 8, 2); // 1
table.add(3, 5, 6); // 2
table.add(4, 6, 2); // 3
table.add(5, 4, 1); // 4
table.add(6, 9, 5); // 5
table.add(7, 8, 7); // 6
table.add(8, 1, 9); // 7
series1 = new DataSeries("series1", table, 0, 1);
series2 = new DataSeries("series2", table, 1, 2);
}
示例5: setUpBeforeClass
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public static void setUpBeforeClass() {
table = new DataTable(Integer.class, String.class);
table.add(1, "Jan"); // 0
table.add(2, "Feb"); // 1
table.add(3, "Mar"); // 2
table.add(4, "Apr"); // 3
table.add(5, "May"); // 4
table.add(6, "Jun"); // 5
table.add(7, "Jul"); // 6
table.add(8, "Aug"); // 7
row = new Row(table, 4);
axis = new Axis(0.0, 10.0);
axisRenderer = new LinearRenderer2D();
axisRenderer.setShape(new Line2D.Double(-5.0, 0.0, 5.0, 0.0));
data = new PointData(
Arrays.asList(null, axis),
Arrays.asList(null, axisRenderer),
row, row.getIndex(), 0);
}
示例6: setUpBeforeClass
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public static void setUpBeforeClass() {
table = new DataTable(Integer.class, Integer.class, String.class);
table.add(1, 9, "Jan"); // 0
table.add(2, 8, "Feb"); // 1
table.add(3, 7, "Mar"); // 2
table.add(4, 6, "Apr"); // 3
table.add(5, 5, "May"); // 4
table.add(6, 4, "Jun"); // 5
table.add(7, 3, "Jul"); // 6
table.add(8, 1, "Aug"); // 7
row = new Row(table, 4);
axis = new Axis(0.0, 10.0);
axisRenderer = new LinearRenderer2D();
axisRenderer.setShape(new Line2D.Double(-5.0, 0.0, 5.0, 0.0));
data = new PointData(
Arrays.asList(null, axis),
Arrays.asList(null, axisRenderer),
row, row.getIndex(), 0);
}
示例7: ScatterPlot
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public ScatterPlot() {
// Generate 100,000 data points
DataTable data = new DataTable(Double.class, Double.class);
for (int i = 0; i <= SAMPLE_COUNT; i++) {
data.add(random.nextGaussian()*2.0, random.nextGaussian()*2.0);
}
// Create a new xy-plot
plot = new XYPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));
plot.getTitle().setText(getDescription());
// Format points
plot.getPointRenderer(data).setColor(COLOR1);
// Add plot to Swing component
add(new InteractivePanel(plot), BorderLayout.CENTER);
}
示例8: addAzimuthLine
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
void addAzimuthLine(XYPlot plot, double azimuth, float length, Color lineColor) {
DataTable bazLine = new DataTable(Float.class, Float.class);
float xMid = (plot.getAxis(XYPlot.AXIS_X).getMin().floatValue() + plot.getAxis(XYPlot.AXIS_X)
.getMax()
.floatValue()) / 2;
float yMid = (plot.getAxis(XYPlot.AXIS_Y).getMin().floatValue() + plot.getAxis(XYPlot.AXIS_Y)
.getMax()
.floatValue()) / 2;
float x = (float)(length / 2 * Math.cos(Math.toRadians(90 - azimuth)));
float y = (float)(length / 2 * Math.sin(Math.toRadians(90 - azimuth)));
bazLine.add(xMid - x, yMid - y);
bazLine.add(xMid + x, yMid + y);
plot.add(bazLine);
LineRenderer bazlr = new DefaultLineRenderer2D();
bazlr.setSetting(LineRenderer.COLOR, lineColor);
plot.setLineRenderer(bazLine, bazlr);
}
示例9: AreaPlot
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
public AreaPlot() {
// Generate data
DataTable data = new DataTable(Double.class, Double.class, Double.class, Double.class);
for (double x = 0.0; x < 50; x ++) {
double y1 = Double.NaN, y2 = Double.NaN, y3 = Double.NaN;
y1 = random.nextGaussian();
y2 = random.nextGaussian();
y3 = random.nextGaussian();
data.add(x, y1, y2, y3);
}
// Create data series
DataSeries data1 = new DataSeries("series 1", data, 0, 1);
DataSeries data2 = new DataSeries("series 2", data, 0, 2);
DataSeries data3 = new DataSeries("series 3", data, 0, 3);
// Create new xy-plot
XYPlot plot = new XYPlot(data1, data2, data3);
plot.setLegendVisible(true);
plot.setInsets(new Insets2D.Double(20.0, 40.0, 20.0, 20.0));
// Format data series
formatFilledArea(plot, data1, COLOR2);
formatFilledArea(plot, data2, COLOR1);
formatLineArea(plot, data3, GraphicsUtils.deriveDarker(COLOR1));
// Add plot to Swing component
add(new InteractivePanel(plot));
}
示例10: SimplePiePlot
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimplePiePlot() {
// Create data
DataTable data = new DataTable(Integer.class);
for (int i = 0; i < SAMPLE_COUNT; i++) {
int val = random.nextInt(8) + 2;
data.add((random.nextDouble() <= 0.15) ? -val : val);
}
// Create new pie plot
PiePlot plot = new PiePlot(data);
// Format plot
plot.getTitle().setText(getDescription());
// Change relative size of pie
plot.setRadius(0.9);
// Display a legend
plot.setLegendVisible(true);
// Add some margin to the plot area
plot.setInsets(new Insets2D.Double(20.0, 40.0, 40.0, 40.0));
PieSliceRenderer pointRenderer =
(PieSliceRenderer) plot.getPointRenderer(data);
// Change relative size of inner region
pointRenderer.setInnerRadius(0.4);
// Change the width of gaps between segments
pointRenderer.setGap(0.2);
// Change the colors
LinearGradient colors = new LinearGradient(COLOR1, COLOR2);
pointRenderer.setColor(colors);
// Show labels
pointRenderer.setValueVisible(true);
pointRenderer.setValueColor(Color.WHITE);
pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));
// Add plot to Swing component
add(new InteractivePanel(plot), BorderLayout.CENTER);
}
示例11: render
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@Override
public void render(Canvas componentCanvas, PLLineChartBlock component) {
PLLinePlotData data = component.getData();
if(data != null){
int linesCount = data.getY().size();
Class[] classes = Arrays.stream((new Class[linesCount + 1])).map(v -> Double.class).toArray(Class[]::new);
DataTable dataTable = new DataTable(classes);
for(int i = 0;i < linesCount;i++){
final int index = i;
Double[] points = Stream.concat(Stream.of(data.getX().get(index)),
data.getY().stream().map(lineData -> lineData.getY().get(index))).toArray(Double[]::new);
dataTable.add(points);
}
DataSeries[] dataSeries = IntStream.range(0, linesCount).mapToObj(index -> new DataSeries(data.getY().get(index).getName(), dataTable, 0, index + 1)).toArray(DataSeries[]::new);
XYPlot plot = new XYPlot(dataSeries);
super.preparePlot(plot, component);
plot.getAxisRenderer(XYPlot.AXIS_X).setIntersection(-Double.MAX_VALUE);
plot.getAxisRenderer(XYPlot.AXIS_Y).setIntersection(-Double.MAX_VALUE);
Color[] seriesColor = (component.getData().getY() == null)?null:component.getData().getY().stream().map(point -> PLColor.create(point.getColor(), Color.class)).toArray(Color[]::new);
if(seriesColor != null){
for(int i = 0;i < seriesColor.length;i++){
try{
PointRenderer ptRenderer = new DefaultPointRenderer2D();
LineRenderer lineRenderer = new DefaultLineRenderer2D();
Color lineColor = seriesColor[i];
ptRenderer.setColor(lineColor);
lineRenderer.setColor(lineColor);
plot.setPointRenderers(dataSeries[i], ptRenderer);
plot.setLineRenderers(dataSeries[i], lineRenderer);
}catch(Exception e){
logger.error("Error caused when trying to set color for a series", e);
}
}
}
super.drawPlot(plot, component, componentCanvas);
}else{
logger.warn("data not set, not rendering " + component);
}
}
示例12: render
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@Override
public void render(Canvas componentCanvas, PLBarPlotBlock component) {
List<PLBarPlotData> plots = component.getPlots();
Double barWidth = component.getBarWidth();
Double xMin = Double.valueOf(0);
if(plots != null && plots.size() > 0){
BarPlot plot = new BarPlot();
super.preparePlot(plot, component);
for(PLBarPlotData p:plots){
DataTable dataTable = new DataTable(Double.class, Double.class, String.class);
for(PLBarPlotPoint point:p.getData()){
if(point.getxData() < xMin) xMin = point.getxData();
dataTable.add(point.getxData(), point.getyData(), point.getLabel());
}
plot.add(dataTable);
BarPlot.BarRenderer pointRenderer = (BarPlot.BarRenderer) plot.getPointRenderers(dataTable).get(0);
Color color = PLColor.create(p.getColor(), Color.class);
pointRenderer.setColor(color);
pointRenderer.setBorderStroke(new BasicStroke(component.getBorderStroke()));
pointRenderer.setBorderColor(PLColor.create(component.getBorderColor(), Color.class));
pointRenderer.setValueVisible(component.isValueVisible());
}
if(barWidth != null) plot.setBarWidth(barWidth);
plot.getAxisRenderer(BarPlot.AXIS_X).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_X).setTickSpacing(0.8);
plot.getAxisRenderer(BarPlot.AXIS_X).setMinorTicksVisible(false);
plot.getAxisRenderer(BarPlot.AXIS_Y).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_Y).setMinorTicksVisible(false);
plot.getAxisRenderer(BarPlot.AXIS_Y).setIntersection(xMin);
super.drawPlot(plot, component, componentCanvas);
}else{
this.logger.warn("data for " + component + " isn't good enough, block was not rendered");
}
}
示例13: render
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
@Override
public void render(Canvas componentCanvas, PLPieChartBlock component) {
DataTable dataTable = new DataTable(Integer.class);
PiePlot plot = new PiePlot(dataTable);
super.preparePlot(plot, component);
Integer[] dataset = component.getData();
Float gap = component.getGap();
Float innerRadius = component.getInnerRadius();
Float outerRadius = component.getOuterRadius();
Color pieColor = PLColor.create(component.getPieColor(), Color.class);
Color[] colors = (component.getColors() == null)?null:Arrays.stream(component.getColors()).map(color -> PLColor.create(color, Color.class)).toArray(Color[]::new);
if(dataset != null){
for(Integer row:dataset){
dataTable.add(row);
}
PieSliceRenderer pointRenderer = (PieSliceRenderer) plot.getPointRenderer(dataTable);
if(gap != null) pointRenderer.setGap(gap);
if(innerRadius != null) pointRenderer.setInnerRadius(innerRadius);
if(outerRadius != null) pointRenderer.setOuterRadius(outerRadius);
if(pieColor != null && colors != null){
IndexedColors indexedColors = new IndexedColors(pieColor, colors);
pointRenderer.setColor(indexedColors);
}
super.drawPlot(plot, component, componentCanvas);
}else{
logger.warn("no data found for " + component + ", ignoring Block");
}
}
示例14: fillWithEmptyRows
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
/**
* Utility method that fills a data table with empty rows.
* @param data Data table that should be filled.
* @param count Number of rows that were added.
*/
private static void fillWithEmptyRows(DataTable data, int count) {
while (data.getRowCount() < count) {
Double[] emptyRow = new Double[data.getColumnCount()];
Arrays.fill(emptyRow, 0.0);
data.add(emptyRow);
}
}
示例15: createBoxData
import de.erichseifert.gral.data.DataTable; //导入方法依赖的package包/类
/**
* Extracts statistics from the columns of an data source that are commonly
* used for box-and-whisker plots. The result is a new data source
* containing <i>column index</i>, <i>median</i>, <i>mininum</i>, <i>first
* quartile</i>, <i>third quartile</i>, and <i>maximum</i> for each column.
* @param data Original data source
* @return New data source with (columnIndex, median, min, quartile1,
* quartile3, max)
*/
@SuppressWarnings("unchecked")
public static DataSource createBoxData(DataSource data) {
if (data == null) {
throw new NullPointerException(
"Cannot extract statistics from null data source.");
}
DataTable stats = new DataTable(Integer.class, Double.class,
Double.class, Double.class, Double.class, Double.class);
// Generate statistical values for each column
for (int c = 0; c < data.getColumnCount(); c++) {
Column col = data.getColumn(c);
if (!col.isNumeric()) {
continue;
}
stats.add(
c + 1,
col.getStatistics(Statistics.MEDIAN),
col.getStatistics(Statistics.MIN),
col.getStatistics(Statistics.QUARTILE_1),
col.getStatistics(Statistics.QUARTILE_3),
col.getStatistics(Statistics.MAX)
);
}
return stats;
}