本文整理汇总了Java中org.jfree.data.statistics.HistogramType类的典型用法代码示例。如果您正苦于以下问题:Java HistogramType类的具体用法?Java HistogramType怎么用?Java HistogramType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HistogramType类属于org.jfree.data.statistics包,在下文中一共展示了HistogramType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getY
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Returns the y-value for a bin
* (calculated to take into account the histogram type).
*
* @param seriesIndex the series index (zero based)
* @param binIndex the bin index (zero based)
* @return the y value
*/
public Number getY( int seriesIndex, int binIndex ) {
PhetHistogramSeries series = getSeries( seriesIndex );
final double totalObservations = series.getNumberOfObservations();
final double binObservations = series.getNumberOfObservations( binIndex );
final double binWidth = series.getBinWidth();
double y = 0;
if ( histogramType == HistogramType.FREQUENCY ) {
y = binObservations;
}
else if ( histogramType == HistogramType.RELATIVE_FREQUENCY ) {
y = binObservations / totalObservations;
}
else if ( histogramType == HistogramType.SCALE_AREA_TO_1 ) {
y = binObservations / ( binWidth * totalObservations );
}
else {
throw new IllegalStateException( "unsupported HistogramType: " + histogramType );
}
return new Double( y );
}
示例2: histogramChart
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Création et affichage d'un histogramme avec JFreeChart
* @param listIn
*/
public static void histogramChart(List<Double> listIn, String listName) {
double tabIn[] = new double[listIn.size()];
for (int i = 0; i < listIn.size(); i++) {
tabIn[i] = listIn.get(i);
}
// Création des datasets
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries(listName, tabIn, 200);
// Création de l'histogramme
JFreeChart chart = ChartFactory.createHistogram("", null, null, dataset,
PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame = new ChartFrame("Spatial Data Quality", chart);
frame.pack();
frame.setVisible(true);
}
示例3: HistogramPlotDataset
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
public HistogramPlotDataset(PeakList peakList, RawDataFile[] rawDataFiles,
int numOfBins, HistogramDataType dataType, Range<Double> range) {
this.list = new Vector<HashMap<?, ?>>();
this.type = HistogramType.FREQUENCY;
this.dataType = dataType;
this.peakList = peakList;
this.numOfBins = numOfBins;
this.rawDataFiles = rawDataFiles;
minimum = range.lowerEndpoint();
maximum = range.upperEndpoint();
updateHistogramDataset();
}
示例4: getY
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Returns the y-value for a bin (calculated to take into account the
* histogram type).
*
* @param series
* the series index (in the range <code>0</code> to
* <code>getSeriesCount() - 1</code>).
* @param item
* the item index (zero based).
*
* @return The y-value.
*
* @throws IndexOutOfBoundsException
* if <code>series</code> is outside the specified range.
*/
public Number getY(int series, int item) {
List<?> bins = getBins(series);
HistogramBin bin = (HistogramBin) bins.get(item);
double total = getTotal(series);
double binWidth = getBinWidth(series);
if (this.type == HistogramType.FREQUENCY) {
return new Double(bin.getCount());
} else if (this.type == HistogramType.RELATIVE_FREQUENCY) {
return new Double(bin.getCount() / total);
} else if (this.type == HistogramType.SCALE_AREA_TO_1) {
return new Double(bin.getCount() / (binWidth * total));
} else { // pretty sure this shouldn't ever happen
throw new IllegalStateException();
}
}
示例5: asChart
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame
* that provides the means to edit the dimensions and also the plot properties via a popup menu. */
public JFreeChart asChart(final boolean show) {
double[] d = new double[this.size()];
int i = 0;
for (Number num : this.values()) d[i++] = num.doubleValue();
HistogramDataset hd = new HistogramDataset();
hd.setType(HistogramType.RELATIVE_FREQUENCY);
String title = "Histogram";
hd.addSeries(title, d, d.length);
JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd,
PlotOrientation.VERTICAL, false, false, false);
setTheme(chart);
if (show) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(new ChartPanel(chart));
frame.pack();
frame.setVisible(true);
}
return chart;
}
示例6: getDataSet
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
private HistogramDataset getDataSet() {
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.FREQUENCY);
List<Double> values =
CollectionUtils.mapNullRemoves(
download.getAllValidConnections(),
new CollectionUtils.Function<BitTorrentConnection, Double>() {
public Double evaluate(BitTorrentConnection connection) {
BitField bitField = connection.getRemoteBitField();
if (bitField == null || !connection.isOpen()) {
return null;
}
return 100.0 * bitField.getAvailablePieceCount() / bitField.getPieceCount();
}
});
dataset.addSeries("Completion", CollectionUtils.toArray(values), 50, 0.0, 100.0);
return dataset;
}
示例7: PhetHistogramDataset
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Create an empty dataset with a specified HistogramType.
*
* @param histogramType the histogram type (null not permitted)
*/
public PhetHistogramDataset( HistogramType histogramType ) {
if ( histogramType == null ) {
throw new IllegalArgumentException( "histogramType is null" );
}
this.histogramType = histogramType;
this.seriesList = new ArrayList();
}
示例8: setHistogramType
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Sets the histogram type.
* Sends a DatasetChangeEvent to all registered listeners.
*
* @param histogramType the histogram type (null not permitted)
*/
public void setHistogramType( HistogramType histogramType ) {
if ( histogramType == null ) {
throw new IllegalArgumentException( "histogramType is null" );
}
if ( histogramType != this.histogramType ) {
this.histogramType = histogramType;
notifyListeners( new DatasetChangeEvent( this, this ) );
}
}
示例9: buildHistogram
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
private static JFreeChart buildHistogram(double[] values, int steps,
String plotTitle, String xAxis, String yAxis) {
HistogramDataset hds = new HistogramDataset();
hds.setType(HistogramType.RELATIVE_FREQUENCY);
hds.addSeries(1, values, steps);
PlotOrientation orientation = PlotOrientation.VERTICAL;
boolean show = false;
boolean toolTips = false;
boolean urls = false;
JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis,
yAxis, hds, orientation, show, toolTips, urls);
return chart;
}
示例10: setType
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
/**
* Sets the histogram type and sends a {@link DatasetChangeEvent} to all
* registered listeners.
*
* @param type
* the type (<code>null</code> not permitted).
*/
public void setType(HistogramType type) {
if (type == null) {
throw new IllegalArgumentException("Null 'type' argument");
}
this.type = type;
notifyListeners(new DatasetChangeEvent(this, this));
}
示例11: getY
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
@Override
public Number getY(int series, int item) {
Number toReturn = super.getY(series, item);
// default implementation uses a 0 to 1 scale; we want 0 to 100
if (getType() == HistogramType.RELATIVE_FREQUENCY) {
return new Double((Double) toReturn * 100);
}
else {
return toReturn;
}
}
示例12: GeneratePlot
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
public void GeneratePlot(String pngfile) throws IOException {
String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt";
FileWriter writer = new FileWriter(modelfile);
double[] IDObs = new double[IDEmpiricalDist.getN()];
double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];
for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
IDObs[i] = IDEmpiricalDist.getObs(i);
}
for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
}
XYSeries model1 = new XYSeries("Incorrect matches");
XYSeries model2 = new XYSeries("Correct matches");
XYSeries model3 = new XYSeries("All target hits");
writer.write("UScore\tModel\tCorrect\tDecoy\n");
for (int i = 0; i < NoBinPoints; i++) {
model1.add(model_kde_x[i], decoy_kde_y[i]);
model2.add(model_kde_x[i], correct_kde_y[i]);
model3.add(model_kde_x[i], model_kde_y[i]);
writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n");
}
writer.close();
MixtureModelProb = new Float[NoBinPoints + 1][3];
float positiveaccu = 0f;
float negativeaccu = 0f;
MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
MixtureModelProb[0][1] = 1f;
MixtureModelProb[0][2] = 1f;
for (int i = 1; i < NoBinPoints + 1; i++) {
double positiveNumber = correct_kde_y[NoBinPoints - i];
double negativeNumber = decoy_kde_y[NoBinPoints - i];
MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
positiveaccu += positiveNumber;
negativeaccu += negativeNumber;
MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(model1);
dataset.addSeries(model2);
dataset.addSeries(model3);
HistogramDataset histogramDataset = new HistogramDataset();
histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
histogramDataset.addSeries("ID hits", IDObs, 100);
histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
//histogramDataset.addSeries("Model hits", ModelObs, 100);
JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = chart.getXYPlot();
NumberAxis domain = (NumberAxis) plot.getDomainAxis();
domain.setRange(min, max);
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setForegroundAlpha(0.8f);
chart.setBackgroundPaint(Color.white);
XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, render);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
try {
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
} catch (IOException e) {
}
}
示例13: displayStochi
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
private void displayStochi(final double[] result) {
final HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries("Unternehmenswert", result, 100);
chart.getXYPlot().setDataset(dataset);
}
示例14: generateDiagram
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
private static void generateDiagram(double[] results2, int bins) {
double[] buffer = new double[results2.length];
for (int i = 0; i < results2.length; i++)
buffer[i] = results2[i];
// The histogram takes an array
HistogramDataset histo = new HistogramDataset();
histo.addSeries("Relative Occurence of Duration", buffer, bins);
histo.setType(HistogramType.RELATIVE_FREQUENCY);
//histo.setType(HistogramType.SCALE_AREA_TO_1);
JFrame aFrame = new JFrame("Time analysis");
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart chart = ChartFactory.createHistogram("Distribution of simulated workflow duration",
"Duration of Workflow execution in ms", "Relative occurence", histo, PlotOrientation.VERTICAL, true, true, false);
// to save as JPG
XYPlot plot = (XYPlot) chart.getPlot();
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesOutlinePaint(0, Color.red);
//plot.getRangeAxis().setRange(0, 0.2);
//plot.getDomainAxis().setRange(0, 30);
plot.getRangeAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getDomainAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getRangeAxis().setLabelFont(new Font("Arial", 1, 28));
plot.getDomainAxis().setLabelFont(new Font("Arial", 1, 28));
//plot.getLegendItems().get(0).set(new Font("Arial", 1, 26));
//plot.getLegendItems().get(1).setLabelFont(new Font("Arial", 1, 24));
LegendTitle legend = chart.getLegend();
Font nwfont = new Font("Arial", 0, 26);
legend.setItemFont(nwfont);
//chart.setLegend(legend);
ChartPanel panel = new ChartPanel(chart);
panel.setPreferredSize(new java.awt.Dimension(900, 600));
aFrame.setContentPane(panel);
aFrame.setPreferredSize(new java.awt.Dimension(900, 600));
aFrame.setSize(new Dimension(900, 600));
aFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
aFrame.setVisible(true);
}
示例15: generateDiagram
import org.jfree.data.statistics.HistogramType; //导入依赖的package包/类
private static void generateDiagram(long[] results2, int bins) {
double[] buffer = new double[results2.length];
for (int i = 0; i < results2.length; i++)
buffer[i] = results2[i];
// The histogram takes an array
HistogramDataset histo = new HistogramDataset();
histo.addSeries("Relative Occurence of Duration", buffer, bins);
//histo.setType(HistogramType.RELATIVE_FREQUENCY);
histo.setType(HistogramType.SCALE_AREA_TO_1);
JFrame aFrame = new JFrame("Time analysis");
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart chart = ChartFactory.createHistogram("Distribution of simulated workflow duration",
"Duration of Workflow execution in ms", "Relative occurence", histo, PlotOrientation.VERTICAL, true, true, false);
// to save as JPG
XYPlot plot = (XYPlot) chart.getPlot();
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesOutlinePaint(0, Color.red);
//plot.getRangeAxis().setRange(0, 0.2);
//plot.getDomainAxis().setRange(0, 30);
plot.getRangeAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getDomainAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getRangeAxis().setLabelFont(new Font("Arial", 1, 28));
plot.getDomainAxis().setLabelFont(new Font("Arial", 1, 28));
//plot.getLegendItems().get(0).set(new Font("Arial", 1, 26));
//plot.getLegendItems().get(1).setLabelFont(new Font("Arial", 1, 24));
LegendTitle legend = chart.getLegend();
Font nwfont = new Font("Arial", 0, 26);
legend.setItemFont(nwfont);
//chart.setLegend(legend);
ChartPanel panel = new ChartPanel(chart);
panel.setPreferredSize(new java.awt.Dimension(800, 600));
aFrame.setContentPane(panel);
aFrame.setPreferredSize(new java.awt.Dimension(800, 600));
aFrame.setSize(new Dimension(800, 600));
aFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
aFrame.setVisible(true);
}