Cartesian Plane Lesson 18 Page 1: A Final Look at Properties

Introduction

Profile Editor Dialog
ProfileEditorDialog

In this lesson, we will develop the Profile class, a repository of all the properties we can use to configure the appearance of our graph window. For example, the length, weight (stroke), and color of the axes, grid lines, and tic marks; the background color of the window; the font properties of the labels on the major tic marks; and the grid unit, the number of pixels used to express the length of one unit on the graph. We’ll also develop the ProfileEditor for modifying properties, the FontEditorDialog, which the ProfileEditor will employ to edit font properties. The ProfileEditorDialog, accessible from the application menubar, will allow the operator to display the ProfileEditor. You can display and interact with the ProfileEditorDialog and its constituent ProfileEditor by runnning application ShowProfileEditorDialog, which can be found in the …app package of the project sandbox.

As shown in the figure above, the ProfileEditorDialog will display a graph window, giving the operator immediate feedback reflecting modifications to graph properties. The window is encapsulated in a small class, ProfileEditorFeedback, and is responsible for responding to events delegated to the window’s paintComponent method. You’ll notice in the figure above that our feedback window looks identical to the main window managed by the CartesianPlane class, suggesting that our feedback window will require a lot of the same logic. To accommodate this and to avoid duplicate code, we will remove the drawing logic from CarteisanPlane and place it in a new class, GraphManager, which can be shared by the CartesianPlane and the ProfileEditorFeedback window. We want the operator to be able to save property configurations to a file and restore them on request. To that end, we will develop the ProfileParser and ProfileFileManager classes.

To test the above, we will integrate a new library, Tess4J, which allows Java programs to access the Tesseract engine for optical character recognition (OCR). Although I won’t list them all here, we will develop several additional classes for test support, including managing GUI components and ensuring that GUI access is performed on the EDT.

Following is a summary of the pages composing this lesson.

GitHub repository: Cartesian Plane Part 18

Previous lesson: Cartesian Plane Lesson 17 Page 17: Testing the Application Menubar

On the next page, we’ll discuss some adjustments to the functions and features we implemented in previous lessons.

Next: Refactoring