Michael Thomas Flanagan's Java Scientific Library

DigiGraph Class:      Digitizing Points on a Graph

     

Last update: 3 December 2008                                                                                                                              Main Page of Michael Thomas Flanagan's Java Scientific Library

This class contains the methods for digitizing points on a graph. The graph must be presented in one of the following graphical formats:

        GIF     [Graphical Interchange Format]     (.gif, .GIF)
        JPEG     [Joint Photographic Experts Group]     (.jpg, .JPG, .jpeg, .JPEG, .jpe, .JPE, .jfif, JFIF)
        PNG     [Portable Network Graphics]     (.png, .PNG)

SUMMARY OF CONSTRUCTOR AND METHODS

Constructors public DigiGraph()
public DigiGraph(String windowPath)
Digitize points on the graph public void digitize()
public void digitise()
Reset window height public void setWindowHeight(int height)
Reset window width public void setWindowWidth(int width)
Reset window closing option public void setCloseChoice(int option)
Reset axes rotation tolerance public void setRotationTolerance(double tol)
Block digitised data plot public void noPlot()
Retain identical points public void keepIdenticalPoints()
End the program public static final synchronized void.endProgram()
System.exit(0)

CONSTRUCTORS AND METHODS

CONSTRUCTORS
public DigiGraph()
public DigiGraph(String windowPath)
Usage:                      DigiGraph dg = new DigiGraph();
Creates a new instance of DigiGraph. A file selection window will appear, if this constructor is used, allowing the user to select the GIF, JPEG or PNG file containing the graph to be digitized. The window will open on your system's default initial directory.

On selecting the required GIF, JPEG or PNG file a dialog box will appear requesting the path\name of the output .txt file. The default path for the output file is to the directory in which the selected image file is stored and the default name is the name of the selected file with"_digitized" added. The path name must conform to the convention of the operating system, e.g. if a Microsoft System is being used, an example would be "C:\\Digitization\\Image_Files\\imageOne_digitized.txt". The output file will be stored in the same directory as the calling program if a name is entered without a directory path, e.g."imageOne_digitized.txt".

On entering an output file name a new dialog box will open requesting the number of decimal places required in the digitised values in the output file. The default option is 16.

On entering the required number of decimal places the selected image will be displayed in a new window. It may open as a minimized icon bar in the top left hand corner of the screen

If so click on the maximize icon (square icon second from the right) to restore a full window displaying the selected image.
The digitization of points on the image require the method digitize() to be called (see below).


Usage:                      DigiGraph dg = new DigiGraph(windowPath);
Creates a new instance of DigiGraph. A file selection window will appear, if this constructor is used, allowing the user to select the GIF, JPEG or PNG file containing the graph to be digitized. The window will open in the directory provided by the argument windowPath. The path name must conform to the convention of the operating system, e.g. if a Microsoft System is being used, an example would be "C:\\Digitization\\Image_Files"
On selecting the required GIF, JPEG or PNG file a dialog box will appear requesting the path\name of the output .txt file. The default path for the output file is to the directory in which the selected image file is stored and the default name is the name of the selected file with"_digitized" added. The path name must conform to the convention of the operating system, e.g. if a Microsoft System is being used, an example would be "C:\\Digitization\\Image_Files\\imageOne_digitized.txt". The output file will be stored in the same directory as the calling program if a name is entered without a directory path, e.g."imageOne_digitized.txt".

On entering an output file name a new dialog box will open requesting the number of decimal places required in the digitised values in the output file. The default option is 16.

On entering the required number of decimal places the selected image will be displayed in a new window. It may open as a minimized icon bar in the top left hand corner of the screen

If so click on the maximize icon (square icon second from the right) to restore a full window displaying the selected image.
The digitization of points on the image require the method digitize() to be called (see below).



DIGITIZE
public void digitize()
public void digitise()
The methods digitize and digitise are identical.
Usage:                      dg.digitize();
This method allows the points on a graph to be digitised. The GIF, JPEG or PNG file, containing the graph, supplied via the constructor initiated select window or constructor argument, is displayed in a window. Throghout the digitization the current digitization instruction is displayed above the selected image. To digitize points: Usage:                      dg.digitise();
The methods digitise and digitize (see immediately above) are identical.



SELECT WINDOW DIRECTORY PATH
Reset the path to the initially displayed directory
public void setPath(String path)
Usage:                      dg.setPath(path);
This method allows the path to the directory displayed in the select file box to be reset. The format of the path String must conform to the convention of the operating system, e.g. if a Microsoft System is being used, an example of path would be "C:\\Java_Programming\\Digitization\\Image_Files".



RESET THE HEIGHT OF THE GRAPH WINDOW
public void setWindowHeight(int height)
Usage:                     dg.setWindowHeight(height);
Resets the height, in pixels, of the graph window. Overwrites the preset value which is your computer's screen height - 40 pixels.



RESET THE WIDTH OF THE GRAPH WINDOW
public void setWindowWidth(int width)
Usage:                     dg.setWindowWidth(width);
Resets the width, in pixels, of the graph window. Overwrites the preset value which is your computer's screen width - 30 pixels.



RESET THE WINDOW CLOSING OPTION
public void setCloseChoice(int closeChoice)
Usage:                     pg.setCloseChoice(closechoice);
Resets the window closing option:

RESET THE AXES ROTATION ANGLE TOLERANCE
public void setRotationTolerance(double tolerance)
Usage:                     dg.setRotationTolerance(tolerance);
If the ordinate (y) and abscissa (x) axes are not coincident with the vertical and horizontal both the axes and the data are rotated to bring the axes in line with the vertical and horizontal. This rotation is applied if the mean angle of divergence of the x and y axis from the horizontal and vertical respectively is greater than a set tolerance. The preset value of the tolerance is zero degrees, i.e. the axes are rotated if the axes are not coincident with vertical and horizontal. This method allows this preset tolerance to be replaced by the user's value, in degrees, through this method's argument tolerance.



BLOCK THE DIGITIZED DATA AND THE INTERPOLATED DATA PLOTS
public void noPlot()
Usage:                     dg.noPlot();
A plot of the digitized data is automatically displayed and, if the interpolation option (see
digitize above) has been chosen, this plot will also display the interpolated data. Calling this method, noPlot(), blocks this plot from being displayed.



RETAIN ALL IDENTICAL POINTS
public void keepIdenticalPoints()
Usage:                     dg.keepIdenticalPoints();
The default option of this class is to search for identical digitized points and remove all but one instance of each set of identical points as these usually arise from accidently clicking the mouse more than once while sat on a point. Calling this method causes this check to be skipped and all identical points are retained..



ENDING AN APPLICATION THAT USES DigiGraph
public void endProgram()
Usage:
                     dg.endProgram();

This method displays a dialogue box that asks if you want to end the program. Answering yes ends the program. Answering no displays a message telling you how you may now end the program. Ending the program also closes the graph window.

Any application that you write that displays a graphical user interface, as the digitize method in this class, DigiGraph, does, must be terminated:
  1. with the line System.exit(0);
  2. or by calling a method that contains that statement, e.g. by calling endProgram()
  3. or, in the special case of DigiGraph, by closing the graph window if window closing option (see setCloseChoice above) is set at 1, i.e. at the default option.
Options 2 or 3 are recommended in the case of applications using DigiGraph.



EXAMPLE APPLICATION

RunDigiGraph is a simple application calling DigiGraph. Users must provide their own image files

Listing of the source code, RunDigiGraph.java



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:



This page was prepared by Dr Michael Thomas Flanagan