Skip to content

Commit 26bf5c2

Browse files
Merge pull request #729 from JordanMartinez/demo-update
Make it easier to run and maintain demos
2 parents bec8fef + b642f19 commit 26bf5c2

15 files changed

Lines changed: 182 additions & 121 deletions

README.md

Lines changed: 8 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ It is intended as a base for rich-text editors and code editors with syntax high
99

1010
For a greater explanation of RichTextFX, its design principles, how it works, and how to style its areas via CSS, please [see the wiki](https://github.com/TomasMikula/RichTextFX/wiki)
1111

12+
Demos
13+
-----
14+
15+
Stand-alone Applications that demonstrate some of the features of RichTextFX have been moved to their own folder [here](./richtextfx-demos/)
16+
17+
Table of Contents
18+
-----------------
19+
1220
* [Who uses RichTextFX?](#who-uses-richtextfx)
1321
* [Features](#features)
1422
* [Flavors](#flavors)
@@ -18,11 +26,6 @@ For a greater explanation of RichTextFX, its design principles, how it works, an
1826
* [StyleClassedTextArea](#styleclassedtextarea)
1927
* [CodeArea (Base for code editors)](#codearea)
2028
* [Requirements](#requirements)
21-
* [Demos](#demos)
22-
* [Highlighting of Java keywords](#automatic-highlighting-of-java-keywords)
23-
* [XML Editor](#xml-editor)
24-
* [Rich-text editor](#rich-text-editor)
25-
* [Custom tooltips](#custom-tooltips)
2629
* [Download](#download)
2730
* [Stable](#stable-release)
2831
* [Snapshot](#snapshot-releases)
@@ -129,98 +132,6 @@ Requirements
129132

130133
JDK 8u40 is recommended, because it fixes some text rendering bugs.
131134

132-
133-
Demos
134-
-----
135-
136-
### Automatic highlighting of Java keywords
137-
138-
![Screenshot of the JavaKeywords demo](https://cloud.githubusercontent.com/assets/8413037/24158979/1ef7af14-0e1b-11e7-8c06-69cb9e5a2dd7.png)
139-
140-
#### Run using the pre-built JAR
141-
142-
[Download](https://github.com/TomasMikula/RichTextFX/releases/download/v0.7-M5/richtextfx-demos-fat-0.7-M5.jar) the pre-built "fat" JAR file and run
143-
144-
java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.JavaKeywords
145-
146-
or
147-
148-
java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.JavaKeywordsAsync
149-
150-
#### Run from the source repo
151-
152-
gradle JavaKeywords
153-
154-
or
155-
156-
gradle JavaKeywordsAsync
157-
158-
#### Source code
159-
160-
[JavaKeywords.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywords.java)
161-
162-
[JavaKeywordsAsync.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsync.java)
163-
164-
The former computes highlighting on the JavaFX application thread, while the latter computes highlighting on a background thread.
165-
166-
167-
### XML Editor
168-
169-
Similar to the [Java Keywords](#automatic-highlighting-of-java-keywords) demo above, this demo highlights XML syntax. Courtesy of @cemartins.
170-
171-
#### Run using the pre-built JAR
172-
173-
[Download](https://github.com/TomasMikula/RichTextFX/releases/download/v0.7-M5/richtextfx-demos-fat-0.7-M5.jar) the pre-built "fat" JAR file and run
174-
175-
java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.XMLEditor
176-
177-
#### Run from the source repo
178-
179-
gradle XMLEditor
180-
181-
#### Source code
182-
183-
[XMLEditor.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/XMLEditor.java)
184-
185-
186-
### Rich-text editor
187-
188-
![Screenshot of the RichText demo](https://cloud.githubusercontent.com/assets/8413037/24158984/22d36a10-0e1b-11e7-95e0-f4546cb528c3.png)
189-
190-
#### Run using the pre-built JAR
191-
[Download](https://github.com/TomasMikula/RichTextFX/releases/download/v0.7-M5/richtextfx-demos-fat-0.7-M5.jar) the pre-built "fat" JAR file and run
192-
193-
java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.richtext.RichText
194-
195-
#### Run from the source repo
196-
197-
gradle RichText
198-
199-
#### Source code
200-
201-
[RichText.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichText.java)
202-
203-
204-
### Custom tooltips
205-
206-
When the mouse pauses over the text area, you can get index of the character under the mouse. This allows you to implement, for example, custom tooltips whose content depends on the text under the mouse.
207-
208-
![Screenshot of the RichText demo](https://cloud.githubusercontent.com/assets/8413037/24158992/2741225e-0e1b-11e7-9d6b-6040dc30cee1.png)
209-
210-
#### Run using the pre-built JAR
211-
[Download](https://github.com/TomasMikula/RichTextFX/releases/download/v0.7-M5/richtextfx-demos-fat-0.7-M5.jar) the pre-built "fat" JAR file and run
212-
213-
java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.TooltipDemo
214-
215-
#### Run from the source repo
216-
217-
gradle TooltipDemo
218-
219-
#### Source code
220-
221-
[TooltipDemo.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/TooltipDemo.java)
222-
223-
224135
Download
225136
--------
226137

richtextfx-demos/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Demos
2+
-----
3+
4+
Note: This page does not show all the demos in the package. Follow the instructions below to see them all.
5+
6+
### Table of Contents
7+
8+
* [Instructions for Running Demos](#instructions-for-running-demos)
9+
* [Structure of the Demos package](#structure-of-the-demos-package)
10+
* Some Demos
11+
* [Rich-text editor](#rich-text-editor)
12+
* [Highlighting of Java keywords](#automatic-highlighting-of-java-keywords)
13+
* [XML Editor](#xml-editor)
14+
* [Multiple Carets and Selections](#multiple-carets-and-selections)
15+
* [Custom tooltips](#custom-tooltips)
16+
17+
### Instructions for running demos
18+
19+
1. Clone the repository: `git clone https://www.github.com/FXMisc/RichTextFX.git`
20+
2. Checkout the latest release version: `git checkout v0.9.0`
21+
3. See the list of demos using a gradle task `./gradlew demos`
22+
4. Run a demo using a gradle task: `./gradlew [Demo Name]`
23+
24+
(For Windows users, replace `./gradlew` with `gradlew.bat` in the above commands)
25+
26+
### Structure of the Demos package
27+
28+
- Each runnable demo class that extends `Application` ends in the suffix: "Demo"
29+
- If a demo requires additional classes that should not be nested, the demo and its helper classes appear in their own package named after the demo (e.g. `RichTextDemo` is found in the `richtext` package)
30+
31+
### Rich-text editor
32+
33+
Source Code: [RichText.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichText.java)
34+
35+
![Screenshot of the RichText demo](./screenshots/RichTextDemo.jpg)
36+
37+
### Automatic highlighting of Java keywords
38+
39+
Source Code:
40+
41+
[JavaKeywords.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywords.java)
42+
43+
[JavaKeywordsAsync.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsync.java)
44+
45+
The former computes highlighting on the JavaFX application thread, while the latter computes highlighting on a background thread.
46+
47+
![Screenshot of the JavaKeywords demo](./screenshots/JavaKeywordsDemo.jpg)
48+
49+
### XML Editor
50+
51+
Similar to the [Java Keywords](#automatic-highlighting-of-java-keywords) demo above, this demo highlights XML syntax. Courtesy of @cemartins.
52+
53+
Source Code: [XMLEditor.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/XMLEditorDemo.java)
54+
55+
![Screenshot of the XML Editor demo](./screenshots/XMLEditorDemo.jpg)
56+
57+
### Multiple Carets and Selections
58+
59+
Source Code: [MultiCaretAndSelectionDemo.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/MultiCaretAndSelectionDemo.java)
60+
61+
![Screenshot of the Multiple Carets and Selections demo](./screenshots/MultiCaretAndSelectionDemo.jpg)
62+
63+
### Custom tooltips
64+
65+
When the mouse pauses over the text area, you can get index of the character under the mouse. This allows you to implement, for example, custom tooltips whose content depends on the text under the mouse.
66+
67+
Source Code: [TooltipDemo.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/TooltipDemo.java)
68+
69+
![Screenshot of the Tooltip demo](./screenshots/TooltipDemo.jpg)

richtextfx-demos/build.gradle

Lines changed: 93 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,118 @@ task fatJar(type: Jar, dependsOn: classes) {
2020

2121
assemble.dependsOn fatJar
2222

23-
task JavaKeywords(type: JavaExec, dependsOn: classes) {
24-
main = 'org.fxmisc.richtext.demo.JavaKeywords'
23+
task demos(description: "Lists the names and the descriptions of the demos that can be run via a Gradle task") {
24+
doLast {
25+
// sort the demos first, so they can be added in the build file in any order
26+
def list = []
27+
tasks.withType(JavaExec) {
28+
if (it.name.endsWith("Demo")) {
29+
list.add(it)
30+
}
31+
}
32+
list.sort { first, next -> first.name <=> next.name }
33+
.each {
34+
println " ${it.name} - ${it.description}"
35+
}
36+
}
37+
}
38+
39+
// To add a task for a demo, use the following template:
40+
/*
41+
task ClassNameDemo(type: JavaExec, dependsOn: classes,
42+
description: "A description of what the demo does") {
43+
main = 'org.fxmisc.richtext.demo.ClassNameDemo'
44+
classpath = files(sourceSets.main.output, configurations.runtime)
45+
}
46+
*/
47+
48+
task JavaKeywordsDemo(type: JavaExec, dependsOn: classes,
49+
description: "A CodeArea with Java syntax highlighting that is computed on the JavaFX Application Thread") {
50+
main = 'org.fxmisc.richtext.demo.JavaKeywordsDemo'
2551
classpath = files(sourceSets.main.output, configurations.runtime)
2652
}
2753

28-
task JavaKeywordsAsync(type: JavaExec, dependsOn: classes) {
29-
main = 'org.fxmisc.richtext.demo.JavaKeywordsAsync'
54+
task JavaKeywordsAsyncDemo(type: JavaExec, dependsOn: classes,
55+
description: "A CodeArea with Java syntax highlighting that is computed on a background thread") {
56+
main = 'org.fxmisc.richtext.demo.JavaKeywordsAsyncDemo'
3057
classpath = files(sourceSets.main.output, configurations.runtime)
3158
}
3259

33-
task XMLEditor(type: JavaExec, dependsOn: classes) {
34-
main = 'org.fxmisc.richtext.demo.XMLEditor'
60+
task XMLEditorDemo(type: JavaExec, dependsOn: classes,
61+
description: "An area with XML syntax highlighting") {
62+
main = 'org.fxmisc.richtext.demo.XMLEditorDemo'
3563
classpath = files(sourceSets.main.output, configurations.runtime)
3664
}
3765

38-
task ManualHighlighting(type: JavaExec, dependsOn: classes) {
39-
main = 'org.fxmisc.richtext.demo.ManualHighlighting'
66+
task ManualHighlightingDemo(type: JavaExec, dependsOn: classes,
67+
description: "Manually highlight various parts of the text in an area via buttons") {
68+
main = 'org.fxmisc.richtext.demo.ManualHighlightingDemo'
4069
classpath = files(sourceSets.main.output, configurations.runtime)
4170
}
4271

43-
task RichText(type: JavaExec, dependsOn: classes) {
44-
main = 'org.fxmisc.richtext.demo.richtext.RichText'
72+
task RichTextDemo(type: JavaExec, dependsOn: classes,
73+
description: "An area showing a large number of RichTextFX's features: " +
74+
"inlined images, rich text (e.g. text alignment and background colors, etc.), and save/load capabilities") {
75+
main = 'org.fxmisc.richtext.demo.richtext.RichTextDemo'
4576
classpath = files(sourceSets.main.output, configurations.runtime)
4677
}
4778

48-
task PopupDemo(type: JavaExec, dependsOn: classes) {
79+
task PopupDemo(type: JavaExec, dependsOn: classes,
80+
description: "A popup that follows the caret and selection when they move") {
4981
main = 'org.fxmisc.richtext.demo.PopupDemo'
5082
classpath = files(sourceSets.main.output, configurations.runtime)
5183
}
5284

53-
task TooltipDemo(type: JavaExec, dependsOn: classes) {
85+
task TooltipDemo(type: JavaExec, dependsOn: classes,
86+
description: "Tells you the letter over which the mouse is hovering") {
5487
main = 'org.fxmisc.richtext.demo.TooltipDemo'
5588
classpath = files(sourceSets.main.output, configurations.runtime)
5689
}
90+
91+
task HyperlinkAreaDemo(type: JavaExec, dependsOn: classes,
92+
description: "An area with hyperlinks that open to their corresponding link") {
93+
main = 'org.fxmisc.richtext.demo.hyperlink.HyperlinkDemo'
94+
classpath = files(sourceSets.main.output, configurations.runtime)
95+
}
96+
97+
task LineIndicatorDemo(type: JavaExec, dependsOn: classes,
98+
description: "Line numbers appear to left of each paragraph and a triangle appears on the same paragraph as the caret") {
99+
main = 'org.fxmisc.richtext.demo.lineindicator.LineIndicatorDemo'
100+
classpath = files(sourceSets.main.output, configurations.runtime)
101+
}
102+
103+
task CloneDemo(type: JavaExec, dependsOn: classes,
104+
description: "Two areas that can modify and show the same underlying document") {
105+
main = 'org.fxmisc.richtext.demo.CloneDemo'
106+
classpath = files(sourceSets.main.output, configurations.runtime)
107+
}
108+
109+
task FontSizeSwitcherDemo(type: JavaExec, dependsOn: classes,
110+
description: "Change the font size of the entire area.") {
111+
main = 'org.fxmisc.richtext.demo.FontSizeSwitcherDemo'
112+
classpath = files(sourceSets.main.output, configurations.runtime)
113+
}
114+
115+
task MultiCaretAndSelectionNameDemo(type: JavaExec, dependsOn: classes,
116+
description: "Add and display multiple carets and selections with different style classes in the same area") {
117+
main = 'org.fxmisc.richtext.demo.MultiCaretAndSelectionDemo'
118+
classpath = files(sourceSets.main.output, configurations.runtime)
119+
}
120+
121+
task OverrideBehaviorDemo(type: JavaExec, dependsOn: classes,
122+
description: "Overrides the area's default behavior and demonstrates some things of which to be aware") {
123+
main = 'org.fxmisc.richtext.demo.OverrideBehaviorDemo'
124+
classpath = files(sourceSets.main.output, configurations.runtime)
125+
}
126+
127+
task ShowLineDemo(type: JavaExec, dependsOn: classes,
128+
description: "Force a specific part of the underlying document to be rendered to the screen.") {
129+
main = 'org.fxmisc.richtext.demo.ShowLineDemo'
130+
classpath = files(sourceSets.main.output, configurations.runtime)
131+
}
132+
133+
task SpellCheckingDemo(type: JavaExec, dependsOn: classes,
134+
description: "Shows how to add a red squiggle underneath misspelled words") {
135+
main = 'org.fxmisc.richtext.demo.SpellCheckingDemo'
136+
classpath = files(sourceSets.main.output, configurations.runtime)
137+
}
93.1 KB
Loading
58.9 KB
Loading
302 KB
Loading
45.5 KB
Loading
115 KB
Loading

richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/FontSizeSwitcher.java renamed to richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/FontSizeSwitcherDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.fxmisc.flowless.VirtualizedScrollPane;
1212
import org.fxmisc.richtext.StyleClassedTextArea;
1313

14-
public class FontSizeSwitcher extends Application {
14+
public class FontSizeSwitcherDemo extends Application {
1515

1616
public static void main(String[] args) {
1717
launch(args);

richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsync.java renamed to richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsyncDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.fxmisc.richtext.model.StyleSpansBuilder;
2323
import org.reactfx.Subscription;
2424

25-
public class JavaKeywordsAsync extends Application {
25+
public class JavaKeywordsAsyncDemo extends Application {
2626

2727
private static final String[] KEYWORDS = new String[] {
2828
"abstract", "assert", "boolean", "break", "byte",
@@ -110,7 +110,7 @@ public void start(Stage primaryStage) {
110110
codeArea.replaceText(0, 0, sampleCode);
111111

112112
Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
113-
scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
113+
scene.getStylesheets().add(JavaKeywordsAsyncDemo.class.getResource("java-keywords.css").toExternalForm());
114114
primaryStage.setScene(scene);
115115
primaryStage.setTitle("Java Keywords Async Demo");
116116
primaryStage.show();

0 commit comments

Comments
 (0)