{"id":30048575,"url":"https://github.com/tharindu714/flyweight-text-editor-application","last_synced_at":"2025-09-19T06:07:09.737Z","repository":{"id":308165208,"uuid":"1031837279","full_name":"Tharindu714/Flyweight-Text-Editor-Application","owner":"Tharindu714","description":"TC Text Editor is a sleek, high-performance Java Swing application showcasing the Flyweight Design Pattern. Built with clean code and Maven, it delivers an intuitive UI and extreme memory efficiency.","archived":false,"fork":false,"pushed_at":"2025-08-04T12:45:20.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T16:53:16.177Z","etag":null,"topics":["flyweight-pattern","java","oodp","texteditor-gui"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tharindu714.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-04T12:05:33.000Z","updated_at":"2025-08-04T12:45:23.000Z","dependencies_parsed_at":"2025-08-04T17:08:46.918Z","dependency_job_id":null,"html_url":"https://github.com/Tharindu714/Flyweight-Text-Editor-Application","commit_stats":null,"previous_names":["tharindu714/flyweight-text-editor-application"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Tharindu714/Flyweight-Text-Editor-Application","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tharindu714%2FFlyweight-Text-Editor-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tharindu714%2FFlyweight-Text-Editor-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tharindu714%2FFlyweight-Text-Editor-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tharindu714%2FFlyweight-Text-Editor-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tharindu714","download_url":"https://codeload.github.com/Tharindu714/Flyweight-Text-Editor-Application/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tharindu714%2FFlyweight-Text-Editor-Application/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275888717,"owners_count":25546591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flyweight-pattern","java","oodp","texteditor-gui"],"created_at":"2025-08-07T10:38:45.061Z","updated_at":"2025-09-19T06:07:09.686Z","avatar_url":"https://github.com/Tharindu714.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flyweight Text Editor Application 🚀\n\n**TC Text Editor** is a sleek, high-performance Java Swing application showcasing the **Flyweight Design Pattern**. Built with clean code and Maven, it delivers an intuitive UI and extreme memory efficiency—ideal for editing large documents with thousands of styled characters.\n\n---\n\u003cimg width=\"1366\" height=\"729\" alt=\"image\" src=\"https://github.com/user-attachments/assets/2370457c-236a-4066-9d10-ee6890ecfd3c\" /\u003e\n\n---\n## 🌟 Key Features\n\n* **Rich Text Editing**: Bold, italic, color, font family \u0026 size controls\n* **Sample Content**: Preloaded header, body, and footer showcasing multiple fonts\n* **Footer Branding**: Customizable footer with your details\n* **Full-Screen Mode**: Maximized window on startup for distraction-free writing\n* **Flyweight Efficiency**: Shared formatting flyweights minimize memory overhead\n\n---\n\n## 📦 Installation \u0026 Usage\n\n1. **Clone the repo**\n\n   ```bash\n   git clone https://github.com/Tharindu714/Flyweight-Text-Editor-Application.git\n   cd Flyweight-Text-Editor-Application\n   ```\n\n2. **Build the JAR**\n\n   ```bash\n   mvn clean package\n   ```\n---\n\n## 🧩 Flyweight Pattern Explained\n\nIn a large document, thousands of characters share identical styling. Without Flyweight, each character would carry its own formatting object, skyrocketing memory usage.\n\n1. **Intrinsic State (Flyweight)**\n\n   * Defined in `CharacterFormat`:\n\n     * `fontFamily`, `fontSize`, `bold`, `italic`, `color`\n   * **Shared**: Only one instance per unique style combination.\n\n2. **Extrinsic State (Context)**\n\n   * Managed by `TextCharacter`:\n\n     * `character` glyph, `line`, `column` position\n   * **Provided at runtime**, kept separate from formatting.\n\n3. **Flyweight Factory**\n\n   * `CharacterFormatFactory` maintains a cache `Map\u003cString,CharacterFormat\u003e`.\n   * On `getFormat(...)`, it returns existing flyweight or creates a new one if needed.\n\n4. **Document Structure**\n\n   * `Document` aggregates `TextCharacter` contexts.\n   * `TextEditorUI` captures keystrokes, retrieves the current `StyledDocument` attributes, and adds characters to the model using shared formats.\n\nBy reusing `CharacterFormat` objects, the application uses **orders of magnitude less memory** and reduces garbage collection overhead—perfect for real-world text editors handling enormous documents.\n\n---\n\n## 🛠️ Code Structure\n\n```\nsrc/main/java/\n  ├─ TextEditorUI.java      # Swing GUI \u0026 user interaction\n  ├─ TextEditorApp.java     # (Optional CLI demo)\n  ├─ CharacterFormat.java   # Flyweight class (intrinsic state)\n  ├─ CharacterFormatFactory.java  # Flyweight factory \u0026 cache\n  ├─ TextCharacter.java     # Context class (extrinsic state)\n  └─ Document.java          # Aggregator of TextCharacters\n```\n\n---\n\n## 🎉 Get Started\n\n1. Launch the editor and explore sample text.\n2. Select text to change fonts, sizes, colors, and styles.\n3. Observe memory savings by printing `formatFactory.getTotalFormats()` in your code.\n\nEmbrace the power of Flyweight—write more, waste less!\n\n---\n\n© 2025 Tharindu Chanaka | [github.com/Tharindu714](https://github.com/Tharindu714)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharindu714%2Fflyweight-text-editor-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftharindu714%2Fflyweight-text-editor-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftharindu714%2Fflyweight-text-editor-application/lists"}