FuncPlotter is a combined Java application and applet for displaying two-dimensional
plots of explicit functions in one variable (ie, functions of the form
y = f(x), where f(x) is an arbitrary
function composed from a set of common mathematical operators). It is distributed under
version 3 of the GNU General Public
License; for details, see the file license.txt
that is included in the
FuncPlotter distribution.
FuncPlotter has the following features:
In this document, FuncPlotter's two operating modes are referred to as application mode and applet mode. Any part of this document that is specific to one mode is drawn with left and right borders in the appropriate colour.
The website of the FuncPlotter project is at http://funcplotter.sourceforge.net/ .
To run as an application, FuncPlotter requires a Java runtime environment that supports Java SE 7 (Java 1.7), such as Oracle's Java Runtime Environment (JRE), version 7 or later.
To run as an applet, FuncPlotter requires a web browser that supports Java SE 7 (Java 1.7) applets. Plug-in components for Java applets are available for most common browsers. Oracle's Java Plug-in is included in its JRE.
The following files are included in the distribution:
funcPlotter.jar | The executable JAR (Java archive) file that is used for both the FuncPlotter application and the applet. |
funcPlotter-config.xml | The configuration file for FuncPlotter, which contains the default values for the configuration properties. |
license.txt | A copy of the licence under which FuncPlotter is distributed (GNU General Public License, version 3). |
docs/manual.html docs/images/*.png docs/scripts/*.js docs/style/*.css |
This manual, its image files, scripts and stylesheets. Any modifications to the manual for the latest version of FuncPlotter will appear in the online version of the document, to which there is a link on the FuncPlotter website. |
dtd/functionList.dtd | The DTD (document type definition) of a FuncPlotter document in XML format. (FuncPlotter does not use the DTD; it is provided only for reference.) |
example/example.xml example/example.txt |
Examples of a FuncPlotter document in the two formats supported by the application. The examples both contain the same arbitrarily chosen functions. |
example/applet1.html example/applet2.html example/applet3.html example/applet4.html |
Examples of how the FuncPlotter applet can be included in an HTML document. The
first three files correspond to one of the numbered HTML fragments, HTML fragment 1, HTML fragment
2 and HTML fragment 3. The fourth file is an
example of how JavaScript can be used to generate an HTML
<object> element according to the type of browser.
|
images/funcPlotter.png images/funcPlotter.ico |
A 48×48-pixel PNG image and a 48×48-pixel Windows-format icon that can be used to customise a desktop icon for the FuncPlotter application. |
Note: FuncPlotter is distributed without an automated means of installation. Because of this, the instructions below assume a certain level of technical knowledge. In particular, the installation of FuncPlotter as an application requires knowledge of environment variables and command lines appropriate to the system on which FuncPlotter is to be installed, while the installation of FuncPlotter as an applet requires knowledge of how Java applets are included in HTML.
FuncPlotter consists of a single JAR (Java archive) file, funcPlotter.jar
.
It may be used with a configuration file,
funcPlotter-config.xml
, which contains user
preferences. Of the files listed in the contents of the
distribution, only the JAR file is required.
The installation of FuncPlotter consists of two stages: copying the JAR file — and, optionally, the default configuration file — to your system, and providing a means of invoking the JAR file. The more advanced topic of configuring FuncPlotter after installation is dealt with in the section on configuration.
The first stage is simple: copy the file funcPlotter.jar
to a suitable
location on your system. The next stage depends on whether you want to use FuncPlotter
as an application or as an applet. (The same copy of funcPlotter.jar
can
be used in both modes, but the method of invocation differs between application and
applet.)
When you installed a Java runtime environment, it may have created an association between JAR files and its Java launcher. (This is normally the case with Oracle's Java Runtime Environment on Linux or Windows.) If so, or if you have created the association yourself, you will be able to run FuncPlotter as an application by double-clicking on a representation of its JAR file on the platform's desktop (eg, an icon in a file manager, in a menu of programs or on the desktop itself). When you run FuncPlotter in this way, it will read a configuration file from the current working directory or the default directory unless you have specified otherwise in the icon's properties.
Alternatively, you can run FuncPlotter as an application by invoking the
java
launcher tool from a command line and supplying the location of the
JAR file as an argument. The command line may contain configuration properties, including the location of a
configuration file. The following subsections describe how to run FuncPlotter from a
command line.
Assuming that your PATH
environment variable includes the path to the
java
tool and that you have copied funcPlotter.jar
to the
directory /home/slothrop/bin/funcplotter/
, the command
will run the FuncPlotter application.
The file funcPlotter.png
can be used as the icon for the FuncPlotter
application.
The FuncPlotter application does not require a console window, so you can use the
javaw
launcher rather than the java
launcher unless you
particularly want a console window. Assuming that your PATH
environment
variable includes the path to the javaw
tool and that you have copied
funcPlotter.jar
to the directory
C:\Program Files (x86)\FuncPlotter\
, the command
will run the FuncPlotter application.
The file funcPlotter.ico
can be used as the icon for the FuncPlotter
application.
You can have the FuncPlotter application open one or more files on startup by specifying the files on the command line after the name of the JAR file. Thus, extending the example for Linux/UNIX given above, the command
would launch FuncPlotter and open the file hyperbolic.xml
.
Note that the Java launcher expands command-line arguments in the same way as a UNIX shell: pathnames that contain wildcards are replaced with multiple pathnames of files that match the pattern.
Since FuncPlotter was first released, JavaScript in its various flavours has become established as the preferred way of embedding functionality such as FuncPlotter's in a web page. Because the use of FuncPlotter as an applet has become obsolete, no effort has been made to update this section for HTML5.
FuncPlotter can be run as an applet by including an <applet>
or
<object>
element in an HTML or XHTML document. Configuration properties may be specified in applet parameters — <param>
elements
within the <object>
or <applet>
element.
Under strict HTML 4.01 and XHTML, a Java applet must be included in HTML or XHTML
using the generic <object>
element; the <applet>
element is deprecated. As described in the HTML 4.01 specification,
the inclusion of Java applets in HTML with the <object>
element is
straightforward. In reality, however, things are rarely so simple, especially where
Microsoft is concerned. Microsoft decided not to include support for Java applets as
<object>
elements in Internet Explorer in the straightforward way
described in the HTML specification. Instead, if you are using Internet Explorer on
Windows and want IE to render a Java applet using the <object>
element, the Java Plug-in must be specified as the classid
attribute of
the <object>
element, and the applet and its codebase as
<param>
elements. This awkward, proprietorial method is not
compatible with conforming browsers like Firefox, so you must either sacrifice (X)HTML
conformity or have two separate pages, one for IE and one for browsers like Firefox
that recognise the application/x-java-applet
MIME type. Alternatively,
you can use JavaScript to detect the browser type and to generate the appropriate
HTML.
Oracle's guide
to including Java applets in HTML says that "the [HTML 4.01] specification is
vague about how browsers should implement the object
tag to support Java
applets, and browser support is currently inconsistent." The specification of the
<object>
element (HTML
4.01, section 13.3) appears to be sufficient for the implementation of support for
Java applets — after all, it's no less detailed or more ambiguous than the
specification of the <applet>
element, which, because of its
widespread support, is Oracle's recommended means of including applets in HTML.
The following fragments of HTML illustrate different ways in which the FuncPlotter
applet can be included in a page of HTML. Three HTML files,
applet1.html
, applet2.html
and applet3.html
,
are included in the FuncPlotter distribution as examples of the use of each fragment.
A fourth HTML file, applet4.html
, illustrates the use of JavaScript to
generate an <object>
element — either fragment 1 or fragment
2, according to the type of browser. In the fragments and the example files, the
values for the codebase
attribute and the app.configDir parameter assume the following arbitrary
directory tree:
All three fragments contain a plot size parameter, app.plot.size, and a function list size parameter, app.function.listSize. If a configuration file exists
and the security manager permits it to be read, the value of the property in the
configuration file will override the value that is specified in the
<object>
or <applet>
element.
This fragment uses the <object>
element to include FuncPlotter as
an applet in an HTML document. It conforms to the HTML 4.01 Strict and XHTML 1.1
DTDs, but it won't work with Internet Explorer.
The codetype
attribute denotes the MIME type of the object: a Java
applet. The version number (1.6) indicates the minimum version of JRE required by the
applet.
<object codetype="application/x-java-applet;version=1.6" classid="java:FuncPlotter" codebase="jar/" archive="funcPlotter.jar" width="937" height="537"> <param name="app.configDir" value="../../config"/> <param name="app.plot.size" value="480, 480"/> <param name="app.function.listSize" value="24, 12"/> The browser may not support Java applets as <em><object></em> elements.<br/> </object>
This fragment also uses the <object>
element to include FuncPlotter
as an applet in an HTML document. It conforms to the HTML 4.01 Strict and XHTML 1.1
DTDs. It will work with Internet Explorer but not with Firefox.
The value of the classid
attribute was obtained from the JDK
documentation. It is associated in the Windows registry with the highest installed
version of Java Plug-in.
The <object>
element should properly have a codebase
attribute that denotes a URI from which an appropriate version of Java Plug-in can be
loaded if it is not already installed. The example assumes that Java Plug-in is
already installed.
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="937" height="537"> <param name="code" value="FuncPlotter"/> <param name="codebase" value="jar/"/> <param name="archive" value="funcPlotter.jar"/> <param name="app.configDir" value="../../config"/> <param name="app.plot.size" value="480, 480"/> <param name="app.function.listSize" value="24, 12"/> The FuncPlotter applet requires a browser with Java Plug-in version 7 or later installed.<br/> </object>
This fragment uses the <applet>
element to include FuncPlotter as
an applet in an HTML document. It conforms to the HTML 4.01 Transitional DTD. It is
known to be compatible with Internet Explorer and Firefox, and it may be compatible
with other browsers.
<applet code="FuncPlotter" codebase="jar/" archive="funcPlotter.jar" width="937" height="537"> <param name="app.configDir" value="../../config"/> <param name="app.plot.size" value="480, 480"/> <param name="app.function.listSize" value="24, 12"/> The browser may not support Java applets as <em><applet></em> elements.<br/> </applet>
<object>
element
If you want to include the FuncPlotter applet in a document that conforms to the
strict HTML 4.01 or XHTML specification, you must use the <object>
element to do so. If you also want a single document that can be used with a range of
popular browsers, the recommended way to do this is with JavaScript. The file
applet4.html
shows how this can be done by including the script within an
HTML document. In practice, it would be better to remove the JavaScript to a function
in a separate file, and to invoke the function from an event handler such as an
onload
handler in the <body>
element, which is the
method that is used by the applet page on the
FuncPlotter website.
If a script is used to generate the HTML that includes the FuncPlotter applet in a
document, it can also extract configuration parameters for the applet from the query
part of the document's URL, then generate the <param>
elements
for the parameters, avoiding the need to include the applet's configuration
parameters in the HTML.
In order for the FuncPlotter applet to be displayed correctly, you must set the
width
and height
attributes of the
<object>
or <applet>
element that invokes the
FuncPlotter applet so that the dimensions of the applet are not less than
FuncPlotter's preferred dimensions. If the applet dimensions are too small, the
plot panel and function list will be reduced to their minimum size, and
FuncPlotter's display will appear to have collapsed. To discover the preferred
dimensions of the FuncPlotter applet, run the applet: the preferred dimensions are
displayed on the Java console and, if either dimension is too small, in an error
message. Note that the preferred dimensions may change as a consequence of modifying
some of FuncPlotter's configuration properties (eg, plot size or fonts), and you
will have to modify the width
and height
attributes of the
<object>
or <applet>
element accordingly.
The applet can be configured to display one or more specified functions on specified x and y intervals when it starts up. The properties app.startup.xInterval, app.startup.yInterval and app.startup.function.<index> are used for this purpose. In the function property, <index> is the zero-based three-digit index of the function (eg, app.startup.function.002 denotes the third function).
The syntax of the x and y intervals and the function definitions is the
same as that of the interval and function definitions in a text-format file except that the x and y
intervals do not have a prefix of '@x
' or
'@y
'.
A Java application with a graphical user interface (GUI), such as FuncPlotter, usually has its own top-level window. An applet, on the other hand, usually runs in a window of a browser, where the components of the applet's GUI become components of the browser's window. Problems may arise from the interaction of the applet's components with the browser's window; one notable problem is the transfer of keyboard focus. FuncPlotter follows the recommendation in the Java documentation for requesting focus. The following (seemingly related) problems have been observed in the past, though not with combinations of recent versions of browsers and Java runtime environments:
FuncPlotter does not have an automated means of uninstallation. To remove it from your
system, delete the file funcPlotter.jar
from the location to which you
copied it when you installed FuncPlotter. If you want to remove FuncPlotter completely,
you should also delete the configuration file, funcPlotter-config.xml
,
which may be at its default location.
Some of the functionality of FuncPlotter — in particular, access to the file system and clipboard — may be restricted by the protection mechanisms of the Java virtual machine on which it is run. Different restrictions are likely to apply according to whether FuncPlotter is run as an application or as an applet: read the relevant section before you run FuncPlotter.
FuncPlotter is distributed as a signed JAR file. The JAR file is self-certificated (ie, it's signed by the author of the software, not with a certificate from a recognised certification authority). The purpose of signing the JAR file is to allow users that trust its digital signature to access features of FuncPlotter that are disabled for untrusted code. As a general policy, it is recommended that you trust the signature of a JAR file no more than is necessary to obtain the functionality that you require. In the case of FuncPlotter, if you can do without accessing the file system (to read a configuration file) and the clipboard (to copy and paste expressions), there is no need to trust FuncPlotter when prompted to do so.
Because FuncPlotter's source code is freely available, it is possible, without much effort, to build a modified version of FuncPlotter that contains malicious code, and to distribute the resulting JAR file with a bogus signature, so the presence of a signature does not in itself confer any security. The recommended method of verifying the integrity of FuncPlotter is to verify the SHA-1 hash value of the entire FuncPlotter distribution against the values in the release notes on SourceForge.
The security restrictions that are imposed on an application running on a Java virtual machine are determined by the security manager and security policy that are in force on a particular system. If no security manager is specified, the default security manager will permit all the functionality of FuncPlotter (that is, FuncPlotter will be implicitly trusted); otherwise, similar restrictions to those imposed on an applet are likely to apply.
Browsers generally have a security manager that restricts access to the file system and clipboard for untrusted applets. This section assumes that you are using Oracle's Java Plug-in to run the applet from within a browser.
When the FuncPlotter applet is run, the Java plug-in will detect that the JAR file is signed and — unless you have previously agreed always to trust its signature — will inform you that the certificate is invalid, is not trusted or cannot be verified because it was not issued by a recognised certification authority. It will then ask you whether you want to run the applet. (The wording of the response of the Java plug-in to a signed applet varies with the browser and the version of the Java plug-in.) If you don't need the features that are enabled as a consequence of trusting the applet, don't agree to trust it, especially if you don't know its provenance. Be aware that, if you agree always to trust the signed applet, you will be implicitly granting trust to all other applets that have the same signature, so it's important that you are sure of the authenticity of the signature before you do so. (You can use the Java control panel to remove a no-longer-trusted certificate, but the damage may already have been done by then.)
Oracle's Java Plug-in adds a warning, "Java Applet Window", to windows that are created by untrusted applets. A window includes a tooltip or a pop-up menu that extends beyond the bounds of the applet.
When it starts up, FuncPlotter is configured from different sources according to whether it is run as an application or as an applet.
Both the application and the applet can get their configuration from a configuration
file whose location may be specified. In addition, the application can be configured
with command-line properties (specifically, the command line that is used to run the
Java launcher), and the applet can be configured with parameters of the HTML
<object>
or <applet>
element.
The recommended method of setting the properties in a configuration file is with the Options > Preferences command from within the FuncPlotter application. Like the other menu commands, this command is not available when FuncPlotter is run as an applet, although it is possible to run FuncPlotter as application in order to generate or to edit a configuration file that is used by FuncPlotter in applet mode. Command-line properties and HTML applet parameters must necessarily be edited manually; the form of the property values is given in the appendix on configuration properties, and it can also be inferred from the sample configuration file.
When FuncPlotter is run by means of the java
launcher, configuration
properties may be specified in the command line using the standard Java form
-Dname="value"
; eg,
-Dapp.plot.size="480, 480"
. (The quotation marks around
the value aren't necessary if the value doesn't contain spaces.)
FuncPlotter's command-line configuration properties all have the prefix
app.
. A list of all the properties that are recognised by FuncPlotter is
given in the appendix on configuration properties.
One particular property, app.configDir, is used to specify the directory that contains a configuration file:
If the configuration file were located in a directory named config
in the
user's home directory, the sample command lines given above would become:
Linux/UNIX: | java -Dapp.configDir="~/config" -jar /home/slothrop/bin/funcplotter/funcPlotter.jar |
Windows: | javaw -Dapp.configDir="~/config" -jar "C:\Program Files (x86)\FuncPlotter\funcPlotter.jar" |
The value of the app.configDir property may contain special constructs for system properties, environment variables and the user's home directory.
When FuncPlotter is run as an applet, configuration properties may be specified as
<param>
elements within the <object>
or
<applet>
element that is used to include the FuncPlotter applet in
an HTML document. The <param>
element takes the form
<param name="name"
value="value"/>
. FuncPlotter's applet configuration
properties all have the prefix app.
. A list of all the properties that
are recognised by FuncPlotter is given in the appendix on configuration properties.
One particular property, app.configDir, is used to specify the directory that contains a configuration file. If the app.configDir property exists, FuncPlotter will look for a configuration file at that location.
If the scheme of the URL denoted by the app.configDir property is "file
",
the property value may contain special constructs for system
properties, environment variables and the user's home directory. If you run
FuncPlotter as an unsigned or untrusted applet, your browser's security manager
may prevent the applet from accessing some system properties or environment variables.
In such cases, the property or variable will have the value of the empty string, but
it's likely that the same security policy would also prevent the applet from
reading a configuration file.
The configuration file, which must be named funcPlotter-config.xml
, is an
XML file that is ordinarily written by FuncPlotter but can be edited manually if you
know what you're doing. (It can also be edited manually if you don't
know what you're doing, but this is not recommended.) FuncPlotter doesn't
require a configuration file — or any of the alternative methods of configuration,
for that matter: it uses a default value for any configuration property that is missing
from the source(s) of configuration. Similarly, if it finds a property value to be
invalid, FuncPlotter will display a message to this effect and use its default value.
In application mode, a configuration file takes precedence over configuration properties in the command line; that is, if the same property is specified as a command-line property and in a configuration file, the value from the configuration file is used.
If the configuration has changed when you exit the application normally (ie, using the File > Exit command or an equivalent), FuncPlotter will save its configuration to a configuration file. If a configuration file was read on startup, it will overwrite that file; otherwise, it will write a configuration file to the default directory described above.
A configuration file can be written explicitly with the Save configuration command within the Preferences dialog.
In applet mode, a configuration file takes precedence over HTML applet parameters; that is, if the same configuration property is specified as an HTML parameter and in a configuration file, the value from the configuration file is used.
When it starts up, the FuncPlotter application is informed of the location of the
configuration file with the app.configDir property, which may be set on the
command line that runs the java
launcher. The existence of a system
property with the key app.configDir determines the
locations that are searched for a configuration file:
$PWD
on Linux/UNIX
systems) depends on the system and the way in which FuncPlotter was invoked. The
default directory is ${user.home}/.blankaspect/funcPlotter
, where
${user.home}
is the user's home directory (the directory denoted
by the environment variable $HOME
on Linux/UNIX systems or
%USERPROFILE%
on Windows systems).
The FuncPlotter applet is informed of the directory that contains the configuration
file with the app.configDir property, which may be set as a
parameter in the HTML <object>
or <applet>
element. A browser's security manager may prevent an untrusted applet from
reading a configuration file.
FuncPlotter uses a tabbed document interface to display multiple documents in application mode. This kind of interface has a single tabbed window in which only one document — referred to as the current document — is visible at any one time. You can select a document by clicking on its tab, or you can select a document from the alphabetically ordered list that is displayed by clicking on the down-arrow button at the right of the tab bar. You can move between documents by pressing Ctrl+PageUp and Ctrl+PageDown.
You can copy x and y intervals between documents using the command Edit > Copy intervals to other documents.
The size of the main window cannot be changed directly, but it can be changed indirectly by modifying the dimensions of the plot and the dimensions of the list of functions. Changes to these properties will not take effect until the next time that FuncPlotter is run. Some of the other configuration properties (eg, the fonts) may also affect the size of the main window.
FuncPlotter's display consists of a main window divided into several panels. On the left side of the main window is the plot panel, which contains plots of the current set of functions. By default, the functions are drawn over a grid of horizontal and vertical lines, but the grid can be hidden from view. The scales of the horizontal dimension (the x scale) and the vertical dimension (the y scale) are always linear.
Like the other numeric values that are displayed by FuncPlotter, the scale markings are subject to rounding. The most important consequence of rounding is that, while the displayed value of the scale marking is always the nearest value (after rounding) for the x or y pixel coordinate of the scale marking, there may be another pixel coordinate that is nearer to the displayed value of the scale marking. If, as a result of rounding, two or more consecutive scale markings have the same value, the duplicate values are not displayed. The text of an x-scale marking is either omitted or truncated according to the plot.truncateXScaleText configuration property if it would overlap the text of the previous marking. The text of a y-scale marking is truncated if it is too wide to be displayed in full. If the text of a scale marking is truncated or omitted, the full text is displayed when the mouse cursor is moved over the region of the truncated or omitted text.
In addition, the following aspects of the plot panel are configurable:
Although the plot panel has no scroll bars, the plot can be scrolled by four methods:
The unit of scrolling is half a grid division in each direction.
To maintain consistency between actual and displayed interval values when the plot panel is scrolled or zoomed, the actual x and y intervals are updated to values that are as close as possible to the intervals that are displayed in the interval fields (see below). The plot.numFractionDigits configuration property determines the granularity of an interval and affects the ability to scroll or to zoom: the more fraction digits, the further you are able to zoom in. As you zoom in, the scrolling increment (half a grid division) approaches the difference between distinct values in the interval. Near the limit, scrolling behaviour becomes irregular, and the ability to scroll eventually disappears.
FuncPlotter plots a function y = f(x) by evaluating y for the values of x that correspond to pixel divisions on the current x interval, and drawing line segments between successive points, (xn, yn) and (xn+1, yn+1).
FuncPlotter uses the mathematical operators and methods of the Java language to evaluate
f(x). The Java operators and methods, which are based on the IEEE 754
standard, sometimes result in an infinity (positive or negative) or a
Not-a-Number (NaN) value. For example, division of a finite number by zero
results in a signed infinity, whereas taking the natural logarithm of a negative number
with the method java.lang.Math.log
results in NaN. When evaluating an
expression, an NaN that appears as an intermediate result is transmitted to the final
result. If the value of yn = f(xn)
is an NaN, FuncPlotter does not draw a line segment between
(xn−1, yn−1) and
(xn, yn) or between
(xn, yn) and
(xn+1, yn+1). This behaviour is
usually what you would expect; for instance, the plot of the function
y = ln x is confined to the right of the y axis.
Expressions for f(x) that involve operators such as acos
or
sqrt
are plotted only for the principal values of f(x) that
are returned by the underlying Java methods. (In the case of
y = acos x, y is confined to the range [0, π],
whereas for y = sqrt x, y is confined to the
positive root of x.)
Two significant problems in the way in which FuncPlotter plots functions have come to light so far. These problems are not bugs but artifacts — unwanted consequences of the design of the software. The join-the-dots approach works adequately for most functions, but periodic functions and functions with an infinite discontinuity each have a problem associated with them.
When plotting periodic functions, FuncPlotter exhibits the problem of aliasing, which occurs when the sample period — the difference between successive x values at which the function is evaluated — is greater than or equal to twice the period of the function. This effect can be observed by plotting a simple periodic function, such as y = sin x, and repeatedly reducing the magnification. The problem of aliasing could be mitigated by oversampling, but it would still occur eventually, and the oversampling would increase the computational burden of plotting a function.
Functions that have an infinite discontinuity — eg, y = (x + 1) / (x − 1), which has a vertical asymptote at x = 1 — suffer from a "cropped tail": the plot of the function stops some way short of its (unattainable) goal of positive or negative infinity. If xd is a value of x in the x interval of the plot at which there is an infinite discontinuity, {xn} is the set of values of x for which f(x) is evaluated by FuncPlotter when plotting y = f(x), and xnd is the member of {xn} that is nearest to xd, then the "cropped tail" artifact occurs when f(xnd) lies within the y interval of the plot or when f(xnd) is NaN. The severity of the problem is determined by how close xnd is to xd; hence, the problem is sensitive to changes in the x interval. (For instance, a "tail" may appear and disappear as a plot is scrolled horizontally.) Like the problem of aliasing, the problem of infinite discontinuities could be mitigated by oversampling.
Functions that are periodic and have infinite discontinuities (eg, y = sec x) don't look too good when drawn by FuncPlotter at low magnification.
At the top right of the display is a panel containing a list of the functions that comprise the current document, and a group of buttons that relate to the list of functions.
Each row of the function list contains an expression for f(x) next to a sample of the colour in which the function is plotted; see Expressions for details of the syntax and semantics of expressions. An expression is truncated with an ellipsis if it is too long to fit within the width of the function list. If an expression is truncated, the full expression can be displayed in a pop-up window by holding down the Ctrl key and pressing the left mouse button while the mouse cursor is over the expression.
If the function is hidden with the Hide command, the colour sample is absent. If the function is obscured because another function has been highlighted with the Highlight command, the colour-sample box is empty (ie, only the border of the box is drawn.) The colour of each function can be edited. The default function colours are configurable.
Functions are plotted in reverse order from the order in which they appear in the list. This means that the function at the top of the list will be drawn on top of all the functions that are below it in the list. The position of a function in the list can be changed by dragging the function up or down the list with the mouse, or by pressing Ctrl+Shift+Up or Ctrl+Shift+Down when the list has keyboard focus. The order of functions in the list can be reversed with the Edit > Reverse order of functions command, which is available only in application mode.
Only one function in the list can be selected at a time. Double-clicking on a function in the list will bring up an Edit function dialog for that function.
The size of the list of functions — the number of columns and rows in the viewable region of the list — is specified as a configuration property, function.listSize.
Immediately below the list of functions is a group of buttons that can be used to issue function-related commands.
Below the function panel is a panel containing a single field labelled Cursor. When the mouse cursor is over the plot panel, this field displays the x and y coordinates at the mouse cursor. To conserve horizontal space, the coordinates are displayed in two rows. The coordinates are formatted according to the scheme for numeric values.
Below the cursor panel is a panel in which the x and y intervals of the plot panel are displayed. The intervals, which are set implicitly by scrolling and zooming the plot panel, can also be set explicitly by entering values in the interval fields. To update an interval after editing a value in an interval field, press the Return key while one of the interval fields has keyboard focus (ie, the text cursor is within an interval field). The minimum and maximum values of the endpoints of both the x and y intervals are 1.0E−100 (10−100) and 1.0E100 (10100) respectively.
Below the intervals panel is a panel containing scroll buttons, zoom buttons and drop-down lists for selecting the zoom factor. The arrow buttons scroll the plot in the direction of the arrow; the circle button centres the plot around the origin, (0, 0). The zoom buttons for each dimension have a zoom factor associated with them, which can be selected from a list of preset values using the drop-down list beside each pair of zoom buttons.
In components of the main window and the function dialog that is displayed in response to the Add and Edit function commands, a minus sign in numerical values and expressions is displayed with (in order of preference) a minus sign (U+2212) or en dash (U+2013) character if one of those characters can be displayed in the component's font. If neither character can be displayed, a hyphen-minus (U+002D) character is used.
The Add and Edit function commands bring up a dialog box in which you can edit the expression for f(x) and select the colour in which the function is plotted.
In the dialog, the colour-selection button invokes a colour-selection dialog. If the function list is not empty, the colours of the current functions are displayed in small buttons beside the colour selection button, to allow you to set a function's colour to the same colour as another function.
The Copy, Paste and Clear commands perform copy, paste and delete operations on the entire contents of the expression field. The Copy command copies the contents of the Expression field to the clipboard; the Paste command replaces the contents of the Expression field with text from the clipboard; the Clear command deletes the contents of the Expression field.
The commands that appear in the menu bar of FuncPlotter's main window are available only when FuncPlotter is run as an application.
The commands in the File menu are mostly standard and self-explanatory, but note the following:
The Open command brings up a file-selection dialog in which you can choose the file that you want to open. FuncPlotter determines the document format — XML or text — by examining the first few bytes of the file.
The reporting of errors in a file differs according to the file's format: files in text format receive more detailed error reporting because it is assumed that they may have been edited manually. (Files in XML format are assumed to have been written by FuncPlotter.)
If a document in text format contains errors, a dialog box is displayed in which the errors are listed. (Documents that are saved by FuncPlotter should be free from errors, but there may be errors in a document that has been edited manually.) The first line of the error list is the pathname of the file that contains the errors; the remaining lines list the first 20 errors in the file, each prefaced by a line number. If the error is a syntax error in an expression, the line number is followed by a number in square brackets that denotes the position (ie, the character index) of the error in the expression.
The Reload command is enabled when the current file has changed since it was last opened or saved. If you select the Reload command, the current file will be read again from storage, replacing the modified file in FuncPlotter's buffer.
When you save a document with the Save command, the
document is written in the same format in which it was previously saved. If you
save a new document with the Save command,
or if you save a document with the Save as command, a
file-selection dialog is displayed in which you can choose not only the file to
which you want to save the document but also the document
format — XML or text. The document format is determined by the file
type that you select in the file-selection dialog, and not by the filename suffix
that you specify. (For example, if you select a file named a.txt
and
the file type "XML files", the file is written in XML format.) If you
select a file whose name has no suffix, the suffix corresponding to the file type
(.xml
or .txt
) is automatically appended to the
filename. If the file type in the file-selection dialog is "All files",
the default file type is assumed.
If the general.saveFunctionColours
configuration property is set to Ask
, you will be asked whether you
want to save the function colours in the document each time you select either the
Save or the Save as
command.
The Export image command writes an image file of the current plot panel in Portable Network Graphics (PNG) format. The command is enabled when a document is open and the implementation of Java supports the PNG image format. The colour resolution of the image is 24 bits per pixel. The PNG format offers a high level of compression for the sort of images that are exported by FuncPlotter.
In the exported image, the margin of the plot, which includes the scale markings, is drawn in the colour denoted by the plot.colour.imageMargin configuration property.
The edits that you make to a document — the changes that you make to a document's functions, intervals or comment — can be undone and redone. The edits to a document are stored in a list called the document's history. The size of this list is limited by the general.maxEditListLength configuration property. The following edits are stored in a document's history:
Changes to an interval in one dimension (eg, scrolling or zooming) are merged if they occur within 0.5 seconds of each other.
The Undo command reverses the last change to the current document.
If an edit is undone with the Undo command, it can
subsequently be restored with the Redo command provided
that no other edits have been made since it was undone. If general.clearEditListOnSave
configuration property is true
, the history of edits is cleared when a
document is saved.
The Clear edit history command clears the history of edits to the current document. The command may be used to make more memory available if a "Not enough memory" error occurs.
A document may contain a single document comment, which is saved with the document. The Comment command brings up a dialog box in which the document comment can be viewed and edited. Any leading and trailing space is removed from text that is entered in the dialog.
For documents that are saved in XML format, the document comment is distinct from XML comments, which are not preserved in a document that is opened and subsequently written by FuncPlotter. For documents that are saved in text format, a document comment uses the general convention for comments in that format, but in a particular way; see Text format for details.
This command reverses the order of the functions in the function list of the current document.
The Copy intervals to other documents command is enabled only when more than one document is open. The purpose of this command is to copy the x and y intervals of the current document to some or all of the other open documents. A dialog box is displayed in which the target documents — the documents whose intervals you wish to set to those of the current document — can be selected.
The Grid option controls whether a grid is drawn in the plot panel. The command to toggle the grid also appears in the pop-up menu.
The Preferences command brings up a tabbed dialog box in which the configuration properties of FuncPlotter can be edited. The configuration properties are global; that is, they apply to all documents. The properties on the various tabbed pages are described below.
Some of the configuration properties in the Preferences dialog are edited with a spinner — a graphical component that consists of a text field adjacent to a pair of small buttons. The value in the text field may be edited manually, or it may be incremented and decremented by one of the following methods:
Using the last two methods, the amount by which the value is incremented or decremented can be modified by holding down the Ctrl, Shift or Ctrl+Shift keys, which correspond respectively to increments of 10, 100 and 1000.
General |
---|
|
|
|
|
|
|
|
Appearance |
---|
|
|
|
Plot |
---|
|
|
|
|
|
|
|
|
Function |
---|
|
|
|
|
Fonts |
---|
|
Some of the configuration properties will take effect when the Preferences dialog is accepted (by closing it with OK); other properties (eg, the look-and-feel and fonts) will not take effect until the next time that FuncPlotter is run.
The configuration file is normally saved automatically when FuncPlotter exits, if the configuration has changed. The Save configuration command in the Preferences dialog can be used to save a configuration file explicitly.
The Show full pathnames option controls whether the full pathname of the current document or only its filename is displayed in the title bar of the main window.
The function panel, below the list of functions, contains six buttons in application mode and eight buttons in applet mode. The buttons issue commands that relate to the list of functions. The commands are also available from a pop-up menu, which is activated in a system-dependent manner. (For example, on Windows systems, the pop-up menu is displayed when the right mouse button is released.)
This command brings up a dialog box in which a new function can be defined. The new function is added to the end of the function list.
This command brings up a dialog box in which the selected function can be edited. When the function list has keyboard focus, this command can be issued by pressing the Return key.
This command copies the expression of the currently selected function to the system clipboard. When the function list has keyboard focus, this command can be issued by pressing Ctrl+C.
This command brings up a small menu containing two check-box items: Highlight and Hide.
This command toggles the highlighting of the selected function. The highlighting leaves the plot of the selected function unchanged but obscures the plots of all the other functions in the document. The way in which the plots are obscured depends on the function.obscuredColour configuration property: if the obscured colour is enabled, the plots are drawn in that colour, otherwise the plots are hidden. Only one function can be highlighted at a time; highlighting a function while another function is highlighted will switch off the highlighting of the first function. The command is enabled only if the document contains more than one function. It can also be issued by pressing Ctrl+Space when the function list has keyboard focus.
This command toggles the visibility of the plot of the selected function. It operates independently of any highlighting.
This command deletes the selected function. When the function list has keyboard focus, the selected function can be deleted by pressing Delete, which requires that you confirm the deletion, or Shift+Delete, which deletes the function immediately.
This command deletes all functions from the list.
This command is the same as the Edit > Undo command in application mode: it undoes the previous edit in the document's history.
This command is the same as the Edit > Redo command in application mode: it reapplies the next edit in the document's history.
If your system supports the feature, you can open files by dragging them and dropping them onto the area of FuncPlotter's main window below the menu bar. This is equivalent to opening the files with the File > Open command. Multiple files can be opened in this way, subject to the constraint that a maximum of 64 documents can be open simultaneously in FuncPlotter.
FuncPlotter uses the double
floating-point type of the Java language for
the numbers that are involved in evaluating and plotting functions. The Java
double
type is based on the double-precision (64-bit) floating-point format
of the IEEE 754 standard, which has 53 bits of precision in the significand. This
precision is adequate for the purpose for which FuncPlotter is intended, and operations
on double
-type numbers are relatively fast on processors with a
floating-point unit that implements the IEEE 754 double-precision format.
Even with the precision of a Java double
, many of the numeric values that
are displayed by FuncPlotter will be approximations. (Remember that the binary
representation of decimal fractions is usually inexact: the decimal fraction 0.1, for
example, cannot be represented by a binary fraction of finite length just as the
fraction 1/3 cannot be represented by a decimal
fraction of finite length.)
Real numbers — or, more correctly, approximations to real numbers — appear in three places in FuncPlotter's display:
For consistency, all three uses are subject to the same constraints and are displayed in the same format, which can be controlled to a limited extent by configuration properties.
The maximum precision (aka the number of "significant figures") of displayed numbers is limited to 12 digits.
The maximum number of fraction digits (aka "decimal places") in displayed numbers is determined by the plot.numFractionDigits configuration property.
Numbers are displayed in one of two formats:
E
') is multiplied by 10 raised to the power
of the exponent (the integer after the 'E
'). If the
first digit of the significand is in the range
'1
'..'9
' and is followed immediately by
the radix point, the number is said to be normalised. Thus, 6.24E−4 is
normalised; 0.773E8 and 52.08E−6 are denormalised.
The format — fixed-point format or scientific notation — is determined by the exponent of the number and the plot.fixedPointExponentRange configuration property: if the exponent of the number lies within the inclusive fixed-point exponent range, the number is displayed in fixed-point format. (The exponent that is used in this determination is the exponent of the number in scientific notation, normalised or denormalised according to the plot.normaliseScientificNotation configuration property.)
An expression consists of operands and operators, optionally separated by spaces.
Subexpressions can be placed within parentheses, '(
' and
')
', to override operator precedence or to make an expression
easier to read.
Simple operands are of three types:
variable |
x
|
The independent variable. |
symbolic constant |
e
|
The base of natural logarithms. |
pi
|
The ratio of the circumference of a circle to its diameter, π. | |
numeric constant |
A string that is a valid representation of a decimal number in the
approximate range 10−308 to 10308, and composed only of
the digits '0 '..'9 ' and the characters
'+ ', '− ',
'. ', 'E ', 'e '.
Numbers can be in exponential form; for example, 1.602 ×
10−19 would be 1.602E−19 or 1.602e−19.
|
There are two types of operator: unary and binary. Unary operators take one operand; binary operators take two operands.
Unary operators use prefix notation: they always appear before the operand in
expressions, and they are right-associative. As well as unary + and -, the unary
operators include several common mathematical functions. Because the unary operators
have a higher precedence than binary operators when evaluating expressions, there is no
need to enclose a simple operand of a mathematical function in parentheses. For
example, the expression sin2x can be written sin x^2
,
though sin(x)^2
and (sin x)^2
are acceptable — and less
ambiguous — equivalents.
Operator | Description |
---|---|
+ | Unary plus |
− | Unary minus |
abs | Absolute value |
acos | Inverse cosine, in the range [0, π] |
acosh | Inverse hyperbolic cosine, in the range [0, ∞] |
acot | Inverse cotangent, in the range [−π/2, π/2] |
acsc | Inverse cosecant, in the range [−π/2, π/2] |
asec | Inverse secant, in the range [0, π] |
asin | Inverse sine, in the range [−π/2, π/2] |
asinh | Inverse hyperbolic sine |
atan | Inverse tangent, in the range ]−π/2, π/2[ |
atanh | Inverse hyperbolic tangent |
ceil | Smallest integer value that is greater than or equal to the operand |
cos | Cosine |
cosh | Hyperbolic cosine |
cot | Cotangent |
csc | Cosecant |
exp | e (base of natural logarithms) raised to the power of the operand |
floor | Largest integer value that is less than or equal to the operand |
lg | Logarithm, base 10 |
ln | Logarithm, base e (ie, natural logarithm) |
round | Closest integer to the operand (1/2 is rounded up) |
sec | Secant |
sin | Sine |
sinh | Hyperbolic sine |
sqrt | Positive square root |
tan | Tangent |
tanh | Hyperbolic tangent |
Binary operators use infix notation: they always appear between their operands in expressions, and they are left-associative (eg, 1 − x − ln x is evaluated as (1 − x) − ln x). The binary operators are the common arithmetic operators along with two types of remainder operator and the exponentiation ("raised to the power of") operator. Different precedence levels exist within the set of binary operators.
Operator | Description |
---|---|
+ | Addition |
− | Subtraction |
* | Multiplication |
/ | Division |
% | Remainder (see below) |
\ | IEEE 754 remainder (see below) |
^ | operand1 raised to the power of operand2 |
The remainder operator, '%
', is implemented in FuncPlotter by
means of the floating-point '%
' operator of the Java language.
The operation, which is analogous to the integer remainder operation, is defined by the
Java
language specification (Java SE 7 edition) thus:
[W]here neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r from the division of a dividend n by a divisor d is defined by the mathematical relation r = n − (d · q) where q is an integer that is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of n and d.
The IEEE 754 remainder operator, '\
', performs a remainder
operation according to the IEEE 754 standard. It is implemented in FuncPlotter by means
of the java.lang.Math.IEEEremainder
method. The Java
API documentation describes the operation thus (with variables and operators renamed
to be consistent with the definition of '%
' above):
The remainder value is mathematically equal to n − (d · q), where q is the mathematical integer closest to the exact mathematical value of the quotient n/d, and if two mathematical integers are equally close to n/d, then q is the integer that is even.
The Java language specification (Java SE 7 edition) explains the difference between the two remainder operations.
The following table lists the precedence of operators in an expression, with precedence decreasing from the top to the bottom of the table. Operators on the same row have equal precedence. Parentheses override operator precedence.
Unary operators |
^ |
* / % \ |
+ − |
FuncPlotter supports two document formats, referred to as XML and text,
although they are both text (as opposed to binary) formats. A document's format
is also referred to as its file type. Files of both types are expected to be
encoded as UTF-8. When a file is opened in FuncPlotter, the file type is determined
by examining the first five bytes of the file: if they are the UTF-8 character
sequence <?xml
, the file is parsed as XML; otherwise, it is parsed as
though it were in text format.
If you don't intend to edit a document manually, it is recommended that you save it in XML format.
The XML format was introduced in version 1.2 in order to provide a standard, interoperable format for FuncPlotter's documents. Although it is possible to edit XML documents manually, it is assumed that such documents were written by FuncPlotter, so the reporting of any errors that are encountered on opening a document in XML format is less detailed than the reporting of errors in a document in text format.
The structure of the XML format is simple: the x and y intervals are
optional attributes of the <functionList>
root element, and the
function definitions are contained in zero or more <function>
elements that are children of the root element. Each <function>
element has an expression
attribute (required) and a colour
attribute (optional) whose forms correspond to the equivalent parts of a function
definition in documents in text format — see below. The root element may
contain a single <comment>
element for the document comment.
The DTD of documents in XML format can be found in the file
functionList.dtd
, which is included in the FuncPlotter distribution. The
DTD is provided only for reference; it is not used by FuncPlotter. Documents written
by FuncPlotter in XML format do not contain a document type declaration.
The original document format, now referred to as text format, was designed to make it easy to create and edit sets of functions with a text editor. A document consists of a series of statements. There are two types of statement: an interval definition and a function definition. Each statement must be on a separate line. Blank lines are ignored. A document must contain no more than 20 function definitions.
If a line contains a '#
' character, any text from the
'#
' to the end of the line is ignored. This can be used to
include comments in a document. There are two types of comment:
#
' and the first
non-space character of the first line of a document comment is taken to be the
indent for the comment as a whole. Leading spaces up to the size of the indent are
removed from subsequent lines of the comment.
An interval definition must begin with an interval identifier: the
'@
' character followed by 'x
' or
'y
' (lower or upper case). The interval identifier is followed
by the comma-separated lower and upper endpoints of the interval. Whitespace is
allowed on either side of the endpoint values. For example, the line
denotes an x interval of [-4.5, 3.2].
An interval definition in a document is subject to the constraints described in Numeric values. For example, if the plot.numFractionDigits configuration property has the value 3 and a document contains an interval of [0.4521, 0.4523], the endpoints of the interval will be deemed to be equal (ie, both are rounded to 0.452), which will result in an error when the document is opened.
A function definition consists of two parts: an expression (required), followed by a
colour definition (optional). The expression is an
expression for f(x) as it would be entered in the Add function or Edit function
dialog. If a colour is specified in the function definition, it consists either of
the RGB components of the colour in the range 0..255, separated by commas, or of a
'#
' followed by six hexadecimal-digit characters (HTML
notation). The colour definition is separated from the expression by a semi-colon.
If the colour definition is absent, the default
colour for that function is used instead. For example, the line
denotes the function y = 2x2 − 3x + 1, to be drawn in dark red, while the line
denotes the function y = e2x − 3x, to be drawn in the default colour for the function at that particular index.
When you save a document with the File > Save or File > Save as commands, you are given the option of saving the colour definition with each of the function definitions in the document according to the policy outlined in the description of the Save and Save as commands.
Where indicated elsewhere in this document, pathname properties in FuncPlotter can contain special constructs for system properties, environment variables and the user's home directory. The special constructs are expanded when the pathname is used.
user.home
)
and environment variables (eg, PATH
) are referenced by enclosing them
between '${
' and '}
'; that is, they must
have the form ${<name>}
. A Java system property takes
precedence over an environment variable with the same name.
${user.home}/projects
${HOME}/projects
sys.
to it.
${sys.user.home}/projects
env.
to it.
${env.HOME}/projects
~
' in a pathname is expanded into the user's
home directory using the user.home
system property, which is usually
equivalent to the environment variable $HOME
on Linux/UNIX systems or
%USERPROFILE%
on Windows systems.
~/projects
The table below lists the properties that can be used in each of the three configuration locations: applet parameters (in HTML), command-line properties and configuration file.
When used in an applet parameter or a -D
command-line property,
app.
must be prefixed to the property key (eg, app.general.mainWindowLocation).
The <index> of an indexed property key (eg, function.colour) is a three-digit decimal-string representation of the zero-based index of the property (eg, the colour of the third function is function.colour.002).
Any commas (',
') or backslash characters
('\
') in the name of a font must be escaped by prefixing a
'\
' character to them.
In the table below, the initial character of an italicised component of a property value denotes its data type according to the following convention:
c | colour: either r, g, b (decimal) or #rrggbb (hex) |
f | floating-point number |
i | integer |
p | platform-specific pathname, which may contain special constructs |
s | string |
Property key | Property value | Applet | System property |
Config file |
---|---|---|---|---|
configDir | pPathname | • | • | |
appearance.backgroundColour | cColour | • | • | • |
appearance.lookAndFeel | sName | • | • | • |
appearance.textAntialiasing |
default | none | normal | subpixelHRgb | subpixelHBgr | subpixelVRgb | subpixelVBgr |
• | • | • |
font.comboBox |
sName, plain | bold | italic | boldItalic, iSize |
• | • | • |
font.main |
sName, plain | bold | italic | boldItalic, iSize |
• | • | • |
font.plot |
sName, plain | bold | italic | boldItalic, iSize |
• | • | • |
font.textField |
sName, plain | bold | italic | boldItalic, iSize |
• | • | • |
function.colour.<index> | cColour | • | • | • |
function.directory | pPathname | • | • | |
function.listSize | iNumColumns, iNumRows | • | • | • |
function.obscuredColour | cColour | • | • | • |
general.clearEditListOnSave | false | true | • | • | • |
general.defaultFileType | xml | text | • | • | |
general.mainWindowLocation | iX, iY | • | • | |
general.maxEditListLength | iLength | • | • | • |
general.newDocumentOnStartup | false | true | • | • | |
general.saveFunctionColours | no | yes | ask | • | • | |
general.showFullPathnames | false | true | • | • | |
general.showUnixPathnames | false | true | • | • | |
plot.colour.axis | cColour | • | • | • |
plot.colour.background | cColour | • | • | • |
plot.colour.focusedBorder | cColour | • | • | • |
plot.colour.grid | cColour | • | • | • |
plot.colour.imageMargin | cColour | • | • | • |
plot.colour.scale | cColour | • | • | • |
plot.fixedPointExponentRange | iLowerLimit, iUpperLimit | • | • | • |
plot.normaliseScientificNotation | false | true | • | • | • |
plot.numFractionDigits | iNumDigits | • | • | • |
plot.numYScaleDigits | iNumDigits | • | • | • |
plot.showGrid | false | true | • | • | • |
plot.size | iWidth, iHeight | • | • | • |
plot.truncateXScaleText | false | true | • | • | • |
startup.xInterval | fLowerEndpoint, fUpperEndpoint | • | ||
startup.yInterval | fLowerEndpoint, fUpperEndpoint | • | ||
startup.function.<index> | sExpression[;cColour] | • |
The FuncPlotter project is hosted by SourceForge. You can submit bug reports, requests for enhancements (RFEs) and suggestions for improvements through the SourceForge website, but the mechanism for doing so may change depending on the facilities that SourceForge provides. For current information, please see the feedback page for Blank Aspect projects.
When reporting a problem with FuncPlotter, please try to include enough relevant information to enable the problem to be reproduced. You should include at least the following information:
A Java stack trace, if one is available, would be helpful.