Skip to content

Commit

Permalink
Merge pull request #729 from JordanMartinez/demo-update
Browse files Browse the repository at this point in the history
Make it easier to run and maintain demos
  • Loading branch information
JordanMartinez authored Apr 14, 2018
2 parents bec8fef + b642f19 commit 26bf5c2
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 121 deletions.
105 changes: 8 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ It is intended as a base for rich-text editors and code editors with syntax high

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)

Demos
-----

Stand-alone Applications that demonstrate some of the features of RichTextFX have been moved to their own folder [here](./richtextfx-demos/)

Table of Contents
-----------------

* [Who uses RichTextFX?](#who-uses-richtextfx)
* [Features](#features)
* [Flavors](#flavors)
Expand All @@ -18,11 +26,6 @@ For a greater explanation of RichTextFX, its design principles, how it works, an
* [StyleClassedTextArea](#styleclassedtextarea)
* [CodeArea (Base for code editors)](#codearea)
* [Requirements](#requirements)
* [Demos](#demos)
* [Highlighting of Java keywords](#automatic-highlighting-of-java-keywords)
* [XML Editor](#xml-editor)
* [Rich-text editor](#rich-text-editor)
* [Custom tooltips](#custom-tooltips)
* [Download](#download)
* [Stable](#stable-release)
* [Snapshot](#snapshot-releases)
Expand Down Expand Up @@ -129,98 +132,6 @@ Requirements

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


Demos
-----

### Automatic highlighting of Java keywords

![Screenshot of the JavaKeywords demo](https://cloud.githubusercontent.com/assets/8413037/24158979/1ef7af14-0e1b-11e7-8c06-69cb9e5a2dd7.png)

#### Run using the pre-built JAR

[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

java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.JavaKeywords

or

java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.JavaKeywordsAsync

#### Run from the source repo

gradle JavaKeywords

or

gradle JavaKeywordsAsync

#### Source code

[JavaKeywords.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywords.java)

[JavaKeywordsAsync.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsync.java)

The former computes highlighting on the JavaFX application thread, while the latter computes highlighting on a background thread.


### XML Editor

Similar to the [Java Keywords](#automatic-highlighting-of-java-keywords) demo above, this demo highlights XML syntax. Courtesy of @cemartins.

#### Run using the pre-built JAR

[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

java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.XMLEditor

#### Run from the source repo

gradle XMLEditor

#### Source code

[XMLEditor.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/XMLEditor.java)


### Rich-text editor

![Screenshot of the RichText demo](https://cloud.githubusercontent.com/assets/8413037/24158984/22d36a10-0e1b-11e7-95e0-f4546cb528c3.png)

#### Run using the pre-built JAR
[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

java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.richtext.RichText

#### Run from the source repo

gradle RichText

#### Source code

[RichText.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichText.java)


### Custom tooltips

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.

![Screenshot of the RichText demo](https://cloud.githubusercontent.com/assets/8413037/24158992/2741225e-0e1b-11e7-9d6b-6040dc30cee1.png)

#### Run using the pre-built JAR
[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

java -cp richtextfx-demos-fat-0.7-M5.jar org.fxmisc.richtext.demo.TooltipDemo

#### Run from the source repo

gradle TooltipDemo

#### Source code

[TooltipDemo.java](https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/TooltipDemo.java)


Download
--------

Expand Down
69 changes: 69 additions & 0 deletions richtextfx-demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Demos
-----

Note: This page does not show all the demos in the package. Follow the instructions below to see them all.

### Table of Contents

* [Instructions for Running Demos](#instructions-for-running-demos)
* [Structure of the Demos package](#structure-of-the-demos-package)
* Some Demos
* [Rich-text editor](#rich-text-editor)
* [Highlighting of Java keywords](#automatic-highlighting-of-java-keywords)
* [XML Editor](#xml-editor)
* [Multiple Carets and Selections](#multiple-carets-and-selections)
* [Custom tooltips](#custom-tooltips)

### Instructions for running demos

1. Clone the repository: `git clone https://www.github.com/FXMisc/RichTextFX.git`
2. Checkout the latest release version: `git checkout v0.9.0`
3. See the list of demos using a gradle task `./gradlew demos`
4. Run a demo using a gradle task: `./gradlew [Demo Name]`

(For Windows users, replace `./gradlew` with `gradlew.bat` in the above commands)

### Structure of the Demos package

- Each runnable demo class that extends `Application` ends in the suffix: "Demo"
- 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)

### Rich-text editor

Source Code: [RichText.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichText.java)

![Screenshot of the RichText demo](./screenshots/RichTextDemo.jpg)

### Automatic highlighting of Java keywords

Source Code:

[JavaKeywords.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywords.java)

[JavaKeywordsAsync.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywordsAsync.java)

The former computes highlighting on the JavaFX application thread, while the latter computes highlighting on a background thread.

![Screenshot of the JavaKeywords demo](./screenshots/JavaKeywordsDemo.jpg)

### XML Editor

Similar to the [Java Keywords](#automatic-highlighting-of-java-keywords) demo above, this demo highlights XML syntax. Courtesy of @cemartins.

Source Code: [XMLEditor.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/XMLEditorDemo.java)

![Screenshot of the XML Editor demo](./screenshots/XMLEditorDemo.jpg)

### Multiple Carets and Selections

Source Code: [MultiCaretAndSelectionDemo.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/MultiCaretAndSelectionDemo.java)

![Screenshot of the Multiple Carets and Selections demo](./screenshots/MultiCaretAndSelectionDemo.jpg)

### Custom tooltips

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.

Source Code: [TooltipDemo.java](https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/TooltipDemo.java)

![Screenshot of the Tooltip demo](./screenshots/TooltipDemo.jpg)
105 changes: 93 additions & 12 deletions richtextfx-demos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,118 @@ task fatJar(type: Jar, dependsOn: classes) {

assemble.dependsOn fatJar

task JavaKeywords(type: JavaExec, dependsOn: classes) {
main = 'org.fxmisc.richtext.demo.JavaKeywords'
task demos(description: "Lists the names and the descriptions of the demos that can be run via a Gradle task") {
doLast {
// sort the demos first, so they can be added in the build file in any order
def list = []
tasks.withType(JavaExec) {
if (it.name.endsWith("Demo")) {
list.add(it)
}
}
list.sort { first, next -> first.name <=> next.name }
.each {
println " ${it.name} - ${it.description}"
}
}
}

// To add a task for a demo, use the following template:
/*
task ClassNameDemo(type: JavaExec, dependsOn: classes,
description: "A description of what the demo does") {
main = 'org.fxmisc.richtext.demo.ClassNameDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}
*/

task JavaKeywordsDemo(type: JavaExec, dependsOn: classes,
description: "A CodeArea with Java syntax highlighting that is computed on the JavaFX Application Thread") {
main = 'org.fxmisc.richtext.demo.JavaKeywordsDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

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

task XMLEditor(type: JavaExec, dependsOn: classes) {
main = 'org.fxmisc.richtext.demo.XMLEditor'
task XMLEditorDemo(type: JavaExec, dependsOn: classes,
description: "An area with XML syntax highlighting") {
main = 'org.fxmisc.richtext.demo.XMLEditorDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

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

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

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

task TooltipDemo(type: JavaExec, dependsOn: classes) {
task TooltipDemo(type: JavaExec, dependsOn: classes,
description: "Tells you the letter over which the mouse is hovering") {
main = 'org.fxmisc.richtext.demo.TooltipDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task HyperlinkAreaDemo(type: JavaExec, dependsOn: classes,
description: "An area with hyperlinks that open to their corresponding link") {
main = 'org.fxmisc.richtext.demo.hyperlink.HyperlinkDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task LineIndicatorDemo(type: JavaExec, dependsOn: classes,
description: "Line numbers appear to left of each paragraph and a triangle appears on the same paragraph as the caret") {
main = 'org.fxmisc.richtext.demo.lineindicator.LineIndicatorDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task CloneDemo(type: JavaExec, dependsOn: classes,
description: "Two areas that can modify and show the same underlying document") {
main = 'org.fxmisc.richtext.demo.CloneDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task FontSizeSwitcherDemo(type: JavaExec, dependsOn: classes,
description: "Change the font size of the entire area.") {
main = 'org.fxmisc.richtext.demo.FontSizeSwitcherDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task MultiCaretAndSelectionNameDemo(type: JavaExec, dependsOn: classes,
description: "Add and display multiple carets and selections with different style classes in the same area") {
main = 'org.fxmisc.richtext.demo.MultiCaretAndSelectionDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task OverrideBehaviorDemo(type: JavaExec, dependsOn: classes,
description: "Overrides the area's default behavior and demonstrates some things of which to be aware") {
main = 'org.fxmisc.richtext.demo.OverrideBehaviorDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task ShowLineDemo(type: JavaExec, dependsOn: classes,
description: "Force a specific part of the underlying document to be rendered to the screen.") {
main = 'org.fxmisc.richtext.demo.ShowLineDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}

task SpellCheckingDemo(type: JavaExec, dependsOn: classes,
description: "Shows how to add a red squiggle underneath misspelled words") {
main = 'org.fxmisc.richtext.demo.SpellCheckingDemo'
classpath = files(sourceSets.main.output, configurations.runtime)
}
Binary file added richtextfx-demos/screenshots/JavaKeywordsDemo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added richtextfx-demos/screenshots/RichTextDemo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added richtextfx-demos/screenshots/TooltipDemo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added richtextfx-demos/screenshots/XMLEditorDemo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea;

public class FontSizeSwitcher extends Application {
public class FontSizeSwitcherDemo extends Application {

public static void main(String[] args) {
launch(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.fxmisc.richtext.model.StyleSpansBuilder;
import org.reactfx.Subscription;

public class JavaKeywordsAsync extends Application {
public class JavaKeywordsAsyncDemo extends Application {

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

Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
scene.getStylesheets().add(JavaKeywordsAsyncDemo.class.getResource("java-keywords.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Java Keywords Async Demo");
primaryStage.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.fxmisc.richtext.model.StyleSpansBuilder;
import org.reactfx.Subscription;

public class JavaKeywords extends Application {
public class JavaKeywordsDemo extends Application {

private static final String[] KEYWORDS = new String[] {
"abstract", "assert", "boolean", "break", "byte",
Expand Down Expand Up @@ -106,7 +106,7 @@ public void start(Stage primaryStage) {
codeArea.replaceText(0, 0, sampleCode);

Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
scene.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
scene.getStylesheets().add(JavaKeywordsAsyncDemo.class.getResource("java-keywords.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Java Keywords Demo");
primaryStage.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea;

public class ManualHighlighting extends Application {
public class ManualHighlightingDemo extends Application {

public static void main(String[] args) {
launch(args);
Expand All @@ -38,7 +38,7 @@ public void start(Stage primaryStage) {
VBox vbox = new VBox(panel, vsPane);

Scene scene = new Scene(vbox, 600, 400);
scene.getStylesheets().add(ManualHighlighting.class.getResource("manual-highlighting.css").toExternalForm());
scene.getStylesheets().add(ManualHighlightingDemo.class.getResource("manual-highlighting.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Manual Highlighting Demo");
primaryStage.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import javafx.stage.Stage;
import org.reactfx.Subscription;

public class SpellChecking extends Application {
public class SpellCheckingDemo extends Application {

private static final Set<String> dictionary = new HashSet<String>();

Expand Down
Loading

0 comments on commit 26bf5c2

Please sign in to comment.