本文整理汇总了Java中de.erichseifert.gral.data.EnumeratedData类的典型用法代码示例。如果您正苦于以下问题:Java EnumeratedData类的具体用法?Java EnumeratedData怎么用?Java EnumeratedData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumeratedData类属于de.erichseifert.gral.data包,在下文中一共展示了EnumeratedData类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HistogramPlot
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
public HistogramPlot() {
// Create example data
Random random = new Random();
DataTable data = new DataTable(Double.class);
for (int i = 0; i < SAMPLE_COUNT; i++) {
data.add(random.nextGaussian());
}
// Create histogram from data
Histogram1D histogram = new Histogram1D(data, Orientation.VERTICAL,
new Number[] {-4.0, -3.2, -2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4, 3.2, 4.0});
// Create a second dimension (x axis) for plotting
DataSource histogram2d = new EnumeratedData(histogram, (-4.0 + -3.2)/2.0, 0.8);
// Create new bar plot
BarPlot plot = new BarPlot(histogram2d);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 65.0, 50.0, 40.0));
plot.getTitle().setText(
String.format("Distribution of %d random samples", data.getRowCount()));
plot.setBarWidth(0.78);
// Format x axis
plot.getAxisRenderer(BarPlot.AXIS_X).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_X).setTickSpacing(0.8);
plot.getAxisRenderer(BarPlot.AXIS_X).setMinorTicksVisible(false);
// Format y axis
plot.getAxis(BarPlot.AXIS_Y).setRange(0.0,
MathUtils.ceil(histogram.getStatistics().get(Statistics.MAX)*1.1, 25.0));
plot.getAxisRenderer(BarPlot.AXIS_Y).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_Y).setMinorTicksVisible(false);
plot.getAxisRenderer(BarPlot.AXIS_Y).setIntersection(-4.4);
// Format bars
plot.getPointRenderer(histogram2d).setColor(
GraphicsUtils.deriveWithAlpha(COLOR1, 128));
plot.getPointRenderer(histogram2d).setValueVisible(true);
// Add plot to Swing component
InteractivePanel panel = new InteractivePanel(plot);
panel.setPannable(false);
panel.setZoomable(false);
add(panel);
}
示例2: setUp
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
@Before
public void setUp() {
data = new EnumeratedData(new DummyData(5, 3, 1.0));
plot = new MockBoxPlot(data);
}
示例3: HistogramPlot
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public HistogramPlot() {
// Create example data
Random random = new Random();
DataTable data = new DataTable(Double.class);
for (int i = 0; i < SAMPLE_COUNT; i++) {
data.add(random.nextGaussian());
}
// Create histogram from data
Histogram2D histogram = new Histogram2D(data, Orientation.VERTICAL,
new Number[] {-4.0, -3.2, -2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4, 3.6, 4.0});
// Create a second dimension (x axis) for plotting
DataSource histogram2d = new EnumeratedData(histogram, (-4.0 + -3.2)/2.0, 0.8);
// Create new bar plot
BarPlot plot = new BarPlot(histogram2d);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 65.0, 50.0, 40.0));
plot.getTitle().setText(
String.format("Distribution of %d random samples", data.getRowCount()));
plot.setBarWidth(0.78);
// Format x axis
plot.getAxisRenderer(BarPlot.AXIS_X).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_X).setTickSpacing(0.8);
plot.getAxisRenderer(BarPlot.AXIS_X).setMinorTicksVisible(false);
// Format y axis
plot.getAxis(BarPlot.AXIS_Y).setRange(0.0,
MathUtils.ceil(histogram.getStatistics().get(Statistics.MAX)*1.1, 25.0));
plot.getAxisRenderer(BarPlot.AXIS_Y).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_Y).setMinorTicksVisible(false);
plot.getAxisRenderer(BarPlot.AXIS_Y).setIntersection(-4.4);
// Format bars
PointRenderer barRenderer = plot.getPointRenderers(histogram2d).get(0);
barRenderer.setColor(GraphicsUtils.deriveWithAlpha(COLOR1, 128));
barRenderer.setValueVisible(true);
// Add plot to Swing component
InteractivePanel panel = new InteractivePanel(plot);
panel.setPannable(false);
panel.setZoomable(false);
add(panel);
}
示例4: HistogramPlot
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public HistogramPlot() {
// Create example data
Random random = new Random();
DataTable data = new DataTable(Double.class);
for (int i = 0; i < SAMPLE_COUNT; i++) {
data.add(random.nextGaussian());
}
// Create histogram from data
Histogram1D histogram = new Histogram1D(data, Orientation.VERTICAL,
new Number[] {-4.0, -3.2, -2.4, -1.6, -0.8, 0.0, 0.8, 1.6, 2.4, 3.6, 4.0});
// Create a second dimension (x axis) for plotting
DataSource histogram2d = new EnumeratedData(histogram, (-4.0 + -3.2)/2.0, 0.8);
// Create new bar plot
BarPlot plot = new BarPlot(histogram2d);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 65.0, 50.0, 40.0));
plot.getTitle().setText(
String.format("Distribution of %d random samples", data.getRowCount()));
plot.setBarWidth(0.78);
// Format x axis
plot.getAxisRenderer(BarPlot.AXIS_X).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_X).setTickSpacing(0.8);
plot.getAxisRenderer(BarPlot.AXIS_X).setMinorTicksVisible(false);
// Format y axis
plot.getAxis(BarPlot.AXIS_Y).setRange(0.0,
MathUtils.ceil(histogram.getStatistics().get(Statistics.MAX)*1.1, 25.0));
plot.getAxisRenderer(BarPlot.AXIS_Y).setTickAlignment(0.0);
plot.getAxisRenderer(BarPlot.AXIS_Y).setMinorTicksVisible(false);
plot.getAxisRenderer(BarPlot.AXIS_Y).setIntersection(-4.4);
// Format bars
plot.getPointRenderer(histogram2d).setColor(
GraphicsUtils.deriveWithAlpha(COLOR1, 128));
plot.getPointRenderer(histogram2d).setValueVisible(true);
// Add plot to Swing component
InteractivePanel panel = new InteractivePanel(plot);
panel.setPannable(false);
panel.setZoomable(false);
add(panel);
}
示例5: getLongHistogramDataSource
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
/**
* Get a DataSource from Long type ArrayList
* @param list
* @return data
*/
private DataSource getLongHistogramDataSource(ArrayList<Long> list)
{
// Create example data
Long max = Collections.max(list);
Long min = Collections.min(list);
int bin = max.intValue() - min.intValue() + 1;
Double gap = 1d;
DataTable data = new DataTable(Long.class);
System.out.println("Bin: " + bin + " SAMPLE:" + SAMPLE);
System.out.println("Max: " + max + " Min: " + min + " Gap:" + 1);
if(bin > SAMPLE) {
bin = SAMPLE;
gap = (max.doubleValue() - min.doubleValue()) / bin;
}
Number[] number = null;
if(!min.equals(max))
{
number = new Number[bin + 1];
for (int i = 0; i <= bin; i++)
number[i] = min + i * gap;
}
else
{
number = new Number[3];
min = min - 1;
number[0] = min;
number[1] = min + 1;
number[2] = min + 2;
}
for (Long d : list)
{
data.add(d);
}
// Create histogram from data
Histogram1D histogram = new Histogram1D(data, Orientation.VERTICAL, number);
// Create a second dimension (x axis) for plotting
return new EnumeratedData(histogram, min, gap);
}
示例6: getDoubleHistogramDataSource
import de.erichseifert.gral.data.EnumeratedData; //导入依赖的package包/类
/**
* Get a DataSource for Double type ArrayList
* @param list
* @return data
*/
private DataSource getDoubleHistogramDataSource(ArrayList<Double> list)
{
// Create example data
DataTable data = new DataTable(Double.class);
Double max = Collections.max(list);
Double min = Collections.min(list);
Double gap = (max.doubleValue() - min.doubleValue()) / SAMPLE;
min -= gap;
System.out.println("NBin: " + SAMPLE);
System.out.println("Max: " + max + " Min: " + min + " Gap:" + gap);
Number[] number = null;
if(min != max)
{
number = new Number[SAMPLE + 3];
for (int i = 0; i < number.length; i++)
number[i] = min + i * gap;
}
else
{
number = new Number[3];
min -= gap;
number[0] = min;
number[1] = min + gap;
number[2] = min + gap;
}
for (Double d : list)
{
data.add(d);
}
// Create histogram from data
Histogram1D histogram = new Histogram1D(data, Orientation.VERTICAL, number);
// Create a second dimension (x axis) for plotting
return new EnumeratedData(histogram, min, gap);
}