Skip to content

This is a Word Processor developed by Joe Huber and Connor Jordan for a senior project as a part of their Advanced Software Engineering Class.

Notifications You must be signed in to change notification settings

Joe-Huber/Text-Editor

Repository files navigation

Text Editor (JavaFX)

A lightweight text editor built with JavaFX featuring a custom document model (Document → Paragraph → Word → Character), a render pipeline, and a keyboard/mouse-driven cursor. This project is intended as a learning-focused editor with a clear separation between model, rendering, and UI.

Editor UI


Features

  • Custom document model:
    • Document contains Paragraphs; Paragraphs contain Words; Words contain DocumentCharacters.
    • Whitespace is represented explicitly (spaces are Words with a single space character; newlines create Paragraphs).
  • Rendering pipeline:
    • Converts the document model into positioned JavaFX Text nodes with word-wrapping based on window width.
    • Maintains a 2D array of DocumentText to map on-screen positions back to model indices.
  • Cursor/navigation:
    • Arrow keys (up/down/left/right), mouse click positioning, and enter/new paragraph.
    • Backspace and delete behavior for characters and word/paragraph merges.
  • Basic formatting state:
    • Font family selection, font size increment/decrement, bold/italic toggles.

Project Structure

  • src/main/java/Classes
    • CharConfig: Tracks current font settings (family/size/bold/italic) and produces Font via buildFont().
    • Cursor: Logical cursor (paragraph/word/char indices) plus on-screen position/height. Handles movement (via display-format mapping).
    • Display: JavaFX Application. Builds the toolbar, scene, handles key/mouse events, and draws text/caret.
    • Document: Core text model with paragraphs/words/chars. Insertion (characters, spaces, paragraphs) and deletion/merging logic.
    • DocumentCharacter: A character with a Font; width/height measured using a JavaFX Text node.
    • DocumentText: Wrapper for a Text node along with its model indices (paragraph, word, char).
    • EventHandler: Dispatches KeyEvent/MouseEvent to Document/Display/Cursor.
    • Paragraph: Holds a list of Word objects and a default Font.
    • Renderer: Lays out the document into lines within the window width; returns DocumentText[][] for Display/Cursor.
    • Word: Holds a linked list of DocumentCharacter with helpers for width/height and sub-word operations.
  • module-info.java
    • Module name: Classes; requires javafx.controls, javafx.fxml, java.desktop; exports Classes.

How It Works (High-level)

  • Input flow:
    • Keyboard input -> EventHandler -> Document mutation (addCharacter, addSpace, addParagraph, deleteLeft) -> Display.displayFlow()/Cursor.update() -> caret reposition.
    • Mouse clicks -> Cursor.cursorClick() to find the nearest DocumentText in the rendered grid and set logical indices accordingly.
  • Rendering:
    • Renderer.renderDocument(Document) walks the model, wraps lines based on Display.getWindowLength(), and computes x/y for each character, returning DocumentText[][] which Display paints.
  • Cursor mapping:
    • Cursor maintains both logical indices and on-screen coordinates. It updates via the current DocumentText[][] to stay in sync with layout.

Running the App

This project uses JavaFX without a build tool file in the repo. Recommended setup is via an IDE (e.g., IntelliJ IDEA) with a JavaFX SDK installed, or via plain javac/java.

Prerequisites

  • Java 17 or later (project uses module-info.java).
  • JavaFX SDK 17+ (download from https://openjfx.io/).

Run in IntelliJ IDEA (recommended)

  1. Open the project in IntelliJ.
  2. Configure the JavaFX SDK in Project Structure (or use IntelliJ’s JavaFX plugin).
  3. Create a Run Configuration for the main class:
    • Main class: Classes.Display
    • VM options (adjust path to your JavaFX SDK): --module-path /path/to/javafx-sdk/lib --add-modules javafx.controls,javafx.fxml
  4. Run the configuration.

Run from the command line

Set PATH_TO_FX to your JavaFX SDK lib directory:

  • macOS/Linux: export PATH_TO_FX=/path/to/javafx-sdk/lib

  • Windows (PowerShell): $env:PATH_TO_FX="C:\path\to\javafx-sdk\lib"

Compile to out/ using the classpath (put JavaFX jars on the classpath):

  • macOS/Linux: find src/main/java -name ".java" > sources.txt javac -cp "$PATH_TO_FX/" -d out @sources.txt

  • Windows (PowerShell): Get-ChildItem -Recurse src/main/java -Filter .java | ForEach-Object { $_.FullName } | Set-Content sources.txt javac -cp "$env:PATH_TO_FX/" -d out @sources.txt

Run the app (classpath; JavaFX on classpath):

  • macOS/Linux: java -cp "out:$PATH_TO_FX/*" Classes.Display

  • Windows (PowerShell): java -cp "out;$env:PATH_TO_FX/*" Classes.Display

Note: You can alternatively use the module path for JavaFX and keep your classes on the classpath. The provided commands follow that pattern for simplicity.


Controls

  • Typing: Inserts characters at the cursor.
  • Space: Insert space (special handling ensures correct word boundaries).
  • Enter: New paragraph (splits content at cursor into a new paragraph as appropriate).
  • Backspace: Deletes left, merging words/paragraphs when needed.
  • Arrow keys: Move caret (left/right/up/down).
  • Mouse click: Repositions caret to the nearest character in the clicked line/column.
  • Toolbar:
    • Bold/Italic toggles.
    • Font size +/−.
    • Font family dropdown.
    • Underline/Color buttons are placeholders in this version.


Screenshots / Images

  • Editor UI overview: Editor UI overview

  • Document model (Document → Paragraph → Word → Character) diagram: Document model diagram

  • Caret movement and selection demo: Caret movement demo

  • Toolbar and formatting controls: Toolbar


Developers

Developed by Joe Huber & Connor Jordan.

About

This is a Word Processor developed by Joe Huber and Connor Jordan for a senior project as a part of their Advanced Software Engineering Class.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages