JComponentを拡張するDrawOutputクラスがあります。ペイントに渡す this.getGraphics はここでは null です。このクラスのグラフィックスを取得するにはどうすればよいですか?
public class DrawOutput extends JComponent {
これがクラスのコンストラクタです。
DrawOutput (MinDistances requiredMinDistances, MainMatrix matrix){
super();
getRequiredMedoidsArray(requiredMinDistances);
paint(this.getGraphics(), requiredMinDistances, matrix);
}
コンテンツはここではnullです
public void paint(Graphics content, MinDistances requiredMinDistances, MainMatrix matrix) {
...
}
private float[] setColor (int colorID){
float[]hsbValues=new float[3];
if(colorID == 1){
hsbValues = Color.RGBtoHSB(0,255,255,hsbValues);
}
else if(colorID == 2){
hsbValues = Color.RGBtoHSB(255,0,255,hsbValues);
}
else if(colorID == 3){
hsbValues = Color.RGBtoHSB(0,255,0,hsbValues);
}
else if(colorID == 4){
hsbValues = Color.RGBtoHSB(255,255,0,hsbValues);
}
else if(colorID == 5){
hsbValues = Color.RGBtoHSB(255,0,0,hsbValues);
}
else if(colorID == 6){
hsbValues = Color.RGBtoHSB(255,255,255,hsbValues);
}
else{
hsbValues = Color.RGBtoHSB(0, 0, 0,hsbValues);
}
return hsbValues;
}
private void getRequiredMedoidsArray(MinDistances distancesCell){
...
}
}
助言がありますか?