当前位置: 首页>>代码示例>>Java>>正文


Java BarPlot类代码示例

本文整理汇总了Java中de.erichseifert.gral.plots.BarPlot的典型用法代码示例。如果您正苦于以下问题:Java BarPlot类的具体用法?Java BarPlot怎么用?Java BarPlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BarPlot类属于de.erichseifert.gral.plots包,在下文中一共展示了BarPlot类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initPanel

import de.erichseifert.gral.plots.BarPlot; //导入依赖的package包/类
/**
 * Initializes the real time 
 */
private void initPanel() {
    plot.setInsets(new Insets2D.Double(20.0, 60.0, 10.0, 40.0));
    plot.setSetting(BarPlot.TITLE, title);
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(AxisRenderer.LABEL,
                                                   xTitle);
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(
            AxisRenderer.TICK_LABELS_ROTATION, 45.0);
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.LABEL,
                                                   yTitle);
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(AxisRenderer.INTERSECTION,
                                                   -Double.MAX_VALUE);
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.INTERSECTION,
                                                   -Double.MAX_VALUE);
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(
            AxisRenderer.TICKS_SPACING, yGap);
    plot.getAxis(XYPlot.AXIS_Y).setRange(0, yMax);
    plot.setLineRenderer(data, lines);

    this.add(panel, BorderLayout.CENTER);
}
 
开发者ID:anthonyjchriste,项目名称:knowledge-is-power,代码行数:24,代码来源:RealTimePlot.java

示例2: render

import de.erichseifert.gral.plots.BarPlot; //导入依赖的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");
    }
}
 
开发者ID:Amine-H,项目名称:PDFLego,代码行数:37,代码来源:BarPlotRenderStrategy.java

示例3: updatePlot

import de.erichseifert.gral.plots.BarPlot; //导入依赖的package包/类
/**
 * Update real time plot.
 * 
 * Title is changed to match current data. The x-axis and range are also
 * dynamically updated.
 * @param x the x location on the plot
 * @param y the y location on the plot
 */
public void updatePlot(long x, double y) {
    double min;
    
    if(y > yMax) {
        yMax = (int) y;
    }
    
    plot.setSetting(BarPlot.TITLE, title + ": " + y);
    data.add(x, y);

    if (data.getRowCount() > bufSize) {
        data.remove(0);
    }

    min = data.getColumn(0).getStatistics(Statistics.MIN);

    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(
            AxisRenderer.TICKS_SPACING,
            (x - min) / bufSize);
    plot.getAxis(XYPlot.AXIS_X).setRange(min, x);
    plot.getAxis(XYPlot.AXIS_Y).setRange(0, yMax + (yMax * .20));

    if (this.isVisible()) {
        this.repaint();
    }
}
 
开发者ID:anthonyjchriste,项目名称:knowledge-is-power,代码行数:35,代码来源:RealTimePlot.java

示例4: init

import de.erichseifert.gral.plots.BarPlot; //导入依赖的package包/类
private void init() {
    redLines.setSetting(LineRenderer.COLOR, java.awt.Color.RED);
    plot.setLineRenderer(dataTable, normalLines);
    plot.setLineRenderer(constantDataTable, redLines);

    plot.getAxis(XYPlot.AXIS_Y).setRange(0, 1024);
    plot.setInsets(new Insets2D.Double(10.0, 50.0, 10.0, 20.0));

    plot.setSetting(BarPlot.TITLE, title + ": ");

    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(AxisRenderer.LABEL,
                                                   "Time");
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(AxisRenderer.INTERSECTION,
                                                   -Double.MAX_VALUE);
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(
            AxisRenderer.TICK_LABELS_ROTATION, 90.0);
    plot.getAxisRenderer(XYPlot.AXIS_X).setSetting(
            AxisRenderer.TICKS_SPACING, 2);

    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.LABEL, "DAC");
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.INTERSECTION,
                                                   -Double.MAX_VALUE);
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.TICKS_MINOR,
                                                   false);
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(
            AxisRenderer.TICKS_SPACING, 200);

    this.add(panel, BorderLayout.CENTER);
    this.repaint();
}
 
开发者ID:anthonyjchriste,项目名称:knowledge-is-power,代码行数:31,代码来源:PacketExplorerPlot.java

示例5: update

import de.erichseifert.gral.plots.BarPlot; //导入依赖的package包/类
/**
 * Update plot with new samples.
 * 
 * Dynamically sets x-range updates title based off of data
 * @param samples
 * @param constant 
 */
public void update(int[] samples, int constant) {
    int pk = 0;

    dataTable.clear();
    constantDataTable.clear();

    plot.getAxis(XYPlot.AXIS_X).setRange(0, samples.length - 1);
    
    for (int i = 0; i < samples.length; i++) {
        dataTable.add((long) i, samples[i]);
        if (constant >= 0) {
            constantDataTable.add((long) i, constant);
        }
        if (samples[i] > pk) {
            pk = samples[i];
        }
    }
    
    plot.getAxis(XYPlot.AXIS_Y).setRange(0, pk + (pk * .10));
    plot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.TICKS_SPACING, pk/5);
    
    plot.setSetting(BarPlot.TITLE, title + ": " + pk);

    if (this.isVisible()) {
        this.repaint();
    }
}
 
开发者ID:anthonyjchriste,项目名称:knowledge-is-power,代码行数:35,代码来源:PacketExplorerPlot.java

示例6: 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));
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:45,代码来源:SimpleBarPlot.java

示例7: 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);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:46,代码来源:HistogramPlot.java

示例8: 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));
}
 
开发者ID:eseifert,项目名称:gral,代码行数:45,代码来源:SimpleBarPlot.java

示例9: 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);
}
 
开发者ID:eseifert,项目名称:gral,代码行数:47,代码来源:HistogramPlot.java

示例10: 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));
}
 
开发者ID:arahusky,项目名称:performance_javadoc,代码行数:45,代码来源:SimpleBarPlot.java

示例11: 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);
}
 
开发者ID:arahusky,项目名称:performance_javadoc,代码行数:47,代码来源:HistogramPlot.java

示例12: plot

import de.erichseifert.gral.plots.BarPlot; //导入依赖的package包/类
/**
 * Plots the time series data provided and displays the plot
 * 
 * @param data The time series data to plot on the Y axis
 * @param label The label for the dataset
 */
@SuppressWarnings("unchecked")
public void plot(ArrayList<Double> data, String label)
{
	/* Add the data provided to the data table series */
	DataTable dataTable = new DataTable(Integer.class, Double.class);
	
	for (Integer i = 0; i < data.size(); ++i)
	{
		dataTable.add(i, data.get(i));
	}
	
	DataSeries series = new DataSeries(label, dataTable);
	
	
	/* Create a time series plot */
	XYPlot seriesPlot = new XYPlot(series);
	
	/* Configure the line for the plot */
	LineRenderer line = new DefaultLineRenderer2D();
	
	/* Configure the line colour, thickness, spacing between points */
	line.setSetting(LineRenderer.COLOR, BLUE);
	line.setSetting(LineRenderer.STROKE, new BasicStroke(1f));
	line.setSetting(LineRenderer.GAP, 0.0);
	line.setSetting(LineRenderer.GAP_ROUNDED, true);
	
	seriesPlot.setLineRenderer(series, line);
	
	
	/* Configure the points for the plot */
	PointRenderer points = seriesPlot.getPointRenderer(series);
	points.setSetting(PointRenderer.COLOR, BLUE);
	points.setSetting(PointRenderer.SHAPE, null);
	
	/* Specify the spacing for the plot */
	seriesPlot.setInsets(new Insets2D.Double(20.0, 60.0, 120.0, 20.0));
	
	/* Set the title, legend, and label the axes */
	seriesPlot.setSetting(BarPlot.TITLE, title);
	seriesPlot.setSetting(Plot.LEGEND, true);
	seriesPlot.setSetting(Plot.LEGEND_LOCATION, Location.SOUTH);
	seriesPlot.setSetting(Plot.LEGEND_DISTANCE, 3.5);
	seriesPlot.getAxisRenderer(XYPlot.AXIS_X).setSetting(AxisRenderer.LABEL, XAxisLabel);
	seriesPlot.getAxisRenderer(XYPlot.AXIS_Y).setSetting(AxisRenderer.LABEL, YAxisLabel);
	
	
	/* Display the plot */
	InteractivePanel panel = new InteractivePanel(seriesPlot);
	add(panel);
	displayPlot();
}
 
开发者ID:gnu-user,项目名称:ai-project,代码行数:58,代码来源:SeriesPlot.java


注:本文中的de.erichseifert.gral.plots.BarPlot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。