there was an issue with some code I had written which I assumed was just an error in my logic. However I have distilled the issue down to the following and can't understand what is going on:
With this class
public class Why extends Application
{
@Override
public void start(Stage arg0) throws Exception
{
System.out.println(textHeight("X", 5, TextBoundsType.LOGICAL)); // A
System.out.println(textHeight("X", 5, TextBoundsType.LOGICAL_VERTICAL_CENTER)); // B
System.exit(0);
}
public double textHeight(String text, double size, TextBoundsType tbt)
{
Text t = new Text(text);
t.setBoundsType(tbt);
t.setFont(Font.font("arial", size));
return t.getLayoutBounds().getHeight();
}
public static void main(String[] args)
{
launch(args);
}
}
If you run this program and observe the output of each function call, then swap the lines commented A and B and run, the output of the call with "LOGICAL" bounds changes. This is very strange since I cannot see how the function "textHeight" is not pure. Further, if you change the size or text parameters in the calls so that they not the same on both lines this behaviour goes away. I am running this program with jre1.8.0_121, could it be a potential bug or am I missing something?