Optimize background color and underline shapes#558
Merged
JordanMartinez merged 2 commits intoFXMisc:masterfrom Aug 2, 2017
JordanMartinez:optimizeBackgroundColorShapes
Merged
Optimize background color and underline shapes#558JordanMartinez merged 2 commits intoFXMisc:masterfrom JordanMartinez:optimizeBackgroundColorShapes
JordanMartinez merged 2 commits intoFXMisc:masterfrom
JordanMartinez:optimizeBackgroundColorShapes
Conversation
Contributor
Author
|
Tested via: import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.InlineCssTextArea;
public class ConsecutiveDemo extends Application {
public static void main(String[] args) {
launch(args);
}
InlineCssTextArea area;
@Override
public void start(Stage primaryStage) {
area = new InlineCssTextArea();
area.replaceText("Some long line of text");
area.setStyle("-fx-font-size: 32pt;");
String blueBackground = "-rtfx-background-color: blue;";
String greenBackground = "-rtfx-background-color: green;";
String narrowUnderline = "-rtfx-underline-width: 2;";
String redUnderline = "-rtfx-underline-color: red;";
String dashedUnderline = "-rtfx-underline-dash-array: 8;";
String wideUnderline = "-rtfx-underline-width: 4;";
setStyles(
narrowUnderline, // shouldn't produce an underline, no color specified
blueBackground + redUnderline, // shouldn't produce an underline (no width specified)
blueBackground + redUnderline + wideUnderline,
greenBackground + redUnderline + wideUnderline,
greenBackground + redUnderline + narrowUnderline + dashedUnderline,
blueBackground + redUnderline + narrowUnderline + dashedUnderline
/*
Expected Shapes & Total Count:
background color shapes: blue, green, blue = total of 3
underline shapes: red wide, red narrow dashed = total of 2
*/
);
VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane<>(area);
Scene scene = new Scene(vsPane, 500, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
private void setStyles(String... styles) {
int index = 0;
for (String s : styles) {
area.setStyle(index, index + 1, s);
index++;
}
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only uses 1 shape for a value (background, underline) shared between multiple consecutive TextExt segments.
This provides the needed support to quickly implement #346 without the adjacent segments issue.