Interdisciplinary Computing In Java Programming 1st Edition Sunchong Wang Auth download
Interdisciplinary Computing In Java Programming 1st Edition Sunchong Wang Auth download
https://ebookbell.com/product/interdisciplinary-computing-in-
java-programming-1st-edition-sunchong-wang-auth-4200180
https://ebookbell.com/product/soft-computing-in-interdisciplinary-
sciences-1st-ed-2022-s-chakraverty-44939266
https://ebookbell.com/product/ubiquitous-computing-in-the-workplace-
what-ethical-issues-an-interdisciplinary-perspective-1st-edition-
katharina-kinderkurlanda-4973668
https://ebookbell.com/product/balancing-the-common-core-curriculum-in-
middle-school-education-composing-archimedes-lever-the-equation-and-
the-sentence-as-an-interdisciplinary-unity-1st-edition-james-h-bunn-
auth-5838812
https://ebookbell.com/product/technology-for-facilitating-humanity-
and-combating-social-deviations-interdisciplinary-perspectives-1st-
edition-miguel-vargas-martin-1884006
Interdisciplinary Applications Of Shameviolence Theory Breaking The
Cycle Roman Gerodimos
https://ebookbell.com/product/interdisciplinary-applications-of-
shameviolence-theory-breaking-the-cycle-roman-gerodimos-45056688
https://ebookbell.com/product/interdisciplinary-research-on-climate-
and-energy-decision-making-30-years-of-research-on-global-change-m-
granger-morgan-46489974
https://ebookbell.com/product/interdisciplinary-and-transdisciplinary-
failures-1st-edition-dena-fam-48239786
https://ebookbell.com/product/interdisciplinary-value-theory-steffen-
steinert-48513658
https://ebookbell.com/product/interdisciplinary-statistics-in-mexico-
ame-virtual-meeting-september-1011-2020-and-34-fne-acatln-mexico-
september-2224-2021-isadora-antonianovillalobos-48704746
INTERDISCIPLINARY COMPUTING
IN JAVA PROGRAMMING
THE KLUWER INTERNATIONAL SERIES
IN ENGINEERING AND COMPUTER SCIENCE
INTERDISCIPLINARY COMPUTING
IN JAV A PROGRAMMING
by
Sun-Chong Wang
TRIUMF, Canada
AII rights reserved. No part of this publication may be reproduced, stored in a retrieval
system or transmitted in any form or by any means, electronic, mechanical, photo-copying,
microfilming, recording, or otherwise, without the prior written permission of the
publisher, with the exception of any material supplied specifically for the purpose of being
entered and executed on a computer system, for exclusive use by the purchaser of the
work.
Preface Xl
2.8 StreamTokenizer 26
2.9 Graphics 27
2.10 Printing 36
2.11 Summary 37
2.12 References and Further Reading 37
3. HIGH PERFORMANCE COMPUTING 39
3.1 Parallel Computing 39
3.2 Java Threads 40
3.3 An Example of Parallel Computing 41
3.4 Distributed Computing 41
3.5 Remote Method Invocation 41
3.6 An RMI Client 42
3.7 The Remote Interface 44
3.8 Serialization 48
3.9 A Reflective RMI Server 48
3.10 Reflection 51
3.11 Build and Run the Server 51
3.12 Build and Run the Client 53
3.13 Summary 54
3.14 Appendix 55
3.15 References and Further Reading 55
Part II Computing
4. SIMULATED ANNEALING 59
4.1 Introduction 59
4.2 Metropolis Algorithm 60
4.3 Ising Model 61
4.4 Cooling Schedule 62
4.5 3-Dimensional Plot and Animation 62
4.6 An Annealing Example 63
4.7 Minimization of Functions of Continuous Variables 77
4.8 Summary 78
4.9 References and Further Reading 79
Contents VB
8. MOLECULAR DYNAMICS
8.1 Computer Experiment
8.2 Statistical Mechanics
8.3 Ergodicity
8.4 Lennard-Jones Potential
8.S Velocity Verlet Algorithm
8.6 Correcting for Finite Size and Finite Time
8.7 An Evaporation Example
8.8 Summary
8.9 References and Further Reading
9. CELLULAR AUTOMATA
9.1 Complexity
9.2 Self-Organized Criticality
9.3 Simulation by Cellular Automata
9.4 Lattice Gas Automata
9.S A Hydrodynamic Example
9.6 Summary
9.7 References and Further Reading
A 253
A.I Web Computing 253
A.2 Class Sources 255
Index 261
Preface
SUN-CHONG WANG
PART I
JAVA LANGUAGE
Chapter 1
JAVA BASICS
}
}
}
int idim/~ ~!~~l;
for (k=O;k<idim;k++) {
int kk=k+l;
i f (k! =ic[k]) {
for (i=kk;i<nmax;i++) if (k==ic[i]) break;
if (i == nmax) throw new
MyMatrixExceptions("Error in matrix inversion 2");
for (j=O;j<nmax;j++) {
atemp=M[j] [k];
M[j] [k] =M [j] [i] ;
M[j] [i] =atemp;
}
itemp=ic[i];
ic [i] =ic [k] ;
ic[k]=itemp;
}
i f (k! =ir [k]) {
for (j=kk;j<nmax;j++) if (k==ir[j]) break;
if (j == nmax) throw new
MyMatrixExceptions("Error in matrix inversion 3");
for (i=O;i<nmax;i++) {
atemp=M [k] [i] ;
M[k] [i] =M [j] [i] ;
M[j] [i] =atemp;
}
itemp=ir[j] ;
ir[j]=ir[k] ;
ir[k]=itemp;
}
} II k loop
det=de;
}
Table 1.1. Primitive data types in Java. Their size/format, minimum, and maximum val-
ues accessible via Type.MIN_VALUE and Type.MALVALUE, where Type can be Byte, Short,
Integer, Long, Float, or Double.
Within the Matrix class, first of all, a 2-dimensional double array is de-
clared. Primitive data types in Java include boolean, char, byte, short,
int, long, float, and double. Their representations and ranges are shown
in Table 1.1. To create an instance of integer my lnt, the following statement
is used,
int mylnt;
An array, unlike primitive data types, assumes the status of a class. The state-
ment in Matrix. java,
double [] [] M;
2Note that, to preserve encapsulation of data in an object, an object-oriented purist may prefer methods
like A. setValueAt (0,1,2.0) and B. setValueAt (2.3. -4.0) to alter variables of the objects. Method-
callings, however, take a longer time than statements. In some cases, we simply optimize speed at the cost
of object encapsulation.
10 INTERDISCIPLINARY COMPUTING
1.6 Exceptions
The inverse () method takes no input parameters. It inverts the 2 dimen-
sional array variable M of the Matrix object. The algorithm used to invert
the matrix is the familiar Gauss-Jordan elimination (with full pivoting) method
found in most texts on numerical computation.
We now encounter in this method a handy utility of Java called exceptions. It
may happen that some matrices cannot be inverted. For example, the set of lin-
ear equations corresponding to the matrix equation does not have a solution. In
this case, the inverse () method will fail and it is desirable that the failure be
handled gracefully without aborting program execution. To accomplish this,
the method indicates that it throws MyMatrixExceptions, which is a class
inheriting Java's class Throwable. Inheritance is another feature of object ori-
ented Java and will be addressed in the next section. Examining the algorithm,
we observe that unsuccessful inversions occur when for example numbers are
divided by zero. Instances of the class MyMatrixExceptions are created and
thrown in these occasions. The exceptions are then caught in the try-catch
block in the object that calls the inverse () method. Examples of the try catch
block will be seen shortly in the following section.
The difference between methods reLint () and inverse () is in their re-
turn types.
1.7 Inheritance
A look at Listing 1.2 shows how easily MyMatrixExceptions inherits
Java's Throwable class by simply extends Throwable. Again, the first
method, bearing the same name as the class (MyMatrixExceptions), is the
constructor of the class. It accepts a single String object as the input pa-
Java Basics 11
1* Sun-Chong Wang
TRIUMF
4004 Wesbrook Mall
Vancouver, V6T 2A3
Canada
e-mail: [email protected]
MyMatrixExceptions.java reports failure to
the calling object *1
class MyMatrixExceptions extends Throwable {
public MyMatrixExceptions(String s) {
super(s);
} II end of constructor
} II end of class
System.out.println("A = II);
demo.printMatrix(demo.A);
System.out.println(IIB = II);
demo.printMatrix(demo.B);
demo.C.M = demo.A.transpose();
System. out. println ("transpose of A ") ;
demo.printMatrix(demo.C);
demo.C.M = demo.A.plus(demo.B.M);
System.out.println(IIA + B = II);
demo.printMatrix(demo.C);
demo.C.M = demo.B.minus(demo.A.M);
System.out.println("B - A = II);
demo.printMatrix(demo.C);
try {
demo.C.M = demo.A.ret_inv();
System.out.println("inverse of A = II);
demo.printMatrix(demo.C);
} catch (MyMatrixExceptions mme) {
System.out.println(mme.getMessage());
}
demo.D.M = demo.A.times(demo.C.M);
System.out.println(IIA x A_inverse II);
demo.printMatrix(demo.D);
try {
demo.E.M =
demo.B.minus(demo.A.times(demo.C.plus(demo.A.ret_inv())));
System.out.println(IIB - (A x (A_inverse + A_inverse)) = II);
demo.printMatrix(demo.E);
} catch (MyMatrixExceptions mme) {
System.out.println(mme.getMessage());
}
} II end of main
public MatrixDemo () {
A. M[OJ [OJ 1.; A.M[OJ [1] 2. ; A.M[OJ [2J 5.
A.M[lJ [OJ 2.; A. M[1] [1J 3. ; A. M[lJ [2J 8.
A.M[2J [OJ -1. ;A.M[2J [1] 1.; A. M[2J [2J 2.
B. M[OJ [OJ 1.; B.M[OJ [1] O. ; B.M[OJ [2J O.
B.M[1] [OJ 0.; B.M[1] [1] 1.; B.M[lJ [2J O.
B.M[2J [OJ 0.; B.M[2J [1] O. ; B. M[2J [2J 1.
} II class constructor
public void printMatrix(Matrix C) {
for (int i=O; i<Size; i++) {
for (int j=O; j<Size; j++)
System.out.print(C.M[iJ [jJ+" II);
System.out.println("");
}
System.out.println('II') ;
}
} II end of class MatrixDemo
Recall that the keyword new calls the constructor of the class. Matrix objects
A, B, C, D, and E are now made to interact by performing subtraction, addition,
multiplication between them and transpose and inversion on itself. The results
are printed out on the screen by the method printMatrix 0 of demo, for
example,
demo.printMatrix(demo.C);
Note that variables and methods of an object are referenced via the. oper-
ator, as in the above example. The try-catch block encompassing the ma-
trix inversion method is also noted. This block is mandatory since the method
inverse 0 indicates that it may throw exceptions when occasions arise. Com-
pilation will fail if the try-catch block is missing. When an exception does
happen, it's caught by catch and the warning message can be printed out.
Namely, remedial procedures are taken in the catch and execution proceeds
to the next statement without crashing program running.
$export JAVAJHOME=/home/wangsc/JAVA/jdkl.2.2
$export PATH=$JAVAJHOME/bin:$PATH
$export CLASSPATH=.
The reader should replace the above Java home directory with the directory
containing the Java tools in her system. Setting-up of the environment is done
14 INTERDISCIPLINARY COMPUTING
only once (per login). We can then compile the sources by the Java compiler,
javac,
$javac MatrixDemo.java
We observe that three (bytecode) class files have been created by the compiler.
We now launch the application by the Java interpreter (or launcher), java,
$java MatrixDemo
We immediately get the following output on screen,
A=
1.0 2.0 5.0
2.0 3.0 8.0
-1.0 1.0 2.0
B =
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
transpose of A =
1.0 2.0 -1.0
2.0 3.0 1.0
5.0 8.0 2.0
A+ B =
2.0 2.0 5.0
2.0 4.0 8.0
-1.0 1.0 3.0
B - A=
0.0 -2.0 -5.0
-2.0 -2.0 -8.0
1.0 -1.0 -1.0
inverse of A =
1.9999999999999996 -0.9999999999999999 -0.9999999999999999
11.999999999999998 -7.0 -1.9999999999999998
-4.999999999999999 3.0000000000000004 0.9999999999999999
Ax A_inverse =
leO 1.7763568394002505E-15 0.0
0.0 1.0000000000000036 0.0
0.0 8.881784197001252E-16 0.9999999999999999
B - (A x (A_inverse + A_inverse)) =
-1.0 -3.552713678800501E-15 0.0
0.0 -1.000000000000007 0.0
0.0 -1.7763568394002505E-15 -0.9999999999999998
The matrix class of this chapter exemplifies creation and use of objects in
Java. In part II, we will meet occasions where we need this matrix class. Java
also provides a mathematics class, java . lang . Math, that performs square
root, calculates sines, cosines, and so on. Visit Sun Microsystems' website for
online documentations of all the classes in a Java distribution: java. sun. com.
1.10 Summary
As software becomes more complicated, expenses on the maintenance sky-
rocket. Besides the urgency to develop intelligent and autonomic software that
Java Basics 15
can maintain and heal itself and each other, a cross-platform programming lan-
guage is an advantage. Java was introduced with such an idea of 'write once,
run everywhere' .
We introduced the concept of object oriented programming. A class is a
blueprint that specifies the functionality. Once a blueprint is laid out, instances
of the class can be incarnated via the new statement, which in fact calls the
constructor method of the class.
An int (long) and float (double) in Java are represented by 4 (8)
bytes. Arrays in Java are objects and their instantiation and initialization are
by the new statements. Information on the array length is retrievable with the
array name.
All objects in Java, including the ones the programmer writes, are sub-
classes. The inheritance property makes it easy for a programmer to use classes
written by others. For example, one may find the class Matrix in this chapter
useful but wants to add to it her own methods. She can then simply extends
Matrix and work on her supplements.
MyWimlowOemo mx
File Forftat View
I
1 .0
p-.""
0.9 / ~. ,
I !
0 .8 I !
q; :'
0.7
~
.11
0 .6
,
.11
;:
0.4
0 .3 I i
In
? ./
0.2 / .100 mV (den.e stack )
~ i II J..~' I
/
0 .1 0 350 rnV <3 - n'lO d u l@ )
.500 mV (3- rnod ule )
0 .0
1100 1150 1200 1250 1300 1350 1400 1450 1500 1550
pl.n .. H .V . (Volts )
--------~-----------------------~
Figure 2.1. The window object
Figure 2.2. Items on the File pull-down Figure 2.3. Items on the View pull-down
menu menu
setSize(new Dimension(500,500));
} II end of constructor
private void addMenus() {
MenuBar mymenubar = new MenuBar(); II list menus
Menu myfile = new Menu("File");
myfile.add("Open"); II items on this menu
myfile.add("Save");
myfile.addSeparator();
myfile.add("Quit");
Menu format = new Menu("Format");
format.add("Import");
Menu operate = new Menu("View");
operate.add("Plot") ;
operate.add("Print");
myfile.addActionListener(this);
format.addActionListener(this);
operate.addActionListener(this);
mymenubar.add(myfile);
mymenubar.add(format);
mymenubar.add(operate);
setMenuBar(mymenubar);
} II end of addMenus
II action handler
public void actionPerformed(ActionEvent e) {
String action_is = e.getActionCommand();
II action when a particular item is selected
if (action_is.equals("Quit")) {
System.exit(O);
} else if (action_is.equals("Open")) {
FileDialog opendlg = new FileDialog(this,
"Open File",FileDialog.LOAD);
opendlg. show () ;
String infile = opendlg.getDirectory() + opendlg.getFile();
if (opendlg.getFile() != null) {
Message readingBox = new Message(this,"MyWindow",
"Reading file ... ");
readingBox.show();
loadData(infile);
readingBox.dispose();
}
} else if (action_is.equals("Import")) {
FDialog formatdlg = new FDialog(this,"Format Dialog");
formatdlg.show();
} else if (action_is.equals("Save")) {
FileDialog savedlg new FileDialog(this,
"Save File As ... ",FileDialog.SAVE);
savedlg. show () ;
String outfile = savedlg.getDirectory()+savedlg.getFile();
Message savingBox = new Message(this,"MyWindow",
"Saving file ... ");
savingBox.show();
writeData(outfile);
savingBox.dispose();
} else i f (action_is.equals("Plot")) {
assignArrays () ;
Graphical and Interactive Java 21
pw.flushO;
ostream. close 0 ;
} catch (IOException ee) {
System. out. println ("IOException "+ee. getMessage 0) ;
}
}
} II end of MyWindow class
2.3 Frame
This MyWindow class inherits, i.e. extends, the class java.awt.Frame.
Here we have ignored java. awt since the import statement above told the
compiler where to search for Frame. ActionListener is a category of classes
called interface. In contrast to other object oriented programming languages
like C++, multiple inheritance (inheritance from multiple parents) is not al-
lowed in Java. One way to work around is via implements'ing interfaces. We
therefore come up with the class declaration like this,
2.4 Panel
A Panel class provides space for any window component, including other
panels. Here a panel object is declared and instantiated: Panel mypanel = new
24 INTERDISCIPLINARY COMPUTING
Panel () ;. This panel object then invokes its setLayout () method to request
an instance of BorderLayout to be the layout manager: mypanel. setLayout
(new BorderLayout 0) ;. This layout manager, managing the space which is
to be used by the plotting object, is then added to this panel: mypanel. add
(plotting, BorderLayout. CENTER) ;. Finally this panel is added to the
MyWindow object by add(mypanel) ;.
2.5 Menu
We might prefer separate menus for very different cuisines. We therefore in
the method addMyMenu () first create an instance of MenuBar to hold subse-
quent submenus.
The file menu is then created: Menu file = new Menu(IFile");. An
entree in this menu is added: file. add ( II Open ") . In this case, three entrees
are available. This file menu is then added to the menubar. Other menus are
populated in the same fashion. In the end of the method, the menubar is added
to MyWindow by setMenuBar (menubar). So far, when a menu is clicked by
a customer, entrees are displayed. We then need a waiter to assist in receiv-
ing, placing, and delivering the order. The responsibilities of the waiter are
prescribed by the interface ActionListener and implemented in the method
public void actionPerformed(ActionEvent e).
2.6 Interactions
An instance of ActionEvent e is passed as the argument for the method.
Invoking the method getActionCommandO of e returns a String object
holding the menu item clicked by the user. This item is to be identified in
the i f else i f else block within which an appropriate action is performed in
response to user selection.
We remind that these responding actions are included in the menus by the
menu's addActionListener 0 method as in the statement myfile. addActi
onListener (this). Again, this refers to MyWindow, which is capable of
reacting because it implements ActionListener. Programmer's implemen-
tation of the method actionPerformedO in class MyWindow is mandatory
since MyWindow implements the ActionListener interface.
-4 MyWirulowDemo
- Oflelll'il x
En~th o~~d!!~~
I f/hoM/wanesclBOOKI JClCH2ti
Filter Files
![".1-1 nyMindoll.Java
Plotter. clan
Plotter. java
fdialoe.ps
idialoa.ps
iiDUliWiM
out.ps
output.dat
pdla!olf. p$
Enter rlie n_:
Iinput. datI
I OK I Update I c"nce1 1
A dialog is shown upon user request, which is identified and acted upon in
method actionPerformedO,
opendlg.show();
A screen shot of the dialog box is displayed in Figure 2.4. Object opendlg's
methods are then deployed to locate the file of user's choice where the mouse
is released,
Before importing the data, we may want to specify the format of the data file.
Listing 2.2 shows the raw data for the curves in Figure 2.1. In this example,
three pieces of information can be supplied to the program: the total number
of columns in the file, the column for the x coordinate data, and the number
of lines to skip in the beginning of the input file. They are represented by the
three integers nColns, xlndex, and nSkips in MyWindow. The interaction
26 INTERDISCIPLINARY COMPUTING
Colunn Ih is K coordinates
~~ ___J _E~~~J
Figure 2.5. Dialog box for the user to update the input file format
medium between the user and the program is the dialog box in Figure 2.5. The
class (FDialog. java in the appendix) also implements an ActionListener
interface to read in user's input.
c
c these header lines are for comments
c data follow
1.10E+3 0.00879531 0.00237217 0.000756203 0.0
1.20E+3 0.0304673 0.0168901 0.0119284 0.051
1.25E+3 0.0863443 0.0337259 0.02265734 0.11
1.30E+3 0.251472 0.106202 0.05121746 0.278
1.35E+3 0.643502 0.306731 0.163953 0.611
1.40E+3 0.934565 0.713828 0.497001 0.938
1.45E+3 0.995856 0.962992 0.881213 0.985
1.50E+3 0.999473 0.997534 0.990032 0.987
1.55E+3 0.999735 0.999733 0.998151 0.991
Listing 2.2 Raw data in the input file for the curves in Figure 2.1
2.8 StreamTokenizer
To read numbers (or characters) from the input file, we introduce the ver-
satile class StrearnTokenizer, which appears in our method loadDataO in
MyWindow. java. A try-catch block is needed because the constructors and
some methods of the first three classes in loadDataO throw various excep-
tions.
First of all, the input file is wrapped into FileInputStrearn which creates
a stream for reading data from a file,
Most often, after data processing, we want to save the manipulated data.
The file name for the output file can be entered by the user and then captured
by the program in the way input files are opened for reading. The dialog box
for this purpose is invoked by selecting the Import item in the Format menu
and is shown in Figure 2.6. Here we demonstrate by writing the raw data of
Listing 2.2 to an output file with the decimal format defined in the method
writeDataO. Listing 2.3 shows the content of the output file. They are seen
to be the same as the raw data of Listing 2.2 except the numeral format.
During reading, saving and even drawing data, it is helpful to show a small
message box on the screen, informing the user that work is in progress. In-
stances of such a class Message are created before and closed after the task
The type of the task being performed is specified as a string argument to the
constructor ofthe class as shown in the example in Figure 2.7. The source code
for this message class is listed in the appendix.
2.9 Graphics
We have so far annotated the class MyWindow, which sets up an interactive
window environment for the class Plotter, whose job is to plot the input data.
28 INTERDISCIPLINARY COMPUTING
MylVimlowDemo o X
1.0
En~e.!:..!~~or- lolder _~an..; : ,.' ..............
j
o.g flhO"e/WeneScl~k/JC/CH2}. I
i
Filter Files j
fi. .·]..;:
0 .8
rFDialOV'ChS;--~
'FDialol.J;lva
I"
Folders ' "essaue.class
F- ' " ..&Sale. java I
!
Il
"yNind~$1.class
I
I I~E~;~~~::S
0 .4
J
0 .3
I Plotter. java f.
0 .2
0 .1 _---'--'-_i'T'IOc't "'@)
I m o d ul e )
0 .0
l ~ J _~~~J ~~~lJ ~~--~
H OO JJSO -===~=======
=t:=!J 1500 1550
pia n e H .V . ( Vo lt $)
------------------------------~.~
Figure 2.6, The dialog box for writing to files
Listing 2.4 shows the code of the plotting class. It is seen that it is subclassed
from class Canvas, which is in tum a subclass of the class Component. The
Component class, inheriting java . lang . Db j ect which is the root of all Java
classes, is the abstract superclass of many window classes. The class Canvas
represents a blank rectangle on which graphics can be drawn and user input
events are listened to. Unlike its parent Component, which is abstract, the
class Canvas requires that its method paint (graphics g) be overridden by
the programmer for customized graphics on the canvas. We now focus on the
the method paint ().
/* Sun-Chong Wang
TRIUMF
4004 Wesbrook Mall
Vancouver, V6T 2A3
Canada
e-mail: [email protected]
Plotter.java connects data points with color lines */
import java.lang.*;
import ~ava.awt.*;
import Java.awt.event.*;
import java.awt.geom.*;
import ~ava.awt.font.*;
import Java.text.DecimaIFormat;
Graphical and Interactive Java 29
MyWindowDemD ·Y X
import java.util.*;
class Plotter extends Canvas {
MyWindow parent;
double xmin,xmax,ymin,ymax;
double topborder,sideborder;
static int bottom,right;
int rectWidth = 6, rectHeight 6;
double x[];
double y [] [] ;
final static int maxCharHeight = 20;
final static int minFontSize = 8;
public Plotter(MyWindow parent) {
super();
thls.parent = parent;
}
if (parent.beforePlot == false) {
setBackground(Color.white);
SetPlottingLimits();
SetBorderSize(0.15,0.15);
fontMetrics = pickFont(g2, "Vth 200 mV", (d.width/6»;
II now draw the axes
DrawXAxis(g2);
DrawYAxis(g2);
putAxisTitles(g2,stroke,d,"efficiency",20,
"plane H.V. (Volts)",-50);
drawPieces(g2,x,y[0],stroke,stroke,Color.green,1);
drawPieces(g2,x,y[1],stroke,dashedl,Color.red,2);
drawPieces(g2,x,y[2] ,stroke,dashed2,Color.black,3);
drawPieces(g2,x,y[3],stroke,stroke,Color.blue,4);
putCaption(g2,"100 mV (dense stack)",1400.,0.2,
Color.blue,4);
putCaption(g2,"200 mV (3-module) " ,1400. ,0.15,
Color.green,l);
putCaption(g2,"350 mV (3-module)",1400.,0.10,Color.red,2);
putCaption(g2,"500 mV (3-module) ",1400. ,0.05,
Color.black,3);
} else g2.drawString("WELCOME", d.width/2, d.height/2);
} II end of re-display method
private void putCaption(Graphics2D g2, String text, double x,
double y, Color color, int symbol) {
int iO, jO;
g2.setPaint(color);
iO GetXCoordinate(x);
jO = GetYCoordinate(y);
Graphical and Interactive Java 31
iO -= rectWidth/2;
jO -= rectHeight/2;
switch (symbol) {
case 1: g2.draw(new Rectangle2D.Double(iO-10, jO-5,
rectWidth, rectHeight»;
break;
case 2: g2.draw(new Ellipse2D.Double(iO-10, jO-5,
rectWidth, rectHeight»;
break;
case 3: g2.fill(new Rectangle2D.Double(iO-10, jO-5,
rectWidth, rectHeight»;
break;
case 4: g2.fill(new Ellipse2D.Double(iO-10, jO-5,
rectWidth, rectHeight»;
default:
} II end of switch
g2.drawString(text, iO, jO);
}
}
g2.setStroke(dashed);
g2.draw(brokenLine);
}
}
double fSpan = 0;
double multiplier = 1;
double span,flnitiaISpan;
long ISpan,quot,rem;
span = AxisMax - AxisMin;
boolean b;
if (AxisMax <= AxisMin)
System.out.println(IIError in axis data range");
flnitialSpan = span;
if (flnitialSpan < 10.0) {
while (span < 10) {
multiplier *= 10;
span *= 10;
}
} else {
while (span > 1. Oe9) {
multiplier 1= 10;
span 1= 10;
}
}
ISpan (long) span;
b = false·
for (int i=10· i>=2· i--) {
quot = ISpanl i; ,
rem = ISpan - quot*i;
if (rem == 0) {
fSpan = (double) quot;
fSpan = fSpan/multiplier;
b = true;
}
if (b == true) break;
}
II if all else fails
i f (b == false)
fSpan = (span/(2*multiplier)); II two intervals by default
return fSpan;
} II FindTicks method
public double GetXMinO {
double dmin = x[O];
for (int i=l; i<x.length; i++) if (x[i] < dmin) dmin xCi];
xmin = dmin;
return xmin;
}
Print ·0 X
'rl"t:
Copies: W-
Pdlll to:
v Prinhr f1
"" fU. fooIIo-u"'..-p-s..--.....;...,--~---.....,I
'rint J c..~ul I
--~--~----------~~~
Figure 2.8. The printing dialog
First of all, color aliases are assigned to the variables of the java. awt . Colo
r class, which is already imported. black, blue, cyan, darkGray, gray,
green, lightGray, magenta, orange, pink, red, white, and yellow Me
defined in the variable field of Color. Other colors can also be created by the
programmer. One such example is in the chapter of artificial neural network
in part 2 of the book. The modifier final here means that those instances are
made constant. BasicStroke defines how lines are drawn, i.e., solid, dotted,
or dashed lines.
Functionality of the class Graphics2D is very rich in its own right. It is
the fundamental class that renders 2-dimensional shapes, text, and images. It
performs coordinate transformation and manages color, fonts, and text layout.
It draws or fills circles, ovals, rectangles, polygons. Its sophistication is to
fulfill demands of computer graphics and animation, which are topics of a
whole book. We in this section grab what we need from Graphics2D to realize
the screen shot that we saw in Figure 2.1. When tailoring for her drawing
needs, the reader can leave most of the code intact except changing the axis
captions, texts, and so forth.
Graphics is cast into Graphics2D,
Graphics2D g2 = (Graphics2D) g;
36 INTERDISCIPLINARY COMPUTING
1.0
/ ~,..
.....
0.9
/ /
O. B I /
'/> .I
>- 0.7
.,<:
u I .I
·u 0.6 I ./
:E., I /
0.4 It
I ./
0.3 I !
1/
0.2 / ./ . 100 mV (dense stack)
/ ~. ,) m /' rn (HI P
Method DrawXAxis 0 draws horizontal and vertical axis, and particularly the
ticks on the axes. Bounds of the axis are calculated by methods getXMin () ,
getXMax 0 , get YMin 0, and get YMax 0 .
Data points read in MyWindow are first stored in instances of GeneralPath.
A symbol (rectangle, or circle) is drawn on every point and then a line is
drawn, connecting the data points. The line attribute (solid, dotted, ... ) is
set by Graphics2D's set Stroke 0 method. Note that data are converted
to pixel coordinates whose origin is at the top-left comer of the screen by
methods GetXCoordinate 0 and GetYCoordinate O. Texts are drawn by
Graphics2D's drawStringO method at coordinates in the coordinate sys-
tem of the data. Finally the method pickFont 0 picks the font of the right
size such that the string "Vth = 200 mV" fits in the given restricted space.
When the user chooses the Plot item inside the View menu, the paint 0
method is called and drawing is engaged.
2.10 Printing
Recall that the class MyWindow implements the Printable interface in
addition to ActionListener. We are therefore obliged to implement the
Graphical and Interactive Java 37
1-
2.11 Summary
FDialog.java
.MYWindow.java--
Message.java
1Plotter.java
Since the advent of the first digital computer decades ago, prices of comput-
ers have dropped significantly, making personal computers affordable. Mean-
while, the performances [in terms of the memory size and speed of the central
processing unit (CPU)] double every 18 to 24 months (the so-called Moore's
law). Computers are usually connected to one another to form a web of com-
puters called Internet. A conceivable avenue of achieving high-performance
computing is to coordinate together the vast number of otherwise idle comput-
ers on the network to tackle single tough tasks of computation. This is the very
idea behind grid computing where both data and computing power are shared
and accessible to a user. We will demonstrate an implementation of the so-
called distributed computing to boost the performance in this chapter. Before
this, let's introduce the other high performance computing via parallelism in
Java. l
1Language design features such as Java's checks of array indexes and references to objects for
out-of-bound and null-pointer exceptions at runtime make Java a secure and reliable programming plat-
form. They however have detrimental effects on technical computing. The arrays of arrays structure for
multidimensional arrays in Java further hurts its numerical performance. As compiler optimization tech-
nologies advance, Java code can achieve 50% to 90% performance of highly optimized Fortran.
Since the book focuses on numerical computation, we play down handy applications of Java's container
classes such as java. util. Vector. When collection classes are nevertheless used, we point out that the
overhead due to extravagant object creation and type casting should be avoided.
the nature of the task and on the hardware architecture of the mUlti-processor
system.
If, for example, data are shared among the processors, deliberate synchro-
nization of the computing processes between data updates has to be devised.
The issue of synchronization for jobs of a subtle nature like this is to be re-
minded of. Otherwise, the program ends up computing what is not meant to do
because of corrupted data. We will see examples of synchronization in Chapter
l3.
If the scattered computers are inter-connected via slow links, communica-
tions overhead counterplays gains in parallelization. The slower the link or the
more frequent for the task to exchange data among computers, the severer is
the penalty.
Bearing in mind the precautions, we show straightforward implementation
of parallelism in Java, via the Thread class.
such as GNU Linux, threads are dispatched to individual CPU's. It is this type
of multi-processor systems that are gaining an edge with parallelization.
Let's assume that i runs from 1 to 4 while j, k can presumably be very large.
We further assume that there is a quad-processor system at our command. To
speed up the process, we can split the multiplication of Eq. (3.1) into four
pieces (threads) with processor one working on L 1j in thread one and processor
two on L 2j in thread two, and so on. At the end of a thread, an array of size
defined by the range of j is returned to the main program. We have to wait to
make sure all the other threads are finished. The four returned arrays are then
grouped into the matrix L before the program execution leaves the statement of
Eq. (3.1). The benefit of the parallel computing in this example is appreciable
when the size of the two multiplying matrices is large. We will see a real,
similar implementation of parallel computation in Chapters 11 and 12.
Mrs. Parbury.
[Tearfully.] It doesn’t occur to you that I might want a change.
Parbury.
Well, have one, dear. Aunt Martha would be delighted to have
you at Oaklands.
Mrs. Parbury.
I don’t want to go to Aunt Martha. How would you like to go to
Aunt Martha?
Parbury.
[Suppressing a groan.] What is it you do want?
Mrs. Parbury.
[Quickly.] You! I want to be with you! It’s very simple—it’s not
asking very much. If you don’t like my being with you, why did you
marry me?
[Taking out her handkerchief.
Parbury.
Now, dear, please don’t cry! [Aside.] If she does, I’m done for!
[Aloud.] It’s only common sense that you can’t go knocking about
with a couple of men in a tub of a boat.
Mrs. Parbury.
Of course I quite know now that you don’t love me.
[Bursts into tears. Sits on sofa.
Parbury.
[With real irritation.] Oh, damn it! [Goes up, but turns quickly
and comes down to her.] ’Pon my soul, you make me almost hate
——
Mrs. Parbury.
Of course you hate me. Your old friend has done that for me. You
are breaking my heart!
Parbury.
[Who has recovered control of his temper and resumed his
natural bantering tone.] Not at all, dear. [Sits at his desk and affects
to be busy.] I was only going to say that I hated—now, what the
deuce was it I hated?—oh, I know—to see a woman cry. I do think a
woman is wise who does her crying in private, and yet—I wonder—
they know best—millions to one they know best. I must write
something about it.
Mrs. Parbury.
[Rises, goes to top of table, R. She is wiping her eyes, her back
to him.] Of course, you’re going all the same?
Parbury.
[Affecting great pre-occupation.] Going? Going where?
Mrs. Parbury.
With Mr. Gunning.
[Pause. She continues to cry gently.
Parbury.
Gunning—Gunning!—who’s Gunning? Oh—George—yachting, you
mean! Not I! I’m staying here.
Mrs. Parbury.
[Comes towards him gladly, her arms extended.] Clement!
Parbury.
Eh? Oh, forgive me for a few minutes.
[Writes.
Mrs. Parbury.
[Reproachfully.] I was only going to kiss you.
Parbury.
[Writing.] All right, dear—presently—presently, there’s a dear girl!
[Mrs. Parbury has a slow silent exit, looking back at him.] [He doesn’t
look up, but goes on writing. When the door closes, he puts down
his pen.] Oh, the tyranny of it! The tyranny of it!
[Slow Curtain.
END OF ACT I.
ACT II
Scene.—The same as Act I. Evening after dinner the same day. The
room is lighted with lamps, but as it is a still warm evening, the
curtains are not drawn over the glass door which leads into the
garden and is open.
Parbury.
Cigarette or cigar, George?
Gunning.
Thanks, I have a cigarette.
[Takes one from his case and lights it.
Parbury.
Colonel?
Colonel.
Thank you, I’ll take a cigar. I think, however, I’ll—er—smoke it in
the garden. Mabel’s limited appreciation of tobacco——
Parbury.
Oh, Mabel won’t mind—she’s quite educated.
Colonel.
Not beyond the cigarette, I fancy.
[He strolls to the glass door, lights his cigar, and
steps out. For a few moments he is still seen,
then he wanders away.
Gunning.
Nice old chap, your father-in-law.
Parbury.
Isn’t he? I’m quite fond of him. [Pause. They smoke in silence,
Parbury standing at mantelpiece.] What are you thinking of?
Gunning.
I’m not thinking. I’m digesting. I had an excellent dinner.
Enter Evans with coffee, &c. Gunning takes coffee.
Evans.
Cognac, sir, or green chartreuse?
Gunning.
Cognac. [He takes glass.] Thank you.
Parbury.
Colonel, here’s your coffee.
Colonel.
[Outside.] I’ll have it out here, if I may.
[Parbury takes his coffee and liqueur.
Parbury.
Serve Colonel Armitage’s coffee in the garden.
Evans.
Yes, sir.
[Exit Evans, L.
Gunning.
I’ve wired for the champagne.
Parbury.
[Uneasily.] Oh, yes!
[Slight pause.
Gunning.
I notice the glass keeps up well.
Parbury.
Really? Good!
[Slight pause.
Gunning.
Yes, we ought to have capital weather.
Parbury.
Capital! [He is very embarrassed.] If it doesn’t rain it’ll be pretty
—er—fine.
[Drinks. Puts his cup on mantelpiece.
Gunning.
[Favours him with a slow stare.] What’s the matter, old man?
Parbury.
Nothing in the world. Why?
Gunning.
Oh, it doesn’t matter. But I think the change will do you good.
[Slight pause.] By the way, would to-morrow afternoon suit you for a
start?
Parbury.
[Standing with his back to the fireplace, looking up at the
ceiling.] I’m not going, old man.
Gunning.
[Indifferently.] Oh!
Re-enter Evans, R., from garden, and exit L. Silence till he has
gone.
Parbury.
Well, you don’t seem surprised.
Gunning.
[Effecting a yawn.] I never permit myself to be surprised.
Parbury.
Or disappointed.
Gunning.
Oh yes, I own I’m disappointed. I looked for a good time for a
few days. You were the only one of the old lot available, and you
were the best of them. I can’t bear the new lot. They wear strange
colours, drop their “g’s,” and get on one’s nerves.
Parbury.
I’m really sorry, George.
Gunning.
Don’t bother. One simply goes alone. [Discreetly.] The calls of
business are often irresistible.
Parbury.
Don’t rot. You know what the situation is.
Gunning.
Mine is one of those poor intelligences that never know without
information.
Parbury.
I’ll supply it.
[Sits on arm of chair, R.C.
Gunning.
Don’t, if it matters.
Parbury.
I will, though it does matter. [Grimly.] My wife wept.
Gunning.
Unanswerable argument.
Parbury.
Quite. George, what the devil is a man to do?
Gunning.
I knew a man who once interfered between a husband and wife
who were disagreeing. The husband and wife each got a black eye.
The man got two.
Parbury.
You might at least talk.
Gunning.
Oh, certainly.
Parbury.
You know the situation.
Gunning.
Well, if one dare say so, I fancy you are suffering from the
tyranny of a fascinating egoism.
Parbury.
I’m suffering from the tyranny of tears.
Gunning.
What I can’t understand is how a man of your strong nature
arrived where you are.
Parbury.
I’ll make an effort to tell you. To begin with, I suppose I’m fairly
good-natured.
Gunning.
Oh yes!
Parbury.
Or say, if you like, of indolent habit, which after all often passes
for the same thing. Then of course I was in love—I am still. One
drifted. It’s so easy to give way in little things—really not unpleasant
when you’re in love. And then there’s one’s work, which fills the
mind and makes the little things appear smaller than they are. I say
one drifted.
Gunning.
Sometimes, if I know you, you rebelled. What then?
Parbury.
[Promptly.] Tears! And over such absurdly paltry things! Oh, the
farcical tragedy of it all! I wished to go shooting for a few days.
Tears! I fancied dining and spending the evening with an old chum.
Tears! I would go on a walking tour for a week. Tears! Some one
would ask me for three days’ hunting. Tears! Tears, you understand,
always on hand. Tears—tears—tears ad—— [Pulling himself up.] No.
Gunning.
[Quietly.] No—not ad nauseam.
Parbury.
No, that would be too low a thing to say.
[Goes up R.C. Takes stopper out of the decanter.
Gunning.
Do you know, Clement, I really like you tremendously.
Parbury.
Thanks, old man. Have some more brandy?
Gunning.
No thanks. [Pause.] Don’t stop. I’m interested.
Parbury.
That’s all. I drifted, almost unconsciously, right up to to-day, for
all the world like the man in the moral story-book one read as a child
on Sundays, who drifted in his boat on the Erie River towards
Niagara. To-night I’m conscious—I’m awake—I can feel the water
gliding along the boat’s keel. I can see Niagara. I don’t like it. What
the devil’s one to do?
Gunning.
Get out and walk.
[Pause. They smoke.
Parbury.
Of course, I shall change it all. I must, but it will be beastly work.
Gunning.
Beastly. When do you begin?
Parbury.
When occasion serves. I can’t go back over this yachting
business. I’ve said I’m not going.
Gunning.
Quite right.
[Slight pause.
Parbury.
Oh, if the exigeant women only knew—if they only knew!
Enter Colonel Armitage, R.
Talking of brandies, this is Hennessy ’63. Have some, Colonel?
Colonel.
Perhaps half a glass.
[Takes brandy and sits.
Mrs. Parbury.
Miss Woodward and I are boring each other. Shall we come to
you, or will you come to us? [Gunning and Armitage rise.] There, the
question’s answered.
[Sits on sofa, L.
Gunning.
[To Mrs. Parbury.] You were playing the piano just now?
Mrs. Parbury.
Yes, but I play wretchedly nowadays. I gave up practising when
we married.
Gunning.
One should never give up an accomplishment.
Colonel.
You used to play charmingly, Mabel.
Mrs. Parbury.
You thought so, dear, and that was enough for me. [She rises
and crosses to C.] Why don’t we sit in the garden? It’s a perfect
night. [Colonel strolls off to garden.] [Mrs. Parbury goes to Parbury,
who is standing by fireplace, and takes his arm. In a low voice.] Are
you still angry?
Parbury.
[As they go out to the garden.] I angry with you! Nonsense. [He
pats her hand.] Poor little woman! Poor little woman!
[Exit Mr. and Mrs. Parbury.
Gunning.
[Crossing to R.C. top of the table.] Are you not coming, Miss
Woodward?
Miss Woodward.
No, thank you. I have some work to do.
Gunning.
But you seem to me to be always working.
Miss Woodward.
I needn’t, you know. I do it because I like it.
Gunning.
What are you doing now?
Miss Woodward.
Correcting proof sheets of a new novel. It will save Mr. Parbury
the trouble of doing it to-morrow.
Gunning.
I wanted you to talk to me.
Miss Woodward.
What about?
Gunning.
Yourself.
Miss Woodward.
I’m not interesting.
Gunning.
On the contrary.
Miss Woodward.
What do you wish to know?
Gunning.
All about you. May I?
Miss Woodward.
Will you go away and leave me to work if I tell you?
Gunning.
Yes.
[Comes down by chair R.C.
Miss Woodward.
[Putting down her pen, and resting her cheek on her hand.] I’m
the thirteenth daughter of a parson. Why my parents had thirteen
daughters, I don’t know; but I suppose it was because they are very
poor. We were all given the names of flowers—Rose, Lily, Tulip,
Mignonette—I can’t remember them all—but Hyacinth fell to my lot.
Why we were called after flowers, I don’t know; but I suppose it was
because we are none of us the least like flowers. My eldest sister
married my father’s curate. I don’t know why, but I suppose it was
because she came first and is the plainest in the family.
Gunning.
[Laughing.] Yes, well?
Miss Woodward.
[Speaking in an even, emotionless way.] Two other of my sisters
run a Kindergarten, and one other is a governess. Personally I would
rather be a domestic servant. The others remain at home, help in
the house, and await husbands. I fear they will wait in vain, because
there are so many women in our part of the country and so few
men. For my part I seized an early opportunity of learning shorthand
and typewriting—and—well, here I am. Now you know the story of
my life.
[She returns to her work.
Gunning.
I’m afraid it was deuced impertinent of me to ask.
Miss Woodward.
Not at all—only eminently man-like.
[Pause. She works, he smokes.
Gunning.
And so you have found your happiness.
Miss Woodward.
Oh no. I’ve only just started to look for it.
Gunning.
Oh ho! Ambitious!
Miss Woodward.
Very. Have you ever been poor?
Gunning.
Yes, at one time—had to pawn things.
Miss Woodward.
I mean being one of fifteen in family—large inferior joints to last
for days—hot, cold, hashed, minced, shepherd’s pie—[Gunning
shudders at this]—too much potatoes—too much boiled rice—too
much bread and dripping—too much weak tea—too much polishing
up of things not worth polishing up—too much darning on too little
material—and for ever giving thanks out of all proportion to the
benefits received. I wish some one would write the history of a hat
or a frock—I mean a hat or a frock that has marched steadily and
sullenly under various guises through an entire family such as ours,
from the mother down to the youngest girl. What might be written
of the thoughts that had been thought under such a hat, or of the
hearts that had felt under such a frock!
Gunning.
Why don’t you write the story?
Miss Woodward.
Perhaps some day I shall try. [Returns to her work.] In the
meantime you ought to go. You promised, you know. You have
nothing more to learn. I don’t think in all my life I’ve talked so much
about myself as I have to you, a stranger.
[She keeps her eyes on her work.
Gunning.
You have been engagingly frank. I do hope I shall have another
opportunity——
Miss Woodward.
Not at all likely, Mr. Gunning. [Pause.] Goodnight. [Still without
looking up.]
[Gunning looks at her, goes up to the window,
turns, looks at her again.
Gunning.
[At window.] Good-night, Miss Woodward.
[Exit to garden, R.
Miss Woodward.
[Soliloquising.] Rather than go back, I—well, I know I’d rather
die. [She looks over the pages for a moment or two, then yawns
slightly; she gathers her pages together and places a paperweight
over them.] That will have to do. [She rises, looks off R.] There was
actually a man ready to take a sort of languid interest in me. Quite a
new experience. [She takes up Parbury’s photograph and speaks to
it.] You don’t take an interest in me of any kind, do you? [To the
photograph.] You never will, and I don’t think I want you to. But I
do want to stay near you, because you are so strong—
Enter Mrs. Parbury from garden carrying the Colonel’s coffee
cup and saucer.
—and so weak, and so kind, and so foolish.
[Mrs. Parbury has come down and is watching her
unobserved. Miss Woodward slowly raises the
photograph to her lips. The cup and saucer
drop from Mrs. Parbury’s hand to the floor and
are broken. Miss Woodward, much startled,
slowly turns towards Mrs. Parbury, and their
eyes meet. There is a pause. Suddenly, with a
quick movement, Mrs. Parbury snatches the
photograph from Miss Woodward.
Mrs. Parbury.
How dare you! How dare you! [Long pause. She is almost
breathless. Then she partly regains self-control.] What train do you
intend taking?
Miss Woodward.
[R.C.] I don’t understand you.
Mrs. Parbury.
I mean for your home, of course.
Miss Woodward.
[Moves as if she had received a blow, and clasps her hands
together.] I am not going home.
Mrs. Parbury.
Oh, indeed you are. You don’t suppose you can stay here, do
you?
Miss Woodward.
Why shouldn’t I?
Mrs. Parbury.
How dare you ask that when I have just caught you in the act of
kissing my husband’s photograph?
Miss Woodward.
That was in a moment of abstraction. I wasn’t even thinking of
Mr. Parbury.
Mrs. Parbury.
Oh! And you are the daughter of a clergyman! [She goes up and
fetches the A.B.C. from bookcase, and offers it to Miss Woodward.]
Here is the A.B.C.
Miss Woodward.
[Turning away.] I have no use for it just now, thank you.
Mrs. Parbury.
Then I’ll look you out an early morning train myself. [Sits L.] Let
me see—[turning over leaves]—Carfields, Worcestershire, isn’t it?
Here it is. 7.20. I suppose that’s too early. 9.35; that will do. Please
understand you are to take the 9.35 from Paddington in the
morning.
Miss Woodward.
[Firmly.] I shall do nothing of the kind.
Mrs. Parbury.
[Ignoring the remark.] In the meanwhile there is no necessity
that my husband should know the reason of your going. You can
make some excuse. I wouldn’t have him know for worlds.
Miss Woodward.
Of course he shall never know from me—but I want you to quite
understand, Mrs. Parbury, that I am not going to Carfields to-
morrow. Rather than go home under the circumstances I would
starve in the gutter.
Mrs. Parbury.
Well, you must find a lodging till you get other employment. You
will have a month’s salary, of course. Anyway, I’m determined you
leave this house in the morning.
[Goes up C. Puts A.B.C. on chair up L.C.
Miss Woodward.
Is there any real occasion for my leaving?
Mrs. Parbury.
Haven’t you sufficient delicacy of feeling left to teach you that?
Miss Woodward.
[Warmly.] I don’t think I need lessons of delicacy of feeling from
you. [Slight pause.] I’m sorry I said that, and it means a great deal
for me to say I’m sorry. I’m sorry too about the photograph. I think
it all might be forgotten.
Mrs. Parbury.
Forgotten!
Miss Woodward.
After all, I’m only a girl; and I’ve worked very hard for Mr.
Parbury. I think you might be more lenient.
Mrs. Parbury.
[At fireplace.] I’m very sorry for you, Miss Woodward; but I owe
a duty to myself and to my husband. You must go in the morning.
[She moves to return to garden.
Miss Woodward.
[Crosses to L.C.] Mrs. Parbury!
Mrs. Parbury.
Well?
Miss Woodward.
I suppose I ought to be a lady and go, because you, the mistress
of the house, wish me to. But I don’t feel a bit like a lady just now. I
only feel like a poor girl whose chances in life are being ruined for a
very small and innocent folly.
Mrs. Parbury.
Well, what does all this mean?
Miss Woodward.
[Fiercely.] It means that I am in Mr. Parbury’s employment, not
yours, and that I will take my dismissal from him only.
Mrs. Parbury.
Oh, I can promise you that. [She calls into the garden.] Clement!
[Exit Mrs. Parbury to garden, R.
Miss Woodward.
I’m only correcting these proof sheets.
Mrs. Parbury.
No doubt Miss Woodward wishes to finish the work to-night, as
she is leaving to-morrow.
Parbury.
Leaving to-morrow?
Miss Woodward.
I think Mrs. Parbury is mistaken.
Parbury.
[To Mrs. Parbury.] What do you mean, dear?
Mrs. Parbury.
I wish her to go.
Parbury.
Why?
Mrs. Parbury.
I can’t tell you. It is not a thing you would understand. It is
simply impossible for her to remain. In her heart she knows I am
right.
[Slight pause. Parbury goes to Miss Woodward.
Parbury.
Are you satisfied here?
Miss Woodward.
Perfectly.
Parbury.
You have no wish to go away?
Miss Woodward.
Not while you wish me to remain.
Parbury.
Do you know why my wife wishes you to go?
Miss Woodward.
Yes.
Parbury.
Will you kindly tell me?
Miss Woodward.
I’m sorry I can’t. I’ve promised. But—[with a look at Mrs. Parbury]
—I don’t think that Mrs. Parbury’s reasons are adequate.
[Pause. Parbury is thoughtful.
Parbury.
[To Mrs. Parbury.] Have you anything more to say?
Mrs. Parbury.
I have only to repeat that it is quite impossible for Miss
Woodward to stay.
Parbury.
Well, I have made up my mind that there is something very
foolish under all this, and I shall not allow it to deprive me of Miss
Woodward’s services. [Mrs. Parbury looks surprised.] I don’t mind
saying in her presence that she is invaluable to me. I should never
be able to replace her. [Sense of relief on Miss Woodward’s part.]
Now, come. [Looking from one to the other.] What is it? A tiff—a
stupid misunderstanding? Oh, you women, why will you fuss about
little things? Make it up, do. Think of “The Roll of Ages.” Shake
hands, cry, embrace, kiss, or whatever your pet method may be.
Weep if you like, though personally I’d rather you didn’t. Anyway, as
far as I am concerned, the incident is closed.
[He turns to go.
Mrs. Parbury.
[Doggedly.] Miss Woodward leaves this house in the morning.
Parbury.
[Looks at his wife for a moment, then turns to Miss Woodward.]
Miss Woodward, would you be so very kind——
[He opens the door for her with great courtesy.
Miss Woodward bows, and exits L. He comes to
C.
Mrs. Parbury.
[Turning to him with assumed brightness.] Now, darling, it will be
different. Of course, I couldn’t say much before her. You were quite
right to be nice and courteous to her now she is going.
Parbury.
But I assure you she is not.
[They are C. Mrs. Parbury takes his arm
caressingly.
Mrs. Parbury.
But she is—believe me, she is. Of course, we don’t want to be
hard on her, and she shall have a month’s salary and a strong
recommendation.
Parbury.
[Disengaging his arm.] My dear Mabel, I absolutely refuse to act
in the dark. I hate mysteries. If you care to tell me what all this
bother is about, I’ll judge for myself what’s the right thing to do.
[Sits on sofa.
Mrs. Parbury.
I can’t—it’s impossible. There are some things that men can’t be
trusted to know about. You must leave this matter to me.
[Sits next him.
Parbury.
That I quite decline to do.
[She again takes his arm and talks rapidly,
gradually rather hysterically, towards the end
appearing about to cry.
Mrs. Parbury.
Darling, do listen. You don’t understand. You have never been
like this with me before. I’m sure I’m not asking very much. You can
easily get another secretary. Another time you shall have a man one,
as you originally wanted to. You were right, dear—you often are.
[Parbury rises; crosses to R. Mrs. Parbury follows him.] Darling, do be
reasonable. I’ve been a good wife to you, haven’t I? I’ve always
respected your wishes, and not bothered you more than I could
help. This is only a little thing, and you must let me have my own
way. You must trust me absolutely, dear. You know anything I would
do would only be for your good, for you know that I love you. [She
takes out her handkerchief.] I adore you, darling. You must give way
—you must—you must!
Parbury.
[Stepping back from her.] If you cry I shall leave the room.
[Sits R. Begins to write.
Mrs. Parbury.
[With her back to the audience, in a low voice.] I wasn’t going to
cry.
Parbury.
I’m glad to hear it.
[Mrs. Parbury puts her handkerchief away and
turns.
Mrs. Parbury.
I had no intention of crying, dear. [Parbury still writes. Pause. She
comes to desk.] Shall I write out an advertisement for you, dear?
Parbury.
What for?
Mrs. Parbury.
For a new secretary—a man.
Parbury.
No. My mind’s made up. I shall not change my secretary.
Mrs. Parbury.
Clement!
Parbury.
[Rises and goes to her.] Listen, my dear Mabel. Perhaps I’m a
good deal to blame for the pain you are going to suffer now, and I’m
very sorry for you; in many ways you are the best little woman in
the world. I’ve been weak and yielding, and I’ve gradually allowed
you to acquire a great deal more power than you know how to use
wisely.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com