modules/graphics/src/main/java/javafx/scene/text/TextFlow.java

Print this page

        

*** 232,243 **** @Override protected void setWidth(double value) { if (value != getWidth()) { TextLayout layout = getTextLayout(); Insets insets = getInsets(); ! double left = snapSpace(insets.getLeft()); ! double right = snapSpace(insets.getRight()); double width = Math.max(1, value - left - right); layout.setWrapWidth((float)width); super.setWidth(value); } } --- 232,243 ---- @Override protected void setWidth(double value) { if (value != getWidth()) { TextLayout layout = getTextLayout(); Insets insets = getInsets(); ! double left = snapSpaceX(insets.getLeft()); ! double right = snapSpaceX(insets.getRight()); double width = Math.max(1, value - left - right); layout.setWrapWidth((float)width); super.setWidth(value); } }
*** 245,277 **** @Override protected double computePrefWidth(double height) { TextLayout layout = getTextLayout(); layout.setWrapWidth(0); double width = layout.getBounds().getWidth(); Insets insets = getInsets(); ! double left = snapSpace(insets.getLeft()); ! double right = snapSpace(insets.getRight()); double wrappingWidth = Math.max(1, getWidth() - left - right); layout.setWrapWidth((float)wrappingWidth); return left + width + right; } @Override protected double computePrefHeight(double width) { TextLayout layout = getTextLayout(); Insets insets = getInsets(); ! double left = snapSpace(insets.getLeft()); ! double right = snapSpace(insets.getRight()); if (width == USE_COMPUTED_SIZE) { layout.setWrapWidth(0); } else { double wrappingWidth = Math.max(1, width - left - right); layout.setWrapWidth((float)wrappingWidth); } double height = layout.getBounds().getHeight(); double wrappingWidth = Math.max(1, getWidth() - left - right); layout.setWrapWidth((float)wrappingWidth); ! double top = snapSpace(insets.getTop()); ! double bottom = snapSpace(insets.getBottom()); return top + height + bottom; } @Override protected double computeMinHeight(double width) { return computePrefHeight(width); --- 245,277 ---- @Override protected double computePrefWidth(double height) { TextLayout layout = getTextLayout(); layout.setWrapWidth(0); double width = layout.getBounds().getWidth(); Insets insets = getInsets(); ! double left = snapSpaceX(insets.getLeft()); ! double right = snapSpaceX(insets.getRight()); double wrappingWidth = Math.max(1, getWidth() - left - right); layout.setWrapWidth((float)wrappingWidth); return left + width + right; } @Override protected double computePrefHeight(double width) { TextLayout layout = getTextLayout(); Insets insets = getInsets(); ! double left = snapSpaceX(insets.getLeft()); ! double right = snapSpaceX(insets.getRight()); if (width == USE_COMPUTED_SIZE) { layout.setWrapWidth(0); } else { double wrappingWidth = Math.max(1, width - left - right); layout.setWrapWidth((float)wrappingWidth); } double height = layout.getBounds().getHeight(); double wrappingWidth = Math.max(1, getWidth() - left - right); layout.setWrapWidth((float)wrappingWidth); ! double top = snapSpaceY(insets.getTop()); ! double bottom = snapSpaceY(insets.getBottom()); return top + height + bottom; } @Override protected double computeMinHeight(double width) { return computePrefHeight(width);
*** 311,322 **** } @Override protected void layoutChildren() { inLayout = true; Insets insets = getInsets(); ! double top = snapSpace(insets.getTop()); ! double left = snapSpace(insets.getLeft()); GlyphList[] runs = getTextLayout().getRuns(); for (int j = 0; j < runs.length; j++) { GlyphList run = runs[j]; TextSpan span = run.getTextSpan(); --- 311,322 ---- } @Override protected void layoutChildren() { inLayout = true; Insets insets = getInsets(); ! double top = snapSpaceY(insets.getTop()); ! double left = snapSpaceX(insets.getLeft()); GlyphList[] runs = getTextLayout().getRuns(); for (int j = 0; j < runs.length; j++) { GlyphList run = runs[j]; TextSpan span = run.getTextSpan();
*** 481,491 **** return lineSpacing; } @Override public final double getBaselineOffset() { Insets insets = getInsets(); ! double top = snapSpace(insets.getTop()); return top - getTextLayout().getBounds().getMinY(); } /*************************************************************************** * * --- 481,491 ---- return lineSpacing; } @Override public final double getBaselineOffset() { Insets insets = getInsets(); ! double top = snapSpaceY(insets.getTop()); return top - getTextLayout().getBounds().getMinY(); } /*************************************************************************** * *
*** 572,586 **** double bottom = margin != null? snapSpace(margin.getBottom(), snap) : 0; double left = margin != null? snapSpace(margin.getLeft(), snap) : 0; double right = margin != null? snapSpace(margin.getRight(), snap) : 0; double alt = -1; if (child.getContentBias() == Orientation.VERTICAL) { // width depends on height ! alt = snapSize(boundedSize( child.minHeight(-1), height != -1? height - top - bottom : child.prefHeight(-1), child.maxHeight(-1))); } ! return left + snapSize(boundedSize(child.minWidth(alt), child.prefWidth(alt), child.maxWidth(alt))) + right; } double computeChildPrefAreaHeight(Node child, Insets margin) { return computeChildPrefAreaHeight(child, margin, -1); } --- 572,586 ---- double bottom = margin != null? snapSpace(margin.getBottom(), snap) : 0; double left = margin != null? snapSpace(margin.getLeft(), snap) : 0; double right = margin != null? snapSpace(margin.getRight(), snap) : 0; double alt = -1; if (child.getContentBias() == Orientation.VERTICAL) { // width depends on height ! alt = snapSizeY(boundedSize( child.minHeight(-1), height != -1? height - top - bottom : child.prefHeight(-1), child.maxHeight(-1))); } ! return left + snapSizeX(boundedSize(child.minWidth(alt), child.prefWidth(alt), child.maxWidth(alt))) + right; } double computeChildPrefAreaHeight(Node child, Insets margin) { return computeChildPrefAreaHeight(child, margin, -1); }
*** 591,605 **** double bottom = margin != null? snapSpace(margin.getBottom(), snap) : 0; double left = margin != null? snapSpace(margin.getLeft(), snap) : 0; double right = margin != null? snapSpace(margin.getRight(), snap) : 0; double alt = -1; if (child.getContentBias() == Orientation.HORIZONTAL) { // height depends on width ! alt = snapSize(boundedSize( child.minWidth(-1), width != -1? width - left - right : child.prefWidth(-1), child.maxWidth(-1))); } ! return top + snapSize(boundedSize(child.minHeight(alt), child.prefHeight(alt), child.maxHeight(alt))) + bottom; } /* end of copied code */ @Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) { --- 591,605 ---- double bottom = margin != null? snapSpace(margin.getBottom(), snap) : 0; double left = margin != null? snapSpace(margin.getLeft(), snap) : 0; double right = margin != null? snapSpace(margin.getRight(), snap) : 0; double alt = -1; if (child.getContentBias() == Orientation.HORIZONTAL) { // height depends on width ! alt = snapSizeX(boundedSize( child.minWidth(-1), width != -1? width - left - right : child.prefWidth(-1), child.maxWidth(-1))); } ! return top + snapSizeY(boundedSize(child.minHeight(alt), child.prefHeight(alt), child.maxHeight(alt))) + bottom; } /* end of copied code */ @Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {