# HG changeset patch # User Kai T. Ohlhus # Date 1461072439 -7200 # Node ID b5d9b95d1e1a875bc2cad245a546f892f834d813 # Parent 9958cead45e296bf4be7bc27c3e5de98a1a2a02e Removing Java dialog boxes. * scripts/gui/module.mk: removed message_dialog.m entry. * scripts/gui/private/message_dialog.m: merged code to msgbox. * scripts/gui/errordlg.m: function now redirects to msgbox. New tests. * scripts/gui/helpdlg.m: function now redirects to msgbox. New tests. * scripts/gui/warndlg.m: function now redirects to msgbox. New tests. * scripts/gui/msgbox.m: merged code from message_dialog. Stripped Java dialog boxes. New tests. * scripts/gui/inputdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/gui/listdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/gui/questdlg.m: stripped Java dialog boxes. Improved doc. New tests. * scripts/miscellaneous/menu.m: stripped Java dialog boxes. Improved doc. * scripts/java/module.mk: removed entries of deleted files. * scripts/java/org/octave/DlgListener.java: removed Java dialog box Listener. * scripts/java/org/octave/images/error.png: removed unused image. * scripts/java/org/octave/images/information.png: removed unused image. * scripts/java/org/octave/images/octave.png: removed unused image. * scripts/java/org/octave/images/question.png: removed unused image. * scripts/java/org/octave/images/warning.png: removed unused image. * scripts/java/org/octave/JDialogBox.java: removed Java dialog box class. * scripts/java/org/octave/TeXcode.java: removed class used by Java dialogs. * scripts/java/org/octave/TeXtranslator.java: removed class used by Java dialogs. * doc/module.mk: removed unused java images and java.txi. * doc/interpreter/java.txi: merged content as minor sections to following files. * doc/interpreter/bugs.txi: moved Java distinguish section here. * doc/interpreter/external.txi: moved Java Interface description here. * doc/interpreter/gui.txi: moved dialog box docstrings here. * doc/interpreter/octave.texi: corrected TOC. * doc/interpreter/java-images/image001.png: removed unused image. * doc/interpreter/java-images/image002.png: removed unused image. * doc/interpreter/java-images/image003.png: removed unused image. * doc/interpreter/java-images/image004.png: removed unused image. * doc/interpreter/java-images/image005.png: removed unused image. * doc/interpreter/java-images/image006.png: removed unused image. * doc/interpreter/java-images/image007.png: removed unused image. * doc/interpreter/java-images/image008.png: removed unused image. * doc/interpreter/java-images/image009.png: removed unused image. * NEWS: Announced changes. diff -r 9958cead45e2 -r b5d9b95d1e1a NEWS --- a/NEWS Tue Apr 19 12:30:18 2016 +0200 +++ b/NEWS Tue Apr 19 15:27:19 2016 +0200 @@ -71,6 +71,10 @@ ** The textscan function is now built-in and is much faster and much more Matlab-compatible than the previous m-file version. + ** Dialog boxes, errordlg, helpdlg, inputdlg, errordlg, listdlg, + msgbox, questdlg, and warndlg, now exclusively use QT. Java based + versions are removed. + ** Other new functions added in 4.2: deg2rad diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/bugs.txi --- a/doc/interpreter/bugs.txi Tue Apr 19 12:30:18 2016 +0200 +++ b/doc/interpreter/bugs.txi Tue Apr 19 15:27:19 2016 +0200 @@ -1,4 +1,4 @@ -@c Copyright (C) 1996-2015 John W. Eaton +@c Copyright (C) 1996-2016 John W. Eaton @c @c This file is part of Octave. @c @@ -53,7 +53,8 @@ @menu * Actual Bugs:: Bugs we will fix later. * Reporting Bugs:: -* Service:: +* How To Get Help with Octave:: +* How to distinguish between Octave and Matlab:: @end menu @node Actual Bugs @@ -381,7 +382,7 @@ the change, send us the header line. @end itemize -@node Service +@node How To Get Help with Octave @appendixsec How To Get Help with Octave @cindex help, where to find @@ -399,3 +400,33 @@ But before you submit a bug report, please read @url{http://www.octave.org/bugs.html} to learn how to submit a useful bug report. + +@node How to distinguish between Octave and Matlab +@appendixsec How to distinguish between Octave and Matlab +@cindex Octave and @sc{matlab}, how to distinguish between + +Octave and @sc{matlab} are very similar, but handle Java slightly different. +Therefore it may be necessary to detect the environment and use the appropriate +functions. The following function can be used to detect the environment. Due +to the persistent variable it can be called repeatedly without a heavy +performance hit. + +Example: + +@example +@group +%% +%% Return: true if the environment is Octave. +%% +function retval = isOctave + persistent cacheval; % speeds up repeated calls + + if isempty (cacheval) + cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); + end + + retval = cacheval; +end +@end group +@end example + diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/external.txi --- a/doc/interpreter/external.txi Tue Apr 19 12:30:18 2016 +0200 +++ b/doc/interpreter/external.txi Tue Apr 19 15:27:19 2016 +0200 @@ -1,4 +1,5 @@ -@c Copyright (C) 2007-2015 John W. Eaton and David Bateman +@c Copyright (C) 2007-2016 John W. Eaton and David Bateman +@c Copyright (C) 2010 Martin Hepperle @c Copyright (C) 2007 Paul Thomas and Christoph Spiel @c @c This file is part of Octave. @@ -107,6 +108,7 @@ * Oct-Files:: * Mex-Files:: * Standalone Programs:: +* Java Interface:: @end menu @node Oct-Files @@ -1820,3 +1822,370 @@ @end group @end example +@node Java Interface +@section Java Interface + +@cindex using Octave with Java +@cindex Java, using with Octave +@cindex calling Java from Octave +@cindex Java, calling from Octave +@cindex calling Octave from Java +@cindex Octave, calling from Java + +The Java Interface is designed for calling Java functions from within Octave. +If you want to do the reverse, and call Octave from within Java, try +a library like +@code{javaOctave} (@url{https://kenai.com/projects/javaoctave/pages/Home}) or +@code{joPas} (@url{http://jopas.sourceforge.net/}). + +@menu +* Java Interface Functions:: +* Making Java classes available:: +* Creating an instance of a Java class:: +* Handling Java memory limitations:: +@end menu + +@node Java Interface Functions +@subsection Java Interface Functions + +The following functions are the core of the Java Interface. They provide +a way to create a Java object, get and set its data fields, and call Java +methods which return results to Octave. + +@cindex object, creating a Java object +@DOCSTRING(javaObject) + +@cindex array, creating a Java array +@DOCSTRING(javaArray) + +There are many different variable types in Octave but only ones created through +@code{javaObject} can use Java functions. Before using Java with an unknown +object the type can be checked with @code{isjava}. + +@DOCSTRING(isjava) + +Once an object has been created it is natural to find out what fields the +object has and to read (get) and write (set) them. + +@cindex fields, displaying available fields of a Java object +In Octave the @code{fieldnames} function for structures has been overloaded +to return the fields of a Java object. For example: + +@example +@group +dobj = javaObject ("java.lang.Double", pi); +fieldnames (dobj) +@result{} +@{ + [1,1] = public static final double java.lang.Double.POSITIVE_INFINITY + [1,2] = public static final double java.lang.Double.NEGATIVE_INFINITY + [1,3] = public static final double java.lang.Double.NaN + [1,4] = public static final double java.lang.Double.MAX_VALUE + [1,5] = public static final double java.lang.Double.MIN_NORMAL + [1,6] = public static final double java.lang.Double.MIN_VALUE + [1,7] = public static final int java.lang.Double.MAX_EXPONENT + [1,8] = public static final int java.lang.Double.MIN_EXPONENT + [1,9] = public static final int java.lang.Double.SIZE + [1,10] = public static final java.lang.Class java.lang.Double.TYPE +@} +@end group +@end example + +@cindex field, returning value of Java object field +The analogy of objects with structures is carried over into reading and +writing object fields. To read a field the object is indexed with the +@samp{.} operator from structures. This is the preferred method for reading +fields, but Octave also provides a function interface to read fields with +@code{java_get}. An example of both styles is shown below. + +@example +@group +dobj = javaObject ("java.lang.Double", pi); +dobj.MAX_VALUE +@result{} 1.7977e+308 +java_get ("java.lang.Float", "MAX_VALUE") +@result{} 3.4028e+38 +@end group +@end example + +@DOCSTRING(java_get) + +@cindex field, setting value of Java object field +@DOCSTRING(java_set) + +@cindex methods, displaying available methods of a Java object +To see what functions can be called with an object use @code{methods}. +For example, using the previously created @var{dobj}: + +@example +@group +methods (dobj) +@result{} +Methods for class java.lang.Double: +boolean equals(java.lang.Object) +java.lang.String toString(double) +java.lang.String toString() +@dots{} +@end group +@end example + +To call a method of an object the same structure indexing operator @samp{.} +is used. Octave also provides a functional interface to calling the methods +of an object through @code{javaMethod}. An example showing both styles is +shown below. + +@example +@group +dobj = javaObject ("java.lang.Double", pi); +dobj.equals (3) +@result{} 0 +javaMethod ("equals", dobj, pi) +@result{} 1 +@end group +@end example + +@cindex method, invoking a method of a Java object +@DOCSTRING(javaMethod) + +The following three functions are used to display and modify the +class path used by the Java Virtual Machine. This is entirely separate +from Octave's PATH variable and is used by the JVM to find the correct +code to execute. + +@cindex classpath, displaying +@cindex classpath, dynamic +@cindex dynamic classpath +@cindex classpath, static +@cindex static classpath +@DOCSTRING(javaclasspath) + +@findex javaaddpath +@cindex classpath, adding new path +@cindex path, adding to classpath +@cindex classpath, dynamic +@cindex dynamic classpath, adding new path +@DOCSTRING(javaaddpath) + +@cindex classpath, removing path +@cindex path, removing from classpath +@DOCSTRING(javarmpath) + +The following functions provide information and control over the interface +between Octave and the Java Virtual Machine. + +@DOCSTRING(javachk) + +@DOCSTRING(usejava) + +@cindex memory, displaying Java memory status +@DOCSTRING(javamem) + +@DOCSTRING(java_matrix_autoconversion) + +@DOCSTRING(java_unsigned_autoconversion) + +@DOCSTRING(debug_java) + +@node Making Java classes available +@subsection Making Java classes available + +@c - index - +@cindex classpath, setting +@cindex classpath, difference between static and dynamic +@cindex static classpath +@cindex dynamic classpath +@cindex @file{javaclasspath.txt} +@cindex @file{classpath.txt} +@cindex classes, making available to Octave +@c - index - + +Java finds classes by searching a @var{classpath}. This is a list of Java +archive files and/or directories containing class files. In Octave +the @var{classpath} is composed of two parts: + +@itemize +@item the @var{static classpath} is initialized once at startup of the JVM, and + +@item the @var{dynamic classpath} which can be modified at runtime. +@end itemize + +Octave searches the @var{static classpath} first, then the @var{dynamic +classpath}. Classes appearing in the @var{static} as well as in the +@var{dynamic classpath} will therefore be found in the @var{static classpath} +and loaded from this location. Classes which will be used frequently or must +be available to all users should be added to the @var{static classpath}. The +@var{static classpath} is populated once from the contents of a plain text file +named @file{javaclasspath.txt} (or @file{classpath.txt} historically) when the +Java Virtual Machine starts. This file contains one line for each individual +classpath to be added to the @var{static classpath}. These lines can identify +single class files, directories containing class files, or Java archives with +complete class file hierarchies. Comment lines starting with a @samp{#} or a +@samp{%} character are ignored. + +The search rules for the file @file{javaclasspath.txt} +(or @file{classpath.txt}) are: + +@itemize +@item First, Octave tries to locate it in the current directory (where Octave +was started from). If such a file is found, it is read and defines the initial +@var{static classpath}. Thus, it is possible to define a static classpath on a +'per Octave invocation' basis. + +@item Next, Octave searches in the user's home directory. If a file +@file{javaclasspath.txt} exists here, its contents are appended to the static +classpath (if any). Thus, it is possible to build an initial static classpath +on a 'per user' basis. + +@item Finally, Octave looks for a next occurrence of file +@file{javaclasspath.txt} in the m-files directory where Octave Java functions +live. This is where @file{javaclasspath.m} resides, usually something like +@file{@w{@env{OCTAVE_HOME}}/share/octave/@w{@env{OCTAVE_VERSION}}/m/java/}. You can +find this directory by executing the command + +@example +which javaclasspath +@end example + +If this file exists here, its contents are also appended to the static +classpath. Note that the archives and class directories defined in this last +step will affect all users. +@end itemize + +Classes which are used only by a specific script should be placed in the +@var{dynamic classpath}. This portion of the classpath can be modified at +runtime using the @code{javaaddpath} and @code{javarmpath} functions. + +Example: + +@example +octave> base_path = "C:/Octave/java_files"; + +octave> % add two JARchives to the dynamic classpath +octave> javaaddpath ([base_path, "/someclasses.jar"]); +octave> javaaddpath ([base_path, "/moreclasses.jar"]); + +octave> % check the dynamic classpath +octave> p = javaclasspath; +octave> disp (p@{1@}); +C:/Octave/java_files/someclasses.jar +octave> disp (p@{2@}); +C:/Octave/java_files/moreclasses.jar + +octave> % remove the first element from the classpath +octave> javarmpath ([base_path, "/someclasses.jar"]); +octave> p = javaclasspath; +octave> disp (p@{1@}); +C:/Octave/java_files/moreclasses.jar + +octave> % provoke an error +octave> disp (p@{2@}); +error: A(I): Index exceeds matrix dimension. +@end example + +Another way to add files to the @var{dynamic classpath} exclusively for your +user account is to use the file @file{.octaverc} which is stored in your home +directory. All Octave commands in this file are executed each time you start a +new instance of Octave. The following example adds the directory @file{octave} +to Octave's search path and the archive @file{myclasses.jar} in this directory +to the Java search path. + +@example +@group +% contents of .octaverc: +addpath ("~/octave"); +javaaddpath ("~/octave/myclasses.jar"); +@end group +@end example + +@c ------------------------------------------------------------------------ +@node Creating an instance of a Java class +@subsection Creating an instance of a Java class +@c - index - +@cindex object, how to create +@cindex instance, how to create +@c - index - + +The function @code{javaObject} can be used to create Java objects. + +Example: + +@example +Passenger = javaObject ("package.FirstClass", row, seat); +@end example + +@node Handling Java memory limitations +@subsection Handling Java memory limitations +@cindex memory, limitations + +In order to execute Java code Octave creates a Java Virtual Machine (JVM). +Such a JVM allocates a fixed amount of initial memory and may expand this pool +up to a fixed maximum memory limit. The default values depend on the Java +version (@pxref{XREFjavamem,,javamem}). The memory pool is shared by all +Java objects running in the JVM@. This strict memory limit is intended mainly +to avoid that runaway applications inside web browsers or in enterprise servers +can consume all memory and crash the system. When the maximum memory limit is +hit, Java code will throw exceptions so that applications will fail or behave +unexpectedly. + +You can specify options for the creation of the JVM inside a file named +@file{java.opts}. This is a text file where you can enter lines containing +@option{-X} and @option{-D} options handed to the JVM during initialization. + +The directory where the Java options file is located is specified by the +environment variable @w{@env{OCTAVE_JAVA_DIR}}. If unset the directory where +@file{javaclasspath.m} resides is used instead (typically +@file{@w{@env{OCTAVE_HOME}}/share/octave/@w{@env{OCTAVE_VERSION}}/m/java/}). You can +find this directory by executing + +@example +which javaclasspath +@end example + +The @option{-X} options allow you to increase the maximum amount of memory +available to the JVM@. The following example allows up to 256 Megabytes to +be used by adding the following line to the @file{java.opts} file: + +@example +-Xmx256m +@end example + +The maximum possible amount of memory depends on your system. On a Windows +system with 2 Gigabytes main memory you should be able to set this maximum to +about 1 Gigabyte. + +If your application requires a large amount of memory from the beginning, you +can also specify the initial amount of memory allocated to the JVM@. Adding +the following line to the @file{java.opts} file starts the JVM with 64 +Megabytes of initial memory: + +@example +-Xms64m +@end example + +For more details on the available @option{-X} options of your Java Virtual +Machine issue the command @samp{java -X} at the operating system command prompt +and consult the Java documentation. + +The @option{-D} options can be used to define system properties which can then +be used by Java classes inside Octave. System properties can be retrieved by +using the @code{getProperty()} methods of the @code{java.lang.System} class. +The following example line defines the property @var{MyProperty} and assigns it +the string @code{12.34}. + +@example +-DMyProperty=12.34 +@end example + +The value of this property can then be retrieved as a string by a Java object +or in Octave: + +@example +@group +octave> javaMethod ("getProperty", "java.lang.System", "MyProperty"); +ans = 12.34 +@end group +@end example + +@seealso{javamem} + + diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/gui.txi --- a/doc/interpreter/gui.txi Tue Apr 19 12:30:18 2016 +0200 +++ b/doc/interpreter/gui.txi Tue Apr 19 15:27:19 2016 +0200 @@ -1,4 +1,4 @@ -@c Copyright (C) 2012-2015 Rik Wehbring +@c Copyright (C) 2012-2016 Rik Wehbring @c @c This file is part of Octave. @c @@ -52,12 +52,39 @@ return a string variable which can then be used with any command requiring a filename. +@cindex dialog, displaying a dialog for selecting directories @DOCSTRING(uigetdir) +@cindex dialog, displaying a dialog for selecting files @DOCSTRING(uigetfile) +@cindex dialog, displaying a dialog for storing files @DOCSTRING(uiputfile) +Additionally, there are dialog boxes for printing further help, warnings or +errors and to get textual input from the user. + +@cindex dialog, displaying an error dialog +@DOCSTRING(errordlg) + +@cindex dialog, displaying a help dialog +@DOCSTRING(helpdlg) + +@cindex dialog, displaying an input dialog +@DOCSTRING(inputdlg) + +@cindex dialog, displaying a list dialog +@DOCSTRING(listdlg) + +@cindex dialog, displaying a message dialog +@DOCSTRING(msgbox) + +@cindex dialog, displaying a question dialog +@DOCSTRING(questdlg) + +@cindex dialog, displaying a warning dialog +@DOCSTRING(warndlg) + @node Progress Bar @section Progress Bar @cindex Progress Bar diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image001.png Binary file doc/interpreter/java-images/image001.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image002.png Binary file doc/interpreter/java-images/image002.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image003.png Binary file doc/interpreter/java-images/image003.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image004.png Binary file doc/interpreter/java-images/image004.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image005.png Binary file doc/interpreter/java-images/image005.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image006.png Binary file doc/interpreter/java-images/image006.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image007.png Binary file doc/interpreter/java-images/image007.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image008.png Binary file doc/interpreter/java-images/image008.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java-images/image009.png Binary file doc/interpreter/java-images/image009.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/java.txi --- a/doc/interpreter/java.txi Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1028 +0,0 @@ -@c Copyright (C) 2010-2015 Martin Hepperle -@c -@c This file is part of Octave. -@c -@c Octave is free software; you can redistribute it and/or modify it -@c under the terms of the GNU General Public License as published by the -@c Free Software Foundation; either version 3 of the License, or (at -@c your option) any later version. -@c -@c Octave is distributed in the hope that it will be useful, but WITHOUT -@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -@c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -@c for more details. -@c -@c You should have received a copy of the GNU General Public License -@c along with Octave; see the file COPYING. If not, see -@c . - -@node Java Interface -@chapter Java Interface - -@cindex using Octave with Java -@cindex Java, using with Octave -@cindex calling Java from Octave -@cindex Java, calling from Octave -@cindex calling Octave from Java -@cindex Octave, calling from Java - -The Java Interface is designed for calling Java functions from within Octave. -If you want to do the reverse, and call Octave from within Java, try -a library like -@code{javaOctave} (@url{http://kenai.com/projects/javaOctave}) or -@code{joPas} (@url{http://jopas.sourceforge.net}). - -@menu -* Java Interface Functions:: -* Dialog Box Functions:: -* FAQ - Frequently asked Questions:: -@end menu - -@node Java Interface Functions -@section Java Interface Functions - -The following functions are the core of the Java Interface. They provide -a way to create a Java object, get and set its data fields, and call Java -methods which return results to Octave. - -@cindex object, creating a Java object -@DOCSTRING(javaObject) - -@cindex array, creating a Java array -@DOCSTRING(javaArray) - -There are many different variable types in Octave but only ones created through -@code{javaObject} can use Java functions. Before using Java with an unknown -object the type can be checked with @code{isjava}. - -@DOCSTRING(isjava) - -Once an object has been created it is natural to find out what fields the -object has and to read (get) and write (set) them. - -@cindex fields, displaying available fields of a Java object -In Octave the @code{fieldnames} function for structures has been overloaded -to return the fields of a Java object. For example: - -@example -@group -dobj = javaObject ("java.lang.Double", pi); -fieldnames (dobj) -@result{} -@{ - [1,1] = public static final double java.lang.Double.POSITIVE_INFINITY - [1,2] = public static final double java.lang.Double.NEGATIVE_INFINITY - [1,3] = public static final double java.lang.Double.NaN - [1,4] = public static final double java.lang.Double.MAX_VALUE - [1,5] = public static final double java.lang.Double.MIN_NORMAL - [1,6] = public static final double java.lang.Double.MIN_VALUE - [1,7] = public static final int java.lang.Double.MAX_EXPONENT - [1,8] = public static final int java.lang.Double.MIN_EXPONENT - [1,9] = public static final int java.lang.Double.SIZE - [1,10] = public static final java.lang.Class java.lang.Double.TYPE -@} -@end group -@end example - -@cindex field, returning value of Java object field -The analogy of objects with structures is carried over into reading and -writing object fields. To read a field the object is indexed with the -@samp{.} operator from structures. This is the preferred method for reading -fields, but Octave also provides a function interface to read fields with -@code{java_get}. An example of both styles is shown below. - -@example -@group -dobj = javaObject ("java.lang.Double", pi); -dobj.MAX_VALUE -@result{} 1.7977e+308 -java_get ("java.lang.Float", "MAX_VALUE") -@result{} 3.4028e+38 -@end group -@end example - -@DOCSTRING(java_get) - -@cindex field, setting value of Java object field -@DOCSTRING(java_set) - -@cindex methods, displaying available methods of a Java object -To see what functions can be called with an object use @code{methods}. -For example, using the previously created @var{dobj}: - -@example -@group -methods (dobj) -@result{} -Methods for class java.lang.Double: -boolean equals(java.lang.Object) -java.lang.String toString(double) -java.lang.String toString() -@dots{} -@end group -@end example - -To call a method of an object the same structure indexing operator @samp{.} -is used. Octave also provides a functional interface to calling the methods -of an object through @code{javaMethod}. An example showing both styles is -shown below. - -@example -@group -dobj = javaObject ("java.lang.Double", pi); -dobj.equals (3) -@result{} 0 -javaMethod ("equals", dobj, pi) -@result{} 1 -@end group -@end example - -@cindex method, invoking a method of a Java object -@DOCSTRING(javaMethod) - -The following three functions are used to display and modify the -class path used by the Java Virtual Machine. This is entirely separate -from Octave's PATH variable and is used by the JVM to find the correct -code to execute. - -@cindex classpath, displaying -@cindex classpath, dynamic -@cindex dynamic classpath -@cindex classpath, static -@cindex static classpath -@DOCSTRING(javaclasspath) - -@findex javaaddpath -@cindex classpath, adding new path -@cindex path, adding to classpath -@cindex classpath, dynamic -@cindex dynamic classpath, adding new path -@DOCSTRING(javaaddpath) - -@cindex classpath, removing path -@cindex path, removing from classpath -@DOCSTRING(javarmpath) - -The following functions provide information and control over the interface -between Octave and the Java Virtual Machine. - -@DOCSTRING(javachk) - -@DOCSTRING(usejava) - -@cindex memory, displaying Java memory status -@DOCSTRING(javamem) - -@DOCSTRING(java_matrix_autoconversion) - -@DOCSTRING(java_unsigned_autoconversion) - -@DOCSTRING(debug_java) - -@node Dialog Box Functions -@section Dialog Box Functions - -The following functions all use the Java Interface to provide some form -of dialog box. - -@cindex dialog, displaying a warning dialog -@DOCSTRING(msgbox) - -@cindex dialog, displaying an error dialog -@DOCSTRING(errordlg) - -@cindex dialog, displaying a help dialog -@DOCSTRING(helpdlg) - -@cindex dialog, displaying an input dialog -@DOCSTRING(inputdlg) - -@cindex dialog, displaying a list dialog -@DOCSTRING(listdlg) - -@cindex dialog, displaying a question dialog -@DOCSTRING(questdlg) - -@cindex dialog, displaying a warning dialog -@DOCSTRING(warndlg) - -@c ------------------------------------------------------------------------ -@node FAQ - Frequently asked Questions -@section FAQ - Frequently asked Questions - -@menu -* How to distinguish between Octave and Matlab?:: -* How to make Java classes available?:: -* How to create an instance of a Java class?:: -* How can I handle memory limitations?:: -* Which @TeX{} symbols are implemented in dialog functions?:: -@end menu - -@c ------------------------------------------------------------------------ -@node How to distinguish between Octave and Matlab? -@subsection How to distinguish between Octave and Matlab? -@anchor{XREFFAQ} -@c - index - -@cindex Octave and @sc{matlab}, how to distinguish between -@c - index - - -Octave and @sc{matlab} are very similar, but handle Java slightly different. -Therefore it may be necessary to detect the environment and use the appropriate -functions. The following function can be used to detect the environment. Due -to the persistent variable it can be called repeatedly without a heavy -performance hit. - -Example: - -@example -@group -%% -%% Return: true if the environment is Octave. -%% -function retval = isOctave - persistent cacheval; % speeds up repeated calls - - if isempty (cacheval) - cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); - end - - retval = cacheval; -end -@end group -@end example - -@c ------------------------------------------------------------------------ -@node How to make Java classes available? -@subsection How to make Java classes available to Octave? -@c - index - -@cindex classpath, setting -@cindex classpath, difference between static and dynamic -@cindex static classpath -@cindex dynamic classpath -@cindex @file{javaclasspath.txt} -@cindex @file{classpath.txt} -@cindex classes, making available to Octave -@c - index - - -Java finds classes by searching a @var{classpath}. This is a list of Java -archive files and/or directories containing class files. In Octave -the @var{classpath} is composed of two parts: - -@itemize -@item the @var{static classpath} is initialized once at startup of the JVM, and - -@item the @var{dynamic classpath} which can be modified at runtime. -@end itemize - -Octave searches the @var{static classpath} first, then the @var{dynamic -classpath}. Classes appearing in the @var{static} as well as in the -@var{dynamic classpath} will therefore be found in the @var{static classpath} -and loaded from this location. Classes which will be used frequently or must -be available to all users should be added to the @var{static classpath}. The -@var{static classpath} is populated once from the contents of a plain text file -named @file{javaclasspath.txt} (or @file{classpath.txt} historically) when the -Java Virtual Machine starts. This file contains one line for each individual -classpath to be added to the @var{static classpath}. These lines can identify -single class files, directories containing class files, or Java archives with -complete class file hierarchies. Comment lines starting with a @samp{#} or a -@samp{%} character are ignored. - -The search rules for the file @file{javaclasspath.txt} -(or @file{classpath.txt}) are: - -@itemize -@item First, Octave tries to locate it in the current directory (where Octave -was started from). If such a file is found, it is read and defines the initial -@var{static classpath}. Thus, it is possible to define a static classpath on a -'per Octave invocation' basis. - -@item Next, Octave searches in the user's home directory. If a file -@file{javaclasspath.txt} exists here, its contents are appended to the static -classpath (if any). Thus, it is possible to build an initial static classpath -on a 'per user' basis. - -@item Finally, Octave looks for a next occurrence of file -@file{javaclasspath.txt} in the m-files directory where Octave Java functions -live. This is where @file{javaclasspath.m} resides, usually something like -@file{@w{@env{OCTAVE_HOME}}/share/octave/@w{@env{OCTAVE_VERSION}}/m/java/}. You can -find this directory by executing the command - -@example -which javaclasspath -@end example - -If this file exists here, its contents are also appended to the static -classpath. Note that the archives and class directories defined in this last -step will affect all users. -@end itemize - -Classes which are used only by a specific script should be placed in the -@var{dynamic classpath}. This portion of the classpath can be modified at -runtime using the @code{javaaddpath} and @code{javarmpath} functions. - -Example: - -@example -octave> base_path = "C:/Octave/java_files"; - -octave> % add two JARchives to the dynamic classpath -octave> javaaddpath ([base_path, "/someclasses.jar"]); -octave> javaaddpath ([base_path, "/moreclasses.jar"]); - -octave> % check the dynamic classpath -octave> p = javaclasspath; -octave> disp (p@{1@}); -C:/Octave/java_files/someclasses.jar -octave> disp (p@{2@}); -C:/Octave/java_files/moreclasses.jar - -octave> % remove the first element from the classpath -octave> javarmpath ([base_path, "/someclasses.jar"]); -octave> p = javaclasspath; -octave> disp (p@{1@}); -C:/Octave/java_files/moreclasses.jar - -octave> % provoke an error -octave> disp (p@{2@}); -error: A(I): Index exceeds matrix dimension. -@end example - -Another way to add files to the @var{dynamic classpath} exclusively for your -user account is to use the file @file{.octaverc} which is stored in your home -directory. All Octave commands in this file are executed each time you start a -new instance of Octave. The following example adds the directory @file{octave} -to Octave's search path and the archive @file{myclasses.jar} in this directory -to the Java search path. - -@example -@group -% contents of .octaverc: -addpath ("~/octave"); -javaaddpath ("~/octave/myclasses.jar"); -@end group -@end example - -@c ------------------------------------------------------------------------ -@node How to create an instance of a Java class? -@subsection How to create an instance of a Java class? -@c - index - -@cindex object, how to create -@cindex instance, how to create -@c - index - - -The function @code{javaObject} can be used to create Java objects.. - -Example: - -@example -Passenger = javaObject ("package.FirstClass", row, seat); -@end example - -@c ------------------------------------------------------------------------ -@node How can I handle memory limitations? -@subsection How can I handle memory limitations? -@cindex memory, limitations - -In order to execute Java code Octave creates a Java Virtual Machine (JVM). -Such a JVM allocates a fixed amount of initial memory and may expand this pool -up to a fixed maximum memory limit. The default values depend on the Java -version (@pxref{XREFjavamem,,javamem}). The memory pool is shared by all -Java objects running in the JVM@. This strict memory limit is intended mainly -to avoid that runaway applications inside web browsers or in enterprise servers -can consume all memory and crash the system. When the maximum memory limit is -hit, Java code will throw exceptions so that applications will fail or behave -unexpectedly. - -You can specify options for the creation of the JVM inside a file named -@file{java.opts}. This is a text file where you can enter lines containing -@option{-X} and @option{-D} options handed to the JVM during initialization. - -The directory where the Java options file is located is specified by the -environment variable @w{@env{OCTAVE_JAVA_DIR}}. If unset the directory where -@file{javaclasspath.m} resides is used instead (typically -@file{@w{@env{OCTAVE_HOME}}/share/octave/@w{@env{OCTAVE_VERSION}}/m/java/}). You can -find this directory by executing - -@example -which javaclasspath -@end example - -The @option{-X} options allow you to increase the maximum amount of memory -available to the JVM@. The following example allows up to 256 Megabytes to -be used by adding the following line to the @file{java.opts} file: - -@example --Xmx256m -@end example - -The maximum possible amount of memory depends on your system. On a Windows -system with 2 Gigabytes main memory you should be able to set this maximum to -about 1 Gigabyte. - -If your application requires a large amount of memory from the beginning, you -can also specify the initial amount of memory allocated to the JVM@. Adding -the following line to the @file{java.opts} file starts the JVM with 64 -Megabytes of initial memory: - -@example --Xms64m -@end example - -For more details on the available @option{-X} options of your Java Virtual -Machine issue the command @samp{java -X} at the operating system command prompt -and consult the Java documentation. - -The @option{-D} options can be used to define system properties which can then -be used by Java classes inside Octave. System properties can be retrieved by -using the @code{getProperty()} methods of the @code{java.lang.System} class. -The following example line defines the property @var{MyProperty} and assigns it -the string @code{12.34}. - -@example --DMyProperty=12.34 -@end example - -The value of this property can then be retrieved as a string by a Java object -or in Octave: - -@example -@group -octave> javaMethod ("getProperty", "java.lang.System", "MyProperty"); -ans = 12.34 -@end group -@end example - -@seealso{javamem} - -@c ------------------------------------------------------------------------ -@node Which @TeX{} symbols are implemented in dialog functions? -@subsection Which @TeX{} symbols are implemented in dialog functions? -@c - index - -@cindex symbols, translation table -@cindex @TeX{} symbols, translation table -@cindex translation table for @TeX{} symbols -@c - index - - -The dialog functions contain a translation table for @TeX{} like symbol codes. -Thus messages and labels can be tailored to show some common mathematical -symbols or Greek characters. No further @TeX{} formatting codes are supported. - The characters are translated to their Unicode equivalent. However, not all -characters may be displayable on your system. This depends on the font used by -the Java system on your computer. - -Each @TeX{} symbol code must be terminated by a space character to make it -distinguishable from the surrounding text. Therefore the string @samp{\alpha -=12.0} will produce the desired result, whereas @samp{\alpha=12.0} would -produce the literal text @var{'\alpha=12.0'}. - -@seealso{errordlg, helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg} - -@need 5000 -@c --------------------------------- -@ifhtml -@float Table -The table below shows each @TeX{} character code and the corresponding Unicode -character: -@multitable @columnfractions 0.18 0.1 0.05 0.18 0.1 0.05 0.18 0.1 -@item \alpha -@tab 'α' -@tab -@tab \beta -@tab 'β' -@tab -@tab \gamma -@tab 'γ' -@c ---------- -@item \delta -@tab 'δ' -@tab -@tab \epsilon -@tab 'ε' -@tab -@tab \zeta -@tab 'ζ' -@c ---------- -@item \eta -@tab 'η' -@tab -@tab \theta -@tab 'θ' -@tab -@tab \vartheta -@tab 'ϑ' -@c ---------- -@item \iota -@tab 'ι' -@tab -@tab \kappa -@tab 'κ' -@tab -@tab \lambda -@tab 'λ' -@c ---------- -@item \mu -@tab 'μ' -@tab -@tab \nu -@tab 'ν' -@tab -@tab \xi -@tab 'ξ' -@c ---------- -@item \pi -@tab 'π' -@tab -@tab \rho -@tab 'ρ' -@tab -@tab \sigma -@tab 'σ' -@c ---------- -@item \varsigma -@tab 'ς' -@tab -@tab \tau -@tab 'τ' -@tab -@tab \phi -@tab 'φ' -@c ---------- -@item \chi -@tab 'χ' -@tab -@tab \psi -@tab 'ψ' -@tab -@tab \omega -@tab 'ω' -@c ---------- -@item \upsilon -@tab 'υ' -@tab -@tab \Gamma -@tab 'Γ' -@tab -@tab \Delta -@tab 'Δ' -@c ---------- -@item \Theta -@tab 'Θ' -@tab -@tab \Lambda -@tab 'Λ' -@tab -@tab \Pi -@tab 'Π' -@c ---------- -@item \Xi -@tab 'Ξ' -@tab -@tab \Sigma -@tab 'Σ' -@tab -@tab \Upsilon -@tab 'Υ' -@c ---------- -@item \Phi -@tab 'Φ' -@tab -@tab \Psi -@tab 'Ψ' -@tab -@tab \Omega -@tab 'Ω' -@c ---------- -@item \Im -@tab 'ℑ' -@tab -@tab \Re -@tab 'ℜ' -@tab -@tab \leq -@tab '≤' -@c ---------- -@item \geq -@tab '≥' -@tab -@tab \neq -@tab '≠' -@tab -@tab \pm -@tab '±' -@c ---------- -@item \infty -@tab '∞' -@tab -@tab \partial -@tab '∂' -@tab -@tab \approx -@tab '≈' -@c ---------- -@item \circ -@tab '∘' -@tab -@tab \bullet -@tab '•' -@tab -@tab \times -@tab '×' -@c ---------- -@item \sim -@tab '~' -@tab -@tab \nabla -@tab '∇' -@tab -@tab \ldots -@tab '…' -@c ---------- -@item \exists -@tab '∃' -@tab -@tab \neg -@tab '¬' -@tab -@tab \aleph -@tab 'ℵ' -@c ---------- -@item \forall -@tab '∀' -@tab -@tab \cong -@tab '≅' -@tab -@tab \wp -@tab '℘' -@c ---------- -@item \propto -@tab '∝' -@tab -@tab \otimes -@tab '⊗' -@tab -@tab \oplus -@tab '⊕' -@c ---------- -@item \oslash -@tab '⊘' -@tab -@tab \cap -@tab '∩' -@tab -@tab \cup -@tab '∪' -@c ---------- -@item \ni -@tab '∋' -@tab -@tab \in -@tab '∈' -@tab -@tab \div -@tab '÷' -@c ---------- -@item \equiv -@tab '≡' -@tab -@tab \int -@tab '∫' -@tab -@tab \perp -@tab '⊥' -@c ---------- -@item \wedge -@tab '∧' -@tab -@tab \vee -@tab '∨' -@tab -@tab \supseteq -@tab '⊇' -@c ---------- -@item \supset -@tab '⊃' -@tab -@tab \subseteq -@tab '⊆' -@tab -@tab \subset -@tab '⊂' -@c ---------- -@item \clubsuit -@tab '♣' -@tab -@tab \spadesuit -@tab '♠' -@tab -@tab \heartsuit -@tab '♥' -@c ---------- -@item \diamondsuit -@tab '♦' -@tab -@tab \copyright -@tab '©' -@tab -@tab \leftarrow -@tab '←' -@c ---------- -@item \uparrow -@tab '↑' -@tab -@tab \rightarrow -@tab '→' -@tab -@tab \downarrow -@tab '↓' -@c ---------- -@item \leftrightarrow -@tab '↔' -@tab -@tab \updownarrow -@tab '↕' -@tab -@c ---------- -@end multitable -@caption{@TeX{} character codes and the resulting symbols.} -@end float -@end ifhtml -@c --------------------------------- -@iftex -@float Table -The table below shows each @TeX{} character code and the corresponding Unicode -character: -@multitable @columnfractions 0.18 0.1 0.05 0.18 0.1 0.05 0.18 0.1 -@headitem @TeX{} code -@tab Symbol -@tab -@tab @TeX{} code -@tab Symbol -@tab -@tab @TeX{} code -@tab Symbol -@c ---------- -@item \alpha -@tab '@math{\alpha}' -@tab -@tab \beta -@tab '@math{\beta}' -@tab -@tab \gamma -@tab '@math{\gamma}' -@c ---------- -@item \delta -@tab '@math{\delta}' -@tab -@tab \epsilon -@tab '@math{\epsilon}' -@tab -@tab \zeta -@tab '@math{\zeta}' -@c ---------- -@item \eta -@tab '@math{\eta}' -@tab -@tab \theta -@tab '@math{\theta}' -@tab -@tab \vartheta -@tab '@math{\vartheta}' -@c ---------- -@item \iota -@tab '@math{\iota}' -@tab -@tab \kappa -@tab '@math{\kappa}' -@tab -@tab \lambda -@tab '@math{\lambda}' -@c ---------- -@item \mu -@tab '@math{\mu}' -@tab -@tab \nu -@tab '@math{\nu}' -@tab -@tab \xi -@tab '@math{\xi}' -@c ---------- -@item \pi -@tab '@math{\pi}' -@tab -@tab \rho -@tab '@math{\rho}' -@tab -@tab \sigma -@tab '@math{\sigma}' -@c ---------- -@item \varsigma -@tab '@math{\varsigma}' -@tab -@tab \tau -@tab '@math{\tau}' -@tab -@tab \phi -@tab '@math{\phi}' -@c ---------- -@item \chi -@tab '@math{\chi}' -@tab -@tab \psi -@tab '@math{\psi}' -@tab -@tab \omega -@tab '@math{\omega}' -@c ---------- -@item \upsilon -@tab '@math{\upsilon}' -@tab -@tab \Gamma -@tab '@math{\Gamma}' -@tab -@tab \Delta -@tab '@math{\Delta}' -@c ---------- -@item \Theta -@tab '@math{\Theta}' -@tab -@tab \Lambda -@tab '@math{\Lambda}' -@tab -@tab \Pi -@tab '@math{\Pi}' -@c ---------- -@item \Xi -@tab '@math{\Xi}' -@tab -@tab \Sigma -@tab '@math{\Sigma}' -@tab -@tab \Upsilon -@tab '@math{\Upsilon}' -@c ---------- -@item \Phi -@tab '@math{\Phi}' -@tab -@tab \Psi -@tab '@math{\Psi}' -@tab -@tab \Omega -@tab '@math{\Omega}' -@c ---------- -@item \Im -@tab '@math{\Im}' -@tab -@tab \Re -@tab '@math{\Re}' -@tab -@tab \leq -@tab '@math{\leq}' -@c ---------- -@item \geq -@tab '@math{\geq}' -@tab -@tab \neq -@tab '@math{\neq}' -@tab -@tab \pm -@tab '@math{\pm}' -@c ---------- -@item \infty -@tab '@math{\infty}' -@tab -@tab \partial -@tab '@math{\partial}' -@tab -@tab \approx -@tab '@math{\approx}' -@c ---------- -@item \circ -@tab '@math{\circ}' -@tab -@tab \bullet -@tab '@math{\bullet}' -@tab -@tab \times -@tab '@math{\times}' -@c ---------- -@item \sim -@tab '@math{\sim}' -@tab -@tab \nabla -@tab '@math{\nabla}' -@tab -@tab \ldots -@tab '@math{\ldots}' -@c ---------- -@item \exists -@tab '@math{\exists}' -@tab -@tab \neg -@tab '@math{\neg}' -@tab -@tab \aleph -@tab '@math{\aleph}' -@c ---------- -@item \forall -@tab '@math{\forall}' -@tab -@tab \cong -@tab '@math{\cong}' -@tab -@tab \wp -@tab '@math{\wp}' -@c ---------- -@item \propto -@tab '@math{\propto}' -@tab -@tab \otimes -@tab '@math{\otimes}' -@tab -@tab \oplus -@tab '@math{\oplus}' -@c ---------- -@item \oslash -@tab '@math{\oslash}' -@tab -@tab \cap -@tab '@math{\cap}' -@tab -@tab \cup -@tab '@math{\cup}' -@c ---------- -@item \ni -@tab '@math{\ni}' -@tab -@tab \in -@tab '@math{\in}' -@tab -@tab \div -@tab '@math{\div}' -@c ---------- -@item \equiv -@tab '@math{\equiv}' -@tab -@tab \int -@tab '@math{\int}' -@tab -@tab \perp -@tab '@math{\perp}' -@c ---------- -@item \wedge -@tab '@math{\wedge}' -@tab -@tab \vee -@tab '@math{\vee}' -@tab -@tab \supseteq -@tab '@math{\supseteq}' -@c ---------- -@item \supset -@tab '@math{\supset}' -@tab -@tab \subseteq -@tab '@math{\subseteq}' -@tab -@tab \subset -@tab '@math{\subset}' -@c ---------- -@item \clubsuit -@tab '@math{\clubsuit}' -@tab -@tab \spadesuit -@tab '@math{\spadesuit}' -@tab -@tab \heartsuit -@tab '@math{\heartsuit}' -@c ---------- -@item \diamondsuit -@tab '@math{\diamondsuit}' -@tab -@tab \copyright -@tab '@math{\copyright}' -@tab -@tab \leftarrow -@tab '@math{\leftarrow}' -@c ---------- -@item \uparrow -@tab '@math{\uparrow}' -@tab -@tab \rightarrow -@tab '@math{\rightarrow}' -@tab -@tab \downarrow -@tab '@math{\downarrow}' -@c ---------- -@item \leftrightarrow -@tab '@math{\leftrightarrow}' -@tab -@tab \updownarrow -@tab '@math{\updownarrow}' -@tab -@c ---------- -@end multitable -@caption{@TeX{} character codes and the resulting symbols.} -@end float -@end iftex -@c --------------------------------- diff -r 9958cead45e2 -r b5d9b95d1e1a doc/interpreter/octave.texi --- a/doc/interpreter/octave.texi Tue Apr 19 12:30:18 2016 +0200 +++ b/doc/interpreter/octave.texi Tue Apr 19 15:27:19 2016 +0200 @@ -185,7 +185,6 @@ * Object Oriented Programming:: * GUI Development:: * System Utilities:: -* Java Interface:: * Packages:: * External Code Interface:: * Test and Demo Functions:: @@ -803,20 +802,6 @@ * URL Manipulation:: * Base64 and Binary Data Transmission:: -Java Interface - -* Java Interface Functions:: -* Dialog Box Functions:: -* FAQ - Frequently asked Questions:: - -FAQ - Frequently asked Questions - -* How to distinguish between Octave and Matlab?:: -* How to make Java classes available?:: -* How to create an instance of a Java class?:: -* How can I handle memory limitations?:: -* Which @TeX{} symbols are implemented in dialog functions?:: - Packages * Installing and Removing Packages:: @@ -836,6 +821,7 @@ * Oct-Files:: * Mex-Files:: * Standalone Programs:: +* Java Interface:: Oct-Files @@ -869,6 +855,13 @@ * Sparse Matrices with Mex-Files:: * Calling Other Functions in Mex-Files:: +Java Interface + +* Java Interface Functions:: +* Making Java classes available:: +* Creating an instance of a Java class:: +* Handling Java memory limitations:: + Test and Demo Functions * Test Functions:: @@ -895,7 +888,8 @@ * Actual Bugs:: Bugs we will fix later. * Reporting Bugs:: -* Service:: +* How To Get Help with Octave:: +* How to distinguish between Octave and Matlab:: Reporting Bugs @@ -970,7 +964,6 @@ @include oop.texi @include gui.texi @include system.texi -@include java.texi @include package.texi @c maybe add again later, if anyone every writes any really interesting diff -r 9958cead45e2 -r b5d9b95d1e1a doc/module.mk --- a/doc/module.mk Tue Apr 19 12:30:18 2016 +0200 +++ b/doc/module.mk Tue Apr 19 15:27:19 2016 +0200 @@ -136,17 +136,6 @@ doc/interpreter/octave-config.1 \ doc/interpreter/octave.1 -DOC_JAVA_IMAGES = \ - doc/interpreter/java-images/image001.png \ - doc/interpreter/java-images/image002.png \ - doc/interpreter/java-images/image003.png \ - doc/interpreter/java-images/image004.png \ - doc/interpreter/java-images/image005.png \ - doc/interpreter/java-images/image006.png \ - doc/interpreter/java-images/image007.png \ - doc/interpreter/java-images/image008.png \ - doc/interpreter/java-images/image009.png - BUILT_DOC_IMAGES += \ $(BUILT_DOC_IMAGES_EPS) \ $(BUILT_DOC_IMAGES_PDF) \ @@ -159,15 +148,10 @@ DOC_IMAGES_TXT += $(BUILT_DOC_IMAGES_TXT) DOC_IMAGES += \ - $(BUILT_DOC_IMAGES) \ - $(DOC_JAVA_IMAGES) + $(BUILT_DOC_IMAGES) $(BUILT_DOC_IMAGES): | $(OCTAVE_INTERPRETER_TARGETS) -## FIXME: DOC_JAVA_IMAGES will eventually need to be added to the HTML build. -## It will require a different Makefile rule later because -## DOC_JAVA_IMAGES live in a subdir rather than in the current directory. - HTMLDIR_IMAGES = $(patsubst doc/interpreter/%.png, doc/interpreter/octave.html/%.png, $(DOC_IMAGES_PNG)) LOGOS = \ @@ -205,7 +189,6 @@ doc/interpreter/interp.texi \ doc/interpreter/intro.texi \ doc/interpreter/io.texi \ - doc/interpreter/java.texi \ doc/interpreter/linalg.texi \ doc/interpreter/matrix.texi \ doc/interpreter/nonlin.texi \ diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/errordlg.m --- a/scripts/gui/errordlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/errordlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -17,41 +17,60 @@ ## . ## -*- texinfo -*- -## @deftypefn {} {@var{h} =} errordlg (@var{msg}) +## @deftypefn {} {@var{h} =} errordlg () +## @deftypefnx {} {@var{h} =} errordlg (@var{msg}) ## @deftypefnx {} {@var{h} =} errordlg (@var{msg}, @var{title}) ## @deftypefnx {} {@var{h} =} errordlg (@var{msg}, @var{title}, @var{createmode}) -## Display @var{msg} using an error dialog box. -## -## The message may have multiple lines separated by newline characters ("\n"), -## or it may be a cellstr array with one element for each line. +## Display an error message @var{msg} using an error dialog box with caption +## @var{title} (character string). The default error message is +## @qcode{"This is the default error string."} and the default caption is +## @qcode{"Error Dialog"}. ## -## The optional input @var{title} (character string) can be used to set the -## dialog caption. The default title is @qcode{"Error Dialog"}. +## The error message may have multiple lines separated by newline characters +## ("\n"), or it may be a cellstr array with one element for each line. ## -## The return value is always 1. +## The return value @var{h} is always 1. ## ## Compatibility Note: The optional argument @var{createmode} is accepted for -## @sc{matlab} compatibility, but is not implemented. +## @sc{matlab} compatibility, but is not implemented. See @code{msgbox} for +## details. +## +## Examples: +## +## @example +## @group +## errordlg ("Some fancy error occured."); +## errordlg ("Some fancy error\nwith two lines."); +## errordlg (@{"Some fancy error", "with two lines."@}); +## errordlg ("Some fancy error occured.", "Fancy caption"); +## @end group +## @end example ## ## @seealso{helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg} ## @end deftypefn -function retval = errordlg (msg, title = "Error Dialog", varargin) +function retval = errordlg (varargin) + + narginchk (0, 3); - if (nargin < 1 || nargin > 3) - print_usage (); + box_msg = "This is the default error string."; + box_title = "Error Dialog"; + + if (nargin > 0) + box_msg = varargin{1}; + endif + if (nargin > 1) + box_title = varargin{2}; endif - retval = message_dialog ("errordlg", msg, title, "error", varargin{:}); + if (nargin < 3) + retval = msgbox (box_msg, box_title, "error"); + else + retval = msgbox (box_msg, box_title, "error", varargin{3}); + endif endfunction - -%!demo -%! disp ('- test errordlg with prompt only.'); -%! errordlg ('Oops, an expected error occurred'); - -%!demo -%! disp ('- test errordlg with prompt and caption.'); -%! errordlg ('Oops another error','This is a very long and informative caption'); - +%!error errordlg (1, 2, 3, 4) +%!error errordlg (1) +%!error errordlg ("msg", 1) diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/helpdlg.m --- a/scripts/gui/helpdlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/helpdlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -17,37 +17,51 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{h} =} helpdlg (@var{msg}) +## @deftypefn {} {@var{h} =} helpdlg () +## @deftypefnx {} {@var{h} =} helpdlg (@var{msg}) ## @deftypefnx {} {@var{h} =} helpdlg (@var{msg}, @var{title}) -## Display @var{msg} in a help dialog box. +## Display help message @var{msg} using a help dialog box with caption +## @var{title} (character string). The default help message is +## @qcode{"This is the default help string."} and the default caption is +## @qcode{"Help Dialog"}. +## +## The help message may have multiple lines separated by newline characters +## ("\n"), or it may be a cellstr array with one element for each line. ## -## The message may have multiple lines separated by newline characters -## ("\n"), or it may be a cellstr array with one element for each -## line. +## The return value @var{h} is always 1. +## +## Examples: ## -## The optional input @var{title} (character string) can be used to -## set the dialog caption. The default title is @qcode{"Help Dialog"}. +## @example +## @group +## helpdlg ("Some helpful text for the user."); +## helpdlg ("Some helpful text\nwith two lines."); +## helpdlg (@{"Some helpful text", "with two lines."@}); +## helpdlg ("Some helpful text for the user.", "Fancy caption"); +## @end group +## @end example ## -## The return value is always 1. ## @seealso{errordlg, inputdlg, listdlg, msgbox, questdlg, warndlg} ## @end deftypefn -function retval = helpdlg (msg, title = "Help Dialog") +function retval = helpdlg (varargin) + + narginchk (0, 2); - if (nargin < 1 || nargin > 2) - print_usage (); + box_msg = "This is the default help string."; + box_title = "Help Dialog"; + + if (nargin > 0) + box_msg = varargin{1}; + endif + if (nargin > 1) + box_title = varargin{2}; endif - retval = message_dialog ("helpdlg", msg, title, "help"); + retval = msgbox (box_msg, box_title, "help"); endfunction - -%!demo -%! disp ('- test helpdlg with a help message only.'); -%! helpdlg ("Below, you should see 3 lines:\nline #1\nline #2, and\nline #3."); - -%!demo -%! disp ('- test helpdlg with help message and caption.'); -%! helpdlg ('You should see a single line.','A help dialog'); - +%!error<narginchk> helpdlg (1, 2, 3) +%!error<MSG must be a character string> helpdlg (1) +%!error<TITLE must be a character string> helpdlg ("msg", 1) diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/inputdlg.m --- a/scripts/gui/inputdlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/inputdlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -50,14 +50,24 @@ ## A list of default values to place in each text fields. It must be a cell ## array of strings with the same size as @var{prompt}. ## @end table +## +## Example: +## +## @example +## @group +## prompt = @{"Width", "Height", "Depth"@}; +## defaults = @{"1.10", "2.20", "3.30"@}; +## rowscols = [1,10; 2,20; 3,30]; +## dims = inputdlg (prompt, "Enter Box Dimensions", rowscols, defaults); +## @end group +## @end example +## ## @seealso{errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg} ## @end deftypefn -function cstr = inputdlg (prompt, title = "Input Dialog", varargin) +function cstr = inputdlg (prompt, varargin) - if (nargin < 1 || nargin > 4) - print_usage (); - endif + narginchk (1, 4); if (iscell (prompt)) ## Silently extract only char elements @@ -65,26 +75,26 @@ elseif (ischar (prompt)) prompt = {prompt}; else - error ("inputdlg: PROMPT must be a character string or cellstr array"); - endif - - if (! ischar (title)) - error ("inputdlg: TITLE must be a character string"); + error ("PROMPT must be a character string or cellstr array"); endif - switch (numel (varargin)) - case 0 - linespec = 1; - defaults = cellstr (cell (size (prompt))); + dlg_title = "Input Dialog"; + if (nargin > 1) + dlg_title = varargin{1}; + if (! ischar (dlg_title)) + error ("TITLE must be a character string"); + endif + endif - case 1 - linespec = varargin{1}; - defaults = cellstr (cell (size (prompt))); + linespec = 1; + if (nargin > 2) + linespec = varargin{2}; + endif - case 2 - linespec = varargin{1}; - defaults = varargin{2}; - endswitch + defaults = cellstr (cell (size (prompt))); + if (nargin > 3) + defaults = varargin{3}; + endif ## specification of text field sizes as in Matlab ## Matlab requires a matrix for linespec, not a cell array... @@ -94,7 +104,7 @@ ## r2 2 20 second text field is 2x20 ## r3 3 30 third text field is 3x30 if (! isnumeric (linespec)) - error ("inputdlg: ROWSCOLS must be numeric"); + error ("ROWSCOLS must be numeric"); endif if (isscalar (linespec)) @@ -111,35 +121,26 @@ rowscols(:,2) = 25; rowscols(:,1) = linespec(:); else - error ("inputdlg: ROWSCOLS vector does not match size of PROMPT"); + error ("ROWSCOLS vector does not match size of PROMPT"); endif elseif (ismatrix (linespec)) if (rows (linespec) == columns (prompt) && columns (linespec) == 2) ## (rows x columns) match, copy array linespec rowscols = linespec; else - error ("inputdlg: ROWSCOLS matrix does not match size of PROMPT"); + error ("ROWSCOLS matrix does not match size of PROMPT"); endif else ## dunno - error ("inputdlg: unknown form of ROWSCOLS argument"); + error ("unknown form of ROWSCOLS argument"); endif rowscols = ceil (rowscols); ## convert numeric values in defaults cell array to strings defs = cellfun (@num2str, defaults, "UniformOutput", false); - rc = arrayfun (@num2str, rowscols, "UniformOutput", false); if (__octave_link_enabled__ ()) - cstr = __octave_link_input_dialog__ (prompt, title, rowscols, defs); - elseif (__have_feature__ ("JAVA")) - user_inputs = javaMethod ("inputdlg", "org.octave.JDialogBox", - prompt, title, rc, defs); - if (isempty (user_inputs)) - cstr = {}; - else - cstr = cellstr (user_inputs); - endif + cstr = __octave_link_input_dialog__ (prompt, dlg_title, rowscols, defs); else error ("inputdlg is not available in this version of Octave"); endif @@ -209,3 +210,9 @@ %! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); %! end +%!error<narginchk> inputdlg (1, 2, 3, 4, 5) +%!error<PROMPT must be a character string> inputdlg (1) +%!error<TITLE must be a character string> inputdlg ("msg", 1) +%!error<ROWSCOLS must be numeric> inputdlg ("msg", "title", "1") +%!error<ROWSCOLS vector does not match size> +%! inputdlg ({"a1", "a2"}, "title", [1, 2, 3]) diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/listdlg.m --- a/scripts/gui/listdlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/listdlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -65,12 +65,16 @@ ## ## @example ## @group -## [sel, ok] = listdlg ("ListString", @{"An item", "another", "yet another"@}, +## my_options = @{"An item", "another", "yet another"@}; +## [sel, ok] = listdlg ("ListString", my_options, ## "SelectionMode", "Multiple"); ## if (ok == 1) +## disp ("You selected:"); ## for i = 1:numel (sel) -## disp (sel(i)); +## disp (sprintf ("\t%s", my_options@{sel(i)@})); ## endfor +## else +## disp ("You cancelled."); ## endif ## @end group ## @end example @@ -135,30 +139,6 @@ [sel, ok] = __octave_link_list_dialog__ (listcell, selmode, listsize, initialvalue, name, prompt, okstring, cancelstring); - elseif (__have_feature__ ("JAVA")) - ## transform matrices to cell arrays of strings - ## swap width and height to correct calling format for JDialogBox - listsize = {num2str(listsize(2)), num2str(listsize(1))}; - initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false); - if (isempty (prompt)) - prompt = {""}; - endif - - ret = javaMethod ("listdlg", "org.octave.JDialogBox", listcell, - selmode, listsize, initialvalue, name, prompt, - okstring, cancelstring); - - if (numel (ret) > 0) - sel = zeros (1, numel (ret)); - ## for loop needed to convert Java array ret into Octave double sel - for i = 1:numel (ret) - sel(i) = ret(i); - endfor - ok = 1; - else - sel = []; - ok = 0; - endif else error ("listdlg is not available in this version of Octave"); endif diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/module.mk --- a/scripts/gui/module.mk Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/module.mk Tue Apr 19 15:27:19 2016 +0200 @@ -10,8 +10,7 @@ scripts/gui/private/__uigetdir_fltk__.m \ scripts/gui/private/__uigetfile_fltk__.m \ scripts/gui/private/__uiobject_split_args__.m \ - scripts/gui/private/__uiputfile_fltk__.m \ - scripts/gui/private/message_dialog.m + scripts/gui/private/__uiputfile_fltk__.m scripts_gui_FCN_FILES = \ scripts/gui/errordlg.m \ diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/msgbox.m --- a/scripts/gui/msgbox.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/msgbox.m Tue Apr 19 15:27:19 2016 +0200 @@ -36,27 +36,90 @@ ## The return value is always 1. ## ## Compatibility Note: The optional argument @var{createmode} is accepted for -## @sc{matlab} compatibility, but is not implemented. +## @sc{matlab} compatibility, but is not implemented. A valid @var{createmode} +## is either one of the character strings @qcode{"nonmodal"}, @qcode{"modal"}, +## or @qcode{"replace"}, or a structure containing a field +## @qcode{"WindowStyle"} with one of the three character strings. +## +## Examples: +## +## @example +## @group +## msgbox ("Some message for the user."); +## msgbox ("Some message\nwith two lines."); +## msgbox (@{"Some message", "with two lines."@}); +## msgbox ("Some message for the user.", "Fancy caption"); +## +## % A message dialog box with error icon +## msgbox ("Some message for the user.", "Fancy caption", "error"); +## @end group +## @end example ## ## @seealso{errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg} ## @end deftypefn -function retval = msgbox (msg, title = "", varargin) +function retval = msgbox (msg, varargin) + + narginchk (1, 4); - if (nargin < 1 || nargin > 4) - print_usage (); + if (! ischar (msg)) + if (iscell (msg)) + msg = sprintf ("%s\n", msg{:}); + msg(end) = ""; + else + error ("MSG must be a character string or cellstr array"); + endif endif - retval = message_dialog ("msgbox", msg, title, varargin{:}); + box_title = ""; + box_icon = "none"; + + if (nargin > 1) + ## check last element to be a structure CREATEMODE + if (isstruct (varargin{end}) && isfield (varargin{end}, "WindowStyle")) + varargin{end} = varargin{end}.WindowStyle; + endif + ## print warning for unsupported CREATEMODE + if ((ischar (varargin{end})) + && (ismember (varargin{end}, {"nonmodal", "modal", "replace"}))) + warning ("CREATEMODE %s is not yet supported", varargin{end}); + nargin = nargin - 1; + elseif (nargin == 4) + error ("CREATEMODE is not a valid type"); + endif + + if ((nargin > 1) && (! ischar (varargin{1}))) + error ("TITLE must be a character string"); + else + box_title = varargin{1}; + endif + + if (nargin > 2) + box_icon = varargin{2}; + switch (box_icon) + case {"error", "help", "warn", "none"} + ## do nothing, all valid + case "custom" + warning ("custom icons are not yet supported"); + otherwise + error ("ICON is not a valid type") + endswitch + endif + endif + + ## make a GUI element or print to console + if (__octave_link_enabled__ ()) + retval = __octave_link_message_dialog__ (box_icon, msg, box_title); + else + disp (sprintf ("\n%s:\t%s\n\t%s\n", upper (box_icon), box_title, + strrep (msg, "\n", "\n\t"))); + retval = 1; + endif endfunction - -%!demo -%! disp('- test msgbox message only.'); -%! msgbox("Below, you should see 3 lines:\nline #1\nline #2, and\nline #3."); - -%!demo -%! disp('- test msgbox message and caption.'); -%! msgbox('You should see a single line.','A msgbox'); - +%!error<narginchk> msgbox (1, 2, 3, 4, 5) +%!error<MSG must be a character string> msgbox (1) +%!error<TITLE must be a character string> msgbox ("msg", 1) +%!error<ICON is not a valid type> msgbox ("msg", "title", 1) +%!error<CREATEMODE is not a valid> msgbox ("msg", "title", "help", "wrong") diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/private/message_dialog.m --- a/scripts/gui/private/message_dialog.m Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -## Copyright (C) 2010, 2013 Martin Hepperle -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {} {@var{h} =} message_dialog (@var{caller}, @var{msg}, @var{title}, @var{icon}, @var{createmode}) -## Undocumented internal function. -## @end deftypefn - -function retval = message_dialog (caller, msg, title = "", icon, createmode) - - if (! ischar (msg)) - if (iscell (msg)) - msg = sprintf ("%s\n", msg{:}); - msg(end) = ""; - else - error ("%s: MSG must be a character string or cellstr array", caller); - endif - endif - - if (! ischar (title)) - error ("%s: TITLE must be a character string", caller); - endif - - dlg = "emptydlg"; - if (nargin >= 4) - switch (icon) - case "error" - dlg = "errordlg"; - case "help" - dlg = "helpdlg"; - case "warn" - dlg = "warndlg"; - case "none" - dlg = "emptydlg"; - case "custom" - icon = "emptydlg"; - warning ("%s: custom icons not yet supported", caller); - otherwise - error ("%s: ICON is not a valid type", caller); - endswitch - else - icon = "none"; - endif - - if (nargin == 5) - if ((isstruct (createmode)) && (isfield (createmode, "WindowStyle"))) - createmode = createmode.WindowStyle; - endif - switch (createmode) - case {"nonmodal", "non-modal", "modal", "replace"} - warning ("%s: %s is not yet supported", caller, createmode); - otherwise - error ("%s: CREATEMODE is not a valid type", caller); - endswitch - endif - - if (__octave_link_enabled__ ()) - retval = __octave_link_message_dialog__ (icon, msg, title); - elseif (__have_feature__ ("JAVA")) - retval = javaMethod (dlg, "org.octave.JDialogBox", msg, title); - else - error ("%s is not available in this version of Octave", dlg); - endif - -endfunction - diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/questdlg.m --- a/scripts/gui/questdlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/questdlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -43,7 +43,18 @@ ## If only two button captions, @var{btn1} and @var{btn2}, are specified the ## dialog will have only these two buttons. ## -## @seealso{errordlg, helpdlg, inputdlg, listdlg, warndlg} +## Examples: +## +## @example +## @group +## btn = questdlg ("Close Octave?", "Some fancy title", "Yes", "No", "No"); +## if (strcmp (btn, "Yes")) +## exit (); +## endif +## @end group +## @end example +## +## @seealso{errordlg, helpdlg, inputdlg, listdlg, msgbox, warndlg} ## @end deftypefn function btn = questdlg (msg, title = "Question Dialog", varargin) @@ -111,9 +122,6 @@ if (__octave_link_enabled__ ()) btn = __octave_link_question_dialog__ (msg, title, options{1}, options{2}, options{3}, options{4}); - elseif (__have_feature__ ("JAVA")) - btn = javaMethod ("questdlg", "org.octave.JDialogBox", msg, - title, options); else error ("questdlg is not available in this version of Octave"); endif @@ -172,4 +180,3 @@ %! endif %! endif %! endif - diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/gui/warndlg.m --- a/scripts/gui/warndlg.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/gui/warndlg.m Tue Apr 19 15:27:19 2016 +0200 @@ -17,41 +17,60 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{h} =} warndlg (@var{msg}) +## @deftypefn {} {@var{h} =} warndlg () +## @deftypefnx {} {@var{h} =} warndlg (@var{msg}) ## @deftypefnx {} {@var{h} =} warndlg (@var{msg}, @var{title}) ## @deftypefnx {} {@var{h} =} warndlg (@var{msg}, @var{title}, @var{createmode}) -## Display @var{msg} using a warning dialog box. -## -## The message may have multiple lines separated by newline characters ("\n"), -## or it may be a cellstr array with one element for each line. +## Display warning message @var{msg} using a warning dialog box with caption +## @var{title} (character string). The default warning message is +## @qcode{"This is the default warning string."} and the default caption is +## @qcode{"Warning Dialog"}. ## -## The optional input @var{title} (character string) can be used to set the -## dialog caption. The default title is @qcode{"Warning Dialog"}. +## The warning message may have multiple lines separated by newline characters +## ("\n"), or it may be a cellstr array with one element for each line. ## -## The return value is always 1. +## The return value @var{h} is always 1. ## ## Compatibility Note: The optional argument @var{createmode} is accepted for -## @sc{matlab} compatibility, but is not implemented. +## @sc{matlab} compatibility, but is not implemented. See @code{msgbox} for +## details. +## +## Examples: ## -## @seealso{helpdlg, inputdlg, listdlg, questdlg} +## @example +## @group +## warndlg ("Some warning text for the user."); +## warndlg ("Some warning text\nwith two lines."); +## warndlg (@{"Some warning text", "with two lines."@}); +## warndlg ("Some warning text for the user.", "Fancy caption"); +## @end group +## @end example +## +## @seealso{errordlg, helpdlg, inputdlg, listdlg, msgbox, questdlg} ## @end deftypefn -function retval = warndlg (msg, title = "Warning Dialog", varargin) +function retval = warndlg (varargin) + + narginchk (0, 3); - if (nargin < 1 || nargin > 3) - print_usage (); + box_msg = "This is the default warning string."; + box_title = "Warning Dialog"; + + if (nargin > 0) + box_msg = varargin{1}; + endif + if (nargin > 1) + box_title = varargin{2}; endif - retval = message_dialog ("warndlg", msg, title, "warn", varargin{:}); + if (nargin < 3) + retval = msgbox (box_msg, box_title, "warn"); + else + retval = msgbox (box_msg, box_title, "warn", varargin{3}); + endif endfunction - -%!demo -%! disp ('- test warndlg with prompt only.'); -%! warndlg ('Oh, a warning occurred'); - -%!demo -%! disp ('- test warndlg with prompt and caption.'); -%! warndlg ('Oh, No...','This is the last Warning'); - +%!error<narginchk> warndlg (1, 2, 3, 4) +%!error<MSG must be a character string> warndlg (1) +%!error<TITLE must be a character string> warndlg ("msg", 1) diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/module.mk --- a/scripts/java/module.mk Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/java/module.mk Tue Apr 19 15:27:19 2016 +0200 @@ -25,48 +25,24 @@ $(org_octave_dir)/OctClassLoader.java \ $(org_octave_dir)/Octave.java \ $(org_octave_dir)/OctaveReference.java \ - $(org_octave_dir)/Matrix.java \ - $(org_octave_dir)/JDialogBox.java \ - $(org_octave_dir)/DlgListener.java \ - $(org_octave_dir)/TeXtranslator.java \ - $(org_octave_dir)/TeXcode.java + $(org_octave_dir)/Matrix.java endif JAVA_CLASSES = $(JAVA_SRC:.java=.class) -JAVA_IMAGES = \ - $(org_octave_dir)/images/question.png \ - $(org_octave_dir)/images/error.png \ - $(org_octave_dir)/images/warning.png \ - $(org_octave_dir)/images/information.png \ - $(org_octave_dir)/images/octave.png - scripts_java_JAVA_SRC = $(addprefix scripts/java/, $(JAVA_SRC)) scripts_java_JAVA_CLASSES = $(addprefix scripts/java/, $(JAVA_CLASSES)) -scripts_java_JAVA_IMAGES = $(addprefix scripts/java/, $(JAVA_IMAGES)) - -scripts_DISTCLEANFILES += $(addprefix $(abs_top_builddir), $(java_JAVA_IMAGES)) - -srcdir_scripts_java_JAVA_IMAGES = $(addprefix $(srcdir)/scripts/java/, $(JAVA_IMAGES)) - $(scripts_java_JAVA_CLASSES) : %.class : %.java | scripts/java/$(octave_dirstamp) $(AM_V_GEN)$(MKDIR_P) scripts/java/$(org_octave_dir) && \ ( cd $(srcdir)/scripts/java; "$(JAVAC)" -source 1.3 -target 1.3 -Xlint:-options -d $(abs_top_builddir)/scripts/java $(org_octave_dir)/$(<F) ) -scripts/java/.images-stamp: $(srcdir_scripts_java_JAVA_IMAGES) - $(AM_V_GEN)if [ "x$(srcdir)" != "x." ]; then \ - $(MKDIR_P) scripts/java/$(org_octave_dir)/images; \ - cp $(srcdir_scripts_java_JAVA_IMAGES) scripts/java/$(org_octave_dir)/images; \ - fi && \ - touch $@ - if AMCOND_HAVE_JAVA -scripts/java/octave.jar: scripts/java/.images-stamp $(scripts_java_JAVA_CLASSES) +scripts/java/octave.jar: $(scripts_java_JAVA_CLASSES) $(AM_V_GEN)rm -f $@-t $@ && \ ( cd scripts/java; \ - "$(JAR)" cf octave.jar-t $(JAVA_CLASSES) $(JAVA_IMAGES) ) && \ + "$(JAR)" cf octave.jar-t $(JAVA_CLASSES) ) && \ mv $@-t $@ endif @@ -84,11 +60,8 @@ scripts_EXTRA_DIST += \ $(scripts_java_JAR_FILES) \ - $(scripts_java_JAVA_SRC) \ - $(scripts_java_JAVA_IMAGES) + $(scripts_java_JAVA_SRC) scripts_CLEANFILES += \ $(scripts_java_JAR_FILES) \ $(scripts_java_JAVA_CLASSES) - -scripts_DISTCLEANFILES += scripts/java/.images-stamp diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/DlgListener.java --- a/scripts/java/org/octave/DlgListener.java Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,164 +0,0 @@ -/* - -Copyright (C) 2010, 2013 Martin Hepperle - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. - -Octave is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -<http://www.gnu.org/licenses/>. - -*/ - -package org.octave; - -import java.awt.event.*; -import javax.swing.*; - -/** - * <p>Implements button click actions for dialog box functions</p> - * - * <p>Copyright (c) 2010 Martin Hepperle</p> - * - * @author Martin Hepperle - * @version 1.0 - */ -public class DlgListener - extends WindowAdapter implements ActionListener, KeyListener -{ - // the parent frame of the dialog - JDialogBox m_Parent; - - public DlgListener (JDialogBox d) - { - m_Parent = d; - } - - - // - // --- extension of the WindowAdapter class --- - // - /** - * Called when the user clicks the close button on the window frame. - * - * @param e WindowEvent - */ - public void windowClosing (WindowEvent e) - { - m_Parent.closeDialog (JDialogBox.CLOSE_CANCEL); - } - - public void windowOpened(WindowEvent e) - { - m_Parent.setFocus(); - } - - - // - // --- implementation of the ActionListener interface --- - // - /** - * Called when the user clicks a button in the dialog. - * Closes the dialog when either a button with an - * action command OK, CANCEL or NO is pressed. - * - * @param e ActionEvent - */ - public void actionPerformed (ActionEvent e) - { - if (e.getActionCommand ().equals ("OK")) - { - m_Parent.closeDialog (JDialogBox.CLOSE_OK); - } - else if (e.getActionCommand ().equals ("CANCEL")) - { - m_Parent.closeDialog (JDialogBox.CLOSE_CANCEL); - } - else if (e.getActionCommand ().equals ("NO")) - { - m_Parent.closeDialog (JDialogBox.CLOSE_NO); - } - else if (e.getActionCommand ().equals ("SELALL")) - { - m_Parent.SelectAll (); - } - } - - - // - // --- implementation of the KeyListener interface --- - // - /** - * Closes the dialog when the ENTER or ESCAPE keys are released. - * - * @param e KeyEvent - */ - public void keyTyped (KeyEvent e) - { - if (e.getKeyCode () == KeyEvent.VK_ESCAPE) - { - m_Parent.closeDialog (JDialogBox.CLOSE_CANCEL); - } - } - - - /** - * @param e KeyEvent - */ - public void keyPressed (KeyEvent e) - { - if (e.getSource ().getClass ().equals (JTextArea.class)) - { - JTextArea ta = (JTextArea) e.getSource (); - if (e.getKeyCode () == KeyEvent.VK_ENTER) - { - char c[] = ta.getText ().toCharArray (); - int nLines = 1; - for (int i = 0; i < c.length; i++) - { - if (c[i] == '\n') - { - nLines++; - } - } - - if (nLines >= ta.getRows ()) - { - e.consume (); - } - } - else if (e.getKeyCode () == KeyEvent.VK_TAB) - { - e.consume (); - - if ((e.getModifiersEx () & KeyEvent.SHIFT_DOWN_MASK) == - KeyEvent.SHIFT_DOWN_MASK) - { - ta.transferFocusBackward(); - } - else - { - ta.transferFocus (); - } - } - } - } - - - /** - * @param e KeyEvent - */ - public void keyReleased (KeyEvent e) - { - } -} diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/JDialogBox.java --- a/scripts/java/org/octave/JDialogBox.java Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,996 +0,0 @@ -/* - -Copyright (C) 2014-2015 Colin Foster -Copyright (C) 2010, 2013 Martin Hepperle - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. - -Octave is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -<http://www.gnu.org/licenses/>. - -*/ - -package org.octave; - -import java.net.*; -import java.util.*; - -import java.awt.*; -import javax.swing.*; - -/** - * <p>Implementation of various dialog box functions</p> - * - * <p>The following functions are provided for being called via - * Octave script files:</p> - * <ul> - * <li>errordlg</li> - * <li>helpdlg</li> - * <li>inputdlg</li> - * </ul> - * - * <p>Copyright (c) 2010 Martin Hepperle</p> - * - * @author Martin Hepperle - * @version 1.0 - */ -public class JDialogBox -{ - public static final int CLOSE_OK = 1; - public static final int CLOSE_NO = 2; - public static final int CLOSE_CANCEL = 3; - - // dialog type - public static int FLAG_LABEL = 1; - public static int FLAG_TEXT = 2; - public static int FLAG_INPUT = 4; - public static int FLAG_LIST = 8; - // icon selection - public static int FLAG_QUESTION = 32; - public static int FLAG_ERROR = 64; - public static int FLAG_WARNING = 128; - public static int FLAG_INFORMATION = 256; - - public static int DLG_QUEST = FLAG_QUESTION | FLAG_TEXT; - public static int DLG_INPUT = FLAG_QUESTION | FLAG_INPUT; - public static int DLG_LIST = FLAG_QUESTION | FLAG_LIST; - - private final static String m_OK = "OK"; - private final static String m_Yes = "Yes"; - private final static String m_No = "No"; - private final static String m_Cancel = "Cancel"; - - private JButton m_ButtonNO; - private JButton m_ButtonOK; - private JButton m_ButtonCANCEL; - private JButton m_Focus; - private JTextArea m_TextField[]; - private JList m_List; - private JFrame m_ParentFrame; - private int m_CloseMethod; - - // ------------------------------------ - // implementation of listdlg function - // ------------------------------------ - - /** - * - * @param listcell String[] - a array of strings, one for each list entry - * @param selmode String - * @param sizecell Object[] - * @param initialcell Object[] - * @param name String - * @param promptcell String[] - * @param okstring String - * @param cancelstring String - * @return String[] - */ - public static int[] listdlg (String[] listcell, - String selmode, - Object[] sizecell, - Object[] initialcell, - String name, - String[] promptcell, - String okstring, - String cancelstring) - { - JDialogBox d = new JDialogBox (); - d.genericdlg (promptcell, listcell, name, selmode, - DLG_LIST, - sizecell, initialcell, okstring, null, cancelstring); - return (d.getSelectedIndices ()); - } - - - // ------------------------------------ - // implementation of inputdlg function - // ------------------------------------- - - /** - * Implements a variation of the inputdlg function. - * - * @param prompt String[] - an array of text strings to be used as labels. - * @param title String - a text string to be used to label the dialog caption. - * @param RowsCols int - defines the width of the text fields in columns. - * @param defaults Object[] - an array of text strings or numbers to be - * placed into the text fields as default values. - * @return String[] - an array of text strings containing the content of the - * text fields. - */ - public static String[] inputdlg (String[] prompt, - String title, - Object[] RowsCols, - Object[] defaults) - { - JDialogBox d = new JDialogBox (); - d.genericdlg (prompt, null, title, "on", - FLAG_INPUT | FLAG_QUESTION, - RowsCols, defaults, m_OK, null, m_Cancel); - return (d.getInput ()); - } - - - /** - * Extract the current content from the text fields of an inputdlg. - * - * @return String[] - the text contained in the fields of an inputdlg. - * null if the dialog was cancelled. - */ - private String[] getInput () - { - String s[] = null; - - if (m_CloseMethod == CLOSE_OK) - { - s = new String[m_TextField.length]; - - for (int i = 0; i < s.length; i++) - { - s[i] = new String (m_TextField[i].getText ()); - } - } - - return (s); - } - - - private String getResult () - { - String s = null; - - if (m_CloseMethod == CLOSE_OK) - { - s = m_ButtonOK.getText (); - } - else if (m_CloseMethod == CLOSE_CANCEL) - { - s = m_ButtonCANCEL.getText (); - } - else - { - s = m_ButtonNO.getText (); - } - - return (s); - } - - - /** - * Extract the current content from the text fields of an inputdlg. - * - * @return String[] - the text contained in the fields of an inputdlg. - * null if the dialog was cancelled. - */ - private String[] getSelection () - { - String s[] = null; - - if (m_CloseMethod == CLOSE_OK) - { - int selection[] = m_List.getSelectedIndices (); - - s = new String[selection.length]; - - for (int i = 0; i < s.length; i++) - { - - // s[i] = new String (Integer.toString(selection[i])); - s[i] = (m_List.getSelectedValues ()[i]).toString (); - } - } - - return (s); - } - - - private int[] getSelectedIndices () - { - int s[] = null; - - if (m_CloseMethod == CLOSE_OK) - { - s = m_List.getSelectedIndices (); - for (int i = 0; i < s.length; i++) - { - - // translate to 1 based indices - s[i] = s[i] + 1; - } - } - - return (s); - } - - - public void SelectAll () - { - if (null != m_List) - { - m_List.setSelectionInterval (0, m_List.getModel ().getSize () - 1); - } - } - - - // ------------------------------------- - // implementation of helpdlg function - // ------------------------------------- - - /** - * Implements a simple helpdlg with default text and caption. Not very useful. - * - * Octave > helpdlg('helpstring','title') - * - * Called via helpdlg.m. - * - * @param helpstring String - a message string to be presented to the user. - * The string can have embedded newline (\n) characters to break the message - * into multiple lines. - * @param title String - a text string to be used to label the dialog caption. - * @return int - always 1 - */ - public static int helpdlg (String helpstring, String title) - { - JDialogBox d = new JDialogBox (); - String s[] = new String[1]; - s[0] = helpstring; - return (d.genericdlg (s, null, title, "on", - FLAG_TEXT | FLAG_INFORMATION, null, null, - m_OK, null, m_Cancel)); - } - - - // ------------------------------------- - // implementation of emptydlg function - // ------------------------------------- - - /** - * Implements a simple helpdlg with default text and caption. Not very useful. - * - * Octave > emptydlg('messagestring','title') - * - * Called via dlgbox.m. - * - * @param messagestring String - a message string to be presented to the user. - * The string can have embedded newline (\n) characters to break the message - * into multiple lines. - * @param title String - a text string to be used to label the dialog caption. - * @return int - always 1 - */ - public static int emptydlg (String helpstring, String title) - { - JDialogBox d = new JDialogBox (); - String s[] = new String[1]; - s[0] = helpstring; - return (d.genericdlg (s, null, title, "on", - FLAG_TEXT, null, null, - m_OK, null, m_Cancel)); - } - - - // ------------------------------------------- - // implementation of questdlg related functions - // ------------------------------------------- - - /** - * Implements a simple questdlg with default text and caption. Not very useful. - * - * @param question String - the question to be presented - * @param title String - the caption - * @param options String[] - 'str1', 'str2', 'str3', 'default' - * @return String - the caption of the button pressed by the user - */ - public static String questdlg (String question, - String title, - String[] options) - { - JDialogBox d = new JDialogBox (); - String s[] = new String[1]; - s[0] = question; - d.genericdlg (s, options, title, "on", - DLG_QUEST, null, null, - options[0], options[1], options[2]); - return (d.getResult ()); - } - - - // ------------------------------------- - // implementation of errordlg function - // ------------------------------------- - - /** - * Implements a simple errordlg with default text and caption. Not very useful. - * - * @param errorstring String - the error message to display. - * @param dlgname String - the caption of the dialog box. - * @return int - always 1 - */ - public static int errordlg (String errorstring, String dlgname) - { - JDialogBox d = new JDialogBox (); - String s[] = new String[1]; - s[0] = errorstring; - return (d.genericdlg (s, null, dlgname, "on", FLAG_TEXT | FLAG_ERROR, - null, null, - m_OK, null, m_Cancel)); - } - - - // ------------------------------------------- - // implementation of warndlg related functions - // ------------------------------------------- - - /** - * Implements a simple warndlg with default text and caption. Not very useful. - * - * Called via warndlg.m. - * - * @param errorstring String - the message to be presented to the user. - * @param dlgname String - the caption of the dialog box. - * @return int - always 1 - */ - public static int warndlg (String errorstring, String dlgname) - { - JDialogBox d = new JDialogBox (); - String s[] = new String[1]; - s[0] = errorstring; - return (d.genericdlg (s, null, dlgname, "on", FLAG_TEXT | FLAG_WARNING, - null, null, - m_OK, null, m_Cancel)); - } - - - // ------------------------------------- - // generic dlg function - // ------------------------------------- - /** - * A generic dialog creation and display function. - * - * @param message String[] - * @param list String[] - * @param caption String - * @param on String - * @param flag int - * @param RowsCols Object[] - * @param defaults Object[] - * @param okstring String - * @param nostring String - * @param cancelstring String - * @return int - */ - public int genericdlg (String message[], - String list[], - String caption, - String on, - int flag, - Object[] RowsCols, - Object[] defaults, - String okstring, - String nostring, - String cancelstring) - { - TeXtranslator theTranslator = new TeXtranslator (); - setSystemLnF (true); - - caption = theTranslator.replace (caption); - - m_ButtonNO = null; - m_ButtonOK = null; - m_ButtonCANCEL = null; - - // create a modal dialog with an empty frame as its parent - m_ParentFrame = new JFrame (); - - // --- trick to bring dialog to the front - // In Windows, the dialog is not brought to the foreground, but hidden - // behind the Octave window as long as the parent frame is not visible. - // To avoid that the frame is visible, we move it outside of the screen. - m_ParentFrame.setBounds (Toolkit.getDefaultToolkit ().getScreenSize (). - width + 100, - Toolkit.getDefaultToolkit ().getScreenSize (). - height + 100, 1, 1); - m_ParentFrame.setVisible (true); - //-- end of trick - - JDialog dlg; - dlg = new JDialog (m_ParentFrame); - dlg.setTitle (caption); - - dlg.setModal (true); - dlg.setDefaultCloseOperation (JDialog.DISPOSE_ON_CLOSE); - - DlgListener theListener = new DlgListener (this); - - Container d = dlg.getContentPane (); - d.setLayout (new BorderLayout (8, 8)); - - // spacer - d.add (new JLabel (" "), BorderLayout.NORTH); - d.add (new JLabel (" "), BorderLayout.EAST); - - JPanel p = new JPanel (); - - if (FLAG_LABEL == (FLAG_LABEL & flag)) - { - // a single line label - JLabel l = new JLabel (theTranslator.replace (message[0])); - p.add (l); - } - else if (FLAG_TEXT == (FLAG_TEXT & flag)) - { - String msg = theTranslator.replace (message[0]); - // a multi-line text display for helpdlg - StringTokenizer st = new StringTokenizer (msg, "\n"); - - int nRows = (null == RowsCols) ? 1 : - Integer.parseInt (RowsCols[0].toString ()); - nRows = Math.max (nRows, st.countTokens ()); - int nCols = Math.max (1, msg.length () / nRows); - - p.setLayout (new GridLayout (message.length, 1)); - JTextArea ta = new JTextArea (msg, nRows, nCols); - ta.setEditable (false); - ta.setFocusable (false); - ta.setOpaque (false); - // replace ugly monospaced font - ta.setFont (p.getFont ()); - p.add (ta); - } - else if (FLAG_INPUT == (FLAG_INPUT & flag)) - { - // a multi label/textfield entry dialog for inputdlg - GridBagConstraints gbc = new GridBagConstraints (); - gbc.insets.top = 4; - gbc.insets.left = 8; - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - - p.setLayout (new GridBagLayout ()); - m_TextField = new JTextArea[message.length]; - - // default values - int nRows = 1; - int nCols = 10; - - for (int i = 0; i < message.length; i++) - { - String msg = theTranslator.replace (message[i]); - JLabel l = new JLabel (msg); - l.setHorizontalAlignment (Label.LEFT); - gbc.gridy = 2 * i; - p.add (l, gbc); - /** - * @todo CHECK handling of RowsCols for inputdlg - */ - if (RowsCols != null) - { - if (RowsCols.length == 2 * message.length) - { - nRows = Integer.parseInt (RowsCols[i].toString ()); - nCols = Integer.parseInt (RowsCols[RowsCols.length / 2 + - i].toString ()); - } - } - - m_TextField[i] = new JTextArea ("", Math.max (nRows, 1), nCols); - // avoid resizing - m_TextField[i].setPreferredSize (new Dimension (Math.max (nRows, - 1), nCols)); - m_TextField[i].setAutoscrolls (false); - m_TextField[i].setFont (p.getFont ()); - m_TextField[i].setBorder (new javax.swing.border.EtchedBorder ()); - m_TextField[i].addKeyListener (theListener); - - gbc.gridy = 2 * i + 1; - p.add (m_TextField[i], gbc); - } - - if (defaults != null) - { - if (defaults.length == message.length) - { - for (int i = 0; i < message.length; i++) - { - String def = theTranslator.replace (defaults[i].toString ()); - m_TextField[i].setText (def); - } - } - } - } - else if (DLG_LIST == (DLG_LIST & flag)) - { - GridBagConstraints gbc = new GridBagConstraints (); - gbc.insets.top = 4; - gbc.insets.left = 8; - gbc.gridx = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - - p.setLayout (new GridBagLayout ()); - - for (int i = 0; i < message.length; i++) - { - // a single line label - String msg = theTranslator.replace (message[i]); - JLabel l = new JLabel (msg); - gbc.gridy = i; - p.add (l, gbc); - } - - String lst[] = new String[list.length]; - - for (int i = 0; i < list.length; i++) - { - lst[i] = theTranslator.replace (list[i]); - } - - JScrollPane scrollPane = new JScrollPane(); - m_List = new JList (lst); - scrollPane.setViewportView(m_List); - - - // replace ugly monospaced font - scrollPane.setFont (p.getFont ()); - - scrollPane.setMinimumSize ( - new Dimension ( - Math.max (1, Integer.parseInt (RowsCols[0].toString ())), - Math.max (1, Integer.parseInt (RowsCols[1].toString ())))); - scrollPane.setPreferredSize ( - new Dimension ( - Math.max (1, Integer.parseInt (RowsCols[1].toString ())), - Math.max (1, Integer.parseInt (RowsCols[0].toString ())))); - scrollPane.setBorder (new javax.swing.border.EtchedBorder ()); - - gbc.gridy = message.length; - gbc.fill = GridBagConstraints.HORIZONTAL; - p.add (scrollPane, gbc); - - if (on.toLowerCase ().equals ("single")) - { - // single selection list - m_List.setSelectionMode (ListSelectionModel.SINGLE_SELECTION); - - m_List.setSelectedIndex (Integer.parseInt ( - defaults[0].toString ()) - 1); - } - else - { - // multiple selection possible - m_List.setSelectionMode (ListSelectionModel. - MULTIPLE_INTERVAL_SELECTION); - - int selection[] = new int[defaults.length]; - for (int i = 0; i < defaults.length; i++) - { - selection[i] = Integer.parseInt (defaults[i].toString ()) - 1; - } - m_List.setSelectedIndices (selection); - - JButton b = new JButton ("Select All"); - b.setActionCommand ("SELALL"); - b.addActionListener (theListener); - gbc.gridy = message.length + 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - p.add (b, gbc); - } - - } - - // prepare icon, if any - String sIconFile = null; - String sIconResource = null; - Icon theIcon = null; - - if (FLAG_ERROR == (FLAG_ERROR & flag)) - { - sIconFile = "images/error.png"; - // Java for Windows - sIconResource = "OptionPane.errorIcon"; - // Java for Linux does not offer these standard icons... - } - else if (FLAG_WARNING == (FLAG_WARNING & flag)) - { - sIconFile = "images/warning.png"; - // Java for Windows - sIconResource = "OptionPane.warningIcon"; - // Java for Linux does not offer these standard icons... - } - else if (FLAG_QUESTION == (FLAG_QUESTION & flag)) - { - sIconFile = "images/question.png"; - // Java for Windows - sIconResource = "OptionPane.questionIcon"; - // Java for Linux does not offer these standard icons... - } - else if (FLAG_INFORMATION == (FLAG_INFORMATION & flag)) - { - sIconFile = "images/information.png"; - // Java for Windows - sIconResource = "OptionPane.informationIcon"; - // Java for Linux does not offer these standard icons... - } - - // first try to find the UIManager specific icon to fit look and feel - // Note: the Windows XP look and feel offers 50 icons. - if (sIconResource != null) - { - UIDefaults df = UIManager.getLookAndFeelDefaults (); - theIcon = df.getIcon (sIconResource); - } - - // fallback on bitmap image resource if icon was not found - if (theIcon == null && - sIconFile != null) - { - URL theResource = JDialogBox.class.getResource (sIconFile); - if (theResource != null) - { - theIcon = new ImageIcon (theResource); - } - } - - if (theIcon != null) - { - // dummy panel to provide space around icon - JPanel pi = new JPanel (new GridLayout (1, 3)); - pi.add (new JLabel ()); - pi.add (new JLabel (theIcon)); - pi.add (new JLabel ()); - d.add (pi, BorderLayout.WEST); - - // use Octave icon if available. otherwise use dialog icon - Icon theOctaveIcon = getOctaveIcon (); - prepareFrameIcon (m_ParentFrame, - theOctaveIcon == null ? theIcon : theOctaveIcon); - } - - d.add (p, BorderLayout.CENTER); - - // button bar (2 rows of 3 columns each - - p = new JPanel (); - p.setLayout (new java.awt.GridLayout (2, 3)); - - // spacer row - p.add (new JLabel ()); - p.add (new JLabel ()); - p.add (new JLabel ()); - - if (DLG_QUEST == (DLG_QUEST & flag)) - { - // questdlg with empty option[2]: only two buttons - if (nostring.length () < 1) - { - // spacer: left - p.add (new JLabel ()); - } - } - else - { - // spacer: left - p.add (new JLabel ()); - } - - m_ButtonOK = new JButton (theTranslator.replace (okstring)); - m_ButtonOK.setActionCommand ("OK"); - m_ButtonOK.addActionListener (theListener); - m_Focus = m_ButtonOK; - p.add (m_ButtonOK); - - if (DLG_QUEST == (DLG_QUEST & flag)) - { - // questdlg with empty option[2]: only two buttons - if (nostring.length () > 01) - { - // questdlg has three buttons - m_ButtonNO = new JButton (theTranslator.replace (nostring)); - m_ButtonNO.setActionCommand ("NO"); - m_ButtonNO.addActionListener (theListener); - p.add (m_ButtonNO); - if (DLG_QUEST == (DLG_QUEST & flag)) - { - // select default button - if (list[3].equals (nostring)) - { - m_Focus = m_ButtonNO; - } - } - } - } - - if (DLG_INPUT == (DLG_INPUT & flag) || - DLG_LIST == (DLG_LIST & flag) || - DLG_QUEST == (DLG_QUEST & flag)) - { - m_ButtonCANCEL = new JButton (theTranslator.replace (cancelstring)); - m_ButtonCANCEL.setActionCommand ("CANCEL"); - m_ButtonCANCEL.addActionListener (theListener); - p.add (m_ButtonCANCEL); - if (DLG_QUEST == (DLG_QUEST & flag)) - { - // select default button - if (list[3].equals (cancelstring)) - { - m_Focus = m_ButtonCANCEL; - } - } - } - else - { - // spacer: right - p.add (new JLabel ()); - } - - d.add (p, BorderLayout.SOUTH); - dlg.pack (); - - dlg.addWindowListener (theListener); - - if (on.equals ("on")) - { - m_ParentFrame.setAlwaysOnTop (true); - } - - // center dialog on screen - Dimension dlgSize = dlg.getSize (); - Dimension screenSize = Toolkit.getDefaultToolkit ().getScreenSize (); - - dlg.setLocation ((screenSize.width - dlgSize.width) / 2, - (screenSize.height - dlgSize.height) / 2); - - dlg.setVisible (true); - dlg.requestFocus (); - - m_ParentFrame.setVisible (false); - - return (1); - } - - - /** - * - * @return Icon - null if icon was not found - */ - private Icon getOctaveIcon () - { - Icon theIcon = null; - URL theResource = JDialogBox.class.getResource ("images/octave.png"); - if (theResource != null) - { - theIcon = new ImageIcon (theResource); - } - return theIcon; - } - - - /** - * Replace the standard Java frame icon with an Octave Icon. - * - * @param theFrame Frame - the Frame to decorate - * @param theIcon Icon - the icon to use if octave icon is not found. - */ - private void prepareFrameIcon (Frame theFrame, Icon theIcon) - { - // prepare icon for upper left corner of Frame window - // maybe there is a simpler way to achieve this - int w = theIcon.getIconWidth (); - int h = theIcon.getIconHeight (); - // Frame must be made displayable by packing it for createImage() to succeed - theFrame.pack (); - Image theImage = theFrame.createImage (w, h); - theIcon.paintIcon (theFrame, theImage.getGraphics (), 0, 0); - theFrame.setIconImage (theImage); - } - - - /** - * Select Look and Feel - * - * @param bSystemLnF boolean - if true, the current systesm Look&Feel is used, - * otherwise the Swing/Metal cross platform Look&Feel is used. - */ - private void setSystemLnF (boolean bSystemLnF) - { - try - { - if (bSystemLnF) - { - // switch from Swing LnF to local system LnF - UIManager.setLookAndFeel (UIManager. - getSystemLookAndFeelClassName ()); - } - else - { - // use Swing LnF - UIManager.setLookAndFeel (UIManager. - getCrossPlatformLookAndFeelClassName ()); - } - } - catch (Exception exception) - { - exception.printStackTrace (); - } - } - - - /** - * Called when the dialog is closed. Allows for specific cleanup actions. - * - * @param closeMethod int - OctaveDialog.CLOSE_OK, OctaveDialog.CLOSE_CANCEL - */ - public void closeDialog (int closeMethod) - { - m_CloseMethod = closeMethod; - m_ParentFrame.dispose (); - } - - - public void setFocus () - { - if (null != m_Focus) - { - m_Focus.requestFocus (); - m_ParentFrame.getRootPane ().setDefaultButton (m_Focus); - m_ParentFrame.setAlwaysOnTop (true); - } - } - - - /** - * Tests the dialogs - * - * @param args String[] - not used. - */ - public static void main (String[] args) - { - TeXtranslator t = new TeXtranslator(); - - if (false) - { - // find out key names of icon UI resources - UIDefaults df = UIManager.getLookAndFeelDefaults (); - - for (Enumeration e = df.keys (); e.hasMoreElements ();) - { - String s = e.nextElement ().toString (); - - if (s.toLowerCase ().contains ("icon")) - { - System.out.println (s); - } - } - } - - try - { - Class[] argTypes = new Class[1]; - argTypes[0] = String.class; - - java.lang.reflect.Constructor c = ClassHelper.findConstructor (java.lang.StringBuffer.class, - argTypes); - Object argValues[] = new Object[1]; - argValues[0] = new String("initial value"); - Object sb = c.newInstance(argValues); - System.out.println(sb.toString()); - - ClassHelper.invokeMethod(sb,"append",argValues,argTypes); - System.out.println(sb.toString()); - - argValues = new Object[2]; - argTypes = new Class[2]; - argTypes[0] = Integer.class; - argTypes[1] = String.class; - argValues[0] = new Integer(0); - argValues[1] = new String("inserted"); - - ClassHelper.invokeMethod(sb,"insert",argValues,argTypes); - System.out.println(sb.toString()); - } - catch (Throwable e) - {} - - if (true) - { - return; - } - - helpdlg ("If you need help\nyou should ask for help\nif someone is around\notherwise you are on your own.", - "Information"); - - String[] options = new String[4]; - options[0] = "Yeah \\vartheta is too low"; - options[1] = "Maybe"; - options[2] = "Nay \\vartheta is too high"; - options[3] = "Maybe"; - - System.out.println (questdlg ("Is it too cold?", "Temperature", options)); - - // test variants of errordlg - // does not affect layering of dialog - errordlg ("Background error!", "Error"); - - // test variants of helpdlg - - // test variants of inputdlg - String prompt[] = new String[2]; - prompt[0] = "Question 1"; - prompt[1] = "Question 2"; - String defaults[] = new String[2]; - defaults[0] = "1.1"; - defaults[1] = "2.2"; - String title = "Enter values"; - - Integer rc[] = new Integer[2 * 2]; - rc[0] = new Integer (1); - rc[1] = new Integer (2); - rc[2] = new Integer (10); - rc[3] = new Integer (20); - - inputdlg (prompt, title, rc, defaults); - - String listcell[] = new String[4]; - listcell[0] = "a \\alpha"; - listcell[1] = "b \\beta"; - listcell[2] = "c \\gamma"; - listcell[3] = "d \\delta"; - - Integer size[] = new Integer[2]; - size[0] = new Integer (80); - size[1] = new Integer (100); - - Integer initial[] = new Integer[2]; - initial[0] = new Integer (4); - initial[1] = new Integer (2); - - String promptcell[] = new String[2]; - promptcell[0] = "Select something"; - promptcell[1] = "(or even more than one thing)"; - - int idx[] = listdlg (listcell, - "Multiple", - size, - initial, - "name", - promptcell, - "okstring", - "cancelstring"); - - if (idx != null) - { - for (int i = 0; i < idx.length; i++) - { - System.out.println (idx[i]); - } - } - } -} diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/TeXcode.java --- a/scripts/java/org/octave/TeXcode.java Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - -Copyright (C) 2010, 2013 Martin Hepperle - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. - -Octave is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -<http://www.gnu.org/licenses/>. - -*/ - -// A class to hold a TeX character code -> Unicode translation pair. - -package org.octave; - -public class TeXcode -{ - protected String tex; - protected char ucode; - - public TeXcode (String t, char u) - { - tex = t; - ucode = u; - } -} diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/TeXtranslator.java --- a/scripts/java/org/octave/TeXtranslator.java Tue Apr 19 12:30:18 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,262 +0,0 @@ -/* - -Copyright (C) 2010, 2013 Martin Hepperle - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at -your option) any later version. - -Octave is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -<http://www.gnu.org/licenses/>. - -*/ - -// A primitive TeX character translator. Provides methods to translate -// a subset of TeX symbol strings into their aequivalent Unicode -// representation. -// -// Note that not all Unicode character sets contain all these characters. -// Suitable Windows fonts are e.g.: -// - Lucida Sans Unicode -// - Arial Unicode MS -// - MS Mincho - -package org.octave; - -public class TeXtranslator -{ - private TeXcode m_texTable[] = - { - // lower case - new TeXcode ("alpha", '\u03B1'), - new TeXcode ("beta", '\u03B2'), - new TeXcode ("gamma", '\u03B3'), - new TeXcode ("delta", '\u03B4'), - new TeXcode ("epsilon", '\u03B5'), - new TeXcode ("zeta", '\u03B6'), - new TeXcode ("eta", '\u03B7'), - new TeXcode ("theta", '\u03B8'), - new TeXcode ("vartheta", '\u03D1'), - new TeXcode ("iota", '\u03B9'), - new TeXcode ("kappa", '\u03BA'), - new TeXcode ("lambda", '\u03BB'), - new TeXcode ("mu", '\u03BC'), - new TeXcode ("nu", '\u03BD'), - new TeXcode ("xi", '\u03BE'), - new TeXcode ("pi", '\u03C0'), - new TeXcode ("rho", '\u03C1'), - new TeXcode ("sigma", '\u03C3'), - new TeXcode ("varsigma", '\u03C2'), - new TeXcode ("tau", '\u03C4'), - new TeXcode ("phi", '\u03C6'), - new TeXcode ("chi", '\u03C7'), - new TeXcode ("psi", '\u03C8'), - new TeXcode ("omega", '\u03C9'), - new TeXcode ("upsilon", '\u03C5'), - // upper case - new TeXcode ("Gamma", '\u0393'), - new TeXcode ("Delta", '\u0394'), - new TeXcode ("Theta", '\u0398'), - new TeXcode ("Lambda", '\u039B'), - new TeXcode ("Pi", '\u03A0'), - new TeXcode ("Xi", '\u039E'), - new TeXcode ("Sigma", '\u03A3'), - new TeXcode ("Upsilon", '\u03A5'), - new TeXcode ("Phi", '\u03A6'), - new TeXcode ("Psi", '\u03A8'), - new TeXcode ("Omega", '\u03A9'), - // complex - new TeXcode ("Im", '\u2111'), - new TeXcode ("Re", '\u211c'), - // special - new TeXcode ("leq", '\u2264'), - new TeXcode ("geq", '\u2265'), - new TeXcode ("neq", '\u2260'), - new TeXcode ("pm", '\u00B1'), - new TeXcode ("infty", '\u221E'), - new TeXcode ("partial", '\u2202'), - new TeXcode ("approx", '\u2248'), - new TeXcode ("circ", '\u2218'), - new TeXcode ("bullet", '\u2022'), - new TeXcode ("times", '\u00D7'), - new TeXcode ("sim", '\u007E'), - new TeXcode ("nabla", '\u2207'), - new TeXcode ("ldots", '\u2026'), - new TeXcode ("exists", '\u2203'), - new TeXcode ("neg", '\u00AC'), - new TeXcode ("aleph", '\u2135'), - new TeXcode ("forall", '\u2200'), - new TeXcode ("cong", '\u2245'), - new TeXcode ("wp", '\u2118'), - new TeXcode ("propto", '\u221D'), - new TeXcode ("otimes", '\u2297'), - new TeXcode ("oplus", '\u2295'), - new TeXcode ("oslash", '\u2298'), - new TeXcode ("cap", '\u2229'), - new TeXcode ("cup", '\u222A'), - new TeXcode ("ni", '\u220B'), - new TeXcode ("in", '\u2208'), - new TeXcode ("div", '\u00F7'), - new TeXcode ("equiv", '\u2261'), - new TeXcode ("int", '\u222B'), - new TeXcode ("perp", '\u22A5'), - new TeXcode ("wedge", '\u2227'), - new TeXcode ("vee", '\u2228'), - // sets - new TeXcode ("supseteq", '\u2287'), - new TeXcode ("supset", '\u2283'), - new TeXcode ("subseteq", '\u2286'), - new TeXcode ("subset", '\u2282'), - // cards - new TeXcode ("clubsuit", '\u2663'), - new TeXcode ("spadesuit", '\u2660'), - new TeXcode ("heartsuit", '\u2665'), - new TeXcode ("diamondsuit", '\u2666'), - new TeXcode ("copyright", '\u00A9'), - // arrows - new TeXcode ("leftarrow", '\u2190'), - new TeXcode ("uparrow", '\u2191'), - new TeXcode ("rightarrow", '\u2192'), - new TeXcode ("downarrow", '\u2193'), - new TeXcode ("leftrightarrow", '\u2194'), - new TeXcode ("updownarrow", '\u2195'), - }; - - public TeXtranslator () - { - /* DEBUG: output table to file - try - { - java.io.PrintWriter pwTeX = new java.io.PrintWriter ("z:/tex.txt", "UTF-8"); - java.io.PrintWriter pwHTML = new java.io.PrintWriter ("z:/html.txt", "UTF-8"); - java.io.PrintWriter pwOctave = new java.io.PrintWriter ("z:/octave.txt", "UTF-8"); - pwOctave.print ("msgbox ( ["); - int i = 0; - for (int k = 0; k < m_texTable.length; k++) - { - if (i++ == 0) - { - pwTeX.print ("@item "); - pwHTML.print ("@item "); - pwOctave.print (" '"); - } - else - { - pwTeX.print ("@tab "); - pwHTML.print ("@tab "); - pwOctave.print (" "); - } - pwTeX.println ("\\" + m_texTable[k].tex); - pwTeX.println ("@tab '@math{\\" + m_texTable[k].tex + "}'"); - pwHTML.println ("\\" + m_texTable[k].tex); - pwHTML.println ("@tab '" + m_texTable[k].ucode + "'"); - pwOctave.print ("\\\\" + m_texTable[k].tex+" "); - pwOctave.print (" = ''\\" + m_texTable[k].tex + " ''"); - if (i == 3) - { - pwTeX.println ("@c ----------"); - pwHTML.println ("@c ----------"); - pwOctave.println ("', 10, ..."); - i=0; - } - else - { - pwTeX.println ("@tab"); - pwHTML.println ("@tab"); - pwOctave.print (" "); - } - } - pwOctave.print ("']);"); - pwTeX.close (); - pwHTML.close (); - pwOctave.close (); - } - catch (Exception e) - { - ; - } - /* */ - } - - - /* - NOT YET TRANSLATED - o - rfloor - lceil - lfloor - cdot - prime - 0 - rceil - surd - mid - varpi - langle - rangle - */ - - public String replace (String s) - { - StringBuffer sb = new StringBuffer (s); - // append trailing blank - sb.append (' '); - - int i = 0; - do - { - // 26 08 2010 MH szatt search at index i - i = sb.indexOf ("\\", i); - if (i > -1) - { - int j = sb.indexOf (" ", i); - if (j > i) - { - String token = sb.substring (i + 1, j); - - for (int k = 0; k < m_texTable.length; k++) - { - if (m_texTable[k].tex.equals (token)) - { - sb.replace (i, j + 1, - Character.toString (m_texTable[k].ucode)); - break; - } - } - if (sb.charAt (i) == '\\') - { - // backslash sztill there: not found - if (sb.charAt (i + 1) == 'n') - { - // newline - sb.replace (i, i + 2, "\n"); - } - else if (sb.charAt (i + 1) == '\\') - { - // backslash - sb.replace (i, i + 2, "\\"); - } - } - - // 26 08 2010 MH - // advance i to avoid deadlock in case of incorrect escape - // sequences like \\\\alpha (double backslash) or - // \\invalid (unknown escape sequence) - i++; - } - } - } - while (i > -1); - // finall: remove trailing blank - return (sb.substring (0, sb.length () - 1).toString ()); - } -} diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/images/error.png Binary file scripts/java/org/octave/images/error.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/images/information.png Binary file scripts/java/org/octave/images/information.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/images/octave.png Binary file scripts/java/org/octave/images/octave.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/images/question.png Binary file scripts/java/org/octave/images/question.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/java/org/octave/images/warning.png Binary file scripts/java/org/octave/images/warning.png has changed diff -r 9958cead45e2 -r b5d9b95d1e1a scripts/miscellaneous/menu.m --- a/scripts/miscellaneous/menu.m Tue Apr 19 12:30:18 2016 +0200 +++ b/scripts/miscellaneous/menu.m Tue Apr 19 15:27:19 2016 +0200 @@ -1,4 +1,4 @@ -## Copyright (C) 1993-2015 John W. Eaton +## Copyright (C) 1993-2016 John W. Eaton ## ## This file is part of Octave. ## @@ -22,9 +22,9 @@ ## Display a menu with heading @var{title} and options @var{opt1}, @dots{}, ## and wait for user input. ## -## If the GUI is running, or Java is available, the menu is displayed -## graphically using @code{listdlg}. Otherwise, the title and menu options -## are printed on the console. +## If the GUI is running, the menu is displayed graphically using +## @code{listdlg}. Otherwise, the title and menu options are printed on the +## console. ## ## @var{title} is a string and the options may be input as individual strings ## or as a cell array of strings. @@ -55,7 +55,7 @@ error ("menu: OPTIONS must be string or cell array of strings"); endif - if (isguirunning () || usejava ("awt")) + if (__octave_link_enabled__ ()) [choice, ok] = listdlg ("Name", "menu", "PromptString", title, "ListString", varargin, "SelectionMode", "Single"); if (! ok) @@ -98,4 +98,3 @@ %!error <TITLE must be a string> menu (1, "opt1") %!error <All OPTIONS must be strings> menu ("title", "opt1", 1) %!error <OPTIONS must be string or cell array of strings> menu ("title", 1) -