I am trying to draw a histogram of the Color values of the pixel of an image. I have done the job of getting the values but I want to draw the Histogram from that values. I am trying to draw it on the panel using paintComponent() method.
if(ae.getActionCommand()=="Hist")
{
jf1.add(new Histo());
jf1.pack();
jf1.setVisible(true);
}
and
class Histo extends JPanel
{
Zoom z = new Zoom();
int x=800;
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.red);
g2d.drawLine(100, 100, 100,z.RedC[1]);
for(int c=1;c<z.count;c++)
{
g2d.drawLine(x, z.RedC[c], 500, z.RedC[c]);
x++;
}
}
}
Zoom is the name of My class and with 'z' i can access the variables but their value is Zero. I cannot get the values that I have read from the pixel. So how can I access it in JPanel. Please help me in it.