< prev index next >
modules/graphics/src/main/java/javafx/scene/text/Text.java
Print this page
*** 113,122 ****
--- 113,143 ----
public void doUpdatePeer(Node node) {
((Text) node).doUpdatePeer();
}
@Override
+ public Bounds doComputeLayoutBounds(Node node) {
+ return ((Text) node).doComputeLayoutBounds();
+ }
+
+ @Override
+ public BaseBounds doComputeGeomBounds(Node node,
+ BaseBounds bounds, BaseTransform tx) {
+ return ((Text) node).doComputeGeomBounds(bounds, tx);
+ }
+
+ @Override
+ public boolean doComputeContains(Node node, double localX, double localY) {
+ return ((Text) node).doComputeContains(localX, localY);
+ }
+
+ @Override
+ public void doGeomChanged(Node node) {
+ ((Text) node).doGeomChanged();
+ }
+
+ @Override
public com.sun.javafx.geom.Shape doConfigShape(Shape shape) {
return ((Text) shape).doConfigShape();
}
});
}
*** 205,215 ****
/* Create new text span every time the font or text changes
* so the text layout can see that the content has changed.
*/
textSpan = null;
! /* Relies on impl_geomChanged() to request text flow to relayout */
} else {
TextLayout layout = getTextLayout();
String string = getTextInternal();
Object font = getFontInternal();
layout.setContent(string, font);
--- 226,236 ----
/* Create new text span every time the font or text changes
* so the text layout can see that the content has changed.
*/
textSpan = null;
! /* Relies on NodeHelper.geomChanged(this) to request text flow to relayout */
} else {
TextLayout layout = getTextLayout();
String string = getTextInternal();
Object font = getFontInternal();
layout.setContent(string, font);
*** 217,227 ****
needsTextLayout();
}
private void needsTextLayout() {
textRuns = null;
! impl_geomChanged();
NodeHelper.markDirty(this, DirtyBits.NODE_CONTENTS);
}
private TextSpan textSpan;
TextSpan getTextSpan() {
--- 238,248 ----
needsTextLayout();
}
private void needsTextLayout() {
textRuns = null;
! NodeHelper.geomChanged(this);
NodeHelper.markDirty(this, DirtyBits.NODE_CONTENTS);
}
private TextSpan textSpan;
TextSpan getTextSpan() {
*** 293,311 ****
/* Sometimes a property change in the text node will causes layout in
* text flow. In this case all the dirty bits are already clear and no
* extra work is necessary. Other times the layout is caused by changes
* in the text flow object (wrapping width and text alignment for example).
* In the second case the dirty bits must be set here using
! * impl_geomChanged() and NodeHelper.markDirty(). Note that impl_geomChanged()
* causes another (undesired) layout request in the parent.
* In general this is not a problem because shapes are not resizable and
* region objects do not propagate layout changes to the parent.
* This is a special case where a shape is resized by the parent during
* layoutChildren(). See TextFlow#requestLayout() for information how
* text flow deals with this situation.
*/
! impl_geomChanged();
NodeHelper.markDirty(this, DirtyBits.NODE_CONTENTS);
}
BaseBounds getSpanBounds() {
if (spanBoundsInvalid) {
--- 314,332 ----
/* Sometimes a property change in the text node will causes layout in
* text flow. In this case all the dirty bits are already clear and no
* extra work is necessary. Other times the layout is caused by changes
* in the text flow object (wrapping width and text alignment for example).
* In the second case the dirty bits must be set here using
! * NodeHelper.geomChanged(this) and NodeHelper.markDirty(). Note that NodeHelper.geomChanged(this)
* causes another (undesired) layout request in the parent.
* In general this is not a problem because shapes are not resizable and
* region objects do not propagate layout changes to the parent.
* This is a special case where a shape is resized by the parent during
* layoutChildren(). See TextFlow#requestLayout() for information how
* text flow deals with this situation.
*/
! NodeHelper.geomChanged(this);
NodeHelper.markDirty(this, DirtyBits.NODE_CONTENTS);
}
BaseBounds getSpanBounds() {
if (spanBoundsInvalid) {
*** 454,464 ****
if (x == null) {
x = new DoublePropertyBase() {
@Override public Object getBean() { return Text.this; }
@Override public String getName() { return "x"; }
@Override public void invalidated() {
! impl_geomChanged();
}
};
}
return x;
}
--- 475,485 ----
if (x == null) {
x = new DoublePropertyBase() {
@Override public Object getBean() { return Text.this; }
@Override public String getName() { return "x"; }
@Override public void invalidated() {
! NodeHelper.geomChanged(Text.this);
}
};
}
return x;
}
*** 482,492 ****
if (y == null) {
y = new DoublePropertyBase() {
@Override public Object getBean() { return Text.this; }
@Override public String getName() { return "y"; }
@Override public void invalidated() {
! impl_geomChanged();
}
};
}
return y;
}
--- 503,513 ----
if (y == null) {
y = new DoublePropertyBase() {
@Override public Object getBean() { return Text.this; }
@Override public String getName() { return "y"; }
@Override public void invalidated() {
! NodeHelper.geomChanged(Text.this);
}
};
}
return y;
}
*** 591,601 ****
type |= TextLayout.BOUNDS_CENTER;
}
if (layout.setBoundsType(type)) {
needsTextLayout();
} else {
! impl_geomChanged();
}
}
};
}
return boundsType;
--- 612,622 ----
type |= TextLayout.BOUNDS_CENTER;
}
if (layout.setBoundsType(type)) {
needsTextLayout();
} else {
! NodeHelper.geomChanged(Text.this);
}
}
};
}
return boundsType;
*** 628,638 ****
if (!isSpan()) {
TextLayout layout = getTextLayout();
if (layout.setWrapWidth((float)get())) {
needsTextLayout();
} else {
! impl_geomChanged();
}
}
}
};
}
--- 649,659 ----
if (!isSpan()) {
TextLayout layout = getTextLayout();
if (layout.setWrapWidth((float)get())) {
needsTextLayout();
} else {
! NodeHelper.geomChanged(Text.this);
}
}
}
};
}
*** 774,799 ****
@Override public CssMetaData<Text,FontSmoothingType> getCssMetaData() {
return StyleableProperties.FONT_SMOOTHING_TYPE;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
! impl_geomChanged();
}
};
}
return fontSmoothingType;
}
! /**
! * @treatAsPrivate implementation detail
! * @deprecated This is an internal API that is not intended
! * for use and will be removed in the next version
*/
! @Deprecated
! @Override
! protected final void impl_geomChanged() {
! super.impl_geomChanged();
if (attributes != null) {
if (attributes.caretBinding != null) {
attributes.caretBinding.invalidate();
}
if (attributes.selectionBinding != null) {
--- 795,815 ----
@Override public CssMetaData<Text,FontSmoothingType> getCssMetaData() {
return StyleableProperties.FONT_SMOOTHING_TYPE;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
! NodeHelper.geomChanged(Text.this);
}
};
}
return fontSmoothingType;
}
! /*
! * Note: This method MUST only be called via its accessor method.
*/
! private final void doGeomChanged() {
if (attributes != null) {
if (attributes.caretBinding != null) {
attributes.caretBinding.invalidate();
}
if (attributes.selectionBinding != null) {
*** 1053,1070 ****
default: return 0;
}
}
}
! /**
! * @treatAsPrivate implementation detail
! * @deprecated This is an internal API that is not intended
! * for use and will be removed in the next version
! */
! @Deprecated
! @Override
! protected final Bounds impl_computeLayoutBounds() {
if (isSpan()) {
BaseBounds bounds = getSpanBounds();
double width = bounds.getWidth();
double height = bounds.getHeight();
return new BoundingBox(0, 0, width, height);
--- 1069,1079 ----
default: return 0;
}
}
}
! private final Bounds doComputeLayoutBounds() {
if (isSpan()) {
BaseBounds bounds = getSpanBounds();
double width = bounds.getWidth();
double height = bounds.getHeight();
return new BoundingBox(0, 0, width, height);
*** 1072,1082 ****
if (getBoundsType() == TextBoundsType.VISUAL) {
/* In Node the layout bounds is computed based in the geom
* bounds and in Shape the geom bounds is computed based
* on the shape (generated here in #configShape()) */
! return super.impl_computeLayoutBounds();
}
BaseBounds bounds = getLogicalBounds();
double x = bounds.getMinX() + getX();
double y = bounds.getMinY() + getY() + getYAdjustment(bounds);
double width = bounds.getWidth();
--- 1081,1091 ----
if (getBoundsType() == TextBoundsType.VISUAL) {
/* In Node the layout bounds is computed based in the geom
* bounds and in Shape the geom bounds is computed based
* on the shape (generated here in #configShape()) */
! return TextHelper.superComputeLayoutBounds(this);
}
BaseBounds bounds = getLogicalBounds();
double x = bounds.getMinX() + getX();
double y = bounds.getMinY() + getY() + getYAdjustment(bounds);
double width = bounds.getWidth();
*** 1084,1105 ****
double wrappingWidth = getWrappingWidth();
if (wrappingWidth != 0) width = wrappingWidth;
return new BoundingBox(x, y, width, height);
}
! /**
! * @treatAsPrivate implementation detail
! * @deprecated This is an internal API that is not intended
! * for use and will be removed in the next version
*/
! @Deprecated
! @Override
! public final BaseBounds impl_computeGeomBounds(BaseBounds bounds,
BaseTransform tx) {
if (isSpan()) {
if (ShapeHelper.getMode(this) != NGShape.Mode.FILL && getStrokeType() != StrokeType.INSIDE) {
! return super.impl_computeGeomBounds(bounds, tx);
}
TextLayout layout = getTextLayout();
bounds = layout.getBounds(getTextSpan(), bounds);
BaseBounds spanBounds = getSpanBounds();
float minX = bounds.getMinX() - spanBounds.getMinX();
--- 1093,1110 ----
double wrappingWidth = getWrappingWidth();
if (wrappingWidth != 0) width = wrappingWidth;
return new BoundingBox(x, y, width, height);
}
! /*
! * Note: This method MUST only be called via its accessor method.
*/
! private BaseBounds doComputeGeomBounds(BaseBounds bounds,
BaseTransform tx) {
if (isSpan()) {
if (ShapeHelper.getMode(this) != NGShape.Mode.FILL && getStrokeType() != StrokeType.INSIDE) {
! return TextHelper.superComputeGeomBounds(this, bounds, tx);
}
TextLayout layout = getTextLayout();
bounds = layout.getBounds(getTextSpan(), bounds);
BaseBounds spanBounds = getSpanBounds();
float minX = bounds.getMinX() - spanBounds.getMinX();
*** 1123,1133 ****
bounds.deriveWithNewBounds(x, y, 0, x + visualBounds.getWidth(),
y + visualBounds.getHeight(), 0);
return tx.transform(bounds, bounds);
} else {
/* Let the super class compute the bounds using shape */
! return super.impl_computeGeomBounds(bounds, tx);
}
}
BaseBounds textBounds = getLogicalBounds();
float x = textBounds.getMinX() + (float)getX();
--- 1128,1138 ----
bounds.deriveWithNewBounds(x, y, 0, x + visualBounds.getWidth(),
y + visualBounds.getHeight(), 0);
return tx.transform(bounds, bounds);
} else {
/* Let the super class compute the bounds using shape */
! return TextHelper.superComputeGeomBounds(this, bounds, tx);
}
}
BaseBounds textBounds = getLogicalBounds();
float x = textBounds.getMinX() + (float)getX();
*** 1152,1163 ****
}
textBounds = new RectBounds(x, y, x + width, y + height);
/* handle stroked text */
if (ShapeHelper.getMode(this) != NGShape.Mode.FILL && getStrokeType() != StrokeType.INSIDE) {
! bounds =
! super.impl_computeGeomBounds(bounds,
BaseTransform.IDENTITY_TRANSFORM);
} else {
TextLayout layout = getTextLayout();
bounds = layout.getBounds(null, bounds);
x = bounds.getMinX() + (float)getX();
--- 1157,1167 ----
}
textBounds = new RectBounds(x, y, x + width, y + height);
/* handle stroked text */
if (ShapeHelper.getMode(this) != NGShape.Mode.FILL && getStrokeType() != StrokeType.INSIDE) {
! bounds = TextHelper.superComputeGeomBounds(this, bounds,
BaseTransform.IDENTITY_TRANSFORM);
} else {
TextLayout layout = getTextLayout();
bounds = layout.getBounds(null, bounds);
x = bounds.getMinX() + (float)getX();
*** 1167,1184 ****
bounds = bounds.deriveWithUnion(textBounds);
return tx.transform(bounds, bounds);
}
! /**
! * @treatAsPrivate implementation detail
! * @deprecated This is an internal API that is not intended
! * for use and will be removed in the next version
*/
! @Deprecated
! @Override
! protected final boolean impl_computeContains(double localX, double localY) {
/* Used for spans, regular text uses bounds based picking */
double x = localX + getSpanBounds().getMinX();
double y = localY + getSpanBounds().getMinY();
GlyphList[] runs = getRuns();
if (runs.length != 0) {
--- 1171,1184 ----
bounds = bounds.deriveWithUnion(textBounds);
return tx.transform(bounds, bounds);
}
! /*
! * Note: This method MUST only be called via its accessor method.
*/
! private boolean doComputeContains(double localX, double localY) {
/* Used for spans, regular text uses bounds based picking */
double x = localX + getSpanBounds().getMinX();
double y = localY + getSpanBounds().getMinY();
GlyphList[] runs = getRuns();
if (runs.length != 0) {
*** 1496,1506 ****
@Override public String getName() { return "textOrigin"; }
@Override public CssMetaData getCssMetaData() {
return StyleableProperties.TEXT_ORIGIN;
}
@Override public void invalidated() {
! impl_geomChanged();
}
};
}
return textOrigin;
}
--- 1496,1506 ----
@Override public String getName() { return "textOrigin"; }
@Override public CssMetaData getCssMetaData() {
return StyleableProperties.TEXT_ORIGIN;
}
@Override public void invalidated() {
! NodeHelper.geomChanged(Text.this);
}
};
}
return textOrigin;
}
*** 1520,1530 ****
return StyleableProperties.UNDERLINE;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
if (getBoundsType() == TextBoundsType.VISUAL) {
! impl_geomChanged();
}
}
};
}
return underline;
--- 1520,1530 ----
return StyleableProperties.UNDERLINE;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
if (getBoundsType() == TextBoundsType.VISUAL) {
! NodeHelper.geomChanged(Text.this);
}
}
};
}
return underline;
*** 1545,1555 ****
return StyleableProperties.STRIKETHROUGH;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
if (getBoundsType() == TextBoundsType.VISUAL) {
! impl_geomChanged();
}
}
};
}
return strikethrough;
--- 1545,1555 ----
return StyleableProperties.STRIKETHROUGH;
}
@Override public void invalidated() {
NodeHelper.markDirty(Text.this, DirtyBits.TEXT_ATTRS);
if (getBoundsType() == TextBoundsType.VISUAL) {
! NodeHelper.geomChanged(Text.this);
}
}
};
}
return strikethrough;
< prev index next >