This is my DialPlot
class:
public class Demo {
private DefaultValueDataset dataset = new DefaultValueDataset(0);
private ChartPanel buildDialPlot(int minimumValue=0,int maximumValue,int majorTickGap) {
DialPlot plot = new DialPlot(dataset);
plot.setDialFrame(new StandardDialFrame());
plot.addLayer(new DialValueIndicator(0));
plot.addLayer(new DialPointer.Pointer());
int redLine =maximumValue / 5 + 10;
plot.addLayer(new StandardDialRange(maximumValue, redLine, Color.blue));
plot.addLayer(new StandardDialRange(redLine, minimumValue, Color.red));
StandardDialScale scale = new StandardDialScale(minimumValue,
maximumValue, -120, -300, majorTickGap, majorTickGap - 1);
scale.setTickRadius(0.88);
scale.setTickLabelOffset(0.20);
scale.setTickLabelsVisible(false);
plot.addScale(0, scale);
return new ChartPanel(new JFreeChart(plot)) {
@Override
public Dimension getPreferredSize() {
return new Dimension(300, 300);
}
};
}
}
This is my JFrame
GUI class
public class NewJFrame extends javax.swing.JFrame {
Demo d=new Demo();
int minimumValue=0;
int maximumValue=100;
int majorTickGap=1;
public NewJFrame() {
initComponents();
d.buildDialPlot(minimumValue,maximumValue,majorTickGap);
this.pack();
this.setLocationRelativeTo(null);
}
I also added it in JFrame
GUI class like this:
this.add(d.buildDialPlot(minimumValue,maximumValue,majorTickGap));
It shows the same result empty JFrame
.
Anyone knows what's my mistake?