1.1 Problem Statement
2.1 Top-Level
2.2 Commands
2.3 Tools
2.4 Canvas
      2.4.1 CanvasWindow
2.5 Continuing Effort...
This document contains both technical and user-oriented information on the JDraw graphics tool. The tool is intended to provide its user with the ability to develop advanced graphic displays using a quick and easy interface.
The main problem to be solved by the JDraw package is the need for a quick, yet powerful graphics application which can be used in a variety of graphical operating systems. The specification basis for development was an independent application titled IDraw, which was written in C++ for the Unix graphical environments. Ultimately the goal was to develop a system with all the functionality of IDraw, yet written in Java to allow for cross-platform compatibility.
What follows is a rundown of the primary information required for developers who wish to continue the work begun with JDraw. Along with JDraw's javadoc documentation, this overview should provide enough explanation of the system to enable further development.
The top level of the JDraw system consists of three main model/view components: A Commands class which contains the methods available through manipulating the CommandMenu, A Tools class which defines the methods invoked by manipulating the ToolsPalette, and a Canvas class which defines the underlying data representation of the CanvasWindow. Within a JDraw session there can be multiple instances of the Canvas class (representing multiple CanvasWindows open simultaneously).
The Commands class contains all the functionality available through the CommandMenu on-screen component. The Model components of the Commands class are represented by seven Model classes.
The File class, represented by the 'File' menu contains file and system access methods, such as Save, Open, Print, and Close. File operations, with the exception of Open and Exit are performed on the currently active Canvas. The 'Revert' item is not currently implemented.
The Edit class, represented by the 'Edit' menu contains methods for altering the properties of currently selected graphics, such as Cut, Copy, Delete, Paste, Flipping Vertically and Horizontally, and Rotating. It also contains items to Undo and Redo previous actions. All Edit operations are performed on the active Canvas.
The Structure class, represented by the 'Structure' menu contains methods for controlling Group affiliations, z-axis relativity, and viewing the current number of graphics. Structure operations are performed on the active Canvas.
The Text class, represented by the 'Text' menu contains methods for changing the current system Text properties, as well as the properties of any selected TextObject items in the active Canvas. The properties, each with its own sub-menu, are Font Type, Font Size, and Font Style.
The BrushPatternColor class, represented by four different menus (Brush, Pattern, FGColor, and BGColor), contains methods for changing the current creation-time graphic properties (in the Tools class), as well as the properties of currently selected graphics in the active Canvas. Each menu, representing one of the four properties, offers a list of commonly used elements, in addition to the option of a user-defined version of its property.
The Align class, represented by the 'Align' menu contains methods for controlling the relative x and y positions of currently selected graphics in the active Canvas, such as aligning the sides together, aligning the centers, or aligning graphics in series. The 'Align to Grid' item is not currently implemented.
The Options class, represented by the 'Options' menu contains methods for controlling the view properties of the currently active Canvas Window, such as zoom factor. The grid items, along with 'Orientation' are not currently implemented.
The Tools class contains all the functionality available through manipulation of the on screen ToolsPalette component. Tools also contains data members for storing all system-wide properties, such as the currently active tool, the list of active Canvas instances, the system's graphics buffer for pasting, and the creation-time graphic properties. Upon clicking an item in the ToolsPalette, the active tool element is set to indicate the appropriate Canvas manipulation tool.
The Canvas class contains data members for storing all Canvas-exclusive information, including the list of its graphics, the list of its group affiliations, the list of selected graphics' indices, the filename under which the data of this Canvas is currently stored, this Canvas' integer ID, and a boolean value representing whether this Canvas needs to be saved.
Canvas also contains access methods to each of its data members, in addition to methods for adding graphics, determining which graphic (or group of graphics) should be selected, given a point on the Canvas, and rotating the list of selected graphics.
The companion class to Canvas, CanvasWindow contains all the runtime functionality for Canvas manipulation. It contains all data members necessary to adjust and append Canvas' graphics list, based on user interaction. It also contains members for specific Canvas-exclusive data, such as zoom factor and the undo/redo buffers and their corresponding methods.
Its button methods, called from its Key Listener data member define the actions taken given mouse events and the currently active tool integer. CanvasWindow also contains an instance of the CanvasPage class, which defines the methods required to write a Canvas' graphics list to the screen or a printer.
There are many features of JDraw which have not been fully implemented to this point. The following is a list of the unimplemented features:
- The File->Revert Menu Item
- The Edit->Precise Scale... Dialog Box
- Gridding and all of it's Menu Items (see Align and Options Menus)
- Options->Orientation
- File->Import image to currently active drawing( image allows tool manipulation)
- File->Print To File... print support for Unix (write to a Post-Script file)
- Hot Key support (Key Listener is already there)
- Eyedropper from the Tool Bar
- Scaling from the Tool Bar
- Stretching from the Tool Bar
- Edit->Paste should paste in center by default or last place clicked
- Align->fix bugs
- Drawing size comparable to MacDraft
In addition to these changes, JDraw is ripe for a thorough testing process.
JDraw - drawing editor
java jdraw.main
You can use JDraw to create and edit drawings containing graphics like text, lines, curved lines, rectangles, polygons, ellipses, and curved shapes. Drawings are stored in JDraw picture files and can be printed to a printer from Windows or stored in PostScript files for printing in other file systems. The graphics are displayed in a scrollable panel, which expands to fit all the Canvas' graphics. There is a toolbar (in a separate) window to the left of the editor pane and a menu bar (in another window) above the editor.DRAWING TOOLS
The drawing tools lie in a vertical row in the toolbar to the left of the editor pane. Select, Move, Scale, Stretch, Rotate, and Reshape manipulate existing graphics. Text, Line, Multi Line, Curve, Ellipse, Rectangle, Polygon, and (Curved) Shape create new graphics. You can set the current drawing tool by clicking on it in the toolbar. Clicking the left mouse button in the drawing area invokes the current drawing tool. The following are the drawing tools available in JDraw:
SelectSelect a graphic whether or not it's already selected and discard all other selections. If you hold down the shift key, Select retains the previous selections while including an unselected graphic or excluding a selected graphic. If you press the button outside any graphic, you can clear all of the selections or drag a rubber band rectangle around a group of graphics to select all of them together.MoveMove graphics from one spot to another.ScaleScale graphics about their centers (not yet implemented).StretchStretch graphics vertically or horizontally while tying down the opposite edge (not yet implemented).RotateRotate graphics about their centers according to the angle between two radii: the one defined by the original clicking point and the one defined by the current dragging point.ReshapeMove one of a graphic's points and reshape the graphic accordingly. Nothing happens when you try to reshape an ellipse or text object because they don't have any points suitable for dragging.
EyeDropper
A color is selected for the eye dropper fill color by clicking on an object that has the desired color. To fill objects with this color select the object by clicking in its interior.
Text
Create some text. You click where you want to put the text line's upper left corner and then type your text. Text is terminated when you hit the 'Enter' key.LineCreate a line. The line begins at the point where you press the left mouse key and ends where the left mouse key is released.Multi LineCreate a set of connected lines. A control point is placed each time the left key is pressed and the final point is placed when the right button is pressed.CurveCreate an open set of Bezier curves. A control point is placed each time the left key is pressed and the final point is placed when the right button is pressed.EllipseCreate an ellipse. One corner resides at the point where you press the left mouse key and the opposite corner resides where the left mouse key is released.RectangleCreate a rectangle. One corner resides at the point where you press the left mouse key and the opposite corner resides where the left mouse key is released.PolygonCreate a polygon. A control point is placed each time the left key is pressed and the final point is placed when the right button is pressed. The polygon is closed by connecting the final point with the first control point.ShapeCreate an closed set of Bezier curves. A control point is placed each time the left key is pressed and the final point is placed when the right button is pressed. The shape is closed by connecting the final point with the first control point.
The pull-down menus File, Edit, Structure, Text, Brush, Pattern, FGColor, BGColor, Align, and Options lie in the menu bar above the editor pane. They contain commands which you execute by pulling down the menu and releasing the mouse button on the command.
The File menu contains the following commands to operate on files:
NewOpen a new graphics editor pane, which is blank.RevertReread the currently active drawing, destroying any unsaved changes (not currently implemented).Open...Open a '.jdr' file and draw its graphics in a new editor pane.Save As...Save the currently active drawing in a file whose name you type.SaveSave the currently active drawing in the file it came from.CloseClose the currently active drawing editor.
Import
Print...Import a .jpeg image to the currently active drawing editor.
Print the currently active drawing to a printer in the Windows environment. The printer can be selected from the Print Dialog.ExitExits the JDraw environment.
The Edit menu contains the following commands to edit graphics:
UndoUndo the last done change to the drawing. Successive Undo commands undo earlier and earlier changes back to the last stored change.RedoRedo the last undone change to the drawing. Successive Redo commands redo later and later changes up to the first change undone by Undo. Any new changes cause all undone changes to be forgotten.CutRemove the selected graphics from the currently active drawing and place them in a temporary graphics buffer.CopyCopy the selected graphics from the currently active drawing into a temporary graphics buffer.PastePaste a copy of the graphics in the graphics buffer (if any) into the currently active drawing.DuplicateDuplicate the selected graphics in the currently active drawing and add the copies to the currently active drawing.DeleteDestroy the selected graphics in the currently active drawing.Select AllSelect every graphic in the currently active drawing.Flip Horizontal, Flip VerticalFlip the selected graphics in the currently active drawing into their mirror images along the horizontal or vertical axes.90 Clockwise, 90 CounterCWRotate the selected graphics in the currently active drawing 90 degrees clockwise or counter clockwise.Precise Move..., Precise Scale..., Precise Rotate...Move, scale or rotate graphics by exact amounts which you type in a dialog box. You type movements in units of screen pixels and rotations in degrees. Precise Scale... is not currently implemented.
The Structure menu contains the following commands to modify the structure of the drawing:
GroupGive the selected graphics the properties of a single graphic. When any of the graphics within the group are manipulated, the changes affect all graphics in the group.UngroupDissolve the group consisting of all selected graphics (if any).Bring To FrontBring the selected graphics to the front of the drawing so that they are drawn on top or (after) the other graphics in the drawing.Send To BackSend the selected graphics to the back of the drawing so that they are drawn behind (before) the other graphics in the drawing.Number of GraphicsCount and display in a pop up window the number of selected graphics. If no graphics are selected, the total number of graphics in the drawing is displayed.
The Font menu contains sub-menus for choosing Font properties. The properties available are Font Type, Font Size, and Font Style. The Font properties are set for all selected Text Objects as well as any which are subsequently created.
The Brush menu contains a set of brushes with which to draw lines, as well as an item to create your own brush. When you set the current brush in the menu, you will also set all the selected graphics' brushes to that brush. The Brush menu also contains a submenu Fill. The Fill menu has commands for choosing the Foreground Color, Background Color and a Pattern submenu.
The Pattern menu contains a set of patterns with which to fill graphics, as well as an item to create your own pattern. When you set the current pattern from the menu, you will also set all the selected graphics; patterns to that pattern.
The FGColor and BGColor commands contain a set of colors with which to draw graphics and text, as well as an item to create your own color. When you set the current foreground or background color from the menu, you will also set all the selected graphics' foreground or background colors.
The Align menu contains commands to align graphics with other graphics. For series alignments, graphics are organized in the order they were selected. 'Align to Grid' is not currently implemented.
The Option menu contains the following commands:
ReduceReduce the magnification of the currently active editor pane by a factor of two so that the drawing's size is decreased by half.EnlargeEnlarge the magnification of the currently active editor pane by a factor of two so that the drawing's size is doubled.Normal SizeSet the magnification to unity so that the drawing appears at actual size.HomeReset the currently active editor's pane to the home position (if scrolled).Gridding on/offToggle the grid's constraining effect on or off (not currently implemented).Grid visible/invisibleToggle the grid's visibility on or off (not currently implemented).Grid Spacing...Change the grid spacing using a dialog box (not currently implemented).
Important: You must have Java installed on your computer to run JDraw.
Download the JDraw jar file from here
Unpack the jar file on your system by entering an MS-DOS prompt, changing to the directory in which you saved it, and typing 'jar xf jdraw.jar'.
Change to the 'jvm' directory and type 'java jdraw.main' to run the program.
Note: If your classpath is currently set, JDraw may not run properly. Reset your classpath by typing 'SET CLASSPATH=;'.
Enjoy! Please send comments to charleskrebs@charter.net