|
13 | 13 | import java.util.function.Consumer; |
14 | 14 | import java.util.function.Function; |
15 | 15 | import java.util.function.Supplier; |
| 16 | +import java.util.function.UnaryOperator; |
16 | 17 |
|
17 | 18 | import javafx.beans.property.ObjectProperty; |
18 | 19 | import javafx.beans.property.SimpleObjectProperty; |
|
27 | 28 | import javafx.geometry.Insets; |
28 | 29 | import javafx.scene.Node; |
29 | 30 | import javafx.scene.control.IndexRange; |
30 | | -import javafx.scene.layout.Background; |
31 | 31 | import javafx.scene.paint.Color; |
32 | 32 | import javafx.scene.paint.Paint; |
33 | 33 | import javafx.scene.shape.LineTo; |
@@ -158,27 +158,15 @@ public ObjectProperty<Paint> highlightTextFillProperty() { |
158 | 158 | }); |
159 | 159 |
|
160 | 160 | // set up custom css shape helpers |
161 | | - Supplier<Path> createBackgroundShape = () -> { |
162 | | - Path shape = new BackgroundPath(); |
163 | | - shape.setManaged(false); |
164 | | - shape.layoutXProperty().bind(leftInset); |
165 | | - shape.layoutYProperty().bind(topInset); |
166 | | - return shape; |
167 | | - }; |
168 | | - Supplier<Path> createBorderShape = () -> { |
169 | | - Path shape = new BorderPath(); |
170 | | - shape.setManaged(false); |
171 | | - shape.layoutXProperty().bind(leftInset); |
172 | | - shape.layoutYProperty().bind(topInset); |
173 | | - return shape; |
174 | | - }; |
175 | | - Supplier<Path> createUnderlineShape = () -> { |
176 | | - Path shape = new UnderlinePath(); |
| 161 | + UnaryOperator<Path> configurePath = shape -> { |
177 | 162 | shape.setManaged(false); |
178 | 163 | shape.layoutXProperty().bind(leftInset); |
179 | 164 | shape.layoutYProperty().bind(topInset); |
180 | 165 | return shape; |
181 | 166 | }; |
| 167 | + Supplier<Path> createBackgroundShape = () -> configurePath.apply(new BackgroundPath()); |
| 168 | + Supplier<Path> createBorderShape = () -> configurePath.apply(new BorderPath()); |
| 169 | + Supplier<Path> createUnderlineShape = () -> configurePath.apply(new UnderlinePath()); |
182 | 170 |
|
183 | 171 | Consumer<Collection<Path>> clearUnusedShapes = paths -> getChildren().removeAll(paths); |
184 | 172 | Consumer<Path> addToBackground = path -> getChildren().add(0, path); |
@@ -482,8 +470,8 @@ private void updateSharedShapeRange(T value, int start, int end, BiFunction<T, T |
482 | 470 | T lastShapeValue = lastShapeValueRange._1; |
483 | 471 |
|
484 | 472 | // calculate smallest possible position which is consecutive to the given start position |
485 | | - final int prevEndNext = lastShapeValueRange.get2().getEnd() + 1; |
486 | | - if (start <= prevEndNext && // Consecutive? |
| 473 | + final int prevEndNext = lastShapeValueRange.get2().getEnd(); |
| 474 | + if (start == prevEndNext && // Consecutive? |
487 | 475 | equals.apply(lastShapeValue, value)) { // Same style? |
488 | 476 |
|
489 | 477 | IndexRange lastRange = lastShapeValueRange._2; |
|
0 commit comments