JDK-8139841 : Axis class does not render ticks marks when tick labels are invisible
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u60
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-10-09
  • Updated: 2020-01-31
  • Resolved: 2015-11-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u152Fixed 9Fixed
Related Reports
Blocks :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

A DESCRIPTION OF THE PROBLEM :
Use a Jfx Axis that the side is set to LEFT, RIGHT or TOP and call setTickLabelsVisible(false). When the Axis is displayed, the major tick marks are not rendered.

Axis class does not render ticks marks when tick labels are invisible. Empty space in position where tick mark is supposed to display. Minor tick marks do display as expected.

The problem looks to be in Axis.layoutChildren(). When ticklabels are not visible then the TickMark instances placed into the tickMarks list do not get updated with the position of the tickMarks. The position will remain 0 for each tickMark in the list.  This is in lines 711 to 777.

Then later (lines 780 to 911) when the tickMarks are to be rendered, the position is 0. So, each tickMark gets rendered at 0 position instead of the correct location.

Interestingly though, for side == Bottom the position is not used from the tickMark instances. Instead, each tickMark position is recalculated by calling getDisplayPosition(tick.getValue()). This special case for position == Bottom explains why the tickMarks will render for Bottom Axes.

REGRESSION.  Last worked in version 7u79

ADDITIONAL REGRESSION INFORMATION: 
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See sample code

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Tick marks should be visible.
ACTUAL -
Blank space in location of expected tick.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;


public class LineChartSample extends Application {

   @Override public void start(Stage stage) {
      stage.setTitle("Line Chart Sample");
      //defining the axes
      final NumberAxis xAxis = new NumberAxis();
      final NumberAxis yAxis = new NumberAxis();
      xAxis.setLabel("Number of Month");
      xAxis.setTickLabelsVisible(false);
      xAxis.setSide(Side.TOP);

      yAxis.setTickLabelsVisible(false);

      //creating the chart
      final LineChart<Number,Number> lineChart =
            new LineChart<Number,Number>(xAxis,yAxis);

      lineChart.setTitle("Stock Monitoring, 2010");
      //defining a series
      XYChart.Series series = new XYChart.Series();
      series.setName("My portfolio");
      //populating the series with data
      series.getData().add(new XYChart.Data(1, 23));
      series.getData().add(new XYChart.Data(2, 14));
      series.getData().add(new XYChart.Data(3, 15));
      series.getData().add(new XYChart.Data(4, 24));
      series.getData().add(new XYChart.Data(5, 34));
      series.getData().add(new XYChart.Data(6, 36));
      series.getData().add(new XYChart.Data(7, 22));
      series.getData().add(new XYChart.Data(8, 45));
      series.getData().add(new XYChart.Data(9, 43));
      series.getData().add(new XYChart.Data(10, 17));
      series.getData().add(new XYChart.Data(11, 29));
      series.getData().add(new XYChart.Data(12, 25));

      Scene scene  = new Scene(lineChart,800,600);
      lineChart.getData().add(series);

      stage.setScene(scene);
      stage.show();
   }

   public static void main(String[] args) {
      launch(args);
   }
}
---------- END SOURCE ----------


Comments
Approved to backport to 8u-dev for 8u122.
19-10-2016

I'd like to backport this to 8u, it's needed for clean backporting of JDK-8166847. Backport applies cleanly.
19-10-2016

Changeset: e856a8ca9757 Author: vadim Date: 2015-11-26 13:11 +0300 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/e856a8ca9757
26-11-2015

+1
25-11-2015

Jonathan, Could you please review the fix: http://cr.openjdk.java.net/~vadim/8139841/webrev.00/ The root cause of the bug is that updateAndGetDisplayPosition was not called for tick if tick label is not visible. This method calls tick.setPosition which is later used when positioning tick marks. I did a little cleanup and refactoring when I've found that the logic for Side.BOTTOM was slightly different from others and the bug was not visible for this side.
25-11-2015