Skip to content
JordanMartinez edited this page Oct 16, 2017 · 5 revisions

RichTextFX is a JavaFX rich text rendering and editing engine. However, it is not meant to be a complete rich text editor ("Batteries not included"), but it should be easily extensible so that any kind of rich text can be rendered and edited.

Design Principles of RichTextFX

  • Prefer delegation over inheritance

    Even though this might lead to duplicated code in some cases, delegation should be preferred over inheritance whenever it makes sense. This is a core Java principle and not completely specific to RichTextFX, but RichTextFX explicitly follows that principle.

  • Prefer parameterized types over delegation

    Instead of delegating to a base class and let the user subclass the base class, use a type parameter. This is much more type safe since it does not require casts in many cases.

  • Functional interfaces

    RichTextFX makes heavy use of functional interfaces and lambdas introduced in Java 8. This allows to parameterize the behavior of the engine, such as how to apply a style to a JavaFX node which is rendered on the screen. Together with the parameterized types, a very strongly typed API can be provided.

  • Reactive programming

    RichTextFX makes heavy use of the ReactFX library to leverage reactive programming. This is very useful to execute any kind of code when some condition occurs, for example when values change or when events are published to an event stream. Make sure to check https://github.com/TomasMikula/ReactFX/wiki when you start hacking on RichTextFX!

"Why don't we add Feature X to RichTextFX?"

RichTextFX's goal is to provide a rich text area base upon which others can build. Developer's use-cases, as is JordanMartinez's understanding, generally falls somewhere in these categories:

  1. Standard RichTextArea (because that is missing from standard JavaFX library)
  2. Slightly-customized RichTextArea (overrides default behavior in some way) for a special use case
  3. Base for a heavily-customized RichTextArea that includes non-text Nodes (images/emoticons, shapes, paragraph bullets, and tables).
  4. Base for a code editor that uses specific items/tools to accomplish some tasks (e.g. syntax-highlighting)

With that being the goal, suggested features that fall into these categories will immediately be rejected because they are "outside the scope of this project:"

  1. Features that may be useless for some users, inflexible for others, or otherwise complicate things for others unnecessarily, such as implementing a specific syntax-highlighter.
  2. Features that can be implemented on top of RichTextFX, such as search-and-replace functionality (which would affect those using non-text custom objects). Features that need to be implemented in the code base to work, like #222, would be merged.

However, if one wants to demonstrate how RichTextFX could be used with a specific syntax-highlighter, search-and-replace functionality, emoticon support out-of-box, etc., one can submit a PR for the richtextfx-demos package, and that would be merged.
Note: Keep in mind that such PRs would fall under the license of this project.

RichTextFX Dependencies

  • ReactFX - See the project's wiki to find a tutorial about EventStreams and Val/Var as they are used throughout this project.
  • UndoFX - See the project's ReadMe
  • Flowless - See the project's ReadMe and javadoc (see release 0.6 or higher)
  • WellBehavedFX - See the project's ReadMe and GenericStyledAreaBehavior as an example of what it's API looks like.