本文整理汇总了Java中de.erichseifert.gral.plots.BarPlot.setInsets方法的典型用法代码示例。如果您正苦于以下问题:Java BarPlot.setInsets方法的具体用法?Java BarPlot.setInsets怎么用?Java BarPlot.setInsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.erichseifert.gral.plots.BarPlot
的用法示例。
在下文中一共展示了BarPlot.setInsets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SimpleBarPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleBarPlot() {
// Create example data
DataTable data = new DataTable(Double.class, Integer.class, String.class);
data.add(0.1, 1, "January");
data.add(0.2, 3, "February");
data.add(0.3, -2, "March");
data.add(0.4, 6, "April");
data.add(0.5, -4, "May");
data.add(0.6, 8, "June");
data.add(0.7, 9, "July");
data.add(0.8, 11, "August");
// Create new bar plot
BarPlot plot = new BarPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(40.0, 40.0, 40.0, 40.0));
plot.setBarWidth(0.075);
// Format bars
BarRenderer pointRenderer = (BarRenderer) plot.getPointRenderer(data);
pointRenderer.setColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { COLOR1, GraphicsUtils.deriveBrighter(COLOR1) }
)
);
/*pointRenderer.setBorderStroke(new BasicStroke(3f));
pointRenderer.setBorderColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { GraphicsUtils.deriveBrighter(COLOR1), COLOR1 }
)
);*/
pointRenderer.setValueVisible(true);
pointRenderer.setValueColumn(2);
pointRenderer.setValueLocation(Location.CENTER);
pointRenderer.setValueColor(GraphicsUtils.deriveDarker(COLOR1));
pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));
// Add plot to Swing component
add(new InteractivePanel(plot));
}
示例2: HistogramPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的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);
}
示例3: SimpleBarPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleBarPlot() {
// Create example data
DataTable data = new DataTable(Double.class, Integer.class, String.class);
data.add(0.1, 1, "January");
data.add(0.2, 3, "February");
data.add(0.3, -2, "March");
data.add(0.4, 6, "April");
data.add(0.5, -4, "May");
data.add(0.6, 8, "June");
data.add(0.7, 9, "July");
data.add(0.8, 11, "August");
// Create new bar plot
BarPlot plot = new BarPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(40.0, 40.0, 40.0, 40.0));
plot.setBarWidth(0.075);
// Format bars
BarRenderer pointRenderer = (BarRenderer) plot.getPointRenderers(data).get(0);
pointRenderer.setColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { COLOR1, GraphicsUtils.deriveBrighter(COLOR1) }
)
);
pointRenderer.setBorderStroke(new BasicStroke(3f));
pointRenderer.setBorderColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { GraphicsUtils.deriveBrighter(COLOR1), COLOR1 }
)
);
pointRenderer.setValueVisible(true);
pointRenderer.setValueColumn(2);
pointRenderer.setValueLocation(Location.CENTER);
pointRenderer.setValueColor(GraphicsUtils.deriveDarker(COLOR1));
pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));
// Add plot to Swing component
add(new InteractivePanel(plot));
}
示例4: HistogramPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的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);
}
示例5: SimpleBarPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public SimpleBarPlot() {
// Create example data
DataTable data = new DataTable(Double.class, Integer.class, String.class);
data.add(0.1, 1, "January");
data.add(0.2, 3, "February");
data.add(0.3, -2, "March");
data.add(0.4, 6, "April");
data.add(0.5, -4, "May");
data.add(0.6, 8, "June");
data.add(0.7, 9, "July");
data.add(0.8, 11, "August");
// Create new bar plot
BarPlot plot = new BarPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(40.0, 40.0, 40.0, 40.0));
plot.setBarWidth(0.075);
// Format bars
BarRenderer pointRenderer = (BarRenderer) plot.getPointRenderer(data);
pointRenderer.setColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { COLOR1, GraphicsUtils.deriveBrighter(COLOR1) }
)
);
pointRenderer.setBorderStroke(new BasicStroke(3f));
pointRenderer.setBorderColor(
new LinearGradientPaint(0f,0f, 0f,1f,
new float[] { 0.0f, 1.0f },
new Color[] { GraphicsUtils.deriveBrighter(COLOR1), COLOR1 }
)
);
pointRenderer.setValueVisible(true);
pointRenderer.setValueColumn(2);
pointRenderer.setValueLocation(Location.CENTER);
pointRenderer.setValueColor(GraphicsUtils.deriveDarker(COLOR1));
pointRenderer.setValueFont(Font.decode(null).deriveFont(Font.BOLD));
// Add plot to Swing component
add(new InteractivePanel(plot));
}
示例6: HistogramPlot
import de.erichseifert.gral.plots.BarPlot; //导入方法依赖的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);
}