本文整理汇总了Java中de.erichseifert.gral.plots.lines.LineRenderer类的典型用法代码示例。如果您正苦于以下问题:Java LineRenderer类的具体用法?Java LineRenderer怎么用?Java LineRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineRenderer类属于de.erichseifert.gral.plots.lines包,在下文中一共展示了LineRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SineGraph
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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: setLineRenderers
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}
示例3: add
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
@Override
public void add(int index, DataSource source, boolean visible) {
super.add(index, source, visible);
// Set axis mapping
setMapping(source, AXIS_X, AXIS_Y);
// The mapping from columns to axes has changed, so scaling has to be
// refreshed
autoscaleAxes();
// Assign default renderers
PointRenderer pointRendererDefault = new DefaultPointRenderer2D();
LineRenderer lineRendererDefault = null;
AreaRenderer areaRendererDefault = null;
// FIXME: Overwrites possible present point and line renderers
setPointRenderers(source, pointRendererDefault);
setLineRenderers(source, lineRendererDefault);
setAreaRenderers(source, areaRendererDefault);
}
示例4: formatFilledArea
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}
示例5: XYPlot
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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();
pointRenderers = new HashMap<DataSource, PointRenderer>(data.length);
lineRenderers = new HashMap<DataSource, LineRenderer>(data.length);
areaRenderers = new HashMap<DataSource, AreaRenderer>(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);
}
}
示例6: addAzimuthLine
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}
示例7: Graph
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
public Graph(boolean simple) {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1200, 1200);
for (int i = 0; i < Pitch.pitches.getItemCount(); i++) {
pitch[i] = Double.valueOf(Pitch.pitches.getItem(i));
time[i] = Double.valueOf(Pitch.time.getItem(i));
}
for (int w = 0; w < pitch.length; w++) {
dataFull.add(time[w], pitch[w]);
}
for (int i = 0; i < Pitch.pitches.getItemCount() / 8; i++) {
SimpleRegression Regression = new SimpleRegression();
double x = 0;
for (int s = 0; s < 8; s++) {
position++;
try {
Regression.addData(time[position], pitch[position]);
x = x + time[position];
} catch (Exception e) {
/* silence... */}
}
double average = x / 8;
data.add(average, Regression.predict(average));
}
XYPlot plot = new XYPlot(data);
XYPlot plotFull = new XYPlot(dataFull);
LineRenderer lines = new DefaultLineRenderer2D();
if (simple) {
getContentPane().add(new InteractivePanel(plot));
plot.setLineRenderers(data, lines);
} else {
getContentPane().add(new InteractivePanel(plotFull));
plotFull.setLineRenderers(dataFull, lines);
}
}
示例8: Graph
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
public Graph(DataTable funcDataTable) {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setTitle("Graph...");
setSize(1200, 1200);
myFuncDataTable = funcDataTable;
XYPlot plotFull = new XYPlot(myFuncDataTable);
panel = new InteractivePanel(plotFull);
getContentPane().add(panel);
LineRenderer lines = new DefaultLineRenderer2D();
plotFull.setLineRenderers(funcDataTable, lines);
}
示例9: formatFilledArea
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}
示例10: render
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}
}
示例11: getLineRenderers
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
/**
* Returns all {@code LineRenderer}s that display the data of the specified data source.
* @param s Data source in question.
* @return Renderers being applied on the specified data source.
*/
public List<LineRenderer> getLineRenderers(DataSource s) {
List<LineRenderer> lineRenderers = lineRenderersByDataSource.get(s);
if (lineRenderers != null) {
return Collections.unmodifiableList(lineRenderers);
}
return Collections.emptyList();
}
示例12: add
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
@Override
public void add(int index, DataSource source, boolean visible) {
super.add(index, source, visible);
// Assign default renderers
PointRenderer pointRendererDefault = new BarRenderer(this);
LineRenderer lineRendererDefault = null;
AreaRenderer areaRendererDefault = null;
// FIXME: Overwrites possible present point and line renderers
setPointRenderers(source, pointRendererDefault);
setLineRenderers(source, lineRendererDefault);
setAreaRenderers(source, areaRendererDefault);
}
示例13: testGetLineRenderers
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
@Test
public void testGetLineRenderers() {
DataSource data = new DummyData(2, 1, 1.0);
MockXYPlot plot = new MockXYPlot(data);
LineRenderer renderer = new DefaultLineRenderer2D();
plot.setLineRenderers(data, renderer);
assertNotNull(plot.getLineRenderers(new DummyData(4, 2, 0.0)));
assertNotNull(plot.getLineRenderers(null));
List<LineRenderer> renderers = plot.getLineRenderers(data);
assertTrue(renderers.contains(renderer));
assertEquals(renderers.size(), 1);
}
示例14: testSetLineRenderers
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的package包/类
@Test
public void testSetLineRenderers() {
DataSource data = new DummyData(2, 1, 1.0);
MockXYPlot plot = new MockXYPlot();
LineRenderer renderer1 = new DefaultLineRenderer2D();
LineRenderer renderer2 = new DefaultLineRenderer2D();
plot.setLineRenderers(data, Arrays.asList(renderer1, renderer2));
List<LineRenderer> renderers = plot.getLineRenderers(data);
assertTrue(renderers.contains(renderer1));
assertTrue(renderers.contains(renderer2));
assertEquals(renderers.size(), 2);
}
示例15: formatFilledArea
import de.erichseifert.gral.plots.lines.LineRenderer; //导入依赖的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);
}