本文整理汇总了Java中de.erichseifert.gral.plots.points.PointRenderer.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java PointRenderer.setColor方法的具体用法?Java PointRenderer.setColor怎么用?Java PointRenderer.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.erichseifert.gral.plots.points.PointRenderer
的用法示例。
在下文中一共展示了PointRenderer.setColor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatFilledArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
private static void formatFilledArea(XYPlot plot, DataSource data, Color color) {
PointRenderer point = new DefaultPointRenderer2D();
point.setShape(new Ellipse2D.Double(-3,-3,6,6));
point.setColor(color);
plot.setPointRenderer(data, point);
LineRenderer line = new DefaultLineRenderer2D();
line.setColor(color);
float[] DOT_DOT = {4.0f, 4.0f};
line.setStroke(new BasicStroke(4.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.f, DOT_DOT, 0.f));
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);
}
示例2: formatFilledArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
示例3: formatLineArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
示例4: render
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
}
示例5: formatFilledArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
private static void formatFilledArea(XYPlot plot, DataSource data, Color color) {
PointRenderer point = new DefaultPointRenderer2D();
point.setColor(color);
plot.setPointRenderers(data, point);
LineRenderer line = new DefaultLineRenderer2D();
line.setColor(color);
line.setGap(3.0);
line.setGapRounded(true);
plot.setLineRenderers(data, line);
AreaRenderer area = new DefaultAreaRenderer2D();
area.setColor(GraphicsUtils.deriveWithAlpha(color, 64));
plot.setAreaRenderers(data, area);
}
示例6: formatLineArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
private static void formatLineArea(XYPlot plot, DataSource data, Color color) {
PointRenderer point = new DefaultPointRenderer2D();
point.setColor(color);
plot.setPointRenderers(data, point);
plot.setLineRenderers(data, null);
AreaRenderer area = new LineAreaRenderer2D();
area.setGap(3.0);
area.setColor(color);
plot.setAreaRenderers(data, area);
}
示例7: MultiplePointRenderers
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MultiplePointRenderers() {
// Generate data
DataTable data = new DataTable(Double.class, Double.class);
for (double x = 1.0; x <= 20.0; x += 1.0) {
data.add(x, x*x);
}
// Create new xy-plot
XYPlot plot = new XYPlot(data);
// Format plot
plot.setInsets(new Insets2D.Double(20.0, 60.0, 40.0, 40.0));
plot.setBackground(Color.WHITE);
plot.getTitle().setText(getDescription());
// Format rendering of data points
PointRenderer defaultPointRenderer = new DefaultPointRenderer2D();
defaultPointRenderer.setColor(GraphicsUtils.deriveDarker(COLOR1));
plot.setPointRenderers(data, defaultPointRenderer);
PointRenderer shadowRenderer = new ShadowPointRenderer(defaultPointRenderer);
plot.addPointRenderer(data, shadowRenderer);
LineRenderer lineRenderer = new DefaultLineRenderer2D();
lineRenderer.setGap(2.0);
plot.setLineRenderers(data, lineRenderer);
// Add plot to Swing component
add(new InteractivePanel(plot), BorderLayout.CENTER);
}
示例8: formatLineArea
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
示例9: createSpecificPlot
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
private JPanel createSpecificPlot() {
GridResult grid = results.get(selectedIndex);
for (int i = 0; i < grid.test.size(); i++) {
dataSpecific.add((double)i, grid.test.get(i), grid.train.get(i) );
}
DataSeries seriesTest = new DataSeries("Test",dataSpecific, 0, 1);
DataSeries seriesTrain = new DataSeries("Training",dataSpecific, 0, 2);
// Create a new xy-plot
final XYPlot plot = new XYPlot(seriesTest,seriesTrain);
// Format plot
plot.setInsets(new Insets2D.Double(60, 60, 60, 20));
plot.getTitle().setText(grid.name);
plot.setLegendVisible(true);
plot.setLegendLocation(Location.NORTH);
specificPlot = plot;
SmoothLineRenderer2D renderTest = new SmoothLineRenderer2D();
renderTest.setColor(deriveDarker(Color.RED));
PointRenderer renderTestPoint = new DefaultPointRenderer2D();
renderTestPoint.setColor(renderTest.getColor());
plot.setLineRenderers(seriesTest, renderTest);
plot.setPointRenderers(seriesTest, renderTestPoint);
SmoothLineRenderer2D renderTrain = new SmoothLineRenderer2D();
renderTrain.setColor(deriveDarker(Color.BLUE));
PointRenderer renderTrainPoint = new DefaultPointRenderer2D();
renderTrainPoint.setColor(renderTrain.getColor());
plot.setLineRenderers(seriesTrain, renderTrain);
plot.setPointRenderers(seriesTrain, renderTrainPoint);
plot.getAxisRenderer(XYPlot.AXIS_X).getLabel().setText("Epoc");
plot.getAxisRenderer(XYPlot.AXIS_Y).getLabel().setText("Score");
plot.getAxis(XYPlot.AXIS_Y).setAutoscaled(false);
plot.getAxis(XYPlot.AXIS_Y).setRange(0,101);
specificPlotPanel = new InteractivePanel(plot);
JPanel wrapper = new JPanel();
wrapper.setLayout(new BorderLayout());
wrapper.add(specificPlotPanel,BorderLayout.CENTER);
wrapper.setBackground(Color.WHITE);
return wrapper;
}
示例10: StackedPlots
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public StackedPlots() {
// Generate data
DataTable data = new DataTable(Double.class, Double.class);
double x=0.0, y=0.0;
for (x=0.0; x<100.0; x+=2.0) {
y += 10.0*random.nextGaussian();
data.add(x, Math.abs(y));
}
// Create and format upper plot
XYPlot plotUpper = new XYPlot(data);
Color colorUpper = COLOR1;
plotUpper.setPointRenderers(data, null);
LineRenderer lineUpper = new DefaultLineRenderer2D();
lineUpper.setColor(colorUpper);
plotUpper.setLineRenderers(data, lineUpper);
AreaRenderer areaUpper = new DefaultAreaRenderer2D();
areaUpper.setColor(GraphicsUtils.deriveWithAlpha(colorUpper, 64));
plotUpper.setAreaRenderers(data, areaUpper);
plotUpper.setInsets(new Insets2D.Double(20.0, 50.0, 40.0, 20.0));
// Create and format lower plot
XYPlot plotLower = new XYPlot(data);
Color colorLower = COLOR1;
PointRenderer pointsLower = plotLower.getPointRenderers(data).get(0);
pointsLower.setColor(colorLower);
pointsLower.setShape(new Ellipse2D.Double(-3, -3, 6, 6));
LineRenderer lineLower = new DefaultLineRenderer2D();
lineLower.setStroke(new BasicStroke(2f));
lineLower.setGap(1.0);
lineLower.setColor(colorLower);
plotLower.setLineRenderers(data, lineLower);
plotLower.setInsets(new Insets2D.Double(20.0, 50.0, 40.0, 20.0));
DrawableContainer plots = new DrawableContainer(new TableLayout(1));
plots.add(plotUpper);
plots.add(plotLower);
// Connect the two plots, i.e. user (mouse) actions affect both plots
plotUpper.getNavigator().connect(plotLower.getNavigator());
InteractivePanel panel = new InteractivePanel(plots);
add(panel);
}
示例11: SimpleXYPlot
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
示例12: HistogramPlot
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}
示例13: StackedPlots
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public StackedPlots() {
// Generate data
DataTable data = new DataTable(Double.class, Double.class);
double x=0.0, y=0.0;
for (x=0.0; x<100.0; x+=2.0) {
y += 10.0*random.nextGaussian();
data.add(x, Math.abs(y));
}
// Create and format upper plot
XYPlot plotUpper = new XYPlot(data);
Color colorUpper = COLOR1;
plotUpper.setPointRenderer(data, null);
LineRenderer lineUpper = new DefaultLineRenderer2D();
lineUpper.setColor(colorUpper);
plotUpper.setLineRenderer(data, lineUpper);
AreaRenderer areaUpper = new DefaultAreaRenderer2D();
areaUpper.setColor(GraphicsUtils.deriveWithAlpha(colorUpper, 64));
plotUpper.setAreaRenderer(data, areaUpper);
plotUpper.setInsets(new Insets2D.Double(20.0, 50.0, 40.0, 20.0));
// Create and format lower plot
XYPlot plotLower = new XYPlot(data);
Color colorLower = COLOR1;
PointRenderer pointsLower = plotLower.getPointRenderer(data);
pointsLower.setColor(colorLower);
pointsLower.setShape(new Ellipse2D.Double(-3, -3, 6, 6));
LineRenderer lineLower = new DefaultLineRenderer2D();
lineLower.setStroke(new BasicStroke(2f));
lineLower.setGap(1.0);
lineLower.setColor(colorLower);
plotLower.setLineRenderer(data, lineLower);
plotLower.setInsets(new Insets2D.Double(20.0, 50.0, 40.0, 20.0));
DrawableContainer plots = new DrawableContainer(new TableLayout(1));
plots.add(plotUpper);
plots.add(plotLower);
// Connect the two plots, i.e. user (mouse) actions affect both plots
plotUpper.getNavigator().connect(plotLower.getNavigator());
InteractivePanel panel = new InteractivePanel(plots);
add(panel);
}
示例14: SimpleXYPlot
import de.erichseifert.gral.plots.points.PointRenderer; //导入方法依赖的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);
}