Ho dimenticato la parte più importante

private Color calcolaColoreContrastatoOttimale(Color color) {

// TODO da fare non funziona bene

float af[] = Color.RGBtoHSB( color.getRed(), color.getGreen(),
color.getBlue(), null );
String args1[] = {
"H=", "S=", "I="
};

DecimalFormat decimalformat = new DecimalFormat("0.000");
for(int j = 0; j < 3; j++)
System.out.println(args1[j] + decimalformat.format(af[j]));

return new Color( Color.HSBtoRGB( af[0]+180, 255, (255 - af[2]) ) );

}