Skip to content

Commit 3877909

Browse files
authored
Fixed paragraph graphic not managed (#1079)
1 parent 8622410 commit 3877909

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

richtextfx/src/main/java/org/fxmisc/richtext/ParagraphBox.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,15 @@ protected void layoutChildren() {
255255

256256
text.resizeRelocate(graphicWidth + ins.getLeft(), ins.getTop() + half, w - graphicWidth, h - half);
257257

258-
graphic.ifPresent(g -> g.resizeRelocate(graphicOffset.get() + ins.getLeft(), ins.getTop(), graphicWidth, h));
258+
graphic.filter( Node::isManaged ).ifPresent(
259+
g -> g.resizeRelocate(graphicOffset.get() + ins.getLeft(), ins.getTop(), graphicWidth, h)
260+
);
259261
}
260262

261263
double getGraphicPrefWidth() {
262-
if(graphic.isPresent()) {
263-
return graphic.getValue().prefWidth(-1);
264-
} else {
265-
return 0.0;
266-
}
264+
return graphic.filter( Node::isManaged )
265+
.map( n -> n.prefWidth(-1) )
266+
.getOrElse( 0.0 );
267267
}
268268

269269
/**

0 commit comments

Comments
 (0)