Java 使用Chart2D的直方图

Java 使用Chart2D的直方图,java,swing,jpeg,histogram,jchart2d,jfreechart,Java,Swing,Jpeg,Histogram,Jchart2d,Jfreechart,我想画JPEG的系数直方图。我在谷歌上搜索了几个小时,想知道如何使用这个库,但并没有带示例的教程。我要绘制的数组是hist[]。我创建了一个LBChart2D对象,但我不知道如何将数组设置为数据集 //coeff[] is the coefficients array for(int i=0;i<coeff.length;i++) hist[coeff[i]]++; LBChart2D lbChart2D = new LBChart2D(); 有什么问题吗?发行版中包含了一些。您可以从

我想画JPEG的系数直方图。我在谷歌上搜索了几个小时,想知道如何使用这个库,但并没有带示例的教程。我要绘制的数组是
hist[]
。我创建了一个
LBChart2D
对象,但我不知道如何将数组设置为数据集

//coeff[] is the coefficients array
for(int i=0;i<coeff.length;i++)
hist[coeff[i]]++;

LBChart2D lbChart2D = new LBChart2D();
有什么问题吗?

发行版中包含了一些。您可以从通过
ImageIO
获得的
buffereImage
中收集数据。另见

附录:如果没有完整的示例,您可以使用
validate()
获取调试消息。至少,请验证您是否使用
hist.length
标签调用
setlabelaxislabeltexts()

//Optional validation:  Prints debug messages if invalid only.
if (!chart2D.validate(false)) {
    chart2D.validate(true);
}

谢谢@trashgood帮我。别担心,我知道了。 我使用库绘制直方图,下面是我使用的代码

int hist[]=new int[11];
int val[]=new int[11];
for(int ii=0;ii<11;ii++)
    hist[ii]=ii-5;//to get negative indeces I used an array to save them 
for(int kk=0;kk<coeff.length;kk++)
if(coeff[kk]<=5 &coeff[kk]>=-5) val[coeff[kk]+5]++;
DefaultCategoryDataset dataset = new DefaultCategoryDataset();  
for(int ii=0;ii<hist.length;ii++)
dataset.setValue(val[ii], "Coefficient value",""+hist[ii]);
JFreeChart chart = ChartFactory.createBarChart("Original Histogram",
    "Coefficient value", "", dataset,
    PlotOrientation.VERTICAL, false,true, false);      
//chart.setBackgroundPaint(Color.yellow); 
chart.getTitle().setPaint(Color.blue); 
CategoryPlot p = chart.getCategoryPlot(); 
p.setOutlinePaint(Color.BLUE);
p.setRangeGridlinePaint(Color.blue); 
orgim=chart.createBufferedImage(400,400);
Image im1= orgim.getScaledInstance(jLabel12.getWidth(),jLabel12.getHeight(),1);
jLabel12.setIcon(new ImageIcon(im1));
///
int hist[]=new int[11];
int val[]=新的int[11];

对于(int ii=0;ii是否有任何示例教程可以帮助我?首先,我想。它们在源代码发行版中。
Chart2D/LBChart2DFrameDemo.java
?它显示了十几种条形图变体。另请参见;这不是免费的编码服务。我问了如何将数组设置为数据集?有人知道吗,告诉我提前付款
//Optional validation:  Prints debug messages if invalid only.
if (!chart2D.validate(false)) {
    chart2D.validate(true);
}
int hist[]=new int[11];
int val[]=new int[11];
for(int ii=0;ii<11;ii++)
    hist[ii]=ii-5;//to get negative indeces I used an array to save them 
for(int kk=0;kk<coeff.length;kk++)
if(coeff[kk]<=5 &coeff[kk]>=-5) val[coeff[kk]+5]++;
DefaultCategoryDataset dataset = new DefaultCategoryDataset();  
for(int ii=0;ii<hist.length;ii++)
dataset.setValue(val[ii], "Coefficient value",""+hist[ii]);
JFreeChart chart = ChartFactory.createBarChart("Original Histogram",
    "Coefficient value", "", dataset,
    PlotOrientation.VERTICAL, false,true, false);      
//chart.setBackgroundPaint(Color.yellow); 
chart.getTitle().setPaint(Color.blue); 
CategoryPlot p = chart.getCategoryPlot(); 
p.setOutlinePaint(Color.BLUE);
p.setRangeGridlinePaint(Color.blue); 
orgim=chart.createBufferedImage(400,400);
Image im1= orgim.getScaledInstance(jLabel12.getWidth(),jLabel12.getHeight(),1);
jLabel12.setIcon(new ImageIcon(im1));
///