0

I am displaying labels on the cube that represents coordinates for future drawing. Labels are numeric and they display values of some variables. Labels attached to the axis that get rotated displays numbers with some digits being upside down.

Here is the chart

Labels on the rotated axis

Here is the fragment of the code

    // back face
    r = new Axis(size);
    r.setFill(Color.TRANSPARENT);

    r.setTranslateX(-0.5 * size);
    r.setTranslateY(-0.5 * size);
    r.setTranslateZ(0.5 * size);

    cubeFaces.add(r);

    // bottom face
    r = new Axis(size);
    r.setFill(Color.TRANSPARENT);
    r.setTranslateX(-0.5 * size);
    r.setTranslateY(0);

    r.setRotationAxis(Rotate.X_AXIS);
    r.setRotate(90);

    // Set LABELS for Z coordinate
    for( int y=0; y <= size; y+=size/10)
    {

        int ry = size-y;
        text = new Text("        " + (size - y));
        text.setFont(new Font(20));

        text.setTranslateX(-90);
        text.setTranslateY(y);
        text.setTranslateZ(0);

        r.getChildren().addAll(text);

    } 

Help is appreciated.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
i262666
  • 23
  • 5
  • Check this [question](https://stackoverflow.com/questions/52017893/how-to-get-2d-coordinates-on-window-for-3d-object-in-javafx), it uses a different approach, mixing 3D (subScene) and a 2D overlay for labels, that you won't need to rotate anymore. – José Pereda Dec 04 '18 at 23:42
  • Jose, Thank you very much for your quick response. I will try to implement your suggestion. In general, it would be very helpful for developers to understand why it does not work. Is it the JavaFX limitation that text labels don't properly work when being attached to a rotated axis? – i262666 Dec 05 '18 at 18:54
  • Actually, there is a simpler way to make the axis label work. I learned it from adihubba's code. Instead of getting the label's data and adding it to an axis,accumulate these values in an array list and then add the array list to a cube. – i262666 Dec 07 '18 at 00:50

0 Answers0