[Mathlib-commitlog] SF.net SVN: mathlib:[856] JMathLib/trunk/src/jmathlib/ui
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-02-21 17:05:39
|
Revision: 856
http://mathlib.svn.sourceforge.net/mathlib/?rev=856&view=rev
Author: st_mueller
Date: 2009-02-21 17:05:29 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
renamed MathLibOutput into JMathLibOutput and added a new method: setStatusText in order to show some status message in the GUI
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/ui/applet/JMathLibGUI.java
JMathLib/trunk/src/jmathlib/ui/awt/Console.java
JMathLib/trunk/src/jmathlib/ui/awt/GUI.java
JMathLib/trunk/src/jmathlib/ui/common/Console.java
JMathLib/trunk/src/jmathlib/ui/servlet/JMathLibServlet.java
JMathLib/trunk/src/jmathlib/ui/swing/Console.java
JMathLib/trunk/src/jmathlib/ui/swing/KeyHandler.java
JMathLib/trunk/src/jmathlib/ui/swing/SwingGUI.java
JMathLib/trunk/src/jmathlib/ui/text/TextUI.java
Modified: JMathLib/trunk/src/jmathlib/ui/applet/JMathLibGUI.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/applet/JMathLibGUI.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/applet/JMathLibGUI.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -2,6 +2,7 @@
import jmathlib.core.interpreter.Interpreter;
import jmathlib.core.interfaces.RemoteAccesible;
+import jmathlib.core.interfaces.JMathLibOutput;
import jmathlib.ui.common.Console;
import java.awt.*;
@@ -9,7 +10,7 @@
import java.applet.*;
/**Rudimentary interface used to test the program*/
-public class JMathLibGUI extends Applet implements RemoteAccesible
+public class JMathLibGUI extends Applet implements RemoteAccesible, JMathLibOutput
{
/**Flag storing whether the program is running as an application or an applet*/
boolean runningStandalone;
@@ -60,7 +61,7 @@
interpreter = new Interpreter(false);
- interpreter.setOutputPanel(answer);
+ interpreter.setOutputPanel(this);
interpreter.executeExpression("startup");
// get parameter for background color (e.g. ff00cc)
@@ -80,7 +81,24 @@
catch (NumberFormatException e){ }
}
+
+ /**
+ * display text
+ */
+ public void displayText(String text)
+ {
+ answer.displayText(text);
+ }
+
+ /**
+ * display status message
+ */
+ public void setStatusText(String status)
+ {
+
+ }
+
/**start the applet*/
public void start()
{
Modified: JMathLib/trunk/src/jmathlib/ui/awt/Console.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/awt/Console.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/awt/Console.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -1,15 +1,16 @@
package jmathlib.ui.awt;
-import jmathlib.core.interfaces.MathLibOutput;
import jmathlib.core.interfaces.RemoteAccesible;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
-/**Class implementing a console style window
-It needs the ConsoleKeyHandler class to work*/
-public class Console extends TextArea implements MathLibOutput
+/**
+ * Class implementing a console style window
+ * It needs the ConsoleKeyHandler class to work
+ */
+public class Console extends TextArea
{
int commandNo;
Modified: JMathLib/trunk/src/jmathlib/ui/awt/GUI.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/awt/GUI.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/awt/GUI.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -3,6 +3,7 @@
import jmathlib.core.interfaces.RemoteAccesible;
import jmathlib.core.interpreter.ErrorLogger;
import jmathlib.core.interpreter.Interpreter;
+import jmathlib.core.interfaces.JMathLibOutput;
import java.awt.*;
import java.awt.event.*;
@@ -21,37 +22,40 @@
* </ul>
* </p>
*/
-public class GUI extends Frame implements WindowListener, ActionListener, RemoteAccesible, ClipboardOwner
+public class GUI extends Frame implements JMathLibOutput, WindowListener, ActionListener, RemoteAccesible, ClipboardOwner
{
- /*The menubar container.*/
- private MenuBar mainMenuBar;
- private Menu fileMenu;
- private Menu editMenu;
- private Menu windowMenu;
- private Menu helpMenu;
- private MenuItem separator1;
- private MenuItem separator2;
- private MenuItem newFileMenuItem;
- private MenuItem openFileMenuItem;
- private MenuItem saveFileMenuItem;
- private MenuItem saveAsFileMenuItem;
- private MenuItem checkForUpdatesMenuItem;
- private MenuItem exitFileMenuItem;
- private MenuItem cutEditMenuItem;
- private MenuItem copyEditMenuItem;
- private MenuItem pasteEditMenuItem;
- private MenuItem consoleWindowMenuItem;
- private MenuItem plotWindowMenuItem;
- private MenuItem aboutHelpMenuItem;
+ /*The menubar container.*/
+ private MenuBar mainMenuBar;
+ private Menu fileMenu;
+ private Menu editMenu;
+ private Menu windowMenu;
+ private Menu helpMenu;
+ private MenuItem separator1;
+ private MenuItem separator2;
+ private MenuItem newFileMenuItem;
+ private MenuItem openFileMenuItem;
+ private MenuItem saveFileMenuItem;
+ private MenuItem saveAsFileMenuItem;
+ private MenuItem checkForUpdatesMenuItem;
+ private MenuItem exitFileMenuItem;
+ private MenuItem cutEditMenuItem;
+ private MenuItem copyEditMenuItem;
+ private MenuItem pasteEditMenuItem;
+ private MenuItem consoleWindowMenuItem;
+ private MenuItem plotWindowMenuItem;
+ private MenuItem aboutHelpMenuItem;
- /**Constant with the application title.*/
- private final String TITLE="JMathLib GUI";
+ /** status message in frame */
+ private Label statusLabel;
+
+ /**Constant with the application title.*/
+ private final String TITLE="JMathLib GUI";
- /**The area used for user input and where the answers are displayed*/
- private Console answer;
+ /**The area used for user input and where the answers are displayed*/
+ private Console answer;
- /**The interpreter*/
- private Interpreter interpreter;
+ /**The interpreter*/
+ private Interpreter interpreter;
/**Reacts to the user menu and update (if necessary) the interface.*/
public void actionPerformed(ActionEvent e)
@@ -207,7 +211,7 @@
// Let's resize the window...
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
if (width == -1)
- width = (d.width*70)/100;
+ width = (d.width*50)/100;
if (height == -1)
height = (d.height*50)/100;
@@ -232,6 +236,7 @@
this.setVisible(false);
this.setLayout(new BorderLayout());
this.setBackground(new Color(214,211,206));
+
//Get the size of the screen
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
//position the frame in the centre of the screen
@@ -256,14 +261,26 @@
InitMenuBar(this);
this.setTitle(TITLE + " [2/4] Initializing console window");
- InitConsole();
+ answer = new Console(this);
+ this.add(answer, BorderLayout.CENTER);
+ answer.displayPrompt();
+ // Sometimes I get an unfocused console, so I request it manually.
+ answer.requestFocus();
+
+ statusLabel = new Label("JMathLib");
+ this.add(statusLabel, BorderLayout.SOUTH);
+
+
+ this.validate();
+
this.setTitle(TITLE + " [3/4] Initializing interpreter");
interpreter = new Interpreter(true);
- interpreter.setOutputPanel(answer);
+ interpreter.setOutputPanel(this); //answer);
+ //interpreter.regStatus(statusLabel);
- this.setTitle(TITLE + " - [4/4] running startup script");
+ this.setTitle(TITLE + " [4/4] running startup script");
interpreter.executeExpression("startup;");
//interpreter.executeExpression("messageoftheday");
answer.displayPrompt();
@@ -289,17 +306,8 @@
} // end GUI
- /**The main console initializer.*/
- private void InitConsole()
- {
- answer = new Console(this);
- this.add(answer);
- this.validate();
- answer.displayPrompt();
- // Sometimes I get an unfocused console, so I request it manually.
- answer.requestFocus();
- }
+
/**The menu initializer.*/
private void InitMenuBar(ActionListener listener)
{
@@ -389,9 +397,28 @@
answer.displayText(answerString);
answer.displayPrompt();
}
+
+
+ /**
+ * displays the output of an evaluation
+ * @param text to display
+ */
+ public void displayText(String text)
+ {
+ answer.displayText(text);
+ }
+
+ /**
+ * displays the current status message at the bottom of the frame
+ * @param status message
+ */
+ public void setStatusText(String status)
+ {
+ statusLabel.setText(status);
+ }
/**
- *
+ * main method
* @param args
*/
public static void main (String[] args)
Modified: JMathLib/trunk/src/jmathlib/ui/common/Console.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/common/Console.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/common/Console.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -1,6 +1,5 @@
package jmathlib.ui.common;
-import jmathlib.core.interfaces.MathLibOutput;
import jmathlib.core.interfaces.RemoteAccesible;
import java.awt.*;
@@ -9,7 +8,7 @@
/**Class implementing a console style window
It needs the ConsoleKeyHandler class to work*/
-public class Console extends TextArea implements MathLibOutput
+public class Console extends TextArea
{
int commandNo;
Modified: JMathLib/trunk/src/jmathlib/ui/servlet/JMathLibServlet.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/servlet/JMathLibServlet.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/servlet/JMathLibServlet.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -12,11 +12,11 @@
import javax.servlet.*;
import javax.servlet.http.*;
-import jmathlib.core.interfaces.MathLibOutput;
+import jmathlib.core.interfaces.JMathLibOutput;
import jmathlib.core.interpreter.*;
/** a basic servlet showing the usage of JMathLib */
-public class JMathLibServlet extends HttpServlet implements MathLibOutput {
+public class JMathLibServlet extends HttpServlet implements JMathLibOutput {
private String dispText ="";
@@ -78,6 +78,15 @@
{
dispText += text;
}
+
+ /**
+ * this method ist used to display status messages
+ * @param status message
+ */
+ public void setStatusText(String status)
+ {
+
+ }
}
Modified: JMathLib/trunk/src/jmathlib/ui/swing/Console.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/swing/Console.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/swing/Console.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -1,6 +1,5 @@
package jmathlib.ui.swing;
-import jmathlib.core.interfaces.MathLibOutput;
import javax.swing.*;
import javax.swing.text.*;
@@ -8,7 +7,7 @@
/**
* Main input text area class.
*/
-public class Console extends JTextArea implements MathLibOutput
+public class Console extends JTextArea
{
public static Console runningReference = null;
Modified: JMathLib/trunk/src/jmathlib/ui/swing/KeyHandler.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/swing/KeyHandler.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/swing/KeyHandler.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -4,6 +4,7 @@
import javax.swing.text.*;
import java.util.*;
import jmathlib.core.interpreter.Interpreter;
+import jmathlib.core.interfaces.JMathLibOutput;
@@ -17,7 +18,7 @@
* See GN0004 for more information.</td></table></p>
* @version 3.1.1
*/
-public class KeyHandler implements KeyListener
+public class KeyHandler implements KeyListener, JMathLibOutput
{
public static KeyHandler runningReference = null;
@@ -26,6 +27,7 @@
// The interpreter
Interpreter interpreter = new Interpreter(true);
+ Console con = null;
/**
@@ -34,14 +36,25 @@
* Initializes the interpreter.
* @param con Where the interpreter will place its output.
*/
- public KeyHandler(Console con)
+ public KeyHandler(Console _con)
{
+ con = _con;
if (runningReference == null)
{
runningReference = this;
}
- interpreter.setOutputPanel(con);
+ interpreter.setOutputPanel(this);
}
+
+ public void displayText(String text)
+ {
+ con.displayText(text);
+ }
+
+ public void setStatusText(String status)
+ {
+
+ }
Modified: JMathLib/trunk/src/jmathlib/ui/swing/SwingGUI.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/swing/SwingGUI.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/swing/SwingGUI.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -5,6 +5,7 @@
import javax.swing.*;
import java.io.*;
import java.util.*;
+import jmathlib.core.interfaces.JMathLibOutput;
@@ -21,7 +22,8 @@
* </table>
* @version 2.0
*/
-public class SwingGUI extends JFrame {
+public class SwingGUI extends JFrame
+{
final String appTitle = "JMathLib SwingGUI";
Modified: JMathLib/trunk/src/jmathlib/ui/text/TextUI.java
===================================================================
--- JMathLib/trunk/src/jmathlib/ui/text/TextUI.java 2009-02-20 19:49:48 UTC (rev 855)
+++ JMathLib/trunk/src/jmathlib/ui/text/TextUI.java 2009-02-21 17:05:29 UTC (rev 856)
@@ -6,7 +6,7 @@
import java.io.*;
-public class TextUI implements RemoteAccesible, MathLibOutput
+public class TextUI implements RemoteAccesible, JMathLibOutput
{
/**store whether executing lines or entering a function def*/
private boolean interactiveMode;
@@ -111,6 +111,15 @@
System.out.println(text);
}
+ /**
+ * display status
+ * @param status message
+ */
+ public void setStatusText(String status)
+ {
+
+ }
+
public void displayPrompt()
{
System.out.print("> ");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|