< prev index next >

modules/javafx.controls/src/main/java/javafx/scene/chart/ValueAxis.java

Print this page

        

*** 354,380 **** // update current lower bound currentLowerBound.set(getLowerBound()); } // we have done all auto calcs, let Axis position major tickmarks super.layoutChildren(); // Update minor tickmarks minorTickPath.getElements().clear(); double minorTickLength = Math.max(0, getMinorTickLength()); ! // The length must be greater then the space required for tick marks, otherwise, there's no reason to create ! // minor tick marks ! if (minorTickLength > 0 && length > 2 * getTickMarks().size()) { ! // Strip factor is >= 1. When == 1, all minor ticks will fit. ! // It's computed as number of minor tick marks divided by available length ! int stripFactor = (int)Math.ceil(2 * minorTickMarkValues.size() / (length - 2 * getTickMarks().size())); if (Side.LEFT.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(-0.5); minorTickPath.setLayoutY(0.5); ! for (int i = 0; i < minorTickMarkValues.size(); i += stripFactor) { ! T value = minorTickMarkValues.get(i); double y = getDisplayPosition(value); if (y >= 0 && y <= length) { minorTickPath.getElements().addAll( new MoveTo(getWidth() - minorTickLength, y), new LineTo(getWidth() - 1, y)); --- 354,377 ---- // update current lower bound currentLowerBound.set(getLowerBound()); } // we have done all auto calcs, let Axis position major tickmarks super.layoutChildren(); + int numMinorTicks = (getTickMarks().size() - 1)*(Math.max(1, getMinorTickCount()) - 1); + double neededLength = (getTickMarks().size()+numMinorTicks)*2; // Update minor tickmarks minorTickPath.getElements().clear(); + // Don't draw minor tick marks if there isn't enough space for them! double minorTickLength = Math.max(0, getMinorTickLength()); ! if (minorTickLength > 0 && length > neededLength) { if (Side.LEFT.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(-0.5); minorTickPath.setLayoutY(0.5); ! for (T value : minorTickMarkValues) { double y = getDisplayPosition(value); if (y >= 0 && y <= length) { minorTickPath.getElements().addAll( new MoveTo(getWidth() - minorTickLength, y), new LineTo(getWidth() - 1, y));
*** 382,393 **** } } else if (Side.RIGHT.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(0.5); ! for (int i = 0; i < minorTickMarkValues.size(); i += stripFactor) { ! T value = minorTickMarkValues.get(i); double y = getDisplayPosition(value); if (y >= 0 && y <= length) { minorTickPath.getElements().addAll( new MoveTo(1, y), new LineTo(minorTickLength, y)); --- 379,389 ---- } } else if (Side.RIGHT.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(0.5); ! for (T value : minorTickMarkValues) { double y = getDisplayPosition(value); if (y >= 0 && y <= length) { minorTickPath.getElements().addAll( new MoveTo(1, y), new LineTo(minorTickLength, y));
*** 395,406 **** } } else if (Side.TOP.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(-0.5); ! for (int i = 0; i < minorTickMarkValues.size(); i += stripFactor) { ! T value = minorTickMarkValues.get(i); double x = getDisplayPosition(value); if (x >= 0 && x <= length) { minorTickPath.getElements().addAll( new MoveTo(x, getHeight() - 1), new LineTo(x, getHeight() - minorTickLength)); --- 391,401 ---- } } else if (Side.TOP.equals(side)) { // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(-0.5); ! for (T value : minorTickMarkValues) { double x = getDisplayPosition(value); if (x >= 0 && x <= length) { minorTickPath.getElements().addAll( new MoveTo(x, getHeight() - 1), new LineTo(x, getHeight() - minorTickLength));
*** 408,419 **** } } else { // BOTTOM // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(0.5); ! for (int i = 0; i < minorTickMarkValues.size(); i += stripFactor) { ! T value = minorTickMarkValues.get(i); double x = getDisplayPosition(value); if (x >= 0 && x <= length) { minorTickPath.getElements().addAll( new MoveTo(x, 1.0F), new LineTo(x, minorTickLength)); --- 403,413 ---- } } else { // BOTTOM // snap minorTickPath to pixels minorTickPath.setLayoutX(0.5); minorTickPath.setLayoutY(0.5); ! for (T value : minorTickMarkValues) { double x = getDisplayPosition(value); if (x >= 0 && x <= length) { minorTickPath.getElements().addAll( new MoveTo(x, 1.0F), new LineTo(x, minorTickLength));
< prev index next >