Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
$Id: History,v 2.10 1998/12/11 20:26:05 allison Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Super-Category History file
|
||||
---------------------------
|
||||
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
at this level and keep track of all relavant tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
envs-00-04-01 11th December 1998 Hajime Yoshida Masayasu Nagamatu
|
||||
- The latest version of GGE, the whole *.java, *.class and example files committed
|
||||
|
||||
10th December Hajime Yoshida
|
||||
- Tcl/Tk GAG warns to the binaries compiled with G4UIterminal session
|
||||
and stops it.
|
||||
|
||||
envs-00-03-04 12th November 1998 John Allison
|
||||
- Tagged (what was envs-00-30-03?).
|
||||
|
||||
12th Nov. 1998 Hajime Yoshida
|
||||
-many new features added to Momo/java/Momo/GGE
|
||||
-minor modification to Momo/GGEmake
|
||||
-addition of Momo/java/Momo/Momo
|
||||
|
||||
envs-00-03-02 14th Sep 1998 Hajime Yoshida
|
||||
- minor updates in GGE
|
||||
envs-00-03-01 13th Sep 1998 Hajime Yoshida
|
||||
-Momo/GGEmake added README and a macro file
|
||||
-Momo/java/Momo/GGE updated.
|
||||
BREPs, sample persistent files etc.
|
||||
envs-00-02-01 3rd Sep 1998 Hajime Yoshida
|
||||
Momo/GGEmake
|
||||
Momo/java/Momo/GGE
|
||||
GGE committed
|
||||
envs-00-01-03 17th Aug 1998 Hajime Yoshida
|
||||
- touched many files in Momo Tcl/Tk and Java
|
||||
|
||||
envs-00-01-02 15th July 1998 John Allison
|
||||
- Removed some files in OPACS for beta01 - see OPACS/History.
|
||||
|
||||
envs-00-01-01 8th July 1998 John Allison
|
||||
- Added XVT (moved from interfaces/xvt_standalone_test).
|
||||
- Forced revision 2.0 on Momo.
|
||||
|
||||
6th July 1998 Satoshi Tanaka
|
||||
- Added Momo (moved from interfaces/standalone_test).
|
||||
|
||||
^^^^^^^^^^^^^^^^^^^^ geant4beta ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
=========================================================================
|
||||
vvvvvvvvvvvvvvvvvvvv geant4alpha vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
||||
|
||||
envs-00-05-01 23rd April 1998 Gabriele Cosmo
|
||||
- Added OPACS directory tagged as OPACS-00-05-01.
|
||||
|
||||
envs-00-05-00 19th March 1998 John Allison
|
||||
- First creation of this super-category.
|
||||
@@ -0,0 +1,26 @@
|
||||
#Momo Plug-in example
|
||||
# An example of Momo/Tcl Plug-in
|
||||
#1998 July 20 H Yoshida
|
||||
|
||||
# A line starting with # is a comment line.
|
||||
# An empty line is ignored.
|
||||
# Momoseparator is a separation line between menu items.
|
||||
# Any Unix X-window applications can be invoked by describing
|
||||
# the command name and associated arguments.
|
||||
# See the example below.
|
||||
# Commands are executed in the background.
|
||||
# But & is not necessary at the end of a line.
|
||||
|
||||
java gge
|
||||
#java gag
|
||||
|
||||
xclock
|
||||
|
||||
Momoseparator
|
||||
xterm
|
||||
|
||||
Momoseparator
|
||||
netscape
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FONT -adobe-courier-bold-r-normal--14-100-100-100-m-90-iso8859-1
|
||||
GUI_STYLE horizontal
|
||||
GUI_POSITION left
|
||||
FORE_GROUND_COLOR #000000000
|
||||
BACK_GROUND_COLOR #b5bfffa3c
|
||||
@@ -0,0 +1,73 @@
|
||||
History file for the G4UIGAG class
|
||||
|
||||
|
||||
4 Dec 1998
|
||||
- ready for release
|
||||
- java GAG and Tcl/tk GAG are protected against G4binary with
|
||||
G4UIterminal session. They terminate the execution of
|
||||
the G4binary and become ready to run other G4binaries
|
||||
with G4UIGAG session.
|
||||
|
||||
- The above is associated with minor modification (only one line)
|
||||
in G4UIterminal.cc
|
||||
|
||||
- many cosmetic changes, specially for Java GAG
|
||||
|
||||
- JDK1.2 version is yet to come.
|
||||
|
||||
- G4UIGAG is now completely equivalent with G4UIterminal in
|
||||
the terminal mode. Including Help functions.
|
||||
|
||||
20 Aug
|
||||
- Beta-01
|
||||
|
||||
6 July 1998
|
||||
- ready for beta
|
||||
|
||||
July , 1998
|
||||
-@@Ask is introduced. G4UIGAG does nothing and simply passes it to
|
||||
GAG.
|
||||
|
||||
July, 1998
|
||||
|
||||
- bug fixed. (uiMode == terminal_mode)
|
||||
|
||||
Apr 15, 98
|
||||
- sendDisableList() is fully implemented. Now the command is properly
|
||||
disabled when the state transition occurs.
|
||||
The state transition is detected only when entering the interaction loop
|
||||
such as {preInit, Idle} state. This limitation comes from our design
|
||||
choice to avoid any overhead when the beam is on.
|
||||
- modified the showCurrent() to open an error message window if the
|
||||
current value is not properly set. The "@@ErrResult" protocol is used.
|
||||
|
||||
Apr 14, 98
|
||||
- fixed the "hang" bug when the current value is asked. The showCurrent()
|
||||
is modified to handle the embedded null string of the current value.
|
||||
|
||||
Apr 06, 98
|
||||
- renamed getRangeString() to getRange()
|
||||
|
||||
March 26, 98
|
||||
- minor bug fix for the help command, terminalHelp() is modified.
|
||||
|
||||
March 16, 98
|
||||
- bug fix for the Disable list.
|
||||
- This is the stable version because the functionality is tested using a
|
||||
check list.
|
||||
|
||||
March 13, 98
|
||||
- handles the parameter update of each command, such as "on the fly"
|
||||
updation of the candidate list
|
||||
- handles the dynamic menu reconfigration using /test/installVis command
|
||||
|
||||
March 12, 98
|
||||
- change the specification of @@PROMPT and @@State
|
||||
- added internal routines such as "sendATclParamProperty()"
|
||||
- send the range string of G4UIcommand
|
||||
|
||||
March 10, 98
|
||||
- modify to send the protocol version string (@@Version) of GAG
|
||||
- send the disable list (ad hoc version to test GUI)
|
||||
- send the attributes of command/parameter even if it is not defined
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#GGE draw macro
|
||||
/vis~/create_view/new_graphics_system DAWN
|
||||
/vis~/camera/viewpoint 60. 30.
|
||||
/vis~/camera/zoom 2
|
||||
/vis~/set/drawing_style 2
|
||||
/vis~/set culling on
|
||||
/vis~/set/cull_by_density on 0.01
|
||||
/vis~/draw/current
|
||||
/vis~/draw/axes 0 0 0 10000 mm
|
||||
/vis~/show/view
|
||||
@@ -0,0 +1,10 @@
|
||||
#GGE draw macro
|
||||
/vis~/create_view/new_graphics_system DAWNFILE
|
||||
/vis~/camera/viewpoint 60. 30.
|
||||
/vis~/camera/zoom 2
|
||||
/vis~/set/drawing_style 2
|
||||
/vis~/set culling on
|
||||
/vis~/set/cull_by_density on 0.01
|
||||
/vis~/draw/current
|
||||
/vis~/draw/axes 0 0 0 10000 mm
|
||||
/vis~/show/view
|
||||
@@ -0,0 +1,10 @@
|
||||
#GGE draw macro
|
||||
/vis~/create_view/new_graphics_system OGLIX
|
||||
/vis~/camera/viewpoint 60. 30.
|
||||
/vis~/camera/zoom 2
|
||||
/vis~/set/drawing_style 2
|
||||
/vis~/set culling on
|
||||
/vis~/set/cull_by_density on 0.01
|
||||
/vis~/draw/current
|
||||
/vis~/draw/axes 0 0 0 10000 mm
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# $Id: GNUmakefile,v 1.2 1998/11/12 10:49:50 yhajime Exp $
|
||||
# --------------------------------------------------------------
|
||||
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
|
||||
# --------------------------------------------------------------
|
||||
|
||||
name := myDetector
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,37 @@
|
||||
# $Id: GNUmakefile.light,v 1.2 1998/11/12 10:49:52 yhajime Exp $
|
||||
# --------------------------------------------------------------
|
||||
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
|
||||
# --------------------------------------------------------------
|
||||
|
||||
name := exampleN01
|
||||
G4TARGET := $(name)
|
||||
G4EXLIB := true
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
LDLIBS := \
|
||||
-l$(G4TARGET) \
|
||||
-lG4run \
|
||||
-lG4event \
|
||||
-lG4tracking \
|
||||
-lG4bosons \
|
||||
-lG4partman \
|
||||
-lG4transportation \
|
||||
-lG4procman \
|
||||
-lG4track \
|
||||
-lG4materials \
|
||||
-lG4digits+hits \
|
||||
-lG4csg \
|
||||
-lG4geometrymng \
|
||||
-lG4volumes \
|
||||
-lG4magneticfield \
|
||||
-lG4graphics_reps \
|
||||
-lG4intercoms \
|
||||
-lG4global
|
||||
|
||||
.PHONY: all
|
||||
all: lib bin
|
||||
|
||||
include $(G4INSTALL)/config/binmake.gmk
|
||||
@@ -0,0 +1,23 @@
|
||||
$Id: History,v 1.2 1998/11/12 10:49:54 yhajime Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
Example N01 History file
|
||||
------------------------
|
||||
This file should be used by the G4 example coordinator to briefly
|
||||
summarize all major modifications introduced in the code and keep
|
||||
track of all tags.
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
May 07, 98 M.Asai
|
||||
- First commitment of all classes.
|
||||
|
||||
April 09, 98 G. Cosmo
|
||||
|
||||
- Created.
|
||||
@@ -0,0 +1,433 @@
|
||||
README of GGE; GEANT4 Geometry Editor
|
||||
|
||||
1998 Oct. 15
|
||||
1998 Sep. 24
|
||||
1998 Sep. 10
|
||||
1998 Aug. 31
|
||||
Hajime YOSHIDA
|
||||
Naruto University of Education
|
||||
|
||||
1) Introduction
|
||||
|
||||
GGE, GEANT4 Geometry Editor, is a visual tool to "create" a
|
||||
detector geometry after GEANT4's.
|
||||
|
||||
It provides users with tables
|
||||
into which users can fill with their detector parameters. After the
|
||||
data in the tables, GGE creates C++ source codes for a detector.
|
||||
When a user uses default functions of GGE, C++ codes generated by GGE is a complete
|
||||
description of a detector, including the definition of atoms, materials, solids, color attributes,
|
||||
logical volumes and physical volumes with rotations and translations.
|
||||
The C++ source codes are saved into files and can be compiled to make a GEANT4 executable.
|
||||
A minimum set of files for the GEANT4 managers to visualise the detector as well as
|
||||
a GNUMakefile are provided for that.
|
||||
|
||||
GAG is helpful to have a visualization of the whole detector.
|
||||
Simple macro files are associated, too, for visualisation.
|
||||
|
||||
GGE consists of two editors (material and volume) which are
|
||||
interrelated upon users' request. Volume editor provides Single
|
||||
Positioned Volume, Repeated Volumes with incremental copy numbers
|
||||
(translational arrangement or axially symmetric arrangement), Replicas (in any axis)
|
||||
and Parametrized volumes(not yet).
|
||||
|
||||
GGE is based on Java's MVC model, or Swing so that any change or input to the tables by a user
|
||||
are automatically reflected to the internal data structure of GGE and C++ codes.
|
||||
|
||||
2) Functions of GGE
|
||||
|
||||
2.1) Material Editor
|
||||
a) implemented in this version
|
||||
|
||||
+ append, insert, edit and delete a material
|
||||
+ material from scratch
|
||||
+ material by combination (number or fractional ratios)
|
||||
+ periodic table of atoms automatically popped up to create a material
|
||||
+ default states are provided (material state, temperature, pressure)
|
||||
+ canonical physical units in GEANT4 selectable from a combobox
|
||||
|
||||
+ "in Use" mark for materials used in user's detector
|
||||
+ materials used in the logical volumes are automatically made "in Use".
|
||||
+ user can add any materials "in Use" to have C++ constructors
|
||||
|
||||
+ persistent material file
|
||||
+ load, append or save a material file
|
||||
+ an exemplary persistent material database file "MaterialDB.g4mt" from the PDG
|
||||
|
||||
b)not yet implemented
|
||||
|
||||
- material from materials (coming soon)
|
||||
- isotope (planned)
|
||||
- protection from duplicated "in Use" instances of the same materials.
|
||||
|
||||
2.2) Volume Editor ; logical and physical volumes
|
||||
|
||||
a)implemented
|
||||
|
||||
+ G4Solids
|
||||
+ CSG solids
|
||||
+ G4box, G4tubs, G4cons, G4trd
|
||||
+ parameters and canonical units
|
||||
+ preview with DAWN (automatically chosen world size)
|
||||
+ BREPs
|
||||
+ Pcone, Pgon
|
||||
+ any number of nodes and facets with parameters and canonical units
|
||||
+ preview with DAWN (automatically chosen world size)
|
||||
+ G4LogicalVolume
|
||||
+ create, delete a logical volume
|
||||
+ Its name, G4Solid, material, visualization attributes
|
||||
+ selectable G4Solid among the above candidates
|
||||
+ type-in materials name (drag and drop is planned)
|
||||
+ Color Chooser to specify visualization attribute (color and its name)
|
||||
+ Used materials link to material DB
|
||||
|
||||
+ G4PVPlacement ; arrangement of physical volumes
|
||||
+ Type 1 constructor = rotation of the frame, physical mother volume
|
||||
+ Type 2 constructor = rotation of a body, physical mother volume
|
||||
+ Type 3 constructor = rotation of the frame, logical mother volume
|
||||
+ Type 4 constructor = rotation of a body, logical mother volume
|
||||
|
||||
+ Single Positioned Volume (SPV)
|
||||
+ mother volume is either
|
||||
null(Master Reference System), logical or physical
|
||||
+ MARS is constructed first in C++ code.
|
||||
+ translation in the X, Y or Z direction (default is no translation)
|
||||
+ rotation around X, Y or Z axis with an angle (frame or body)
|
||||
|
||||
+ Repeated Volumes with incremental copy numbers (RVArrangement)
|
||||
+ translational arrangement of any number of copies of a logical volume
|
||||
+ placements in the X, Y or Z direction
|
||||
+ the position of the first copy and incremental step size
|
||||
+ with respect to a logical or physical mother volume
|
||||
+ axially symmetric arrangement
|
||||
+ rotational axis is parallel to X, Y or Z axis
|
||||
+ rotation of the frames or a body
|
||||
+ position of the center of axial symmetry
|
||||
+ radius of axially symmetric arrangement
|
||||
+ starting angle and incremental step angle with number of copies
|
||||
+ logical or physical mother volume
|
||||
|
||||
+ Replica
|
||||
+ replication in the X, Y or Z direction
|
||||
+ replication in rho, phi or Z direction
|
||||
+ width (in length or angle) and number of replicas
|
||||
+ offset (in length or angle)
|
||||
+ logical or physical mother volume
|
||||
|
||||
b)to be implemented
|
||||
|
||||
- other CSG solids
|
||||
|
||||
- paremetrised volumes
|
||||
- linear scaling
|
||||
- linear rotation
|
||||
|
||||
2.3) Generation of C++ code ; "MyDetectorConstruction.cc"
|
||||
|
||||
a) implemented
|
||||
+ C++ code is output to a editor widget
|
||||
+ necessary header files are automatically included
|
||||
+ save the file with a file chooser
|
||||
+ order of creating instances;
|
||||
G4Elements, G4Material, G4VisAttributes, G4Solids, G4LogicalVolume,
|
||||
Single Positioned Volumes, Repeated Volumes, Replicas
|
||||
x order of instantiation inside each section is decided by GGE user,
|
||||
except MARS
|
||||
+ return the instance name of the MARS
|
||||
|
||||
b)not implemented
|
||||
- automatic correct ordering of constructors of volumes
|
||||
|
||||
|
||||
2.4) GGEmake; a directory containing the GEANT4 codes to compile and visualize the detector
|
||||
a) implemented
|
||||
+ GNUmakefile
|
||||
+ myDetector.cc ; main() with GAG session and visualization manager
|
||||
+ src/ directory contains
|
||||
+ MyDetectorConstruction.cc
|
||||
+ MyPhysicsList.cc
|
||||
+ MyPrimaryGeneratorAction.cc
|
||||
+ MyVisManager.cc
|
||||
+ include/ directory
|
||||
|
||||
2.5) compile and visualize with Momo and GAG
|
||||
|
||||
a) implemented
|
||||
|
||||
+ canonical scheme of GEANT4 to compile
|
||||
+ make G4TARGET=myDetector
|
||||
+ the binary is created as $G4INSTALL/bin/G4SYSTEM/myDetector
|
||||
|
||||
+ Momo (GAG, Compile and GGE buttons)
|
||||
+ rapid cycling of GGE and GAG to edit and view the geometry
|
||||
+ a macro file for visualization (OGLIX default) "DrawDAWN.g4m", etc..
|
||||
|
||||
b) not implemented
|
||||
- automatic "calibration" of the detector with geantino
|
||||
|
||||
2.6) exemplary persistent detector files with *.g4dt suffix
|
||||
+ 3D array of lead plates using translational RVArrangement
|
||||
+ BREP Pcones trumpetss using axially symmetric RVArrangement
|
||||
+ Replicas to form cylinders
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
3) Installation
|
||||
|
||||
The minimum set to get C++ source code
|
||||
1) GGE.jar file
|
||||
2) Java interpreter ; java
|
||||
Additional set to compile
|
||||
3) GEANT4 toolkit with compiled libraries
|
||||
4) GGEmake directory
|
||||
Additional set to visualise and use GUI
|
||||
4) DAWN (plus Ghostview) or OGLIX or VRML
|
||||
5) GAG (Java version) or GAG.jar file
|
||||
Additional too to make life easy
|
||||
6) Momo to use all the above ingredients; Momo.jar file
|
||||
(without Momo, you have to invoke GGE, compile and GAG respectively in windows.)
|
||||
|
||||
3.1) Java and Swing
|
||||
We have tested GGE on Unix-en (Linux and Solaris) and Windows (95/NT).
|
||||
|
||||
3.1.1) Unix:
|
||||
|
||||
+ Linux: jdk1.1.3 or later(i.,e., jdk-1.1.6) + Swing-1.0.2
|
||||
1) jdk1.1.5 may have bugs, while jdk1.1.6 works
|
||||
2) GGE co-works with Swing-1.0.2 and not with 1.0.1 (or maybe not
|
||||
with 1.0.3).
|
||||
3) we are testing the current GGE with JRE1.2-beta04. The present source can be
|
||||
compiled but doesn't execute correctly. In any case
|
||||
Sun has announced on 17 August that JDK1.2 will be delayed
|
||||
till November!!
|
||||
+ Solaris: jdk1.1.6 + swing-1.0.2
|
||||
|
||||
|
||||
We assume that you have
|
||||
1)jdk1.1.6/bin/java (Java interpreter) to which paths are set
|
||||
2)Swing-1.0.2 which is defreezed and placed in $HOME/swing/swingall.jar
|
||||
|
||||
3.1.2) Windows:
|
||||
|
||||
We use JBuilder2 with Swing-1.0.2. Note that you have to
|
||||
eliminate all other libraries than swing-1.0.2, after having
|
||||
copied it into JBuilder2.
|
||||
|
||||
We are trying JDK1.2beta4 + JRE1.2 with JBuilder2.
|
||||
|
||||
NOTE! At present we have not Momo/GAG for Windows. So,
|
||||
you can only create C++ code under the Windows.
|
||||
|
||||
3.2) GGE and related files
|
||||
The latest product of GGE is that of Sep. 24.
|
||||
All *.java, *.class and GGE.jar files are placed in
|
||||
geant4beta/environments/Momo/java/Momo/GGE
|
||||
|
||||
Only "GGE.jar" file is necessary to run GGE.
|
||||
|
||||
GGE/*.java GGE source files
|
||||
GGE/*.class GGE byte code files
|
||||
GGE/GGE.jar jar archive file to which CLASSPATH must be set
|
||||
GGE/*.g4mt material database after PDG data
|
||||
GGE/*.g4dt exampleN0x detector file
|
||||
C++ source codes and GNUmakefiles to compile with GEANT4 are placed in
|
||||
geant4beta/environments/Momo/GGEmake.
|
||||
|
||||
Only geantino is instantiated in the initialization of GEANT4, so that it is quite
|
||||
rapid to have a visualization of the geometry. You can choose DAWN, OpenGL or VRML system.
|
||||
|
||||
GGEmake/myGGEdetector.cc main() program
|
||||
/GNUmakefile
|
||||
/src
|
||||
/src/MyDetectorConstruction.cc C++ generated by GGE
|
||||
/src/MyPrimaryGeneratorAction.cc geantino gun
|
||||
/src/MyVisManager.cc DAWN, DAWNFILE, OGLIX, OGLSX, VRML1, VRML1FILE
|
||||
/src/MyPhysicsList.cc geantino definition
|
||||
/include/*.hh
|
||||
/GGEdraw.g4m default macro file to visualize with OGLIX
|
||||
|
||||
3.3) install, setenv and run
|
||||
|
||||
%set path=($path jdk1.1.6/bin) <=== add the path to java and javac
|
||||
%setenv CLASSPATH .:$HOME/swing/swingall.jar:$HOME/geant4beta/environments/Momo/java/Momo/GGE/GGE.jar
|
||||
|
||||
|
||||
Then in any directory, you can invoke GGE.
|
||||
|
||||
%java gge
|
||||
|
||||
|
||||
3.4) DAWN, Tcl/Tk and Postscript for the preview of CSG or BREP solids
|
||||
If you don't use GGE's preview button, these are not necessary.
|
||||
|
||||
If you want to preview G4Solids, you have to install
|
||||
DAWN, Fukui renderer as well as Tcl/Tk wish (Tcl/Tk 8.0) for its GUI.
|
||||
DAWN uses also Postscript to draw *.prim files.
|
||||
|
||||
For the visualization of the whole detector, DAWN or Mesa (for OGLIX)
|
||||
are necessary.
|
||||
|
||||
3.5) GEANT4 toolkit and its environments
|
||||
The visualization manager instantiates DAWN, DAWNFILE, OPENGLIX,
|
||||
OPENGLSX, VRML, VRMLFILE. So, you have to setenv accordingly.
|
||||
|
||||
4) A First Lesson; how to use GGE.
|
||||
|
||||
Here is a walk-through of how to use GGE.
|
||||
|
||||
4.1) Visualize the prefabricated detector sample
|
||||
1) In a xterm, type %java gge
|
||||
2) In the "Volume window", select "Load a Volume file" menu
|
||||
and double click on "trumpetBREP.g4dt"
|
||||
3) Click "Makesource" and select "Make C++ code". Have a look of the generated C++ code.
|
||||
4) Save the C++ code (overwrite the existing one)
|
||||
in .../GGEmake/src/MyDetectorConstruction.cc" using the file chooser.
|
||||
5) In another xterm, go to the directory GGEmake/ and type
|
||||
%make G4TARGET=myGGEdetector
|
||||
|
||||
Watch if there is any compilation error. At present,
|
||||
GGE is made so that it generates correct C++ codes,
|
||||
if a user uses GGE correctly.
|
||||
|
||||
In the example of "trumpetBREP.g4dt", a few warnings are shown on BREP.
|
||||
6) Check that you have "myGGEdetector" executable, in $(G4INSTALL)/bin/$(G4SYSTEM)
|
||||
7) In another xterm, type
|
||||
%java gag
|
||||
|
||||
and with the "Run GEANT4" button, choose and run "myGGEdetector".
|
||||
8) Use /control/execute command and double click on "GGEdraw.g4m".
|
||||
To have a better view, use vis~ commands (camera/viewpoint, zoom etc).
|
||||
You can select DAWNFILE to draw and have a PS hardcopy.
|
||||
|
||||
4.2) Modify the prefabricated detector
|
||||
Now let's change the detector configuration. Go to the "Volume" window
|
||||
and change any part of it, including material.
|
||||
|
||||
4.2.1) Changing materials
|
||||
|
||||
1) First, you have to "Clear Material" in the Material editor.
|
||||
2) Then, select "Load material" and double click on "MaterialDB.g4mt".
|
||||
Now you have a list of materials.
|
||||
3) Then, in the "Logical Volume" panel, double click the box you want to change
|
||||
and type in the name of the material in the material editor.
|
||||
4) Change as many materials as you like and push "Used Material" button.
|
||||
You see that materials you have typed in are marked "Used" in red.
|
||||
If not, you might have mistyped the name of a material.
|
||||
5) If you want to use additional materials, select "Use" in the material
|
||||
editor (the leftmost column).
|
||||
6) Push "Makesource" and see your change has been realized in the C++ code.
|
||||
|
||||
NOTE!! Be careful that there are no duplicated "Used" materials, when
|
||||
you load the material DB without "Clear Material".
|
||||
|
||||
4.2.2) Modifying the size parameters of solids
|
||||
|
||||
To change the sizes of G4 solids
|
||||
1) click a "solid" box of the logical volume of your choice.
|
||||
2) You have a pop-up window to edit the parameters. Change a parameter
|
||||
or its unit, as you like.
|
||||
3) Push "Makesource" and see if your changes have been correctly applied
|
||||
to C++ code.
|
||||
4) In case of BREP solids, the pop-up window has variable number of columns
|
||||
to accept any number of nodes.
|
||||
5) For complicated solids like BREPs, preview may be useful. Click "View"
|
||||
button and you have a view with the DAWN renderer. Its g4.prim file
|
||||
is also shown in an edit-able widget.
|
||||
|
||||
4.2.3) Changing the type of solid of an existing logical volume
|
||||
You may want to replace the current G4Solid with another one. In the
|
||||
present GGE you can't do so directly. You have to "Create" a new logical
|
||||
volume with the type of solid you want and then delete the unnecessary volume.
|
||||
|
||||
1) Choose your new solid with "Select Solid" combo-box.
|
||||
2) Push "Create" button and you have a pop-up window to input parameters.
|
||||
3) Type in numbers and select their units.
|
||||
4) Preview if you like and then push "OK".
|
||||
5) Check the C++ code.
|
||||
|
||||
4.2.4) Changing visualization attributes (Color).
|
||||
1) You have to "Create" a new VisAttributes
|
||||
2) Upon the "Create" button, you have a Color Chooser.
|
||||
3) Select RGB (not HSV). Set your color with slide-bars.
|
||||
4) Give it a name, and push "OK". Then you have a color circle and name in the
|
||||
VisAttrib panel.
|
||||
5) Edit the VisAtb box in the LogicalVolume panel.
|
||||
6) See the C++ code.
|
||||
|
||||
4.2.5) Changing Repeated Volumes
|
||||
|
||||
|
||||
|
||||
|
||||
"exampleN01.g4dt" contains three "single positioned volumes"
|
||||
and one "repeated volumes" in the X direction.
|
||||
Change the parameter of repetition such as the number
|
||||
or width, or you can add another "repeated volumes"
|
||||
in another direction.
|
||||
|
||||
In "trumpetBREP.g4dt" you can edit BREPs, adding new faces etc..
|
||||
|
||||
b) making C++ code "MyDetectorConstruction.cc" and compile.
|
||||
|
||||
Finally, back to the step 3 and recompile.
|
||||
|
||||
|
||||
Opening GGE, compile, GAG simultaneously, you can
|
||||
test and improve the geometry, just like creating
|
||||
HTML or TeX documents.
|
||||
|
||||
|
||||
4) Naming conventions in GGE
|
||||
|
||||
Knowledge of GGE's naming convention is helpful to read the generated C++ code as
|
||||
well as using GGE correctly.
|
||||
|
||||
4-1) Elements and materials
|
||||
|
||||
a) Elements are named "elementXXX", where XXX stands for the
|
||||
element's symbol in the periodic table.
|
||||
b) materials are named just as you have typed in the second column
|
||||
of the material window.
|
||||
|
||||
4-2) solids and logical volumes
|
||||
The "Name" typed in the first (leftmost) column of the "Logical Volume"
|
||||
is used to name the corresponding solid. If the name "world" is given
|
||||
to a logical volume of a Box, the G4Solid has an instance "solidworld".
|
||||
4-3) logical and physical volumes
|
||||
The instance of a physical volume defined by "pName" has a name prefixed
|
||||
with "physical", i.,e., instance's name is "physical" + pName ( + =>
|
||||
string concatenation). "logical" is added to the instance of a logical
|
||||
volume.
|
||||
In case of SPV (single positioned volume), the columns "pName" (instance of
|
||||
physical volume) and "pLogical" may have the same strings.
|
||||
|
||||
In case of RVA (repeated volumes arrangement), "pName" is different from
|
||||
"pLogical" whose copies are repeatedly placed.
|
||||
|
||||
4-4) All variables are named after their proper instances.
|
||||
See for example, the control variable used in the for loop in the
|
||||
RVA.
|
||||
|
||||
Another examples are arrays to define BREP geometry.
|
||||
5) Default values and combo-boxes
|
||||
|
||||
|
||||
5.1) Default optional values of materials
|
||||
GGE provides default values in a pre-filled columns or with the
|
||||
combo-boxes. "Use", "State" and "Unit" columns are equipped with
|
||||
combo-boxes. Temperature and pressure column are pre-filled with
|
||||
273.15 * kelvin and 1 * atmosphere.
|
||||
5.2) Default values in volumes
|
||||
"Mother Type" is either NULL (mother of all), logical (type 2, 4 constructors)
|
||||
or physical (type 2 or 4 constructors) in G4PVPlacement.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyDetectorConstruction.hh,v 1.2 1998/11/12 10:50:05 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#ifndef MyDetectorConstruction_H
|
||||
#define MyDetectorConstruction_H 1
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
class MyDetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
MyDetectorConstruction();
|
||||
~MyDetectorConstruction();
|
||||
|
||||
public:
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyPhysicsList.hh,v 1.2 1998/11/12 10:50:06 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
// ExN01PhysicsList
|
||||
// Construct/define particles and physics processes
|
||||
//
|
||||
// Particle defined in ExampleN01
|
||||
// geantino
|
||||
//
|
||||
// Process defined in ExampleN01
|
||||
// transportation
|
||||
//
|
||||
|
||||
#ifndef MyPhysicsList_h
|
||||
#define MyPhysicsList_h 1
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class MyPhysicsList: public G4VUserPhysicsList
|
||||
{
|
||||
public:
|
||||
MyPhysicsList();
|
||||
~MyPhysicsList();
|
||||
|
||||
protected:
|
||||
// Construct particle and physics process
|
||||
void ConstructParticle();
|
||||
void ConstructProcess();
|
||||
void SetCuts(G4double cut);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyPrimaryGeneratorAction.hh,v 1.2 1998/11/12 10:50:06 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#ifndef MyPrimaryGeneratorAction_h
|
||||
#define MyPrimaryGeneratorAction_h 1
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4Event;
|
||||
|
||||
class MyPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
public:
|
||||
MyPrimaryGeneratorAction();
|
||||
~MyPrimaryGeneratorAction();
|
||||
|
||||
public:
|
||||
void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
private:
|
||||
G4ParticleGun* particleGun;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyVisManager.hh,v 1.2 1998/11/12 10:50:07 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
// Example Visualization Manager implementing virtual function
|
||||
// RegisterGraphicsSystems. Exploits C-pre-processor variables
|
||||
// G4VIS_USE_DAWN, etc., which are set by the GNUmakefiles if
|
||||
// environment variables of the same name are set.
|
||||
|
||||
// So all you have to do is set environment variables and compile and
|
||||
// instantiate this in your main().
|
||||
|
||||
// Alternatively, you can implement an empty function here and just
|
||||
// register the systems you want in your main(), e.g.:
|
||||
// G4VisManager* myVisManager = new MyVisManager;
|
||||
// myVisManager -> RegisterGraphicsSystem (new MyGraphicsSystem);
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#ifndef MyVisManager_h
|
||||
#define MyVisManager_h 1
|
||||
|
||||
#include "G4VisManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
class MyVisManager: public G4VisManager {
|
||||
|
||||
public:
|
||||
|
||||
MyVisManager ();
|
||||
|
||||
private:
|
||||
|
||||
void RegisterGraphicsSystems ();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: myDetector.cc,v 1.1 1998/11/12 10:50:01 yhajime Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
// GEANT 4 - GGEVis.cc
|
||||
//
|
||||
// For information related to this code contact:
|
||||
// CERN, IT Division, ASD Group
|
||||
// --------------------------------------------------------------
|
||||
// Comments
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIGAG.hh"
|
||||
#include "MyDetectorConstruction.hh"
|
||||
#include "MyPhysicsList.hh"
|
||||
#include "MyPrimaryGeneratorAction.hh"
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
#include "MyVisManager.hh"
|
||||
#endif
|
||||
|
||||
|
||||
#include "g4templates.hh"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Construct the default run manager
|
||||
G4RunManager* runManager = new G4RunManager;
|
||||
|
||||
// set mandatory initialization classes
|
||||
runManager->SetUserInitialization(new MyDetectorConstruction);
|
||||
runManager->SetUserInitialization(new MyPhysicsList);
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
// visualization manager
|
||||
G4VisManager* visManager = new MyVisManager;
|
||||
visManager->Initialize();
|
||||
#endif
|
||||
|
||||
// set mandatory user action class
|
||||
runManager->SetUserAction(new MyPrimaryGeneratorAction);
|
||||
|
||||
// Initialize G4 kernel
|
||||
runManager->Initialize();
|
||||
|
||||
// get the pointer to the User Interface manager
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
G4UIsession * session = new G4UIGAG;
|
||||
session->SessionStart();
|
||||
delete session;
|
||||
|
||||
|
||||
// job termination
|
||||
#ifdef G4VIS_USE
|
||||
delete visManager;
|
||||
#endif
|
||||
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
//------HeaderFile-
|
||||
#include "MyDetectorConstruction.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
#include "G4Element.hh"
|
||||
#include "G4ElementTable.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
MyDetectorConstruction::MyDetectorConstruction( )
|
||||
{ ; }
|
||||
MyDetectorConstruction::~MyDetectorConstruction( )
|
||||
{ ; }
|
||||
G4VPhysicalVolume* MyDetectorConstruction::Construct( )
|
||||
{
|
||||
// Elements
|
||||
G4Element* elementN = new G4Element( "Nitrogen", "N", 7. , 14.00674*g/mole );
|
||||
G4Element* elementO = new G4Element( "Oxygen", "O", 8. , 15.9994*g/mole );
|
||||
G4Element* elementH = new G4Element( "Hydrogen", "H", 1. , 1.00794*g/mole );
|
||||
G4Element* elementC = new G4Element( "Carbon", "C", 6. , 12.011*g/mole );
|
||||
|
||||
// Materials from Combination
|
||||
|
||||
G4Material* Air = new G4Material("Air", 1.205*g/cm3, 2, kStateGas, 293.0*kelvin, 1.0*atmosphere );
|
||||
Air->AddElement( elementN, 3 );
|
||||
Air->AddElement( elementO, 1 );
|
||||
G4Material* Methane = new G4Material("Methane", 0.4241*g/cm3, 2, kStateLiquid, 111.7*kelvin, 1.0*atmosphere );
|
||||
Methane->AddElement( elementH, 4 );
|
||||
Methane->AddElement( elementC, 1 );
|
||||
|
||||
// Materials from Scratch
|
||||
|
||||
G4Material* Cu = new G4Material("Cu", 29, 63.546*g/mole, 8.96*g/cm3,kStateSolid, 293.0*kelvin, 1.0*pascal );
|
||||
G4Material* Xeliquid = new G4Material("Xeliquid", 54, 131.29*g/mole, 3.52*g/cm3,kStateLiquid, 165.0*kelvin, 1.0*atmosphere );
|
||||
|
||||
// Visualization attributes
|
||||
|
||||
|
||||
G4VisAttributes * blue= new G4VisAttributes( G4Colour(133,255,255 ));
|
||||
|
||||
G4VisAttributes * darkgray= new G4VisAttributes( G4Colour(75,84,87 ));
|
||||
|
||||
G4VisAttributes * trackred= new G4VisAttributes( G4Colour(234,84,87 ));
|
||||
|
||||
G4VisAttributes * calred= new G4VisAttributes( G4Colour(234,178,87 ));
|
||||
|
||||
// Logical Volumes
|
||||
|
||||
G4Box *solidexpHall= new G4Box("solidexpHall", 5.0*m, 2.0*m, 2.0*m );
|
||||
G4LogicalVolume * logicalexpHall = new G4LogicalVolume(solidexpHall, Air, "logicalexpHall" ,0,0,0);
|
||||
logicalexpHall->SetVisAttributes(blue);
|
||||
G4Box *solidcalblock= new G4Box("solidcalblock", 60.0*cm, 11.0*cm, 11.0*cm );
|
||||
G4LogicalVolume * logicalcalblock = new G4LogicalVolume(solidcalblock, Xeliquid, "logicalcalblock" ,0,0,0);
|
||||
logicalcalblock->SetVisAttributes(darkgray);
|
||||
G4Tubs *solidtracker= new G4Tubs("solidtracker", 0.0*cm, 60.0*cm, 50.0*cm, 0.0*deg, 360.0*deg );
|
||||
G4LogicalVolume * logicaltracker = new G4LogicalVolume(solidtracker, Methane, "logicaltracker" ,0,0,0);
|
||||
logicaltracker->SetVisAttributes(trackred);
|
||||
G4Box *solidcallayer= new G4Box("solidcallayer", 1.0*cm, 10.0*cm, 10.0*cm );
|
||||
G4LogicalVolume * logicalcallayer = new G4LogicalVolume(solidcallayer, Cu, "logicalcallayer" ,0,0,0);
|
||||
logicalcallayer->SetVisAttributes(calred);
|
||||
G4Box *solidcalstack= new G4Box("solidcalstack", 60.0*cm, 11.0*cm, 68.0*cm );
|
||||
G4LogicalVolume * logicalcalstack = new G4LogicalVolume(solidcalstack, Xeliquid, "logicalcalstack" ,0,0,0);
|
||||
logicalcalstack->SetVisAttributes(darkgray);
|
||||
|
||||
// Physical Volumes -------Single Positioned Volume, Repeated Volumes, Replicas---------------------------
|
||||
|
||||
|
||||
// Single Positioned Volumes
|
||||
|
||||
G4VPhysicalVolume * physicalexpHall= new G4PVPlacement(0,G4ThreeVector(0.0*m,0.0*mm,0.0*cm), "physicalexpHall",logicalexpHall,NULL,false, 0);
|
||||
|
||||
G4VPhysicalVolume * physicaltracker= new G4PVPlacement(0,G4ThreeVector(-1.0*m,0.0*mm,0.0*cm), "physicaltracker",logicaltracker,physicalexpHall,false, 0);
|
||||
|
||||
|
||||
// Repeated Volumes
|
||||
|
||||
G4int copycallayerx;
|
||||
copycallayerx=0;
|
||||
for (G4int callayerx=1; callayerx<=20; callayerx++){
|
||||
G4double transcallayerx =-55.0*cm+5.0*cm*(callayerx-1);
|
||||
G4VPhysicalVolume * physicalcallayerx = new G4PVPlacement(0,G4ThreeVector(transcallayerx,0.0*cm,0.0*cm), logicalcallayer,"physicalcallayerx",logicalcalblock,false,copycallayerx++);
|
||||
}
|
||||
|
||||
G4int copystacky;
|
||||
copystacky=0;
|
||||
for (G4int stacky=1; stacky<=6; stacky++){
|
||||
G4double transstacky =-66.0*cm+22.0*cm*(stacky-1);
|
||||
G4VPhysicalVolume * physicalstacky = new G4PVPlacement(0,G4ThreeVector(0.0*cm, transstacky, 0.0*mm), logicalcalblock,"physicalstacky",logicalcalstack,false,copystacky++);
|
||||
}
|
||||
G4int copystackz;
|
||||
copystackz=0;
|
||||
for (G4int stackz=1; stackz<=6; stackz++){
|
||||
G4double transstackz =-68.0*cm+22.0*cm*(stackz-1);
|
||||
G4VPhysicalVolume * physicalstackz = new G4PVPlacement(0,G4ThreeVector(80.0*cm,0.0*cm,transstackz), "physicalstackz", logicalcalstack, physicalexpHall,false,copystackz++);
|
||||
}
|
||||
|
||||
// Replicas
|
||||
|
||||
|
||||
// return the physical World
|
||||
|
||||
|
||||
return physicalexpHall;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyPhysicsList.cc,v 1.1 1998/09/02 12:10:38 masayasu Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
|
||||
#include "MyPhysicsList.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
|
||||
|
||||
MyPhysicsList::MyPhysicsList()
|
||||
{;}
|
||||
|
||||
MyPhysicsList::~MyPhysicsList()
|
||||
{;}
|
||||
|
||||
void MyPhysicsList::ConstructParticle()
|
||||
{
|
||||
// In this method, static member functions should be called
|
||||
// for all particles which you want to use.
|
||||
// This ensures that objects of these particle types will be
|
||||
// created in the program.
|
||||
|
||||
G4Geantino::GeantinoDefinition();
|
||||
}
|
||||
|
||||
void MyPhysicsList::ConstructProcess()
|
||||
{
|
||||
// Define transportation process
|
||||
|
||||
AddTransportation();
|
||||
}
|
||||
|
||||
void MyPhysicsList::SetCuts(G4double cut)
|
||||
{
|
||||
// set a cut value to all particles
|
||||
|
||||
SetCutValueForOthers(cut);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyPrimaryGeneratorAction.cc,v 1.1 1998/09/02 12:10:39 masayasu Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
|
||||
#include "MyPrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
MyPrimaryGeneratorAction::MyPrimaryGeneratorAction()
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
UI->ApplyCommand("/gun/particle geantino");
|
||||
UI->ApplyCommand("/gun/energy 1.0 GeV");
|
||||
UI->ApplyCommand("/gun/position -2.0 0.0 0.0 m");
|
||||
}
|
||||
|
||||
MyPrimaryGeneratorAction::~MyPrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
}
|
||||
|
||||
void MyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
G4int i = anEvent->GetEventID() % 3;
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
UI->ApplyCommand("/gun/direction 1.0 0.0 0.0");
|
||||
break;
|
||||
case 1:
|
||||
UI->ApplyCommand("/gun/direction 1.0 0.1 0.0");
|
||||
break;
|
||||
case 2:
|
||||
UI->ApplyCommand("/gun/direction 1.0 0.0 0.1");
|
||||
break;
|
||||
}
|
||||
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: MyVisManager.cc,v 1.1 1998/09/02 12:10:40 masayasu Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 24th January 1998.
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#ifdef G4VIS_USE
|
||||
|
||||
#include "MyVisManager.hh"
|
||||
|
||||
// Supported drivers...
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
#include "G4FukuiRenderer.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_DAWNFILE
|
||||
#include "G4DAWNFILE.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
#include "G4OpenGLImmediateX.hh"
|
||||
#include "G4OpenGLStoredX.hh"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
#include "G4VRML1.hh"
|
||||
// #include "G4VRML2.hh"
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRMLFILE
|
||||
#include "G4VRML1File.hh"
|
||||
//#include "G4VRML2File.hh"
|
||||
#endif
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
MyVisManager::MyVisManager () {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void MyVisManager::RegisterGraphicsSystems () {
|
||||
|
||||
#ifdef G4VIS_USE_DAWN
|
||||
RegisterGraphicsSystem (new G4FukuiRenderer);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_DAWNFILE
|
||||
RegisterGraphicsSystem (new G4DAWNFILE);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef G4VIS_USE_OPENGLX
|
||||
RegisterGraphicsSystem (new G4OpenGLImmediateX);
|
||||
RegisterGraphicsSystem (new G4OpenGLStoredX);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef G4VIS_USE_VRML
|
||||
RegisterGraphicsSystem (new G4VRML1);
|
||||
// RegisterGraphicsSystem (new G4VRML2);
|
||||
#endif
|
||||
|
||||
#ifdef G4VIS_USE_VRMLFILE
|
||||
RegisterGraphicsSystem (new G4VRML1File);
|
||||
// RegisterGraphicsSystem (new G4VRML2File);
|
||||
#endif
|
||||
|
||||
if (fVerbose > 0) {
|
||||
G4cout <<
|
||||
"\nYou have successfully chosen to use the following graphics systems."
|
||||
<< endl;
|
||||
PrintAvailableGraphicsSystems ();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
README of GGE; GEANT4 Geometry Editor
|
||||
|
||||
1998 Dec. 11
|
||||
1998 Oct. 15
|
||||
1998 Sep. 24
|
||||
1998 Sep. 10
|
||||
1998 Aug. 31
|
||||
Hajime YOSHIDA
|
||||
Naruto University of Education
|
||||
0) Reference
|
||||
GGE is changing day-by-day. It will be adapted to the new Java2 (ex JDK1.2).
|
||||
So, after this release, we will keep the latest versions and related information in our URL;
|
||||
|
||||
http://erpc1.naruto-u.ac.jp/~geant4
|
||||
|
||||
|
||||
1) Introduction
|
||||
|
||||
GGE, GEANT4 Geometry Editor, is a visual tool to "create" a C++ source code which
|
||||
implements a detector geometry after GEANT4's norm.
|
||||
|
||||
It provides users with tables which users fill with their detector parameters,
|
||||
such as its materials, solid shapes, visualisation attributes and placement. After the
|
||||
data in the tables, GGE creates C++ source codes for a detector. The C++ codes is a complete
|
||||
description of a detector, including the definition of atoms, materials, solids, color attributes,
|
||||
logical volumes and physical volumes with rotations and translations.
|
||||
The C++ source code is saved into a file and can be compiled to make a GEANT4 executable.
|
||||
A minimum set of files for the GEANT4 managers to visualise the detector as well as
|
||||
a GNUMakefile are provided for that.
|
||||
|
||||
GAG is helpful to have a visualization of the whole detector.
|
||||
Simple macro files are associated, too, for visualisation.
|
||||
|
||||
GGE consists of two editors (material and volume) which are
|
||||
interrelated upon users' request. Volume editor has two main functions;
|
||||
first is to define logical volumes, while the second is to position or relocate them.
|
||||
GGE provides users a variety of relocation; Single Placement, Multiple Copies
|
||||
with incremental copy numbers (translational arrangement or axially symmetric arrangement),
|
||||
Replicas (in any axis or phi direction) and Parametrized volumes(not yet).
|
||||
|
||||
GGE is based on Java's MVC model so that any change or input to the tables by a user
|
||||
are automatically reflected to the internal data structure of GGE and C++ codes.
|
||||
|
||||
2) Functions of GGE
|
||||
|
||||
2.1) Material Editor
|
||||
a) implemented in this version
|
||||
|
||||
+ append, insert, edit and delete a material
|
||||
+ material from scratch
|
||||
+ material by combination (number or fractional ratios)
|
||||
+ periodic table of atoms automatically popped up to create a material
|
||||
+ default states are provided (material state, temperature, pressure)
|
||||
+ canonical physical units in GEANT4 selectable from a combobox
|
||||
|
||||
+ "in Use" mark for materials used in user's detector
|
||||
+ materials used in the logical volumes are automatically made "in Use".
|
||||
+ user can add any materials "in Use" to have C++ constructors
|
||||
|
||||
+ persistent material file
|
||||
+ load, append or save a material file
|
||||
+ an exemplary persistent material database file "MaterialDB.g4mt" from the PDG
|
||||
|
||||
b)not yet implemented
|
||||
|
||||
- material from materials (coming)
|
||||
- isotope (planned)
|
||||
- protection from duplicated "in Use" instances of the same materials.
|
||||
|
||||
2.2) Volume Editor ; logical and physical volumes
|
||||
|
||||
a)implemented
|
||||
|
||||
+ G4Solids
|
||||
+ CSG solids
|
||||
+ Box, Tube segment, Cone segment, Sphere segment, Torus segment, Parallelepiped,
|
||||
Symmetric Trapezoid, HYPE
|
||||
+ parameters and canonical units
|
||||
+ preview with DAWN (automatically chosen world size)
|
||||
+ BREPs
|
||||
+ Polycone segment, Polyhedra
|
||||
+ any number of nodes and facets with parameters and canonical units
|
||||
+ preview with DAWN (automatically chosen world size)
|
||||
+ G4LogicalVolume
|
||||
+ create, delete a logical volume
|
||||
+ Its name, G4Solid, material, visualization attributes
|
||||
+ selectable G4Solid among the above candidates (CSGs, BREPs)
|
||||
+ type-in materials name (drag and drop is planned)
|
||||
+ Color Chooser to specify visualization attribute (color and its name)
|
||||
+ Used materials link to material DB
|
||||
|
||||
+ G4PVPlacement ; Placement of physical volumes
|
||||
+ Type 1 constructor = rotation of the frame, physical mother volume
|
||||
+ Type 2 constructor = rotation of a body, physical mother volume
|
||||
+ Type 3 constructor = rotation of the frame, logical mother volume
|
||||
+ Type 4 constructor = rotation of a body, logical mother volume
|
||||
|
||||
+ Single Placement of a Volume (SPV)
|
||||
+ mother volume is either
|
||||
null(Master Reference System), logical or physical
|
||||
+ MARS is constructed first in C++ code.
|
||||
+ logical mother is for nested volumes
|
||||
+ translation in the X, Y or Z direction (default is no translation)
|
||||
+ rotation around X, Y or Z axis with an angle (frame or body)
|
||||
|
||||
+ Repeated Placement of a Volume with incremental copy numbers (RPV)
|
||||
+ translational arrangement of any number of copies of a logical volume
|
||||
+ placements in the X, Y or Z direction
|
||||
+ the position of the first copy and incremental step size
|
||||
+ with respect to a logical or physical mother volume
|
||||
+ axially symmetric arrangement
|
||||
+ rotational axis is parallel to X, Y or Z axis
|
||||
+ rotation of the frames or a body
|
||||
+ position of the center of axial symmetry can be set
|
||||
+ radius of axially symmetric arrangement
|
||||
+ starting angle and incremental step angle with number of copies
|
||||
+ logical or physical mother volume
|
||||
|
||||
+ Slicing or Replica
|
||||
+ replication in the X, Y or Z direction (cartesian coordinates)
|
||||
+ replication in rho or phi direction (cylindrical coordinates)
|
||||
+ width (in length or angle) and number of replicas
|
||||
+ offset (in length or angle)
|
||||
+ logical or physical mother volume
|
||||
|
||||
b)to be implemented
|
||||
|
||||
|
||||
|
||||
- paremetrised volumes (coming soon)
|
||||
- linear scaling
|
||||
- linear rotation
|
||||
|
||||
2.3) Generation of C++ code ; "MyDetectorConstruction.cc" (default naming)
|
||||
|
||||
a) implemented
|
||||
+ C++ code is output to a editor widget
|
||||
+ all necessary header files are automatically included
|
||||
+ save the file with a file chooser; "GGEmake/MyDetectorConstruction.cc" (default naming)
|
||||
+ order of creating instances;
|
||||
G4Elements, G4Material, G4VisAttributes, G4Solids, G4LogicalVolume,
|
||||
Single Positioned Volumes, Repeated Volumes, Replicas
|
||||
x order of instantiation inside each section is decided by GGE user,
|
||||
except MARS
|
||||
+ return the instance name of the MARS
|
||||
|
||||
b)not implemented
|
||||
- automatic correct ordering of constructors of volumes
|
||||
|
||||
|
||||
2.4) GGEmake; a directory containing the GEANT4 codes to compile and visualize the detector
|
||||
a) implemented
|
||||
+ GNUmakefile
|
||||
+ myDetector.cc ; main() with GAG session and visualization manager
|
||||
+ src/ directory contains
|
||||
+ MyDetectorConstruction.cc
|
||||
+ MyPhysicsList.cc
|
||||
+ MyPrimaryGeneratorAction.cc
|
||||
+ MyVisManager.cc
|
||||
+ include/ directory
|
||||
|
||||
2.5) compile and visualize with Momo and GAG
|
||||
|
||||
a) implemented
|
||||
|
||||
+ canonical scheme of GEANT4 to compile
|
||||
+ make G4TARGET=myDetector
|
||||
+ the binary is created as $G4INSTALL/bin/$G4SYSTEM/myDetector
|
||||
|
||||
+ Momo (GAG, Compile and GGE buttons)
|
||||
+ rapid cycling of GGE and GAG to edit and view the geometry
|
||||
+ a macro file for visualization (OGLIX default) "DrawDAWN.g4m", etc..
|
||||
|
||||
b) not implemented
|
||||
- automatic "calibration" of the detector with geantino
|
||||
|
||||
2.6) exemplary persistent detector files with *.g4dt suffix
|
||||
+ rotateallsolids.g4dt; all CSG except HYPE and two BREPs are placed in an axially symmetric manner
|
||||
+ translateallsolids.g4dt
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
3) Installation
|
||||
|
||||
The minimum set to run GGE and to create the C++ source code
|
||||
1) GGE.jar file
|
||||
2) Java interpreter ; java
|
||||
Additional set to compile and get the executable
|
||||
3) GEANT4 toolkit with compiled libraries
|
||||
4) GGEmake directory
|
||||
Additional set to visualise and use GUI
|
||||
4) DAWN (plus Ghostview) or OGLIX or VRML
|
||||
5) GAG (Java version) or GAG.jar file
|
||||
Additional too to make life easy
|
||||
6) Momo to use all the above ingredients; Momo.jar file
|
||||
(without Momo, you have to invoke GGE, compile and GAG respectively in windows.)
|
||||
|
||||
3.1) Java and Swing
|
||||
We have tested GGE on Unix-en (Linux and Solaris) and Windows (95/NT).
|
||||
|
||||
3.1.1) Unix:
|
||||
|
||||
+ Linux: jdk1.1.3 or later(i.,e., jdk-1.1.6 or jdk-1.1.7) + Swing-1.0.2
|
||||
|
||||
1) GGE co-works with Swing-1.0.2 and not with 1.0.1 (or maybe not
|
||||
with 1.0.3).
|
||||
2) we are testing the current GGE with JRE1.2-beta04. The present source can be
|
||||
compiled but doesn't execute correctly. In any case
|
||||
Sun has announced on 17 August that JDK1.2 will be delayed
|
||||
till November!!
|
||||
+ Solaris: jdk1.1.6 + swing-1.0.2
|
||||
|
||||
|
||||
We assume that you have
|
||||
1)$JAVAHOME/jdk1.1.6/bin/java (Java interpreter) to which paths are set
|
||||
2)Swing-1.0.2 which is defreezed and placed in $JAVAHOME/swing/swingall.jar
|
||||
|
||||
3.1.2) Windows:
|
||||
|
||||
We use JBuilder2 with Swing-1.0.2. Note that you have to
|
||||
eliminate all other libraries other than swing-1.0.2, after having
|
||||
copied it into JBuilder2.
|
||||
|
||||
We are trying JDK1.2beta4 + JRE1.2 with JBuilder2.
|
||||
|
||||
NOTE! At present you can only create C++ code under the Windows.
|
||||
|
||||
3.2) GGE and related files
|
||||
|
||||
The latest product of GGE is that of 11th December 1998.
|
||||
All *.java, *.class and GGE.jar files are placed in
|
||||
$G4INSTALL/environments/Momo/java/Momo/GGE
|
||||
|
||||
Only "GGE.jar" file is necessary to run GGE. The following files are included for
|
||||
completeness.
|
||||
|
||||
GGE/*.java GGE source files
|
||||
GGE/*.class GGE byte code files
|
||||
GGE/GGE.jar jar archive file to which CLASSPATH must be set
|
||||
GGE/*.g4mt material database after PDG data
|
||||
GGE/*.g4dt exampleN0x detector file
|
||||
|
||||
A set of C++ source codes and GNUmakefiles necessary to compile with GEANT4 are placed in
|
||||
$G4INSTALL/environments/Momo/GGEmake.
|
||||
|
||||
Only geantino is instantiated in the initialization of GEANT4, so that it is quite
|
||||
rapid to have a visualization of the geometry. You can choose DAWN, OpenGL or VRML system.
|
||||
|
||||
GGEmake/myDetector.cc main() program
|
||||
/GNUmakefile
|
||||
/src
|
||||
/src/MyDetectorConstruction.cc C++ generated by GGE
|
||||
/src/MyPrimaryGeneratorAction.cc geantino gun
|
||||
/src/MyVisManager.cc DAWN, DAWNFILE, OGLIX, OGLSX, VRML1, VRML1FILE
|
||||
/src/MyPhysicsList.cc geantino definition
|
||||
/include/*.hh
|
||||
/DrawOGLIX.g4m macro file to visualize with OGLIX
|
||||
/DrawDAWN.g4m macro file for DAWN
|
||||
/DrawDAWNFILE.g4m macro file for DAWN with Postscript file
|
||||
|
||||
3.3) install, setenv and run
|
||||
|
||||
%set path=($path $JAVAHOME/jdk1.1.6/bin) <=== add the path to java and javac
|
||||
%setenv CLASSPATH .:$JAVAHOME/swing/swingall.jar:$G4INSTALL/environments/Momo/java/Momo/GGE/GGE.jar
|
||||
|
||||
|
||||
In any directory, you can invoke GGE.
|
||||
|
||||
%java gge
|
||||
Then, the material window appears, followed by the volume window.
|
||||
|
||||
3.4) DAWN, Tcl/Tk and Postscript for the preview of CSG or BREP solids
|
||||
|
||||
|
||||
If you want to preview G4Solids, you have to install
|
||||
DAWN, Fukui renderer as well as Tcl/Tk wish (Tcl/Tk 8.0) for its GUI.
|
||||
DAWN uses also Postscript to draw *.prim files.
|
||||
If you don't use GGE's preview button, these are not necessary.
|
||||
|
||||
For the visualization of the whole detector, DAWN or Mesa (for OGLIX)
|
||||
are necessary.
|
||||
|
||||
3.5) GEANT4 toolkit and its environments
|
||||
The visualization manager instantiates DAWN, DAWNFILE, OPENGLIX,
|
||||
OPENGLSX, VRML, VRMLFILE. So, you have to setenv accordingly.
|
||||
|
||||
4) A First Lesson; how to use GGE.
|
||||
|
||||
Here is a walk-through of how to use GGE.
|
||||
|
||||
4.1) Visualize the prefabricated detector sample
|
||||
1) In a xterm, type %java gge
|
||||
2) In the "Volume window", select "Load a Volume file" menu
|
||||
and double click on "rotateallsolids.g4dt"
|
||||
3) Click "Makesource" and select "Make C++ code". Have a look of the generated C++ code.
|
||||
4) Save the C++ code (overwrite the existing one)
|
||||
in .../GGEmake/src/MyDetectorConstruction.cc" using the file chooser.
|
||||
5) In another xterm, go to the directory GGEmake/ and type
|
||||
%make G4TARGET=myDetector
|
||||
|
||||
Watch if there is any compilation error. At present,
|
||||
GGE is made so that it generates correct C++ codes,
|
||||
if a user uses GGE correctly.
|
||||
|
||||
|
||||
6) Check that you have "myDetector" executable, in $(G4INSTALL)/bin/$(G4SYSTEM)
|
||||
7) In another xterm, type
|
||||
%java gag
|
||||
|
||||
and with the "Run GEANT4" button, choose and run "myDetector".
|
||||
8) Use /control/execute command and double click on "DrawOGLIX.g4m".
|
||||
To have a better view, use vis commands (camera/viewpoint, zoom etc).
|
||||
You can select DrawDAWNFILE to draw and have a PS hardcopy.
|
||||
|
||||
4.2) Modify the prefabricated detector
|
||||
Now let's change the detector configuration. Go to the "Volume" window
|
||||
and change any part of it, including material.
|
||||
|
||||
4.2.1) Changing materials
|
||||
|
||||
1) First, you have to "Clear Material" in the Material editor.
|
||||
2) Then, select "Load material" and double click on "MaterialDB.g4mt".
|
||||
Now you have a list of materials.
|
||||
3) Then, in the "Logical Volume" panel, double click the box you want to change
|
||||
and type in the name of the material in the material editor.
|
||||
4) Change as many materials as you like and push "Used Material" button.
|
||||
You see that materials you have typed in are marked "Used" in red.
|
||||
If not, you might have mistyped the name of a material.
|
||||
5) If you want to use additional materials, select "Use" in the material
|
||||
editor (the leftmost column).
|
||||
6) Push "Makesource" and see your change has been realized in the C++ code.
|
||||
|
||||
NOTE!! Be careful that there are no duplicated "Used" materials, when
|
||||
you load the material DB without "Clear Material".
|
||||
|
||||
4.2.2) Modifying the size parameters of solids
|
||||
|
||||
To change the sizes of G4 solids
|
||||
1) click a "solid" box of the logical volume of your choice.
|
||||
2) You have a pop-up window to edit the parameters. Change a parameter
|
||||
or its unit, as you like.
|
||||
3) Push "Makesource" and see if your changes have been correctly applied
|
||||
to C++ code.
|
||||
4) In case of BREP solids, the pop-up window has variable number of columns
|
||||
to accept any number of nodes.
|
||||
5) For complicated solids like BREPs, preview may be useful. Click "View"
|
||||
button and you have a view with the DAWN renderer. Its g4.prim file
|
||||
is also shown in an edit-able widget.
|
||||
|
||||
4.2.3) Changing the type of solid of an existing logical volume
|
||||
You may want to replace the current G4Solid with another one. In the
|
||||
present GGE you can't do so directly. You have to "Create" a new logical
|
||||
volume with the type of solid you want and then delete the unnecessary volume.
|
||||
|
||||
1) Choose your new solid with "Select Solid" combo-box.
|
||||
2) Push "Create" button and you have a pop-up window to input parameters.
|
||||
3) Type in numbers and select their units.
|
||||
4) Preview if you like and then push "OK".
|
||||
5) Check the C++ code.
|
||||
|
||||
4.2.4) Changing visualization attributes (Color).
|
||||
1) You have to "Create" a new VisAttributes
|
||||
2) Upon the "Create" button, you have a Color Chooser.
|
||||
3) Select RGB (not HSV). Set your color with slide-bars.
|
||||
4) Give it a name, and push "OK". Then you have a color circle and name in the
|
||||
VisAttrib panel.
|
||||
5) Edit the VisAtb box in the LogicalVolume panel.
|
||||
6) See the C++ code.
|
||||
|
||||
4.2.5) Changing Repeated Volumes
|
||||
|
||||
|
||||
a) "edit" the physical volumes
|
||||
|
||||
"translateallsolids.g4dt" contains all except HYPE CSG and two BREP volumes which are
|
||||
positioned in "Pepeated Placement Volumes" in threee directions.
|
||||
Change the parameter of repetition such as the number or width, or you can
|
||||
add another "repeated volumes" in another direction.
|
||||
|
||||
|
||||
|
||||
b) making C++ code "MyDetectorConstruction.cc" and compile.
|
||||
|
||||
Finally, back to the step 3 and recompile.
|
||||
If you have any compiler errors, in most cases, it is due to unfilled table, misspelled name
|
||||
etc.. GGE is not yet wise enough to correct such simple mistakes.
|
||||
|
||||
|
||||
|
||||
|
||||
Opening GGE, compile, GAG simultaneously, you can
|
||||
test and improve the geometry, just like creating
|
||||
HTML or TeX documents.
|
||||
|
||||
|
||||
4) Naming conventions in GGE
|
||||
|
||||
Knowledge of GGE's naming convention is helpful to read the generated C++ code as
|
||||
well as using GGE correctly.
|
||||
|
||||
4-1) Elements and materials
|
||||
|
||||
a) Elements are named "elementXXX", where XXX stands for the
|
||||
element's symbol in the periodic table.
|
||||
b) materials are named just as you have typed in the second column
|
||||
of the material window.
|
||||
|
||||
4-2) solids and logical volumes
|
||||
The "Name" typed in the first (leftmost) column of the "Logical Volume"
|
||||
is used to name the corresponding solid. If, for example, the name "world" is given
|
||||
to a logical volume of a Box, the G4Box has an instance "solidworld".
|
||||
4-3) logical and physical volumes
|
||||
The instance of a physical volume defined by "pName" has a name prefixed
|
||||
with "physical", i.,e., instance's name is "physical" + pName ( the plus sign means
|
||||
string concatenation). "logical" is added to the instance of a logical
|
||||
volume.
|
||||
In case of SPV (single placement of a volume), the columns "pName" (instance of
|
||||
physical volume) and "pLogical" may have the same strings.
|
||||
|
||||
In case of RPV (repeated placement of a volume ), "pName" must be different from
|
||||
"pLogical" whose copies are repeatedly placed.
|
||||
|
||||
4-4) All variables are named after their proper instances.
|
||||
See for example, the control variable used in the for loop in the
|
||||
RPV. Another examples are seen in the arrays to define BREP geometry.
|
||||
|
||||
5) Default values and combo-boxes
|
||||
|
||||
|
||||
5.1) Default optional values of materials
|
||||
GGE provides default values in a pre-filled columns or with the
|
||||
combo-boxes. "Use", "State" and "Unit" columns are equipped with
|
||||
combo-boxes. Temperature and pressure column are pre-filled with
|
||||
273.15 * kelvin and 1 * atmosphere.
|
||||
5.2) Default values in volumes
|
||||
"Mother Type" is either NULL (mother of all), logical (type 2, 4 constructors)
|
||||
or physical (type 2 or 4 constructors) in G4PVPlacement.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
How to Install and Use GAG and Momo
|
||||
|
||||
1998 December 4 revised for release
|
||||
1998 July 6 written for beta
|
||||
|
||||
Hajime YOSHIDA
|
||||
|
||||
1) Necessary Toolkits for GAG, GGE and Momo
|
||||
|
||||
1.1) Tcl/Tk and JAVA
|
||||
|
||||
GAG, GGE and Momo are implemented, using the popular "Open Source
|
||||
Programs", or free software; Tcl/tk 8.0a or later and
|
||||
JDK 1.1.3 or later and JAVA Foundation Class Swing-1.0.2.
|
||||
Both are supported and freely distributed by Sun Microsystems.
|
||||
|
||||
As of July 6, JAVA GAG is tested on Linux with JDK-1.1.3 + Swing-1.0.2 and on
|
||||
Solaris with JDK-1.1.6 + Swing-1.0.2. Tcl/Tk GAG is tested on
|
||||
Linux and Solaris with Tcl8.0p2/Tk8.0p2.
|
||||
|
||||
As of December 4, Java GAG is running on Linux (RedHat 5.2) with JDK-1.1.7 +
|
||||
Swing-1.0.2. So, replace JDK-1.1.3 below with the latest JDK-1.1.7.
|
||||
JDK1.2 version is not yet delivered.
|
||||
|
||||
1.2) Installation
|
||||
If the required toolkits as well as GAG, GGE and Momo have been installed
|
||||
in your computer system by your system administrator or by your collegues,
|
||||
you have only to set PATH and environment variables which
|
||||
will be explained later. Such lucky few can skip the next section of
|
||||
installation.
|
||||
|
||||
1.2.1) Installation of Tcl/tk
|
||||
|
||||
If you are using free Unix like Linux, the latest version (8.0a or
|
||||
later) of Tcl/tk is already included. If it is installed by root to
|
||||
the default destination, /usr/local/bin and /uar/local/lib,
|
||||
and if you can locate wish (version 8.0) in your path, everuthing is
|
||||
good.
|
||||
|
||||
To verify this, do as follows;
|
||||
|
||||
[yoshidah@ermac1 G++-Linux]$ wish
|
||||
% info tclversion
|
||||
8.0
|
||||
% exit
|
||||
[yoshidah@ermac1 G++-Linux]$
|
||||
|
||||
|
||||
Tk command "wish" pops up a small white window. You delete it with "exit".
|
||||
|
||||
|
||||
If not, you can install it under your home directory without root's permission.
|
||||
You can get the latest version of Tcl/tk from many mirror sites world-wide.
|
||||
It is easy to compile and install them.
|
||||
Be careful that tcl8.0.tar.gz and tk8.0.tar.gz files are placed in the same
|
||||
directory.
|
||||
|
||||
First attack the Tcl package. You do " ./configure" then "make"
|
||||
and finally "make install".
|
||||
Then, you repeat the same procedure for Tk package.
|
||||
|
||||
If Tcl/Tk is installed in an arbitrary destination, you have to set
|
||||
path and environmental variables.
|
||||
|
||||
: Verify that {\tt wish} is in in your PATH and its version is correct.
|
||||
: setenv TCL_LIBRARY to the directory where "libtcl.a" is placed
|
||||
: setenv TK_LIBRARY to the directory where "libtk.a" is placed
|
||||
|
||||
1.2.2 Installation of JAVA
|
||||
|
||||
GAG, GGE and Momo use JDK 1.1.3 or later and Java Foundation Class,
|
||||
or Swing-1.0.2 (early access version).
|
||||
Note that older or newer versions of Swing are imcompatible with
|
||||
the current Java GAG.
|
||||
|
||||
GAG, GGE anf Momo is going to be updated to JDK1.2 which has not been
|
||||
released yet. JAVA Foundation Class will follow important
|
||||
modifications in the JDK1.2. Thus present GUI may not work
|
||||
correctly with other than Swing-1.0.2 on which it is implemented.
|
||||
(Swing-1.0.2 still contains "preview" classes!! -July 1998-)
|
||||
|
||||
Swing is available from JAVA Developer Connection. You are requested to
|
||||
register yourself as a JDC member. Please read carefully licence agreement
|
||||
to use it on your computer.
|
||||
For general information on JAVA, visit JavaSoft Home Page.
|
||||
|
||||
You may put Swing package in any directory, but you have to make the
|
||||
environment variable CLASSPATH include "swingall.jar".
|
||||
|
||||
%setenv CLASSPATH .:/home/foo/swing1.0.2/swingall.jar:
|
||||
|
||||
You are recommended to check sample programs associated with it.
|
||||
|
||||
% cd ~foo/swing1.0.2/examples/SwingSet/classes
|
||||
% java SwingSet
|
||||
|
||||
Wait a moment while loading many classes. If it works well, though
|
||||
very slowly, you can use GAG of JAVA version.
|
||||
|
||||
|
||||
JAVA GAG uses TextWidget, a free software which is includes as is in the
|
||||
current GAG distribution. Please read and respect the copyleft written
|
||||
there.
|
||||
|
||||
|
||||
2) Install and Run GAG, GGE and Momo
|
||||
|
||||
After unpacking GEANT4 package you have the Momo files under the
|
||||
"geant4alpha/environments/Momo/" directory.
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!!!!! Important!!!!!
|
||||
Keep the following directory hierarchy. Tcl/tk
|
||||
products assume that all relevant files are found under $MOMOPATH, while
|
||||
JAVA products assume that all relevant classes are found in $CLASSPATH.
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
2.1) JAVA GUIs
|
||||
2.1.1 Files
|
||||
|
||||
../Momo/java/Momo/ necessary hierarchy for JAVA's name space.
|
||||
/Momo/GAG/ Java source codes; *.java
|
||||
/Momo/GGE/ Java source codes; *.java (to come)
|
||||
/Momo/GAG/GAG.jar JAVA binary archive
|
||||
|
||||
2.1.2) CLASSPATH
|
||||
|
||||
JAVA's CLASSPATH must contain the following;
|
||||
|
||||
JDK's class file : The path to "classes.zip" is set by default.
|
||||
Otherwise let's assume /home/foo/jdk1.1.6/lib/classes.zip.
|
||||
|
||||
Swing-1.0: As was explained above, "swingall.jar" is the only file necessary
|
||||
for Swing-1.0.2. Let us assume that you have Swing-1.0.2 in your
|
||||
$HOME/swing1.0.2/swingall.jar.
|
||||
|
||||
GAG.jar: In the GEANT4 distribution, it is placed in
|
||||
geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar. So, let's
|
||||
assume that it is at
|
||||
$HOME/geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar.
|
||||
|
||||
Assuming you have everything in your $HOME, CLASSPATH example for Unix
|
||||
is like;
|
||||
|
||||
%setenv CLASSPATH .:$HOME/swing1.0.2/swingall.jar:\
|
||||
$HOME/geant4alpha/environments/Momo/java/Momo/GAG/GAG.jar:
|
||||
$HOME/jdk1.1.6/lib/classes.zip
|
||||
|
||||
2.1.3) Run JAVA GAG
|
||||
|
||||
To run JAVA GAG without Momo, type the following line at any directory.
|
||||
|
||||
% java gag
|
||||
|
||||
Then, choose a GEANT4 executable file.
|
||||
|
||||
2.2) Tcl/Tk GUIs
|
||||
|
||||
2.2.1) Files
|
||||
|
||||
../Momo/tcltk/ This is the MOMOPATH.
|
||||
/tcltk/tMomo.tcl Momo script file
|
||||
/tcltk/tmomo* Momo executable file
|
||||
/tcltk/GAG/ GAG procedures script files
|
||||
/tcltk/GAG/GAG.tcl GAG script file
|
||||
/tcltk/XXXXX Other directories containing procedures used
|
||||
in GAG.tcl
|
||||
|
||||
2.2.2) MOMOPATH
|
||||
|
||||
You have to setenv MOMOPATH which specifies the position of Momo/tcltk/.
|
||||
For example, like;
|
||||
|
||||
%setenv MOMOPATH $HOME/geant4alpha/environments/Momo/tcltk
|
||||
|
||||
2.2.3) Run Tcl/Tk Momo and GAG
|
||||
|
||||
Then you can run Momo
|
||||
|
||||
%$MOMOPATH/tmomo
|
||||
|
||||
Or without using Momo, GAG can be directly invoked by
|
||||
|
||||
%wish $MOMOPATH/GAG/GAG.tcl
|
||||
|
||||
Good luck!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* @(#)ExampleFileFilter.java 1.4 98/04/14
|
||||
*
|
||||
* Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of Sun
|
||||
* Microsystems, Inc. ("Confidential Information"). You shall not
|
||||
* disclose such Confidential Information and shall use it only in
|
||||
* accordance with the terms of the license agreement you entered into
|
||||
* with Sun.
|
||||
*
|
||||
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
|
||||
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
|
||||
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
|
||||
* THIS SOFTWARE OR ITS DERIVATIVES.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import com.sun.java.swing.*;
|
||||
import com.sun.java.swing.preview.filechooser.*;
|
||||
import com.sun.java.swing.preview.*;
|
||||
|
||||
/**
|
||||
* A convenience implementation of FileFilter that filters out
|
||||
* all files except for those type extensions that it knows about.
|
||||
*
|
||||
* Extensions are of the type ".foo", which is typically found on
|
||||
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
|
||||
*
|
||||
* Example - create a new filter that filerts out all files
|
||||
* but gif and jpg image files:
|
||||
*
|
||||
* JFileChooser chooser = new JFileChooser();
|
||||
* ExampleFileFilter filter = new ExampleFileFilter(
|
||||
* new String{"gif", "jpg"}, "JPEG & GIF Images")
|
||||
* chooser.addChoosableFileFilter(filter);
|
||||
* chooser.showOpenDialog(this);
|
||||
*
|
||||
* @version 1.4 04/14/98
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class ExampleFileFilter extends FileFilter {
|
||||
|
||||
private static String TYPE_UNKNOWN = "Type Unknown";
|
||||
private static String HIDDEN_FILE = "Hidden File";
|
||||
|
||||
private Hashtable filters = null;
|
||||
private String description = null;
|
||||
private String fullDescription = null;
|
||||
private boolean useExtensionsInDescription = true;
|
||||
|
||||
/**
|
||||
* Creates a file filter. If no filters are added, then all
|
||||
* files are accepted.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter() {
|
||||
this((String) null, (String) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter that accepts files with the given extension.
|
||||
* Example: new ExampleFileFilter("jpg");
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String extension) {
|
||||
this(extension,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter that accepts the given file type.
|
||||
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
|
||||
*
|
||||
* Note that the "." before the extension is not needed. If
|
||||
* provided, it will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String extension, String description) {
|
||||
this(new String[] {extension}, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter from the given string array.
|
||||
* Example: new ExampleFileFilter(String {"gif", "jpg"});
|
||||
*
|
||||
* Note that the "." before the extension is not needed adn
|
||||
* will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String[] filters) {
|
||||
this(filters, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter from the given string array and description.
|
||||
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
|
||||
*
|
||||
* Note that the "." before the extension is not needed and will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String[] filters, String description) {
|
||||
this.filters = new Hashtable(filters.length);
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
// add filters one by one
|
||||
addExtension(filters[i]);
|
||||
}
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this file should be shown in the directory pane,
|
||||
* false if it shouldn't.
|
||||
*
|
||||
* Files that begin with "." are ignored.
|
||||
*
|
||||
* @see #getExtension
|
||||
* @see FileFilter#accepts
|
||||
*/
|
||||
public boolean accept(File f) {
|
||||
if(f != null) {
|
||||
if(f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
String extension = getExtension(f);
|
||||
if(extension != null && filters.get(getExtension(f)) != null) {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the extension portion of the file's name .
|
||||
*
|
||||
* @see #getExtension
|
||||
* @see FileFilter#accept
|
||||
*/
|
||||
public String getExtension(File f) {
|
||||
if(f != null) {
|
||||
String filename = f.getName();
|
||||
int i = filename.lastIndexOf('.');
|
||||
if(i>0 && i<filename.length()-1) {
|
||||
return filename.substring(i+1).toLowerCase();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filetype "dot" extension to filter against.
|
||||
*
|
||||
* For example: the following code will create a filter that filters
|
||||
* out all files except those that end in ".jpg" and ".tif":
|
||||
*
|
||||
* ExampleFileFilter filter = new ExampleFileFilter();
|
||||
* filter.addExtension("jpg");
|
||||
* filter.addExtension("tif");
|
||||
*
|
||||
* Note that the "." before the extension is not needed and will be ignored.
|
||||
*/
|
||||
public void addExtension(String extension) {
|
||||
if(filters == null) {
|
||||
filters = new Hashtable(5);
|
||||
}
|
||||
filters.put(extension.toLowerCase(), this);
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the human readable description of this filter. For
|
||||
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
|
||||
*
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
* @see isExtensionListInDescription
|
||||
* @see FileFilter#getDescription
|
||||
*/
|
||||
public String getDescription() {
|
||||
if(fullDescription == null) {
|
||||
if(description == null || isExtensionListInDescription()) {
|
||||
if(description != null) {
|
||||
fullDescription = description;
|
||||
}
|
||||
fullDescription += " (";
|
||||
// build the description from the extension list
|
||||
Enumeration extensions = filters.keys();
|
||||
if(extensions != null) {
|
||||
fullDescription += "." + (String) extensions.nextElement();
|
||||
while (extensions.hasMoreElements()) {
|
||||
fullDescription += ", " + (String) extensions.nextElement();
|
||||
}
|
||||
}
|
||||
fullDescription += ")";
|
||||
} else {
|
||||
fullDescription = description;
|
||||
}
|
||||
}
|
||||
return fullDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the human readable description of this filter. For
|
||||
* example: filter.setDescription("Gif and JPG Images");
|
||||
*
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
* @see isExtensionListInDescription
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the extension list (.jpg, .gif, etc) should
|
||||
* show up in the human readable description.
|
||||
*
|
||||
* Only relevent if a description was provided in the constructor
|
||||
* or using setDescription();
|
||||
*
|
||||
* @see getDescription
|
||||
* @see setDescription
|
||||
* @see isExtensionListInDescription
|
||||
*/
|
||||
public void setExtensionListInDescription(boolean b) {
|
||||
useExtensionsInDescription = b;
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the extension list (.jpg, .gif, etc) should
|
||||
* show up in the human readable description.
|
||||
*
|
||||
* Only relevent if a description was provided in the constructor
|
||||
* or using setDescription();
|
||||
*
|
||||
* @see getDescription
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
*/
|
||||
public boolean isExtensionListInDescription() {
|
||||
return useExtensionsInDescription;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* @(#)ExampleFileFilter.java 1.4 98/04/14
|
||||
*
|
||||
* Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* This software is the confidential and proprietary information of Sun
|
||||
* Microsystems, Inc. ("Confidential Information"). You shall not
|
||||
* disclose such Confidential Information and shall use it only in
|
||||
* accordance with the terms of the license agreement you entered into
|
||||
* with Sun.
|
||||
*
|
||||
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
|
||||
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
|
||||
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
|
||||
* THIS SOFTWARE OR ITS DERIVATIVES.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import com.sun.java.swing.*;
|
||||
import com.sun.java.swing.preview.filechooser.*;
|
||||
import com.sun.java.swing.preview.*;
|
||||
|
||||
/**
|
||||
* A convenience implementation of FileFilter that filters out
|
||||
* all files except for those type extensions that it knows about.
|
||||
*
|
||||
* Extensions are of the type ".foo", which is typically found on
|
||||
* Windows and Unix boxes, but not on Macinthosh. Case is ignored.
|
||||
*
|
||||
* Example - create a new filter that filerts out all files
|
||||
* but gif and jpg image files:
|
||||
*
|
||||
* JFileChooser chooser = new JFileChooser();
|
||||
* ExampleFileFilter filter = new ExampleFileFilter(
|
||||
* new String{"gif", "jpg"}, "JPEG & GIF Images")
|
||||
* chooser.addChoosableFileFilter(filter);
|
||||
* chooser.showOpenDialog(this);
|
||||
*
|
||||
* @version 1.4 04/14/98
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class ExampleFileFilter extends FileFilter {
|
||||
|
||||
private static String TYPE_UNKNOWN = "Type Unknown";
|
||||
private static String HIDDEN_FILE = "Hidden File";
|
||||
|
||||
private Hashtable filters = null;
|
||||
private String description = null;
|
||||
private String fullDescription = null;
|
||||
private boolean useExtensionsInDescription = true;
|
||||
|
||||
/**
|
||||
* Creates a file filter. If no filters are added, then all
|
||||
* files are accepted.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter() {
|
||||
this((String) null, (String) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter that accepts files with the given extension.
|
||||
* Example: new ExampleFileFilter("jpg");
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String extension) {
|
||||
this(extension,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter that accepts the given file type.
|
||||
* Example: new ExampleFileFilter("jpg", "JPEG Image Images");
|
||||
*
|
||||
* Note that the "." before the extension is not needed. If
|
||||
* provided, it will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String extension, String description) {
|
||||
this(new String[] {extension}, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter from the given string array.
|
||||
* Example: new ExampleFileFilter(String {"gif", "jpg"});
|
||||
*
|
||||
* Note that the "." before the extension is not needed adn
|
||||
* will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String[] filters) {
|
||||
this(filters, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file filter from the given string array and description.
|
||||
* Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
|
||||
*
|
||||
* Note that the "." before the extension is not needed and will be ignored.
|
||||
*
|
||||
* @see #addExtension
|
||||
*/
|
||||
public ExampleFileFilter(String[] filters, String description) {
|
||||
this.filters = new Hashtable(filters.length);
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
// add filters one by one
|
||||
addExtension(filters[i]);
|
||||
}
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this file should be shown in the directory pane,
|
||||
* false if it shouldn't.
|
||||
*
|
||||
* Files that begin with "." are ignored.
|
||||
*
|
||||
* @see #getExtension
|
||||
* @see FileFilter#accepts
|
||||
*/
|
||||
public boolean accept(File f) {
|
||||
if(f != null) {
|
||||
if(f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
String extension = getExtension(f);
|
||||
if(extension != null && filters.get(getExtension(f)) != null) {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the extension portion of the file's name .
|
||||
*
|
||||
* @see #getExtension
|
||||
* @see FileFilter#accept
|
||||
*/
|
||||
public String getExtension(File f) {
|
||||
if(f != null) {
|
||||
String filename = f.getName();
|
||||
int i = filename.lastIndexOf('.');
|
||||
if(i>0 && i<filename.length()-1) {
|
||||
return filename.substring(i+1).toLowerCase();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a filetype "dot" extension to filter against.
|
||||
*
|
||||
* For example: the following code will create a filter that filters
|
||||
* out all files except those that end in ".jpg" and ".tif":
|
||||
*
|
||||
* ExampleFileFilter filter = new ExampleFileFilter();
|
||||
* filter.addExtension("jpg");
|
||||
* filter.addExtension("tif");
|
||||
*
|
||||
* Note that the "." before the extension is not needed and will be ignored.
|
||||
*/
|
||||
public void addExtension(String extension) {
|
||||
if(filters == null) {
|
||||
filters = new Hashtable(5);
|
||||
}
|
||||
filters.put(extension.toLowerCase(), this);
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the human readable description of this filter. For
|
||||
* example: "JPEG and GIF Image Files (*.jpg, *.gif)"
|
||||
*
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
* @see isExtensionListInDescription
|
||||
* @see FileFilter#getDescription
|
||||
*/
|
||||
public String getDescription() {
|
||||
if(fullDescription == null) {
|
||||
if(description == null || isExtensionListInDescription()) {
|
||||
if(description != null) {
|
||||
fullDescription = description;
|
||||
}
|
||||
fullDescription += " (";
|
||||
// build the description from the extension list
|
||||
Enumeration extensions = filters.keys();
|
||||
if(extensions != null) {
|
||||
fullDescription += "." + (String) extensions.nextElement();
|
||||
while (extensions.hasMoreElements()) {
|
||||
fullDescription += ", " + (String) extensions.nextElement();
|
||||
}
|
||||
}
|
||||
fullDescription += ")";
|
||||
} else {
|
||||
fullDescription = description;
|
||||
}
|
||||
}
|
||||
return fullDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the human readable description of this filter. For
|
||||
* example: filter.setDescription("Gif and JPG Images");
|
||||
*
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
* @see isExtensionListInDescription
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the extension list (.jpg, .gif, etc) should
|
||||
* show up in the human readable description.
|
||||
*
|
||||
* Only relevent if a description was provided in the constructor
|
||||
* or using setDescription();
|
||||
*
|
||||
* @see getDescription
|
||||
* @see setDescription
|
||||
* @see isExtensionListInDescription
|
||||
*/
|
||||
public void setExtensionListInDescription(boolean b) {
|
||||
useExtensionsInDescription = b;
|
||||
fullDescription = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the extension list (.jpg, .gif, etc) should
|
||||
* show up in the human readable description.
|
||||
*
|
||||
* Only relevent if a description was provided in the constructor
|
||||
* or using setDescription();
|
||||
*
|
||||
* @see getDescription
|
||||
* @see setDescription
|
||||
* @see setExtensionListInDescription
|
||||
*/
|
||||
public boolean isExtensionListInDescription() {
|
||||
return useExtensionsInDescription;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,618 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// H Yoshida 1998 June , for Beta release
|
||||
// Now, use swing 1.0.2 JFileChooser to select by file extensions
|
||||
// Now displayed labels change color to notify busy state.
|
||||
// July 1, add @@Ask to accept users key-in with showInputDialog (imcomplete)
|
||||
// July 5 now use more readable fonts.
|
||||
|
||||
package GAG;
|
||||
|
||||
import TextEdit.TextEdit;
|
||||
// Swing 1.0.2 ExampleFileFilter.class is in the same dir as gag.class
|
||||
import ExampleFileFilter;
|
||||
|
||||
import com.sun.java.swing.preview.*;
|
||||
import com.sun.java.swing.preview.filechooser.*;
|
||||
// now use Swing-1.0.2 FileChooser, yet in the preview stage !!
|
||||
|
||||
import java.awt.*;
|
||||
//import java.awt.Cursor.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import com.sun.java.swing.*;
|
||||
import com.sun.java.swing.event.*;
|
||||
import com.sun.java.swing.tree.*;
|
||||
|
||||
public class GAG extends JFrame implements TreeSelectionListener, ActionListener {
|
||||
static final String gagVer = "J1.0a";
|
||||
private String g4Ver, command;
|
||||
private GAGpipe geant4;
|
||||
private ErrStream errStream;
|
||||
private GAGtextEditor textEdit;
|
||||
private Hashtable paramsHash;
|
||||
private Vector disableCommands;
|
||||
private ParamPanel paramPanel;
|
||||
private JPanel geantPanel;
|
||||
private JSplitPane splitPane;
|
||||
private JFileChooser geant4Chooser, historyChooser;
|
||||
private JMenuItem execG4, exitG4, killG4, exitGAG, clearOneHist, clearAllHist, saveHist, htmlHelp, about;
|
||||
private JTextField directField;
|
||||
private JLabel promptLabel;
|
||||
private String fileName;
|
||||
private CardLayout cardLayout;
|
||||
private boolean endGAG;
|
||||
//use p1' background color to show GEANT4's busy states. Not Yet!
|
||||
private JPanel p1;
|
||||
|
||||
// FileFilter in Swing-1.0.2 test
|
||||
private ExampleFileFilter exeFilter, outFilter, g4hFilter,
|
||||
g4histFilter, txtFilter, histFilter;
|
||||
|
||||
public GAG(){
|
||||
super("GAG");
|
||||
getContentPane().setLayout(cardLayout = new CardLayout());
|
||||
geantPanel = new JPanel(new BorderLayout());
|
||||
|
||||
JMenu geantMenu = new JMenu("GEANT4");
|
||||
|
||||
geantMenu.setBackground(Color.orange);
|
||||
geantMenu.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
|
||||
execG4 = new JMenuItem("Exec GEANT4");
|
||||
exitG4 = new JMenuItem("Exit GEANT4");
|
||||
killG4 = new JMenuItem("Kill GEANT4");
|
||||
exitGAG = new JMenuItem("Exit GAG");
|
||||
execG4.setBackground(Color.green);
|
||||
exitG4.setBackground(Color.green);
|
||||
killG4.setBackground(Color.orange);
|
||||
exitGAG.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
execG4.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
exitG4.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
killG4.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
exitGAG.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
|
||||
geantMenu.add(execG4);
|
||||
geantMenu.add(exitG4);
|
||||
geantMenu.add(killG4);
|
||||
geantMenu.addSeparator();
|
||||
geantMenu.add(exitGAG);
|
||||
|
||||
JMenu histMenu = new JMenu("History");
|
||||
|
||||
histMenu.setBackground(Color.yellow);
|
||||
histMenu.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
|
||||
clearOneHist = new JMenuItem("Clear One");
|
||||
clearAllHist = new JMenuItem("Clear All");
|
||||
saveHist = new JMenuItem("Save history");
|
||||
clearOneHist.setBackground(Color.yellow);
|
||||
clearAllHist.setBackground(Color.yellow);
|
||||
saveHist.setBackground(Color.green);
|
||||
clearOneHist.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
clearAllHist.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
saveHist.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
|
||||
|
||||
histMenu.add(clearOneHist);
|
||||
histMenu.add(clearAllHist);
|
||||
histMenu.add(saveHist);
|
||||
|
||||
JMenu helpMenu = new JMenu("Help");
|
||||
helpMenu.setBackground(Color.white);
|
||||
helpMenu.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
helpMenu.add(htmlHelp = new JMenuItem("Help"));
|
||||
helpMenu.add(about = new JMenuItem("About"));
|
||||
|
||||
execG4.addActionListener(this);
|
||||
exitG4.addActionListener(this);
|
||||
killG4.addActionListener(this);
|
||||
exitGAG.addActionListener(this);
|
||||
clearOneHist.addActionListener(this);
|
||||
clearAllHist.addActionListener(this);
|
||||
saveHist.addActionListener(this);
|
||||
htmlHelp.addActionListener(this);
|
||||
about.addActionListener(this);;
|
||||
|
||||
JMenuBar mb = new JMenuBar();
|
||||
mb.add(geantMenu);
|
||||
mb.add(histMenu);
|
||||
mb.add(helpMenu); // mb.setHelpMenu(helpMenu);
|
||||
|
||||
//to the last position executingMenu(false);
|
||||
setJMenuBar(mb);
|
||||
directField = new JTextField();
|
||||
directField.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
directField.addActionListener(this);
|
||||
|
||||
p1 = new JPanel(new BorderLayout());
|
||||
promptLabel = new JLabel("****** PROMPT ******", JLabel.CENTER);
|
||||
promptLabel.setForeground(Color.black);
|
||||
promptLabel.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
p1.add("Center", directField);
|
||||
p1.add("West", promptLabel);
|
||||
|
||||
geantPanel.add("South", p1);
|
||||
JLabel idleLabel =new JLabel("Welcome to GEANT4",JLabel.CENTER);
|
||||
idleLabel.setFont(new Font("Serif", Font.BOLD, 18));
|
||||
getContentPane().add("idle", idleLabel);
|
||||
JLabel treeLabel = new JLabel("Making command tree");
|
||||
treeLabel.setFont(new Font("Serif", Font.BOLD, 18));
|
||||
getContentPane().add("tree", treeLabel);
|
||||
getContentPane().add("geant",geantPanel);
|
||||
|
||||
cardLayout.show(getContentPane(), "idle");
|
||||
setSize(600,400);
|
||||
setVisible(true);
|
||||
geant4Chooser = new JFileChooser(".");
|
||||
// Swing 1.0.2 FileFilter OK!! 1998 June 25
|
||||
geant4Chooser.setDialogTitle("GEANT4 Executable");
|
||||
|
||||
exeFilter = new ExampleFileFilter("exe", "DOS executable");
|
||||
outFilter = new ExampleFileFilter("out", "Unix executable");
|
||||
|
||||
geant4Chooser.addChoosableFileFilter(exeFilter);
|
||||
geant4Chooser.addChoosableFileFilter(outFilter);
|
||||
//
|
||||
|
||||
historyChooser = new JFileChooser(".");
|
||||
|
||||
// Swing 1.0.2 FileFilter OK!! 1998 June 25
|
||||
historyChooser.setDialogTitle("Command History");
|
||||
g4hFilter = new ExampleFileFilter("g4h", "Geant4 History");
|
||||
g4histFilter = new ExampleFileFilter("g4hist", "Geant4 History");
|
||||
txtFilter = new ExampleFileFilter("txt", "Geant4 History");
|
||||
histFilter = new ExampleFileFilter("hist", "Geant4 History");
|
||||
|
||||
historyChooser.addChoosableFileFilter(g4hFilter);
|
||||
historyChooser.addChoosableFileFilter(g4histFilter);
|
||||
historyChooser.addChoosableFileFilter(txtFilter);
|
||||
historyChooser.addChoosableFileFilter(histFilter);
|
||||
|
||||
// end of Swing test
|
||||
|
||||
executingMenu(false);
|
||||
|
||||
}
|
||||
private void executingMenu(boolean b){
|
||||
execG4.setEnabled(!b);
|
||||
//originally exitG4.setEnabled(b);
|
||||
exitG4.setEnabled(!b);
|
||||
killG4.setEnabled(b);
|
||||
//yoshida
|
||||
// exitGAG.setEnabled(b);
|
||||
clearOneHist.setEnabled(b);
|
||||
clearAllHist.setEnabled(b);
|
||||
saveHist.setEnabled(b);
|
||||
|
||||
//
|
||||
//this hide allthe time p1.setVisible(!b);
|
||||
if (!b) {
|
||||
p1.setBackground(Color.green); repaint();
|
||||
}else{
|
||||
p1.setBackground(Color.red); repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void mainLoop(String args[]){
|
||||
endGAG = false;
|
||||
if (args.length > 0) {
|
||||
fileName = args[0];
|
||||
geantStart(args);
|
||||
}
|
||||
String[] fn = new String[1];
|
||||
while(!endGAG){
|
||||
waiting();
|
||||
if (endGAG) return;
|
||||
fn[0] = fileName;
|
||||
geantStart(fn);
|
||||
}
|
||||
}
|
||||
private synchronized void waiting(){
|
||||
try{
|
||||
wait();
|
||||
}catch(InterruptedException e){
|
||||
}
|
||||
}
|
||||
private synchronized void resume(){
|
||||
notify();
|
||||
}
|
||||
private void geantStart(String[] args){
|
||||
String line, prompt = "G4";
|
||||
geant4 = new GAGpipe(args);
|
||||
boolean paramChanged = false;
|
||||
if (geant4.isError()){
|
||||
JOptionPane.showMessageDialog(this, geant4.getErrorMsg(),
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
geant4 = null;
|
||||
return;
|
||||
}
|
||||
executingMenu(true);
|
||||
if (textEdit == null) textEdit = new TextEdit();
|
||||
errStream = new ErrStream(geant4);
|
||||
errStream.start();
|
||||
geant4.writeLine("@@GAGmodeJAVA");
|
||||
while ((line = geant4.readStdLine()) != null){
|
||||
if (line.startsWith("@@")){
|
||||
if (line.equals("@@JTreeBegin")){
|
||||
if (makeCommandTree()) break;
|
||||
continue;
|
||||
}
|
||||
if (line.equals("@@JParamBegin")){
|
||||
if (receiveParams()) break;
|
||||
paramChanged = true;
|
||||
continue;
|
||||
}
|
||||
if (line.equals("@@JDirGuideBegin")){
|
||||
if (receiveCascade()) break;
|
||||
continue;
|
||||
}
|
||||
if (line.equals("@@DisableListBegin")){
|
||||
if (receiveDisables()) break;
|
||||
paramChanged = true;
|
||||
continue;
|
||||
}
|
||||
if (line.equals("@@Ready")){
|
||||
//yoshida effective even if paramPanel is null. But PROMPT case is enough.
|
||||
p1.setVisible(true);
|
||||
|
||||
p1.setBackground(Color.green); repaint();
|
||||
if (paramPanel != null) {
|
||||
paramPanel.toReady();
|
||||
if (paramChanged && !command.equals("")) setParamPanel(command);
|
||||
}
|
||||
paramChanged = false;
|
||||
textEdit.writeString(prompt + ">");
|
||||
exitG4.setEnabled(true);
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith("@@PROMPT")){
|
||||
prompt = line.substring(line.indexOf("\"")+1, line.lastIndexOf("\""));
|
||||
promptLabel.setText(prompt);
|
||||
//yoshida effective even if paramPanel is null
|
||||
p1.setVisible(true);
|
||||
p1.setBackground(Color.green); repaint();
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
show();
|
||||
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith("@@State")){
|
||||
continue;
|
||||
}
|
||||
// direct interaction with users
|
||||
if (line.startsWith("@@Ask")){
|
||||
String answer = JOptionPane.showInputDialog(this,line);
|
||||
geant4.writeLine(answer);
|
||||
continue;
|
||||
}
|
||||
//direct questionnaire
|
||||
|
||||
if (line.startsWith("@@CurrentValue")){
|
||||
paramPanel.loadCurrentValues(line);
|
||||
textEdit.writeLine(line.substring(line.indexOf(" ")+1));
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith("@@Version")){
|
||||
StringTokenizer st = new StringTokenizer( line );
|
||||
st.nextToken();
|
||||
g4Ver = st.nextToken();
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith("@@ErrResult")){
|
||||
JOptionPane.showMessageDialog(this,
|
||||
line.substring(line.indexOf("\"")+1, line.lastIndexOf("\"")),
|
||||
"Warning", JOptionPane.WARNING_MESSAGE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
textEdit.writeLine(line);
|
||||
}
|
||||
geantTerminate();
|
||||
}
|
||||
private void geantTerminate(){
|
||||
executingMenu(false);
|
||||
if (geant4 != null){
|
||||
geant4.processKill();
|
||||
geant4 = null;
|
||||
}
|
||||
paramsHash = null;
|
||||
if (errStream != null){
|
||||
errStream.close();
|
||||
errStream = null;
|
||||
}
|
||||
cardLayout.show(getContentPane(), "idle");
|
||||
paramPanel = null;
|
||||
}
|
||||
private boolean makeCommandTree() {
|
||||
String pLine, label;
|
||||
command = "";
|
||||
DefaultMutableTreeNode topTree, nowTree, childTree;
|
||||
boolean found;
|
||||
cardLayout.show(getContentPane(), "tree");
|
||||
if (splitPane != null) geantPanel.remove(splitPane);
|
||||
int lastIndex = fileName.lastIndexOf("/");
|
||||
topTree = new DefaultMutableTreeNode( (lastIndex<0) ? fileName : fileName.substring(lastIndex+1) );
|
||||
while( !(pLine = geant4.readStdLine()).equals("@@JTreeEnd") ){
|
||||
if (pLine == null){ return true;}
|
||||
nowTree = topTree; childTree = null; found = true;
|
||||
StringTokenizer stCo = new StringTokenizer(pLine,"/");
|
||||
while(stCo.hasMoreTokens()){
|
||||
label = stCo.nextToken();
|
||||
if (found){
|
||||
found = false;
|
||||
for (int i=0; i<nowTree.getChildCount(); i++){
|
||||
childTree = (DefaultMutableTreeNode)nowTree.getChildAt(i);
|
||||
if (label.equals( (String)childTree.getUserObject() )){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found == false) nowTree.add(childTree = new DefaultMutableTreeNode(label));
|
||||
nowTree = childTree;
|
||||
}
|
||||
}
|
||||
JTree tree = new JTree(topTree);
|
||||
tree.addTreeSelectionListener(this);
|
||||
paramPanel = new ParamPanel(this);
|
||||
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree), paramPanel );
|
||||
|
||||
// test 1998 June 25 to keep left space
|
||||
splitPane.setDividerLocation(200);
|
||||
|
||||
geantPanel.add("Center", splitPane);
|
||||
cardLayout.show(getContentPane(), "geant");
|
||||
paramsHash = new Hashtable();
|
||||
disableCommands = new Vector();
|
||||
return false;
|
||||
}
|
||||
private boolean receiveParams() {
|
||||
String lines, name, guide[], range;
|
||||
int guideEnts, paramEnts;
|
||||
name = geant4.readStdLine();
|
||||
lines = geant4.readStdLine();
|
||||
try{
|
||||
guideEnts = Integer.parseInt(lines);
|
||||
}catch(NumberFormatException e){
|
||||
return true;
|
||||
}
|
||||
guide = new String[guideEnts];
|
||||
for (int i=0; i<guideEnts; i++){
|
||||
guide[i] = geant4.readStdLine();
|
||||
}
|
||||
range = geant4.readStdLine();
|
||||
if (geant4.isError()) return true;
|
||||
lines = geant4.readStdLine();
|
||||
try{
|
||||
paramEnts = Integer.parseInt(lines);
|
||||
}catch(NumberFormatException e){
|
||||
return true;
|
||||
}
|
||||
GAGcommandItem ci = new GAGcommandItem(name, guide, range, paramEnts);
|
||||
for (int i=0; i<ci.getParamEntries(); i++){
|
||||
for (int j=0; j<ci.MAX; j++){
|
||||
lines = geant4.readStdLine();
|
||||
if (lines == null) return true;
|
||||
ci.params[i][j]=lines;
|
||||
}
|
||||
}
|
||||
if ( !(geant4.readStdLine()).equals("@@JParamEnd") ) return true;
|
||||
paramsHash.put(name, ci);
|
||||
return false;
|
||||
}
|
||||
private boolean receiveCascade() {
|
||||
String name, guide;
|
||||
name = geant4.readStdLine();
|
||||
guide = geant4.readStdLine();
|
||||
// System.out.println("CASCADE: "+name+" "+guide);
|
||||
if ( !(geant4.readStdLine()).equals("@@JDirGuideEnd") ) return true;
|
||||
paramsHash.put(name, guide);
|
||||
return false;
|
||||
}
|
||||
private boolean receiveDisables(){
|
||||
String line;
|
||||
disableCommands.removeAllElements();
|
||||
while(!(line = geant4.readStdLine()).equals("@@DisableListEnd")){
|
||||
if (line == null) return true;
|
||||
disableCommands.addElement(line);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void reqCurrent(String cmd){
|
||||
sendCommand("?"+cmd);
|
||||
return;
|
||||
}
|
||||
void sendCommand(String com){
|
||||
textEdit.writeLine(com);
|
||||
geant4.writeLine(com);
|
||||
exitG4.setEnabled(false);
|
||||
//yoshida cursor
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
p1.setBackground(Color.red); repaint();
|
||||
p1.setVisible(true);
|
||||
// executingMenu(true);
|
||||
// too much?
|
||||
}
|
||||
boolean setParamPanel(String key){
|
||||
GAGcommandItem ci = (GAGcommandItem)paramsHash.get(key);
|
||||
if (ci == null) return false;
|
||||
command = key;
|
||||
paramPanel.setParamBox(ci, isEnableCommand(key));
|
||||
return true;
|
||||
}
|
||||
public void valueChanged(TreeSelectionEvent te){
|
||||
if ( te.isAddedPath() == false ) return;
|
||||
String dirHelp, tempPath;
|
||||
StringBuffer com = new StringBuffer();
|
||||
Object path[] = te.getPath().getPath();
|
||||
if (path.length > 1) {
|
||||
for (int i=1; i<path.length; i++) com.append(("/"+path[i]));
|
||||
command = com.toString();
|
||||
}else{
|
||||
command = "";
|
||||
}
|
||||
|
||||
DefaultMutableTreeNode nowNode = (DefaultMutableTreeNode)path[path.length-1];
|
||||
int childCount = nowNode.getChildCount();
|
||||
if ( childCount > 0 ){
|
||||
DefaultMutableTreeNode tempNode;
|
||||
if (path.length > 1) {
|
||||
dirHelp = (String)paramsHash.get(command+"/");
|
||||
}else{
|
||||
dirHelp = new String(path[0].toString());
|
||||
}
|
||||
JLabel[][] helpLabel = new JLabel[2][childCount];
|
||||
for (int i=0; childCount > i; i++){
|
||||
tempNode = (DefaultMutableTreeNode)nowNode.getChildAt(i);
|
||||
tempPath = command + "/" + tempNode;
|
||||
if (tempNode.getChildCount() == 0){
|
||||
helpLabel[0][i] = new JLabel(tempNode+" ");
|
||||
helpLabel[0][i].setForeground(isEnableCommand(tempPath) ? Color.red : Color.lightGray);
|
||||
helpLabel[1][i] = new JLabel(((GAGcommandItem)(paramsHash.get(tempPath))).getTitle());
|
||||
}else{
|
||||
helpLabel[0][i] = new JLabel(tempNode+"/ ");
|
||||
helpLabel[0][i].setForeground(isEnableCommand(tempPath+"/") ? Color.blue : Color.lightGray);
|
||||
helpLabel[1][i] = new JLabel((String)paramsHash.get(tempPath +"/"));
|
||||
}
|
||||
}
|
||||
paramPanel.setTreeHelp(dirHelp, helpLabel);
|
||||
}else{
|
||||
GAGcommandItem ci = (GAGcommandItem)paramsHash.get(command);
|
||||
if (ci == null) return;
|
||||
paramPanel.setParamBox(ci, isEnableCommand(command));
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean isEnableCommand(String command){
|
||||
return !disableCommands.contains(command);
|
||||
}
|
||||
public void actionPerformed(ActionEvent ae){
|
||||
|
||||
|
||||
Object o = ae.getSource();
|
||||
if ( o == directField){
|
||||
sendCommand(directField.getText());
|
||||
paramPanel.addHistory(directField.getText());
|
||||
directField.setText("");
|
||||
return;
|
||||
}
|
||||
if (o == exitGAG){
|
||||
if (geant4 != null) {
|
||||
if(JOptionPane.showConfirmDialog(this, "Kill GEANT4 automatically.", "Exit GAG", JOptionPane.YES_NO_OPTION) == 1) {return;}
|
||||
geantTerminate();
|
||||
endGAG = true;
|
||||
}else{
|
||||
resume();
|
||||
endGAG = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (o == exitG4){
|
||||
sendCommand("exit");
|
||||
return;
|
||||
}
|
||||
if (o == execG4){
|
||||
if (geant4Chooser.showOpenDialog(this) == -1 )return;
|
||||
// Swing1.0.2
|
||||
File f = geant4Chooser.getSelectedFile();
|
||||
if (f.isFile()) {
|
||||
fileName = f.getPath();
|
||||
resume();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (o == killG4){
|
||||
geantTerminate();
|
||||
return;
|
||||
}
|
||||
if (o == htmlHelp){
|
||||
return;
|
||||
}
|
||||
if (o == about){
|
||||
new AboutDialog(this, gagVer, g4Ver);
|
||||
return;
|
||||
}
|
||||
if (o == clearAllHist){
|
||||
paramPanel.clearAllHistory();
|
||||
return;
|
||||
}
|
||||
if (o == clearOneHist){
|
||||
paramPanel.clearOneHistory();
|
||||
return;
|
||||
}
|
||||
if (o == saveHist){
|
||||
if (historyChooser.showSaveDialog(this) == -1 ) return;
|
||||
// Swing1.0.2
|
||||
try{
|
||||
FileOutputStream fo = new FileOutputStream(historyChooser.getSelectedFile());
|
||||
PrintWriter outf = new PrintWriter(new DataOutputStream(fo));
|
||||
String[] items = paramPanel.getHistoryItems();
|
||||
for (int i=0; i<items.length; i++) outf.println(items[i]);
|
||||
outf.close();
|
||||
}catch(IOException e){ System.out.println(e.getMessage()); }
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ErrStream extends Thread implements ActionListener {
|
||||
private GAGpipe geant4;
|
||||
private Frame errFrame;
|
||||
private TextArea errArea;
|
||||
private Button close;
|
||||
ErrStream(GAGpipe geant4){
|
||||
this.geant4 = geant4;
|
||||
errFrame = new Frame("Std Error");
|
||||
errFrame.setLayout(new BorderLayout());
|
||||
errFrame.add("Center", errArea = new TextArea());
|
||||
errFrame.add("South", close = new Button("Close"));
|
||||
close.addActionListener(this);
|
||||
errFrame.setSize(400, 200);
|
||||
}
|
||||
public void run(){
|
||||
String line;
|
||||
while((line=geant4.readErrLine())!=null){
|
||||
errArea.append(line+"\n");
|
||||
if (!errFrame.isVisible()) errFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent ae){
|
||||
errFrame.setVisible(false);
|
||||
errArea.setText("");
|
||||
}
|
||||
void close(){
|
||||
errFrame.dispose();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
class AboutDialog extends Dialog implements ActionListener {
|
||||
Button ok;
|
||||
public AboutDialog(Frame parent, String ver1, String ver2){
|
||||
super(parent, "About GAG", true);
|
||||
setForeground(Color.black);
|
||||
Panel center = new Panel(new GridLayout(0,1));
|
||||
center.add(new Label("GAG Version "+ ver1));
|
||||
center.add(new Label("G4UIGAG Version "+ ver2));
|
||||
center.add(new Label("Toshiaki Kodama, GEANT4 GUI GROUP"));
|
||||
add("Center", center);
|
||||
|
||||
Panel p = new Panel();
|
||||
ok = new Button("Ok");
|
||||
ok.addActionListener(this);
|
||||
p.add(ok);
|
||||
add("South",p);
|
||||
pack();
|
||||
setVisible(true);
|
||||
}
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (event.getSource() == ok)
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
|
||||
package GAG;
|
||||
|
||||
class GAGcommandItem extends Object {
|
||||
static final int NAME=0, GUIDE=1, TYPE=2, OMITTABLE=3, DEFAULT=4, RANGE=5, CANDIDATE=6;
|
||||
static final int MAX = 7;
|
||||
private String name, guide[], range;
|
||||
private int paramEnts;
|
||||
String params[][];
|
||||
GAGcommandItem(String name, String guide[], String range, int ents){
|
||||
this.name = name;
|
||||
this.guide = guide;
|
||||
paramEnts = ents;
|
||||
if (ents > 0) {
|
||||
params = new String[paramEnts][MAX];
|
||||
}
|
||||
this.range = range;
|
||||
return;
|
||||
}
|
||||
String getCommandName(){
|
||||
return name;
|
||||
}
|
||||
String[] getCommandGuide(){
|
||||
return guide;
|
||||
}
|
||||
String getTitle(){
|
||||
return guide[0];
|
||||
}
|
||||
String getCommandRange(){
|
||||
return range;
|
||||
}
|
||||
int getParamEntries(){
|
||||
return paramEnts;
|
||||
}
|
||||
String getParamName(int pos){
|
||||
return params[pos][NAME];
|
||||
}
|
||||
String getParamGuide(int pos){
|
||||
return params[pos][GUIDE];
|
||||
}
|
||||
String getParamType(int pos){
|
||||
return params[pos][TYPE];
|
||||
}
|
||||
boolean isOmittable(int ent){
|
||||
return params[ent][OMITTABLE].equals("1");
|
||||
}
|
||||
String getParamDefault(int pos){
|
||||
return params[pos][DEFAULT];
|
||||
}
|
||||
String getParamRange(int pos){
|
||||
return params[pos][RANGE];
|
||||
}
|
||||
String getParamCandidate(int pos){
|
||||
return params[pos][CANDIDATE];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
|
||||
package GAG;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
class GAGpipe {
|
||||
private Process ps;
|
||||
private BufferedReader inpS, errS;
|
||||
private PrintWriter outS;
|
||||
private String errMsg;
|
||||
private boolean isErr;
|
||||
|
||||
GAGpipe(String[] execFile){
|
||||
errMsg = null; isErr = false;
|
||||
try {
|
||||
ps = Runtime.getRuntime().exec(execFile);
|
||||
} catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
return;
|
||||
}
|
||||
inpS = new BufferedReader(new InputStreamReader(ps.getInputStream()));
|
||||
errS = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
|
||||
outS = new PrintWriter(new DataOutputStream(ps.getOutputStream()));
|
||||
}
|
||||
String readStdLine(){
|
||||
String line = null;
|
||||
try{
|
||||
line=inpS.readLine();
|
||||
}catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
}
|
||||
return line;
|
||||
}
|
||||
String readErrLine(){
|
||||
String line = null;
|
||||
try{
|
||||
line=errS.readLine();
|
||||
}catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
System.err.println(errMsg);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
synchronized boolean writeLine(String st){
|
||||
outS.println(st);
|
||||
return outS.checkError();
|
||||
}
|
||||
synchronized void processKill(){
|
||||
ps.destroy();
|
||||
}
|
||||
boolean isError(){
|
||||
return isErr;
|
||||
}
|
||||
String getErrorMsg(){
|
||||
if (!isErr) return "";
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// Toshiaki Kodama GEANT4 GUI Group
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
// This is an junction to better TextEditor in future.
|
||||
|
||||
package GAG;
|
||||
|
||||
public interface GAGtextEditor {
|
||||
public void writeString(String str);
|
||||
public void writeLine(String str);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
// jdk-1.1.3 (or later) + swing-1.0.2
|
||||
// This is not required in GAG
|
||||
|
||||
import com.sun.java.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class HtmlFrame extends JFrame {
|
||||
public HtmlFrame() {
|
||||
// setBackground(Color.white);
|
||||
setLayout(new BorderLayout());
|
||||
try {
|
||||
URL url = new URL("http://erlt1.naruto-u.ac.jp/~geant4/README_Momo.html");
|
||||
JEditorPane html = new JEditorPane(url);
|
||||
JScrollPane scroller = new JScrollPane(html);
|
||||
add("Center", scroller);
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("Malformed URL: " + e);
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOException: " + e);
|
||||
}
|
||||
setSize(400, 400);
|
||||
show();
|
||||
}
|
||||
public static void main(String arg[]){
|
||||
new HtmlFrame();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,416 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// modified by H Yoshida, 1998 June 25
|
||||
// use of FileFilter of Swing 1.0.2, to select after file extensions
|
||||
// improvement of notification method of GEANT4 states
|
||||
// by using setVisible and setBackground of relevant buttons
|
||||
// specially "ok" button.
|
||||
|
||||
package GAG;
|
||||
|
||||
import com.sun.java.swing.preview.*;
|
||||
//FileFilter of Swing1.0.2
|
||||
import ExampleFileFilter;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.awt.event.*;
|
||||
import com.sun.java.swing.*;
|
||||
import com.sun.java.swing.preview.filechooser.*;
|
||||
// for Swing-1.0.2 FileChooser
|
||||
|
||||
class ParamPanel extends JPanel implements ActionListener, ItemListener {
|
||||
private GAG gag;
|
||||
private GridBagLayout gbl; GridBagConstraints gbc;
|
||||
private JPanel paramArea;
|
||||
private JButton def, current, clear, ok, fileBrowser;
|
||||
private JComboBox history;
|
||||
private int posY;
|
||||
private GAGcommandItem ci;
|
||||
private Component paraBox[];
|
||||
private boolean isExecuting;
|
||||
private JFileChooser fileChooser;
|
||||
// FileFilter in Swing-1.0.2 test
|
||||
private ExampleFileFilter g4mFilter, macroFilter, g4macroFilter,
|
||||
txtFilter;
|
||||
|
||||
|
||||
|
||||
ParamPanel(GAG gag){
|
||||
isExecuting = false;
|
||||
this.gag = gag;
|
||||
setLayout( new BorderLayout() );
|
||||
|
||||
gbc = new GridBagConstraints();
|
||||
gbl = new GridBagLayout();
|
||||
|
||||
paramArea = new JPanel();
|
||||
paramArea.setLayout(gbl);
|
||||
paramArea.setBackground(new Color(255, 250, 230));
|
||||
add("Center", new JScrollPane(paramArea));
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setLayout(new GridLayout( 1, 0, 2, 2));
|
||||
// Yoshida color
|
||||
def = new JButton("Default");
|
||||
current = new JButton("Current");
|
||||
clear = new JButton("Clear");
|
||||
ok = new JButton("OK");
|
||||
ok.setBackground(Color.green);
|
||||
//no good?? ok.setFont(new Font("OK",1,12));
|
||||
def.setBackground(Color.blue);
|
||||
current.setBackground(Color.orange);
|
||||
clear.setBackground(SystemColor.white);
|
||||
// ok.setBackground(SystemColor.control);
|
||||
// color
|
||||
|
||||
buttons.add( def );
|
||||
buttons.add( current );
|
||||
buttons.add( clear );
|
||||
buttons.add( ok );
|
||||
add("South", buttons);
|
||||
|
||||
history = new JComboBox();
|
||||
history.addItem("# GEANT4 history macro.");
|
||||
history.addItemListener(this);
|
||||
add("North", history);
|
||||
//yoshida setinvisible and setdisable
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
def.setMargin(new Insets(1,3,1,3));
|
||||
def.addActionListener(this);
|
||||
|
||||
//yoshida
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
current.setMargin(new Insets(1,3,1,3));
|
||||
current.addActionListener(this);
|
||||
//yoshida
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
clear.setMargin(new Insets(1,3,1,3));
|
||||
clear.addActionListener(this);
|
||||
|
||||
//yoshida
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
ok.setMargin(new Insets(1,3,1,3));
|
||||
ok.addActionListener(this);
|
||||
|
||||
fileBrowser = new JButton("Open a Macro File");
|
||||
fileBrowser.addActionListener(this);
|
||||
fileChooser = new JFileChooser(".");
|
||||
// Swing 1.0.2 FileFilter OK!! 1998 June 25
|
||||
fileChooser.setDialogTitle("Macro File");
|
||||
g4mFilter = new ExampleFileFilter("g4m", "Geant4 macro");
|
||||
g4macroFilter = new ExampleFileFilter("g4macro", "Geant4 macro");
|
||||
txtFilter = new ExampleFileFilter("txt", "Geant4 macro");
|
||||
macroFilter = new ExampleFileFilter("macro", "Geant4 macro");
|
||||
|
||||
fileChooser.addChoosableFileFilter(g4mFilter);
|
||||
fileChooser.addChoosableFileFilter(g4macroFilter);
|
||||
fileChooser.addChoosableFileFilter(txtFilter);
|
||||
fileChooser.addChoosableFileFilter(macroFilter);
|
||||
|
||||
// end of Swing-1.0.2 FileChooser
|
||||
|
||||
|
||||
}
|
||||
void setParamBox(GAGcommandItem ci, boolean enable){
|
||||
paramArea.removeAll();
|
||||
this.ci = ci;
|
||||
posY = 0;
|
||||
JLabel l;
|
||||
if (!enable){
|
||||
l = new JLabel("This command is not available.");
|
||||
l.setForeground(Color.red);
|
||||
addComponent(l);
|
||||
}
|
||||
addComponent(new JLabel(ci.getCommandName()));
|
||||
String guide[] = ci.getCommandGuide();
|
||||
for (int i=0; i<guide.length; i++){
|
||||
addComponent(new JLabel(guide[i]));
|
||||
}
|
||||
if (!ci.getCommandRange().equals("")){
|
||||
l = new JLabel(ci.getCommandRange());
|
||||
l.setForeground(Color.green);
|
||||
addComponent(l);
|
||||
}
|
||||
if (ci.getParamEntries() > 0){
|
||||
def.setEnabled(true);
|
||||
//yoshida
|
||||
def.setVisible(true);
|
||||
current.setEnabled(!isExecuting && enable);
|
||||
//yoshida
|
||||
current.setVisible(!isExecuting && enable);
|
||||
clear.setEnabled(true);
|
||||
//yoshida
|
||||
clear.setVisible(true);
|
||||
paraBox = new JComponent[ci.getParamEntries()];
|
||||
String candidateList;
|
||||
for (int i=0; i<ci.getParamEntries(); i++){
|
||||
candidateList = ci.getParamCandidate(i);
|
||||
if (candidateList.equals("")){
|
||||
if (ci.getParamType(i).equals("b")){
|
||||
paraBox[i] = new BooleanCombo(ci.getParamDefault(i));
|
||||
}else{
|
||||
paraBox[i] = new JTextField(20);
|
||||
((JTextField)paraBox[i]).setText(ci.getParamDefault(i));
|
||||
}
|
||||
}else{
|
||||
paraBox[i] = new JComboBox();
|
||||
StringTokenizer st = new StringTokenizer(candidateList);
|
||||
while(st.hasMoreTokens()){
|
||||
((JComboBox)paraBox[i]).addItem(st.nextToken());
|
||||
}
|
||||
if (!ci.getParamDefault(i).equals("")){
|
||||
((JComboBox)paraBox[i]).setSelectedItem(ci.getParamDefault(i));
|
||||
}
|
||||
}
|
||||
addComponent(new JLabel(ci.getParamName(i)), paraBox[i], new JLabel("("+ci.getParamType(i) +") "+ci.getParamGuide(i) ));
|
||||
if (ci.getParamName(i).equals("fileName")) addComponent(new JLabel(), fileBrowser);
|
||||
}
|
||||
}else{
|
||||
//yoshida setinvisible and then setdisable
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
}
|
||||
ok.setEnabled(!isExecuting && enable);
|
||||
//yoshida OK button order of enable and visible is important
|
||||
ok.setVisible(!isExecuting && enable);
|
||||
|
||||
validate();
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
void setTreeHelp(String dirHelp, JLabel helps[][]){
|
||||
//yoshida setinvisible then setdisable
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
//
|
||||
paramArea.removeAll();
|
||||
posY = 0; ci = null;
|
||||
JLabel title = new JLabel(dirHelp);
|
||||
title.setForeground(Color.green);
|
||||
addComponent(title);
|
||||
for (int i=0; i<helps[0].length; i++){
|
||||
addComponent(helps[0][i], helps[1][i]);
|
||||
}
|
||||
validate();
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
private String makeCommandLine(){
|
||||
StringBuffer param = new StringBuffer(ci.getCommandName());
|
||||
if (ci.getParamEntries() > 0){
|
||||
String val;
|
||||
for (int i=0; i<ci.getParamEntries(); i++){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
val = (((JTextField)paraBox[i]).getText()).trim();
|
||||
if (val.equals("")){
|
||||
if (!ci.isOmittable(i)){
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot omitted.", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}else{
|
||||
if (!ci.getParamDefault(i).equals(""))
|
||||
val = ci.getParamDefault(i);
|
||||
else{
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis omittable parameter has not default value.", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}else if ( val.indexOf(" ") >= 0){
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot include SPACE character", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}
|
||||
}else{
|
||||
val = (String)((JComboBox)paraBox[i]).getSelectedItem();
|
||||
}
|
||||
param.append(" "+val);
|
||||
}
|
||||
//yoshida
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
}
|
||||
//yoshida
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
history.addItem(param.toString());
|
||||
return param.toString();
|
||||
}
|
||||
private void addComponent(Component compo){
|
||||
gbc.gridx = 0; gbc.gridy = posY++;
|
||||
gbc.gridwidth = 3; gbc.gridheight = 1;
|
||||
gbc.weightx = 1.0; gbc.weighty = 0.0;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo, gbc);
|
||||
paramArea.add(compo);
|
||||
}
|
||||
private void addComponent(Component compo1, Component compo2){
|
||||
gbc.gridx = 0; gbc.gridy = posY;
|
||||
gbc.gridwidth = 1; gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0; gbc.weighty = 0.0;
|
||||
gbc.anchor = GridBagConstraints.EAST;
|
||||
gbl.setConstraints(compo1, gbc);
|
||||
paramArea.add(compo1);
|
||||
gbc.gridx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo2, gbc);
|
||||
paramArea.add(compo2);
|
||||
posY++;
|
||||
}
|
||||
private void addComponent(Component title, Component compo1, Component compo2){
|
||||
gbc.gridx = 0; gbc.gridy = posY;
|
||||
gbc.gridwidth = 1; gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0; gbc.weighty = 0.0;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.anchor = GridBagConstraints.EAST;
|
||||
gbl.setConstraints(title, gbc);
|
||||
paramArea.add(title);
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbl.setConstraints(compo1, gbc);
|
||||
paramArea.add(compo1);
|
||||
gbc.gridx = 2;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo2, gbc);
|
||||
paramArea.add(compo2);
|
||||
posY++;
|
||||
}
|
||||
private void loadValue(int i, String str){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
((JTextField)paraBox[i]).setText(str);
|
||||
}
|
||||
if (paraBox[i] instanceof JComboBox){
|
||||
((JComboBox)paraBox[i]).setSelectedItem(str);
|
||||
}
|
||||
}
|
||||
void addHistory(String line){
|
||||
if (line.startsWith("/")) history.addItem(line);
|
||||
}
|
||||
void clearAllHistory(){
|
||||
history.removeAllItems();
|
||||
}
|
||||
void clearOneHistory(){
|
||||
int ix = history.getSelectedIndex();
|
||||
if (ix >= 0) history.removeItemAt(ix);
|
||||
}
|
||||
String[] getHistoryItems(){
|
||||
String[] item = new String[history.getItemCount()];
|
||||
for (int i=0; i>history.getItemCount(); i++){
|
||||
item[i] = (String)history.getItemAt(i);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
void loadCurrentValues(String line){
|
||||
StringTokenizer st = new StringTokenizer( line );
|
||||
st.nextToken();
|
||||
int i=0;
|
||||
while(st.hasMoreTokens()){
|
||||
loadValue(i++, st.nextToken());
|
||||
}
|
||||
}
|
||||
public void itemStateChanged(ItemEvent ie){
|
||||
if (isExecuting) return;
|
||||
if (ie.getStateChange() != ItemEvent.SELECTED) return;
|
||||
String str = (String)ie.getItem();
|
||||
if ( !str.startsWith("/") ) return;
|
||||
StringTokenizer st = new StringTokenizer( str );
|
||||
if (!gag.setParamPanel(st.nextToken())) return;
|
||||
int i=0;
|
||||
while(st.hasMoreTokens()){
|
||||
loadValue(i++, st.nextToken());
|
||||
if (i >= ci.getParamEntries()) return;
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent ev){
|
||||
Object source = ev.getSource();
|
||||
if ( source == ok ){
|
||||
String p = makeCommandLine();
|
||||
if (p == null) return;
|
||||
isExecuting = true;
|
||||
gag.sendCommand(p);
|
||||
//yoshida instead of sandwatch, ok button becomes invisible
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
// Be careful! mouse may freeze, if setinvisible but not setdisabled!!
|
||||
return;
|
||||
}else if (source == def){
|
||||
for (int i=0; ci.getParamEntries()>i; i++){
|
||||
loadValue(i, ci.getParamDefault(i));
|
||||
}
|
||||
return;
|
||||
}else if (source == current){
|
||||
gag.reqCurrent(ci.getCommandName());
|
||||
return;
|
||||
}else if (source == clear){
|
||||
for (int i=0; ci.getParamEntries()>i; i++){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
((JTextField)paraBox[i]).setText("");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}else if (source == fileBrowser){
|
||||
//swing102 filechooser showDialog(this, null) or the next
|
||||
if (fileChooser.showOpenDialog(this) == -1 ) return;
|
||||
File f = fileChooser.getSelectedFile();
|
||||
if (f.isFile()) {
|
||||
if (paraBox[0] instanceof JTextField){
|
||||
((JTextField)paraBox[0]).setText(f.getPath());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
void toReady(){
|
||||
isExecuting = false;
|
||||
if (ci == null) return;
|
||||
ok.setEnabled(true);
|
||||
//yoshida setenable then setvisible
|
||||
ok.setVisible(true);
|
||||
if (ci.getParamEntries() == 0) return;
|
||||
current.setEnabled(true);
|
||||
//yoshida
|
||||
current.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanCombo extends JComboBox {
|
||||
BooleanCombo(String str){
|
||||
String def = str.toUpperCase();
|
||||
if (def.equals("0") || def.equals("1")){
|
||||
addItem("0");
|
||||
addItem("1");
|
||||
}else if (def.equals("Y") || def.equals("N")){
|
||||
addItem("Y");
|
||||
addItem("N");
|
||||
}else if (def.equals("YES") || def.equals("NO")){
|
||||
addItem("YES");
|
||||
addItem("NO");
|
||||
}else if (def.equals("T") || def.equals("F")){
|
||||
addItem("T");
|
||||
addItem("F");
|
||||
} else {
|
||||
addItem("FALSE");
|
||||
addItem("TRUE");
|
||||
}
|
||||
if (!def.equals("")){
|
||||
setSelectedItem(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
1998 June 25 Yoshida
|
||||
|
||||
Improve look-and-feel of GAG by KOdama (as of 31/March/1998).
|
||||
|
||||
|
||||
Swing-1.0.1 is used.
|
||||
Swing-1.0.2 is desirable, but wait a moment. Swing-1.0.2 has
|
||||
not yet frozen classes and interfaces, among them JColorChooser
|
||||
and JFileChooser.
|
||||
They are left as before in swing.preview package!!
|
||||
|
||||
|
||||
Swing-1.0.2 JFileChooser is good for us since it allows file filtering,
|
||||
free label on buttons etc..
|
||||
|
||||
But it is better to wait JDK1.2!!
|
||||
|
||||
|
||||
So there is only minor improvements.
|
||||
|
||||
Font is one of the most iportant improvement.
|
||||
Current fonts are too small or not beautiful.
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,131 @@
|
||||
// jdk-1.1.3 (or later) + swing-1.0.2
|
||||
// JFileChooser is to be used soon.
|
||||
//
|
||||
package GAG;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.java.swing.text.*;
|
||||
import com.sun.java.swing.*;
|
||||
|
||||
class TextEditor extends JFrame implements ActionListener {
|
||||
private JMenuItem newf, open, save, cut, copy, paste;
|
||||
private JTextArea editor;
|
||||
private JToolBar toolbar;
|
||||
protected FileDialog fileDialog;
|
||||
|
||||
TextEditor() {
|
||||
super("GAG TextEditor");
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
editor = new JTextArea();
|
||||
editor.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
JScrollPane scroller = new JScrollPane();
|
||||
//scroller.setVerticalScrollBarPolicy(JScrollPane.SCROLLBARS_ALWAYS);
|
||||
JViewport port = scroller.getViewport();
|
||||
port.add(editor);
|
||||
port.setBackingStoreEnabled(false);
|
||||
setJMenuBar( createMenubar() );
|
||||
getContentPane().add("Center", scroller);
|
||||
pack();
|
||||
setSize(500, 600);
|
||||
show();
|
||||
}
|
||||
JMenuBar createMenubar(){
|
||||
JMenu file, edit;
|
||||
JMenuBar mb = new JMenuBar();
|
||||
file = new JMenu("File");
|
||||
file.add(newf = new JMenuItem("New"));
|
||||
file.add(open = new JMenuItem("Open"));
|
||||
file.add(save = new JMenuItem("Save"));
|
||||
edit = new JMenu("Edit");
|
||||
edit.add(cut = new JMenuItem("Cut"));
|
||||
edit.add(copy = new JMenuItem("Copy"));
|
||||
edit.add(paste = new JMenuItem("Paste"));
|
||||
mb.add(file);
|
||||
mb.add(edit);
|
||||
newf.addActionListener(this);
|
||||
open.addActionListener(this);
|
||||
save.addActionListener(this);
|
||||
cut.addActionListener(this);
|
||||
copy.addActionListener(this);
|
||||
paste.addActionListener(this);
|
||||
return mb;
|
||||
}
|
||||
void writeString(String s){
|
||||
editor.append(s);
|
||||
}
|
||||
void writeLine(String s){
|
||||
editor.append(s+"\n");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TextEditor();
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object o = e.getSource();
|
||||
if (o == newf){newAction(); return;}
|
||||
if (o == open){openAction(); return;}
|
||||
if (o == save){saveAction(); return;}
|
||||
if (o == cut){editor.cut(); return;}
|
||||
if (o == copy){editor.copy(); return;}
|
||||
if (o == paste){editor.paste(); return;}
|
||||
}
|
||||
void newAction(){
|
||||
editor.setDocument(new PlainDocument());
|
||||
validate();
|
||||
}
|
||||
void openAction(){
|
||||
if (fileDialog == null) {
|
||||
fileDialog = new FileDialog(this);
|
||||
}
|
||||
fileDialog.setMode(FileDialog.LOAD);
|
||||
fileDialog.show();
|
||||
|
||||
String file = fileDialog.getFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
newAction();
|
||||
String directory = fileDialog.getDirectory();
|
||||
File f = new File(directory, file);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (f.exists()) {
|
||||
setTitle(file);
|
||||
try{
|
||||
Reader in = new FileReader(f);
|
||||
char[] buff = new char[4096];
|
||||
int nch;
|
||||
while ((nch = in.read(buff, 0, buff.length)) != -1) {
|
||||
sb.append(new String(buff, 0, nch));
|
||||
}
|
||||
}catch(IOException e){ System.err.println(e.getMessage()); }
|
||||
editor.setText(sb.toString());
|
||||
validate();
|
||||
}
|
||||
}
|
||||
void saveAction(){
|
||||
String saveText;
|
||||
if (fileDialog == null) {
|
||||
fileDialog = new FileDialog(this);
|
||||
}
|
||||
fileDialog.setMode(FileDialog.LOAD);
|
||||
fileDialog.show();
|
||||
|
||||
String file = fileDialog.getFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String directory = fileDialog.getDirectory();
|
||||
File f = new File(directory, file);
|
||||
try{
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
PrintWriter outf = new PrintWriter(new DataOutputStream(fo));
|
||||
outf.println(editor.getText());
|
||||
outf.close();
|
||||
}catch(IOException e){ System.err.println(e.getMessage()); }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
|
||||
package GAG;
|
||||
|
||||
class GAGcommandItem extends Object {
|
||||
static final int NAME=0, GUIDE=1, TYPE=2, OMITTABLE=3, DEFAULT=4, RANGE=5, CANDIDATE=6;
|
||||
static final int MAX = 7;
|
||||
private String name, guide[], range;
|
||||
private int paramEnts;
|
||||
String params[][];
|
||||
GAGcommandItem(String name, String guide[], String range, int ents){
|
||||
this.name = name;
|
||||
this.guide = guide;
|
||||
paramEnts = ents;
|
||||
if (ents > 0) {
|
||||
params = new String[paramEnts][MAX];
|
||||
}
|
||||
this.range = range;
|
||||
return;
|
||||
}
|
||||
String getCommandName(){
|
||||
return name;
|
||||
}
|
||||
String[] getCommandGuide(){
|
||||
return guide;
|
||||
}
|
||||
String getTitle(){
|
||||
return guide[0];
|
||||
}
|
||||
String getCommandRange(){
|
||||
return range;
|
||||
}
|
||||
int getParamEntries(){
|
||||
return paramEnts;
|
||||
}
|
||||
String getParamName(int pos){
|
||||
return params[pos][NAME];
|
||||
}
|
||||
String getParamGuide(int pos){
|
||||
return params[pos][GUIDE];
|
||||
}
|
||||
String getParamType(int pos){
|
||||
return params[pos][TYPE];
|
||||
}
|
||||
boolean isOmittable(int ent){
|
||||
return params[ent][OMITTABLE].equals("1");
|
||||
}
|
||||
String getParamDefault(int pos){
|
||||
return params[pos][DEFAULT];
|
||||
}
|
||||
String getParamRange(int pos){
|
||||
return params[pos][RANGE];
|
||||
}
|
||||
String getParamCandidate(int pos){
|
||||
return params[pos][CANDIDATE];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
|
||||
package GAG;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
class GAGpipe {
|
||||
private Process ps;
|
||||
private BufferedReader inpS, errS;
|
||||
private PrintWriter outS;
|
||||
private String errMsg;
|
||||
private boolean isErr;
|
||||
|
||||
GAGpipe(String[] execFile){
|
||||
errMsg = null; isErr = false;
|
||||
try {
|
||||
ps = Runtime.getRuntime().exec(execFile);
|
||||
} catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
return;
|
||||
}
|
||||
inpS = new BufferedReader(new InputStreamReader(ps.getInputStream()));
|
||||
errS = new BufferedReader(new InputStreamReader(ps.getErrorStream()));
|
||||
outS = new PrintWriter(new DataOutputStream(ps.getOutputStream()));
|
||||
}
|
||||
String readStdLine(){
|
||||
String line = null;
|
||||
try{
|
||||
line=inpS.readLine();
|
||||
}catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
}
|
||||
return line;
|
||||
}
|
||||
String readErrLine(){
|
||||
String line = null;
|
||||
try{
|
||||
line=errS.readLine();
|
||||
}catch(IOException e){
|
||||
isErr = true;
|
||||
errMsg = e.getMessage();
|
||||
System.err.println(errMsg);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
synchronized boolean writeLine(String st){
|
||||
outS.println(st);
|
||||
return outS.checkError();
|
||||
}
|
||||
synchronized void processKill(){
|
||||
ps.destroy();
|
||||
}
|
||||
boolean isError(){
|
||||
return isErr;
|
||||
}
|
||||
String getErrorMsg(){
|
||||
if (!isErr) return "";
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// Toshiaki Kodama GEANT4 GUI Group
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
// This is an junction to better TextEditor in future.
|
||||
|
||||
package GAG;
|
||||
|
||||
public interface GAGtextEditor {
|
||||
public void writeString(String str);
|
||||
public void writeLine(String str);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
// jdk-1.1.3 (or later) + swing-1.0.2
|
||||
// This is not required in GAG
|
||||
|
||||
import com.sun.java.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class HtmlFrame extends JFrame {
|
||||
public HtmlFrame() {
|
||||
// setBackground(Color.white);
|
||||
setLayout(new BorderLayout());
|
||||
try {
|
||||
URL url = new URL("http://erlt1.naruto-u.ac.jp/~geant4/README_Momo.html");
|
||||
JEditorPane html = new JEditorPane(url);
|
||||
JScrollPane scroller = new JScrollPane(html);
|
||||
add("Center", scroller);
|
||||
} catch (MalformedURLException e) {
|
||||
System.out.println("Malformed URL: " + e);
|
||||
} catch (IOException e) {
|
||||
System.out.println("IOException: " + e);
|
||||
}
|
||||
setSize(400, 400);
|
||||
show();
|
||||
}
|
||||
public static void main(String arg[]){
|
||||
new HtmlFrame();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
1998 July 6 JAVA GAG for Beta-01 release
|
||||
|
||||
H. Yoshida; Naruto UE
|
||||
|
||||
This directory and its subdirectories contain all necessary JAVA
|
||||
source codes as well as *.class files. All are archived into
|
||||
GAG.jar file.
|
||||
|
||||
JAVA GAG uses Swing-1.0.2. Older versions based on Swing-1.0.1 can't
|
||||
be compiled, and pour out "deprecated" errors on javac.
|
||||
|
||||
But Swing-1.0.2 has yet unfrozen classes and interfaces, among them
|
||||
are JColorChooser and JFileChooser which JAVA GAG uses.
|
||||
|
||||
They are left as before in swing.preview package!!
|
||||
Swing-1.0.3 is announced, but we will wait JDK1.2 which
|
||||
is forseen in the next September (right?).
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,416 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/31
|
||||
// GEANT4 GUI Group, Toshiaki Kodama
|
||||
// modified by H Yoshida, 1998 June 25
|
||||
// use of FileFilter of Swing 1.0.2, to select after file extensions
|
||||
// improvement of notification method of GEANT4 states
|
||||
// by using setVisible and setBackground of relevant buttons
|
||||
// specially "ok" button.
|
||||
|
||||
package GAG;
|
||||
|
||||
import com.sun.java.swing.preview.*;
|
||||
//FileFilter of Swing1.0.2
|
||||
import ExampleFileFilter;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.awt.event.*;
|
||||
import com.sun.java.swing.*;
|
||||
import com.sun.java.swing.preview.filechooser.*;
|
||||
// for Swing-1.0.2 FileChooser
|
||||
|
||||
class ParamPanel extends JPanel implements ActionListener, ItemListener {
|
||||
private GAG gag;
|
||||
private GridBagLayout gbl; GridBagConstraints gbc;
|
||||
private JPanel paramArea;
|
||||
private JButton def, current, clear, ok, fileBrowser;
|
||||
private JComboBox history;
|
||||
private int posY;
|
||||
private GAGcommandItem ci;
|
||||
private Component paraBox[];
|
||||
private boolean isExecuting;
|
||||
private JFileChooser fileChooser;
|
||||
// FileFilter in Swing-1.0.2 test
|
||||
private ExampleFileFilter g4mFilter, macroFilter, g4macroFilter,
|
||||
txtFilter;
|
||||
|
||||
|
||||
|
||||
ParamPanel(GAG gag){
|
||||
isExecuting = false;
|
||||
this.gag = gag;
|
||||
setLayout( new BorderLayout() );
|
||||
|
||||
gbc = new GridBagConstraints();
|
||||
gbl = new GridBagLayout();
|
||||
|
||||
paramArea = new JPanel();
|
||||
paramArea.setLayout(gbl);
|
||||
paramArea.setBackground(new Color(255, 250, 230));
|
||||
add("Center", new JScrollPane(paramArea));
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setLayout(new GridLayout( 1, 0, 2, 2));
|
||||
// Yoshida color
|
||||
def = new JButton("Default");
|
||||
current = new JButton("Current");
|
||||
clear = new JButton("Clear");
|
||||
ok = new JButton("OK");
|
||||
ok.setBackground(Color.green);
|
||||
//no good?? ok.setFont(new Font("OK",1,12));
|
||||
def.setBackground(Color.blue);
|
||||
current.setBackground(Color.orange);
|
||||
clear.setBackground(SystemColor.white);
|
||||
// ok.setBackground(SystemColor.control);
|
||||
// color
|
||||
|
||||
buttons.add( def );
|
||||
buttons.add( current );
|
||||
buttons.add( clear );
|
||||
buttons.add( ok );
|
||||
add("South", buttons);
|
||||
|
||||
history = new JComboBox();
|
||||
history.addItem("# GEANT4 history macro.");
|
||||
history.addItemListener(this);
|
||||
add("North", history);
|
||||
//yoshida setinvisible and setdisable
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
def.setMargin(new Insets(1,3,1,3));
|
||||
def.addActionListener(this);
|
||||
|
||||
//yoshida
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
current.setMargin(new Insets(1,3,1,3));
|
||||
current.addActionListener(this);
|
||||
//yoshida
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
clear.setMargin(new Insets(1,3,1,3));
|
||||
clear.addActionListener(this);
|
||||
|
||||
//yoshida
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
ok.setMargin(new Insets(1,3,1,3));
|
||||
ok.addActionListener(this);
|
||||
|
||||
fileBrowser = new JButton("Open a Macro File");
|
||||
fileBrowser.addActionListener(this);
|
||||
fileChooser = new JFileChooser(".");
|
||||
// Swing 1.0.2 FileFilter OK!! 1998 June 25
|
||||
fileChooser.setDialogTitle("Macro File");
|
||||
g4mFilter = new ExampleFileFilter("g4m", "Geant4 macro");
|
||||
g4macroFilter = new ExampleFileFilter("g4macro", "Geant4 macro");
|
||||
txtFilter = new ExampleFileFilter("txt", "Geant4 macro");
|
||||
macroFilter = new ExampleFileFilter("macro", "Geant4 macro");
|
||||
|
||||
fileChooser.addChoosableFileFilter(g4mFilter);
|
||||
fileChooser.addChoosableFileFilter(g4macroFilter);
|
||||
fileChooser.addChoosableFileFilter(txtFilter);
|
||||
fileChooser.addChoosableFileFilter(macroFilter);
|
||||
|
||||
// end of Swing-1.0.2 FileChooser
|
||||
|
||||
|
||||
}
|
||||
void setParamBox(GAGcommandItem ci, boolean enable){
|
||||
paramArea.removeAll();
|
||||
this.ci = ci;
|
||||
posY = 0;
|
||||
JLabel l;
|
||||
if (!enable){
|
||||
l = new JLabel("This command is not available.");
|
||||
l.setForeground(Color.red);
|
||||
addComponent(l);
|
||||
}
|
||||
addComponent(new JLabel(ci.getCommandName()));
|
||||
String guide[] = ci.getCommandGuide();
|
||||
for (int i=0; i<guide.length; i++){
|
||||
addComponent(new JLabel(guide[i]));
|
||||
}
|
||||
if (!ci.getCommandRange().equals("")){
|
||||
l = new JLabel(ci.getCommandRange());
|
||||
l.setForeground(Color.green);
|
||||
addComponent(l);
|
||||
}
|
||||
if (ci.getParamEntries() > 0){
|
||||
def.setEnabled(true);
|
||||
//yoshida
|
||||
def.setVisible(true);
|
||||
current.setEnabled(!isExecuting && enable);
|
||||
//yoshida
|
||||
current.setVisible(!isExecuting && enable);
|
||||
clear.setEnabled(true);
|
||||
//yoshida
|
||||
clear.setVisible(true);
|
||||
paraBox = new JComponent[ci.getParamEntries()];
|
||||
String candidateList;
|
||||
for (int i=0; i<ci.getParamEntries(); i++){
|
||||
candidateList = ci.getParamCandidate(i);
|
||||
if (candidateList.equals("")){
|
||||
if (ci.getParamType(i).equals("b")){
|
||||
paraBox[i] = new BooleanCombo(ci.getParamDefault(i));
|
||||
}else{
|
||||
paraBox[i] = new JTextField(20);
|
||||
((JTextField)paraBox[i]).setText(ci.getParamDefault(i));
|
||||
}
|
||||
}else{
|
||||
paraBox[i] = new JComboBox();
|
||||
StringTokenizer st = new StringTokenizer(candidateList);
|
||||
while(st.hasMoreTokens()){
|
||||
((JComboBox)paraBox[i]).addItem(st.nextToken());
|
||||
}
|
||||
if (!ci.getParamDefault(i).equals("")){
|
||||
((JComboBox)paraBox[i]).setSelectedItem(ci.getParamDefault(i));
|
||||
}
|
||||
}
|
||||
addComponent(new JLabel(ci.getParamName(i)), paraBox[i], new JLabel("("+ci.getParamType(i) +") "+ci.getParamGuide(i) ));
|
||||
if (ci.getParamName(i).equals("fileName")) addComponent(new JLabel(), fileBrowser);
|
||||
}
|
||||
}else{
|
||||
//yoshida setinvisible and then setdisable
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
}
|
||||
ok.setEnabled(!isExecuting && enable);
|
||||
//yoshida OK button order of enable and visible is important
|
||||
ok.setVisible(!isExecuting && enable);
|
||||
|
||||
validate();
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
void setTreeHelp(String dirHelp, JLabel helps[][]){
|
||||
//yoshida setinvisible then setdisable
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
def.setVisible(false);
|
||||
def.setEnabled(false);
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
clear.setVisible(false);
|
||||
clear.setEnabled(false);
|
||||
//
|
||||
paramArea.removeAll();
|
||||
posY = 0; ci = null;
|
||||
JLabel title = new JLabel(dirHelp);
|
||||
title.setForeground(Color.green);
|
||||
addComponent(title);
|
||||
for (int i=0; i<helps[0].length; i++){
|
||||
addComponent(helps[0][i], helps[1][i]);
|
||||
}
|
||||
validate();
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
private String makeCommandLine(){
|
||||
StringBuffer param = new StringBuffer(ci.getCommandName());
|
||||
if (ci.getParamEntries() > 0){
|
||||
String val;
|
||||
for (int i=0; i<ci.getParamEntries(); i++){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
val = (((JTextField)paraBox[i]).getText()).trim();
|
||||
if (val.equals("")){
|
||||
if (!ci.isOmittable(i)){
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot omitted.", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}else{
|
||||
if (!ci.getParamDefault(i).equals(""))
|
||||
val = ci.getParamDefault(i);
|
||||
else{
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis omittable parameter has not default value.", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}else if ( val.indexOf(" ") >= 0){
|
||||
JOptionPane.showMessageDialog(this, ci.getParamName(i)+"\nThis parameter cannot include SPACE character", "Error", JOptionPane.WARNING_MESSAGE);
|
||||
return null;
|
||||
}
|
||||
}else{
|
||||
val = (String)((JComboBox)paraBox[i]).getSelectedItem();
|
||||
}
|
||||
param.append(" "+val);
|
||||
}
|
||||
//yoshida
|
||||
current.setVisible(false);
|
||||
current.setEnabled(false);
|
||||
}
|
||||
//yoshida
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
history.addItem(param.toString());
|
||||
return param.toString();
|
||||
}
|
||||
private void addComponent(Component compo){
|
||||
gbc.gridx = 0; gbc.gridy = posY++;
|
||||
gbc.gridwidth = 3; gbc.gridheight = 1;
|
||||
gbc.weightx = 1.0; gbc.weighty = 0.0;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo, gbc);
|
||||
paramArea.add(compo);
|
||||
}
|
||||
private void addComponent(Component compo1, Component compo2){
|
||||
gbc.gridx = 0; gbc.gridy = posY;
|
||||
gbc.gridwidth = 1; gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0; gbc.weighty = 0.0;
|
||||
gbc.anchor = GridBagConstraints.EAST;
|
||||
gbl.setConstraints(compo1, gbc);
|
||||
paramArea.add(compo1);
|
||||
gbc.gridx = 1;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo2, gbc);
|
||||
paramArea.add(compo2);
|
||||
posY++;
|
||||
}
|
||||
private void addComponent(Component title, Component compo1, Component compo2){
|
||||
gbc.gridx = 0; gbc.gridy = posY;
|
||||
gbc.gridwidth = 1; gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0; gbc.weighty = 0.0;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.anchor = GridBagConstraints.EAST;
|
||||
gbl.setConstraints(title, gbc);
|
||||
paramArea.add(title);
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbl.setConstraints(compo1, gbc);
|
||||
paramArea.add(compo1);
|
||||
gbc.gridx = 2;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.anchor = GridBagConstraints.WEST;
|
||||
gbl.setConstraints(compo2, gbc);
|
||||
paramArea.add(compo2);
|
||||
posY++;
|
||||
}
|
||||
private void loadValue(int i, String str){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
((JTextField)paraBox[i]).setText(str);
|
||||
}
|
||||
if (paraBox[i] instanceof JComboBox){
|
||||
((JComboBox)paraBox[i]).setSelectedItem(str);
|
||||
}
|
||||
}
|
||||
void addHistory(String line){
|
||||
if (line.startsWith("/")) history.addItem(line);
|
||||
}
|
||||
void clearAllHistory(){
|
||||
history.removeAllItems();
|
||||
}
|
||||
void clearOneHistory(){
|
||||
int ix = history.getSelectedIndex();
|
||||
if (ix >= 0) history.removeItemAt(ix);
|
||||
}
|
||||
String[] getHistoryItems(){
|
||||
String[] item = new String[history.getItemCount()];
|
||||
for (int i=0; i>history.getItemCount(); i++){
|
||||
item[i] = (String)history.getItemAt(i);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
void loadCurrentValues(String line){
|
||||
StringTokenizer st = new StringTokenizer( line );
|
||||
st.nextToken();
|
||||
int i=0;
|
||||
while(st.hasMoreTokens()){
|
||||
loadValue(i++, st.nextToken());
|
||||
}
|
||||
}
|
||||
public void itemStateChanged(ItemEvent ie){
|
||||
if (isExecuting) return;
|
||||
if (ie.getStateChange() != ItemEvent.SELECTED) return;
|
||||
String str = (String)ie.getItem();
|
||||
if ( !str.startsWith("/") ) return;
|
||||
StringTokenizer st = new StringTokenizer( str );
|
||||
if (!gag.setParamPanel(st.nextToken())) return;
|
||||
int i=0;
|
||||
while(st.hasMoreTokens()){
|
||||
loadValue(i++, st.nextToken());
|
||||
if (i >= ci.getParamEntries()) return;
|
||||
}
|
||||
}
|
||||
public void actionPerformed(ActionEvent ev){
|
||||
Object source = ev.getSource();
|
||||
if ( source == ok ){
|
||||
String p = makeCommandLine();
|
||||
if (p == null) return;
|
||||
isExecuting = true;
|
||||
gag.sendCommand(p);
|
||||
//yoshida instead of sandwatch, ok button becomes invisible
|
||||
ok.setVisible(false);
|
||||
ok.setEnabled(false);
|
||||
// Be careful! mouse may freeze, if setinvisible but not setdisabled!!
|
||||
return;
|
||||
}else if (source == def){
|
||||
for (int i=0; ci.getParamEntries()>i; i++){
|
||||
loadValue(i, ci.getParamDefault(i));
|
||||
}
|
||||
return;
|
||||
}else if (source == current){
|
||||
gag.reqCurrent(ci.getCommandName());
|
||||
return;
|
||||
}else if (source == clear){
|
||||
for (int i=0; ci.getParamEntries()>i; i++){
|
||||
if (paraBox[i] instanceof JTextField){
|
||||
((JTextField)paraBox[i]).setText("");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}else if (source == fileBrowser){
|
||||
//swing102 filechooser showDialog(this, null) or the next
|
||||
if (fileChooser.showOpenDialog(this) == -1 ) return;
|
||||
File f = fileChooser.getSelectedFile();
|
||||
if (f.isFile()) {
|
||||
if (paraBox[0] instanceof JTextField){
|
||||
((JTextField)paraBox[0]).setText(f.getPath());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
void toReady(){
|
||||
isExecuting = false;
|
||||
if (ci == null) return;
|
||||
ok.setEnabled(true);
|
||||
//yoshida setenable then setvisible
|
||||
ok.setVisible(true);
|
||||
if (ci.getParamEntries() == 0) return;
|
||||
current.setEnabled(true);
|
||||
//yoshida
|
||||
current.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanCombo extends JComboBox {
|
||||
BooleanCombo(String str){
|
||||
String def = str.toUpperCase();
|
||||
if (def.equals("0") || def.equals("1")){
|
||||
addItem("0");
|
||||
addItem("1");
|
||||
}else if (def.equals("Y") || def.equals("N")){
|
||||
addItem("Y");
|
||||
addItem("N");
|
||||
}else if (def.equals("YES") || def.equals("NO")){
|
||||
addItem("YES");
|
||||
addItem("NO");
|
||||
}else if (def.equals("T") || def.equals("F")){
|
||||
addItem("T");
|
||||
addItem("F");
|
||||
} else {
|
||||
addItem("FALSE");
|
||||
addItem("TRUE");
|
||||
}
|
||||
if (!def.equals("")){
|
||||
setSelectedItem(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
1998 June 25 Yoshida
|
||||
|
||||
Improve look-and-feel of GAG by KOdama (as of 31/March/1998).
|
||||
|
||||
|
||||
Swing-1.0.1 is used.
|
||||
Swing-1.0.2 is desirable, but wait a moment. Swing-1.0.2 has
|
||||
not yet frozen classes and interfaces, among them JColorChooser
|
||||
and JFileChooser.
|
||||
They are left as before in swing.preview package!!
|
||||
|
||||
|
||||
Swing-1.0.2 JFileChooser is good for us since it allows file filtering,
|
||||
free label on buttons etc..
|
||||
|
||||
But it is better to wait JDK1.2!!
|
||||
|
||||
|
||||
So there is only minor improvements.
|
||||
|
||||
Font is one of the most iportant improvement.
|
||||
Current fonts are too small or not beautiful.
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.datatransfer.*;
|
||||
|
||||
class EditMan extends Object implements ActionListener, ClipboardOwner
|
||||
{
|
||||
// remember stuff
|
||||
|
||||
private TextEdit textEdit;
|
||||
private TextCanvas textCanvas;
|
||||
private String undoString = new String("Undo");
|
||||
private String redoString = new String("Redo");
|
||||
private String copyString = new String("Copy");
|
||||
private String cutString = new String("Cut");
|
||||
private String pasteString = new String("Paste");
|
||||
private String findString = new String("Find");
|
||||
private String replaceString = new String("Replace");
|
||||
private MenuItem undoItem;
|
||||
private MenuItem redoItem;
|
||||
private MenuItem copyItem;
|
||||
private MenuItem cutItem;
|
||||
private Clipboard clipboard;
|
||||
|
||||
private FindDialog findDialog = null;
|
||||
private String findPattern = null;
|
||||
private ReplaceDialog replaceDialog = null;
|
||||
private String ReplacePattern = null;
|
||||
private String ReplaceReplace = null;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public EditMan(TextEdit p)
|
||||
{
|
||||
textEdit = p;
|
||||
textCanvas = textEdit.getCanvas();
|
||||
clipboard = textEdit.getToolkit().getSystemClipboard();
|
||||
}
|
||||
|
||||
public void addItems(Menu menu)
|
||||
{
|
||||
MenuItem item;
|
||||
undoItem = new MenuItem(undoString, new MenuShortcut(KeyEvent.VK_Z,false));
|
||||
undoItem.setActionCommand(undoString);
|
||||
undoItem.setEnabled(false);
|
||||
menu.add(undoItem);
|
||||
redoItem = new MenuItem(redoString, new MenuShortcut(KeyEvent.VK_Y,false));
|
||||
redoItem.setActionCommand(redoString);
|
||||
redoItem.setEnabled(false);
|
||||
menu.add(redoItem);
|
||||
menu.addSeparator();
|
||||
copyItem = new MenuItem(copyString, new MenuShortcut(KeyEvent.VK_C,false));
|
||||
copyItem.setActionCommand(copyString);
|
||||
copyItem.setEnabled(false);
|
||||
menu.add(copyItem);
|
||||
cutItem = new MenuItem(cutString, new MenuShortcut(KeyEvent.VK_X,false));
|
||||
cutItem.setActionCommand(cutString);
|
||||
cutItem.setEnabled(false);
|
||||
menu.add(cutItem);
|
||||
item = new MenuItem(pasteString, new MenuShortcut(KeyEvent.VK_V,false));
|
||||
item.setActionCommand(pasteString);
|
||||
menu.add(item);
|
||||
menu.addSeparator();
|
||||
item = new MenuItem(findString, new MenuShortcut(KeyEvent.VK_F,false));
|
||||
item.setActionCommand(findString);
|
||||
menu.add(item);
|
||||
item = new MenuItem(replaceString, new MenuShortcut(KeyEvent.VK_H,false));
|
||||
item.setActionCommand(replaceString);
|
||||
menu.add(item);
|
||||
menu.addActionListener(this);
|
||||
|
||||
textCanvas.setEditMan(this);
|
||||
}
|
||||
|
||||
public void updateCopyItems(boolean have_selection)
|
||||
{
|
||||
copyItem.setEnabled(have_selection);
|
||||
cutItem.setEnabled(have_selection);
|
||||
}
|
||||
|
||||
public void updateUndoItems(boolean have_undo, boolean have_redo)
|
||||
{
|
||||
undoItem.setEnabled(have_undo);
|
||||
redoItem.setEnabled(have_redo);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
String cmd = evt.getActionCommand();
|
||||
|
||||
if (cmd == null)
|
||||
return;
|
||||
|
||||
if (cmd.equals(undoString))
|
||||
{
|
||||
textCanvas.undo(true);
|
||||
}
|
||||
if (cmd.equals(redoString))
|
||||
{
|
||||
textCanvas.undo(false);
|
||||
}
|
||||
else
|
||||
if (cmd.equals(copyString))
|
||||
{
|
||||
// Implement Copy operation
|
||||
String srcData = textCanvas.copy(false);
|
||||
if (srcData != null)
|
||||
{
|
||||
StringSelection contents = new StringSelection(srcData);
|
||||
clipboard.setContents(contents, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (cmd.equals(cutString))
|
||||
{
|
||||
// Implement Copy operation
|
||||
String srcData = textCanvas.copy(true);
|
||||
if (srcData != null)
|
||||
{
|
||||
StringSelection contents = new StringSelection(srcData);
|
||||
clipboard.setContents(contents, this);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (cmd.equals(pasteString))
|
||||
{
|
||||
String dstData;
|
||||
// Implement Paste operation
|
||||
Transferable content = clipboard.getContents(this);
|
||||
if (content != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
dstData = (String)content.getTransferData(DataFlavor.stringFlavor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Could not read clipboard");
|
||||
return;
|
||||
}
|
||||
textCanvas.paste(dstData);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (cmd.equals(findString))
|
||||
{
|
||||
if (findDialog == null)
|
||||
findDialog = new FindDialog(textEdit,this,findPattern);
|
||||
findDialog.show();
|
||||
}
|
||||
else
|
||||
if (cmd.equals(replaceString))
|
||||
{
|
||||
if (replaceDialog == null)
|
||||
replaceDialog = new ReplaceDialog(textEdit,this,ReplacePattern,ReplaceReplace);
|
||||
replaceDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseFindDialog(String pat)
|
||||
{
|
||||
findDialog = null;
|
||||
findPattern = new String(pat);
|
||||
}
|
||||
|
||||
public void CloseReplaceDialog(String pat, String rep)
|
||||
{
|
||||
replaceDialog = null;
|
||||
ReplacePattern = new String(pat);
|
||||
ReplaceReplace = new String(rep);
|
||||
}
|
||||
|
||||
public void lostOwnership(Clipboard clipboard, Transferable contents)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class FindDialog extends Frame implements WindowListener, ActionListener
|
||||
{
|
||||
private Button fbutton,cbutton;
|
||||
private EditMan editMan;
|
||||
private TextEdit textEdit;
|
||||
private TextField pattern;
|
||||
|
||||
public FindDialog(TextEdit te, EditMan em, String pat)
|
||||
{
|
||||
super("Find");
|
||||
|
||||
setBackground(Color.lightGray);
|
||||
|
||||
textEdit = te;
|
||||
editMan = em;
|
||||
|
||||
Panel p1 = new Panel();
|
||||
p1.setLayout(new FlowLayout());
|
||||
p1.add(new Label("Find:"));
|
||||
|
||||
|
||||
pattern = new TextField();
|
||||
pattern.setColumns(35);
|
||||
|
||||
if (pat != null)
|
||||
pattern.setText(pat);
|
||||
|
||||
p1.add(pattern);
|
||||
p1.doLayout();
|
||||
add("North", p1);
|
||||
|
||||
Panel p2 = new Panel();
|
||||
fbutton = new Button("Find Next");
|
||||
fbutton.addActionListener(this);
|
||||
p2.add(fbutton);
|
||||
cbutton = new Button("Cancel");
|
||||
cbutton.addActionListener(this);
|
||||
p2.add(cbutton);
|
||||
add("South",p2);
|
||||
setSize(400,110);
|
||||
|
||||
addWindowListener(this);
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
editMan.CloseFindDialog(pattern.getText());
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (evt.getSource() == cbutton)
|
||||
{
|
||||
editMan.CloseFindDialog(pattern.getText());
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.getSource() == fbutton)
|
||||
if (!textEdit.getCanvas().find(pattern.getText()))
|
||||
{
|
||||
NotFound nf = new NotFound(textEdit);
|
||||
nf.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ReplaceDialog extends Frame implements WindowListener, ActionListener
|
||||
{
|
||||
private Button fbutton,rbutton,cbutton;
|
||||
private TextField pattern;
|
||||
private TextField replace;
|
||||
private TextEdit textEdit;
|
||||
private EditMan editMan;
|
||||
boolean foundOnce = false;
|
||||
|
||||
public ReplaceDialog(TextEdit p, EditMan em, String pat, String rep)
|
||||
{
|
||||
super("Find and Replace");
|
||||
|
||||
setBackground(Color.lightGray);
|
||||
|
||||
textEdit = p;
|
||||
editMan = em;
|
||||
Panel p1 = new Panel();
|
||||
|
||||
GridBagLayout gridbag = new GridBagLayout();
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
p1.setLayout(gridbag);
|
||||
|
||||
Label flabel = new Label("Find:");
|
||||
constraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
gridbag.setConstraints(flabel, constraints);
|
||||
|
||||
pattern = new TextField();
|
||||
pattern.setColumns(35);
|
||||
|
||||
if (pat != null)
|
||||
pattern.setText(pat);
|
||||
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
gridbag.setConstraints(pattern, constraints);
|
||||
|
||||
p1.add(flabel);
|
||||
p1.add(pattern);
|
||||
|
||||
Label rlabel = new Label("Replace:");
|
||||
constraints.anchor = GridBagConstraints.WEST;
|
||||
constraints.gridwidth = 1;
|
||||
gridbag.setConstraints(rlabel, constraints);
|
||||
|
||||
replace = new TextField();
|
||||
replace.setColumns(35);
|
||||
|
||||
if (rep != null)
|
||||
replace.setText(rep);
|
||||
|
||||
constraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||
gridbag.setConstraints(replace, constraints);
|
||||
|
||||
p1.add(rlabel);
|
||||
p1.add(replace);
|
||||
|
||||
add("Center", p1);
|
||||
|
||||
Panel p3 = new Panel();
|
||||
fbutton = new Button("Find Next");
|
||||
fbutton.addActionListener(this);
|
||||
p3.add(fbutton);
|
||||
rbutton = new Button("Replace");
|
||||
rbutton.addActionListener(this);
|
||||
p3.add(rbutton);
|
||||
cbutton = new Button("Cancel");
|
||||
cbutton.addActionListener(this);
|
||||
p3.add(cbutton);
|
||||
add("South",p3);
|
||||
setSize(400,120);
|
||||
|
||||
addWindowListener(this);
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
editMan.CloseReplaceDialog(pattern.getText(),replace.getText());
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (evt.getSource() == cbutton)
|
||||
{
|
||||
editMan.CloseReplaceDialog(pattern.getText(),replace.getText());
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.getSource() == fbutton)
|
||||
foundOnce = textEdit.getCanvas().find(pattern.getText());
|
||||
else
|
||||
if (evt.getSource() == rbutton)
|
||||
{
|
||||
if (!foundOnce)
|
||||
{
|
||||
TextCanvas textCanvas = textEdit.getCanvas();
|
||||
String selection= textCanvas.copy(false);
|
||||
if (selection != null)
|
||||
foundOnce = selection.equals(pattern.getText());
|
||||
}
|
||||
|
||||
if (foundOnce)
|
||||
textEdit.getCanvas().paste(replace.getText());
|
||||
|
||||
foundOnce = textEdit.getCanvas().find(pattern.getText());
|
||||
}
|
||||
|
||||
if (!foundOnce)
|
||||
{
|
||||
NotFound nf = new NotFound(textEdit);
|
||||
nf.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NotFound extends Dialog implements WindowListener, ActionListener
|
||||
{
|
||||
private Button okButton;
|
||||
|
||||
public NotFound(TextEdit te)
|
||||
{
|
||||
super(te,"",true);
|
||||
|
||||
Panel north = new Panel();
|
||||
north.add(new Label("String not found"));
|
||||
add("North", north);
|
||||
|
||||
okButton = new Button("OK");
|
||||
okButton.addActionListener(this);
|
||||
Panel south = new Panel();
|
||||
south.add(okButton);
|
||||
add("South", south);
|
||||
|
||||
setSize(200,110);
|
||||
|
||||
addWindowListener(this);
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (evt.getSource() == okButton)
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
// This extension of Dialog implements modal dialogs with a callback interface
|
||||
// to work around the "modal dialog problem" on Windows. The "NoteListener"
|
||||
// interface is used to return an action code to the parent when "continue" is
|
||||
// pressed.
|
||||
|
||||
class Note extends Dialog implements WindowListener, ActionListener
|
||||
{
|
||||
int noteAction;
|
||||
NoteListener noteListener;
|
||||
Button accepted;
|
||||
Button whatever;
|
||||
|
||||
// Constructor takes a string and an action. Note that action == 0 implies
|
||||
// that there is only an "ok" button, while action != 0 implies a "Continue" and
|
||||
// a "Cancel" button.
|
||||
|
||||
public Note(Frame parent, String s, int action)
|
||||
{
|
||||
super(parent, "Note", true);
|
||||
|
||||
noteListener = (NoteListener)parent;
|
||||
noteAction = action;
|
||||
|
||||
Panel center = new Panel();
|
||||
center.add(new Label(s));
|
||||
add("Center", center);
|
||||
|
||||
Panel south = new Panel();
|
||||
|
||||
if (action != 0)
|
||||
{
|
||||
accepted = new Button("Continue");
|
||||
accepted.addActionListener(this);
|
||||
south.add(accepted);
|
||||
whatever = new Button("Cancel");
|
||||
whatever.addActionListener(this);
|
||||
south.add(whatever);
|
||||
}
|
||||
else
|
||||
{
|
||||
whatever = new Button("Ok");
|
||||
whatever.addActionListener(this);
|
||||
south.add(whatever);
|
||||
}
|
||||
|
||||
add("South", south);
|
||||
|
||||
setSize(300, 100);
|
||||
|
||||
addWindowListener(this);
|
||||
}
|
||||
|
||||
// if we get a "Continue" button, call the parent's noteListener
|
||||
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
Object source;
|
||||
|
||||
source = event.getSource();
|
||||
|
||||
if (source == accepted)
|
||||
{
|
||||
setVisible(false);
|
||||
setModal(false);
|
||||
noteListener.noteListen(noteAction);
|
||||
}
|
||||
|
||||
if ((source == accepted) || (source == whatever))
|
||||
dispose();
|
||||
}
|
||||
|
||||
// add the 1.1 WindowListener stuff
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
|
||||
public void windowClosing(WindowEvent event) {
|
||||
dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
interface NoteListener
|
||||
{
|
||||
public void noteListen(int action);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
public class PrintMan extends Thread
|
||||
{
|
||||
|
||||
private PrintJob pjob;
|
||||
private Vector spool;
|
||||
private Font font;
|
||||
private Frame parent;
|
||||
private String jobName;
|
||||
private int tabsize;
|
||||
|
||||
private final int PRINT_PROGRESS = 10000;
|
||||
|
||||
public PrintMan(Frame p, String n, Vector lines, Font f, int t)
|
||||
{
|
||||
int i,max,part,tens;
|
||||
|
||||
parent = p;
|
||||
jobName = n;
|
||||
font = f;
|
||||
tabsize = t;
|
||||
|
||||
max = lines.size();
|
||||
spool = new Vector(max);
|
||||
tens = max / 10;
|
||||
part = 0;
|
||||
|
||||
Progress spoolProgress = null;
|
||||
|
||||
if (max > PRINT_PROGRESS)
|
||||
{
|
||||
spoolProgress = new Progress(parent,"Saving print copy ... ");
|
||||
spoolProgress.show();
|
||||
}
|
||||
|
||||
for (i=0;i<max;i++)
|
||||
{
|
||||
spool.addElement( new String((String)lines.elementAt(i)) );
|
||||
if (max > PRINT_PROGRESS)
|
||||
part++;
|
||||
if (part > tens)
|
||||
{
|
||||
spoolProgress.update( (int)(100 * i / max) );
|
||||
part = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (spoolProgress != null)
|
||||
spoolProgress.dispose();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
pjob = parent.getToolkit().getPrintJob(parent, jobName, null);
|
||||
|
||||
if (pjob == null)
|
||||
return;
|
||||
|
||||
Graphics pg = pjob.getGraphics();
|
||||
|
||||
if (pg != null)
|
||||
{
|
||||
String nextLine;
|
||||
int pageHeight = pjob.getPageDimension().height;
|
||||
pg.setFont(font);
|
||||
FontMetrics fm = pg.getFontMetrics(font);
|
||||
int fontHeight = fm.getHeight();
|
||||
int fontDescent = fm.getDescent();
|
||||
int curHeight = 0;
|
||||
|
||||
for (int i = 0; i < spool.size(); i++ )
|
||||
{
|
||||
curHeight += fontHeight;
|
||||
if (curHeight > pageHeight)
|
||||
{
|
||||
pg.dispose();
|
||||
pg = pjob.getGraphics();
|
||||
if (pg == null)
|
||||
return;
|
||||
pg.setFont(font);
|
||||
curHeight = fontHeight;
|
||||
}
|
||||
nextLine = detabbed((String)spool.elementAt(i),tabsize);
|
||||
pg.drawString(nextLine, 0, curHeight - fontDescent);
|
||||
}
|
||||
|
||||
pg.dispose();
|
||||
}
|
||||
|
||||
pjob.end();
|
||||
}
|
||||
|
||||
private String detabbed(String s, int tabSize)
|
||||
{
|
||||
if (s.indexOf('\t') < 0)
|
||||
return s;
|
||||
|
||||
char c;
|
||||
String t = new String("");
|
||||
int j=0;
|
||||
int tabs;
|
||||
int max = s.length();
|
||||
|
||||
for (int i=0; i<max; i++)
|
||||
{
|
||||
c = s.charAt(i);
|
||||
if (c == '\t')
|
||||
{
|
||||
tabs = tabSize - (j % tabSize);
|
||||
j += tabs;
|
||||
while (tabs-- > 0) t = t + ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
t = t + c;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
// This extension of Dialog implements modal dialogs with a callback interface
|
||||
// to work around the "modal dialog problem" on Windows. The "NoteListener"
|
||||
// interface is used to return an action code to the parent when "continue" is
|
||||
// pressed.
|
||||
|
||||
class Progress extends Dialog
|
||||
{
|
||||
Panel center;
|
||||
|
||||
public Progress(Frame parent, String s)
|
||||
{
|
||||
super(parent);
|
||||
|
||||
Panel north = new Panel();
|
||||
north.add(new Label(s));
|
||||
add("North", north);
|
||||
|
||||
center = new Panel();
|
||||
add("Center", center);
|
||||
|
||||
setSize(300, 100);
|
||||
}
|
||||
|
||||
public void update( int percent )
|
||||
{
|
||||
Dimension d = center.getSize();
|
||||
Graphics g = center.getGraphics();
|
||||
|
||||
int fifth = d.width / 5;
|
||||
int third = d.height / 3;
|
||||
|
||||
g.fillRect( fifth, third, (fifth * 3 * percent) / 100, third);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
class TextCursor extends Thread
|
||||
{
|
||||
private TextCanvas canvas;
|
||||
private boolean flash;
|
||||
private boolean undraw; // true when the next draw erases
|
||||
private Rectangle r;
|
||||
|
||||
public TextCursor(TextCanvas c)
|
||||
{
|
||||
canvas = c;
|
||||
r = new Rectangle();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
sync_draw();
|
||||
try { sleep(400); }
|
||||
catch(InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void sync_draw()
|
||||
{
|
||||
if (flash)
|
||||
draw_or_undraw();
|
||||
}
|
||||
|
||||
public boolean getUndraw()
|
||||
{
|
||||
return undraw;
|
||||
}
|
||||
|
||||
public synchronized void pause_cursor(boolean draw)
|
||||
{
|
||||
// if (draw && undraw)
|
||||
if (undraw)
|
||||
draw_or_undraw();
|
||||
flash = false;
|
||||
}
|
||||
|
||||
public synchronized void release_cursor(boolean draw)
|
||||
{
|
||||
if (!undraw)
|
||||
draw_or_undraw();
|
||||
flash = true;
|
||||
}
|
||||
|
||||
private boolean draw_or_undraw()
|
||||
{
|
||||
Graphics g = canvas.getGraphics();
|
||||
|
||||
if (g != null)
|
||||
{
|
||||
if (!undraw)
|
||||
canvas.getCursorPos(g,r);
|
||||
g.setXORMode(Color.white);
|
||||
g.drawLine(r.x, r.y, r.x, r.y+r.height);
|
||||
undraw = !undraw;
|
||||
g.dispose();
|
||||
}
|
||||
return undraw;
|
||||
}
|
||||
|
||||
// public static void dumpStack() {new Exception("Stack trace").printStackTrace();}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import GAG.*;
|
||||
|
||||
public class TextEdit extends Frame implements GAGtextEditor, NoteListener, WindowListener
|
||||
{
|
||||
// The NoteListen member fuction of NoteListener is overridded to support
|
||||
// the following actions.
|
||||
|
||||
final private int NOACTION = 0;
|
||||
final private int NEWFILE = 1;
|
||||
final private int OPENFILE = 2;
|
||||
final private int QUITAPP = 3;
|
||||
|
||||
// allocate standard components of TextEdit as part of initialization:
|
||||
|
||||
public File file = new File("Untitled");
|
||||
|
||||
private String openPrompt = new String("Open text file");
|
||||
private String closePrompt = new String("Save file as");
|
||||
|
||||
// initialize some state flags
|
||||
|
||||
private boolean neverNamed = true;
|
||||
private boolean menuBusy = false;
|
||||
|
||||
// these three .. no four! .. four objects form the main window
|
||||
|
||||
private Scrollbar horiz;
|
||||
private Scrollbar vert;
|
||||
private TextCanvas textCanvas;
|
||||
private TextMenu textMenu;
|
||||
|
||||
// font
|
||||
|
||||
private String fontString = new String("Courier");
|
||||
private int fontSize = 12;
|
||||
private int tabSize = 4;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public TextEdit() {
|
||||
this.setTitle();
|
||||
|
||||
vert = new Scrollbar(Scrollbar.VERTICAL);
|
||||
add("East", vert);
|
||||
horiz = new Scrollbar(Scrollbar.HORIZONTAL);
|
||||
add("South", horiz);
|
||||
|
||||
textCanvas = new TextCanvas(this,horiz,vert);
|
||||
add("Center", textCanvas);
|
||||
textCanvas.setFont(fontString,fontSize);
|
||||
addKeyListener(textCanvas);
|
||||
|
||||
textMenu = new TextMenu(this);
|
||||
setMenuBar(textMenu);
|
||||
|
||||
addWindowListener(this);
|
||||
|
||||
setSize(500, 400);
|
||||
setVisible(true);
|
||||
try { Thread.sleep(400); } catch(InterruptedException e) {}
|
||||
}
|
||||
public void writeString(String s){
|
||||
textCanvas.writeString(s);
|
||||
}
|
||||
public void writeLine(String s){
|
||||
textCanvas.writeLine(s);
|
||||
}
|
||||
|
||||
// allow others to go straight to the canvas
|
||||
public TextCanvas getCanvas() {
|
||||
return textCanvas;
|
||||
}
|
||||
|
||||
// add current filename to window title
|
||||
|
||||
private void setTitle(){
|
||||
super.setTitle("TextEdit - " + file.getName());
|
||||
}
|
||||
|
||||
// add the 1.1 WindowListener stuff
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
|
||||
public void windowClosing(WindowEvent event) {
|
||||
if (isItSafe(QUITAPP))
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// high level command processors (invoked my menu)
|
||||
|
||||
public void setFont(String fs) {
|
||||
fontString = fs;
|
||||
textCanvas.setFont(fontString, fontSize);
|
||||
}
|
||||
|
||||
public void setFontSize(int s) {
|
||||
fontSize = s;
|
||||
textCanvas.setFont(fontString, fontSize);
|
||||
}
|
||||
|
||||
public void setTabSize(int s) {
|
||||
tabSize = s;
|
||||
textCanvas.setTab(tabSize);
|
||||
}
|
||||
|
||||
public int getTabSize() {
|
||||
return tabSize;
|
||||
}
|
||||
|
||||
public void cmdFileNew() {
|
||||
if (isItSafe(NEWFILE))
|
||||
newFile();
|
||||
}
|
||||
|
||||
public void cmdFileOpen() {
|
||||
if (isItSafe(OPENFILE))
|
||||
openFile();
|
||||
}
|
||||
|
||||
public void cmdFileSave() {
|
||||
saveFile(false);
|
||||
}
|
||||
|
||||
public void cmdFileSaveAs() {
|
||||
saveFile(true);
|
||||
}
|
||||
|
||||
public void cmdPrint() {
|
||||
textCanvas.print(file.getName());
|
||||
}
|
||||
|
||||
public void cmdFileQuit() {
|
||||
if (isItSafe(QUITAPP))
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// if the file has been modified (dirty), fire off a notify dialog
|
||||
// and pass it the "action" you want returned to noteListen. This
|
||||
// dataflow beats the "modal dialog problem" on Windows
|
||||
|
||||
// I believe isItSafe is what Laurence Olivier said repeatedly to
|
||||
// Dustan Hoffman in Marathon Man.
|
||||
|
||||
private boolean isItSafe(int action) {
|
||||
if (textCanvas.isDirty())
|
||||
{
|
||||
notify( "The current file has not been saved. ", action );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
// implementation of the NoteListener interface - it does whatever
|
||||
// action the user agreed to by pressing "Continue" on a modal dialog
|
||||
|
||||
public void noteListen(int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case NOACTION:
|
||||
break;
|
||||
case NEWFILE:
|
||||
newFile();
|
||||
break;
|
||||
case OPENFILE:
|
||||
openFile();
|
||||
break;
|
||||
case QUITAPP:
|
||||
System.exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// clear out the document
|
||||
|
||||
private void newFile()
|
||||
{
|
||||
neverNamed = true;
|
||||
file = new File("Untitled");
|
||||
this.setTitle();
|
||||
textCanvas.clear();
|
||||
textCanvas.validate();
|
||||
}
|
||||
|
||||
// call getFile to get a file path, and if you get one open it
|
||||
|
||||
private void openFile()
|
||||
{
|
||||
if (getFile(FileDialog.LOAD))
|
||||
openTheFile();
|
||||
}
|
||||
|
||||
public void openTheFile()
|
||||
{
|
||||
textCanvas.read(file);
|
||||
textCanvas.validate();
|
||||
neverNamed = false;
|
||||
this.setTitle();
|
||||
}
|
||||
|
||||
// call getFile to get a file path, and if you get one save to it
|
||||
|
||||
private void saveFile(boolean As)
|
||||
{
|
||||
boolean ok;
|
||||
|
||||
if (neverNamed || As)
|
||||
{
|
||||
ok = getFile(FileDialog.SAVE);
|
||||
neverNamed = false;
|
||||
}
|
||||
else
|
||||
ok = true;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
textCanvas.write(file);
|
||||
neverNamed = false;
|
||||
this.setTitle();
|
||||
}
|
||||
}
|
||||
|
||||
// use FileDialog to get a filepath
|
||||
|
||||
private boolean getFile(int mode)
|
||||
{
|
||||
String prompt;
|
||||
String filename;
|
||||
String pathname;
|
||||
|
||||
if (mode == FileDialog.LOAD)
|
||||
prompt = openPrompt;
|
||||
else
|
||||
prompt = closePrompt;
|
||||
|
||||
FileDialog d = new FileDialog(this, prompt, mode);
|
||||
|
||||
if (mode == FileDialog.LOAD)
|
||||
d.setFile("*");
|
||||
else
|
||||
d.setFile(file.getName());
|
||||
|
||||
d.setDirectory(".");
|
||||
d.setVisible(true);
|
||||
|
||||
filename = d.getFile();
|
||||
|
||||
pathname = d.getDirectory() + filename;
|
||||
|
||||
d.dispose();
|
||||
|
||||
if (filename != null)
|
||||
{
|
||||
file = new File(pathname);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// launch a note
|
||||
|
||||
private void notify(String s, int action) {
|
||||
Note note = new Note(this,s,action);
|
||||
note.setVisible(true);
|
||||
}
|
||||
|
||||
// main declares the TextEdit frame which does everything
|
||||
|
||||
public static void main(String[] args) {
|
||||
TextEdit f = new TextEdit();
|
||||
if (args.length > 0) {
|
||||
f.file = new File(args[0]);
|
||||
if (f.file.isFile())
|
||||
f.openTheFile();
|
||||
else
|
||||
f.notify("File not found: "+args[0],0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class TextEdit extends Frame implements NoteListener, WindowListener
|
||||
{
|
||||
// The NoteListen member fuction of NoteListener is overridded to support
|
||||
// the following actions.
|
||||
|
||||
final private int NOACTION = 0;
|
||||
final private int NEWFILE = 1;
|
||||
final private int OPENFILE = 2;
|
||||
final private int QUITAPP = 3;
|
||||
|
||||
// allocate standard components of TextEdit as part of initialization:
|
||||
|
||||
public File file = new File("Untitled");
|
||||
|
||||
private String openPrompt = new String("Open text file");
|
||||
private String closePrompt = new String("Save file as");
|
||||
|
||||
// initialize some state flags
|
||||
|
||||
private boolean neverNamed = true;
|
||||
private boolean menuBusy = false;
|
||||
|
||||
// these three .. no four! .. four objects form the main window
|
||||
|
||||
private Scrollbar horiz;
|
||||
private Scrollbar vert;
|
||||
private TextCanvas textCanvas;
|
||||
private TextMenu textMenu;
|
||||
|
||||
// font
|
||||
|
||||
private String fontString = new String("Courier");
|
||||
private int fontSize = 12;
|
||||
private int tabSize = 4;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public TextEdit() {
|
||||
this.setTitle();
|
||||
|
||||
vert = new Scrollbar(Scrollbar.VERTICAL);
|
||||
add("East", vert);
|
||||
horiz = new Scrollbar(Scrollbar.HORIZONTAL);
|
||||
add("South", horiz);
|
||||
|
||||
textCanvas = new TextCanvas(this,horiz,vert);
|
||||
add("Center", textCanvas);
|
||||
textCanvas.setFont(fontString,fontSize);
|
||||
addKeyListener(textCanvas);
|
||||
|
||||
textMenu = new TextMenu(this);
|
||||
setMenuBar(textMenu);
|
||||
|
||||
addWindowListener(this);
|
||||
}
|
||||
public void writeStr(String t){
|
||||
textCanvas.appendLine(t);
|
||||
}
|
||||
public void writeText(String t){
|
||||
textCanvas.appendLine(t);
|
||||
}
|
||||
|
||||
// allow others to go straight to the canvas
|
||||
|
||||
public TextCanvas getCanvas() {
|
||||
return textCanvas;
|
||||
}
|
||||
|
||||
// add current filename to window title
|
||||
|
||||
private void setTitle(){
|
||||
super.setTitle("TextEdit - " + file.getName());
|
||||
}
|
||||
|
||||
// add the 1.1 WindowListener stuff
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
|
||||
public void windowClosing(WindowEvent event) {
|
||||
if (isItSafe(QUITAPP))
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// high level command processors (invoked my menu)
|
||||
|
||||
public void setFont(String fs) {
|
||||
fontString = fs;
|
||||
textCanvas.setFont(fontString, fontSize);
|
||||
}
|
||||
|
||||
public void setFontSize(int s) {
|
||||
fontSize = s;
|
||||
textCanvas.setFont(fontString, fontSize);
|
||||
}
|
||||
|
||||
public void setTabSize(int s) {
|
||||
tabSize = s;
|
||||
textCanvas.setTab(tabSize);
|
||||
}
|
||||
|
||||
public int getTabSize() {
|
||||
return tabSize;
|
||||
}
|
||||
|
||||
public void cmdFileNew() {
|
||||
if (isItSafe(NEWFILE))
|
||||
newFile();
|
||||
}
|
||||
|
||||
public void cmdFileOpen() {
|
||||
if (isItSafe(OPENFILE))
|
||||
openFile();
|
||||
}
|
||||
|
||||
public void cmdFileSave() {
|
||||
saveFile(false);
|
||||
}
|
||||
|
||||
public void cmdFileSaveAs() {
|
||||
saveFile(true);
|
||||
}
|
||||
|
||||
public void cmdPrint() {
|
||||
textCanvas.print(file.getName());
|
||||
}
|
||||
|
||||
public void cmdFileQuit() {
|
||||
if (isItSafe(QUITAPP))
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// if the file has been modified (dirty), fire off a notify dialog
|
||||
// and pass it the "action" you want returned to noteListen. This
|
||||
// dataflow beats the "modal dialog problem" on Windows
|
||||
|
||||
// I believe isItSafe is what Laurence Olivier said repeatedly to
|
||||
// Dustan Hoffman in Marathon Man.
|
||||
|
||||
private boolean isItSafe(int action) {
|
||||
if (textCanvas.isDirty())
|
||||
{
|
||||
notify( "The current file has not been saved. ", action );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
// implementation of the NoteListener interface - it does whatever
|
||||
// action the user agreed to by pressing "Continue" on a modal dialog
|
||||
|
||||
public void noteListen(int action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case NOACTION:
|
||||
break;
|
||||
case NEWFILE:
|
||||
newFile();
|
||||
break;
|
||||
case OPENFILE:
|
||||
openFile();
|
||||
break;
|
||||
case QUITAPP:
|
||||
System.exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// clear out the document
|
||||
|
||||
private void newFile()
|
||||
{
|
||||
neverNamed = true;
|
||||
file = new File("Untitled");
|
||||
this.setTitle();
|
||||
textCanvas.clear();
|
||||
textCanvas.validate();
|
||||
}
|
||||
|
||||
// call getFile to get a file path, and if you get one open it
|
||||
|
||||
private void openFile()
|
||||
{
|
||||
if (getFile(FileDialog.LOAD))
|
||||
openTheFile();
|
||||
}
|
||||
|
||||
public void openTheFile()
|
||||
{
|
||||
textCanvas.read(file);
|
||||
textCanvas.validate();
|
||||
neverNamed = false;
|
||||
this.setTitle();
|
||||
}
|
||||
|
||||
// call getFile to get a file path, and if you get one save to it
|
||||
|
||||
private void saveFile(boolean As)
|
||||
{
|
||||
boolean ok;
|
||||
|
||||
if (neverNamed || As)
|
||||
{
|
||||
ok = getFile(FileDialog.SAVE);
|
||||
neverNamed = false;
|
||||
}
|
||||
else
|
||||
ok = true;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
textCanvas.write(file);
|
||||
neverNamed = false;
|
||||
this.setTitle();
|
||||
}
|
||||
}
|
||||
|
||||
// use FileDialog to get a filepath
|
||||
|
||||
private boolean getFile(int mode)
|
||||
{
|
||||
String prompt;
|
||||
String filename;
|
||||
String pathname;
|
||||
|
||||
if (mode == FileDialog.LOAD)
|
||||
prompt = openPrompt;
|
||||
else
|
||||
prompt = closePrompt;
|
||||
|
||||
FileDialog d = new FileDialog(this, prompt, mode);
|
||||
|
||||
if (mode == FileDialog.LOAD)
|
||||
d.setFile("*");
|
||||
else
|
||||
d.setFile(file.getName());
|
||||
|
||||
d.setDirectory(".");
|
||||
d.setVisible(true);
|
||||
|
||||
filename = d.getFile();
|
||||
|
||||
pathname = d.getDirectory() + filename;
|
||||
|
||||
d.dispose();
|
||||
|
||||
if (filename != null)
|
||||
{
|
||||
file = new File(pathname);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// launch a note
|
||||
|
||||
private void notify(String s, int action) {
|
||||
Note note = new Note(this,s,action);
|
||||
note.setVisible(true);
|
||||
}
|
||||
|
||||
// main declares the TextEdit frame which does everything
|
||||
|
||||
public static void main(String[] args) {
|
||||
TextEdit f = new TextEdit();
|
||||
f.setSize(500, 400);
|
||||
f.setVisible(true);
|
||||
if (args.length > 0) {
|
||||
f.file = new File(args[0]);
|
||||
if (f.file.isFile())
|
||||
f.openTheFile();
|
||||
else
|
||||
f.notify("File not found: "+args[0],0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,463 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
class TextJournal
|
||||
{
|
||||
private TextCanvas canvas; // the parent
|
||||
private Vector lines; // the document
|
||||
private TextJournalItem journal; // the journal
|
||||
private TextJournalItem undo_list; // where we are in undo
|
||||
private TextJournalItem redo_list; // where we are in redo
|
||||
|
||||
private boolean had_undo;
|
||||
private boolean had_redo;
|
||||
|
||||
private String lineSeparator;
|
||||
|
||||
private final int REPLACE_LINE = 1;
|
||||
private final int SPLIT_LINE = 2;
|
||||
private final int JOIN_LINE = 3;
|
||||
private final int INSERT = 4;
|
||||
private final int DELETE = 5;
|
||||
|
||||
public TextJournal(TextCanvas c, Vector v, String ls)
|
||||
{
|
||||
canvas = c;
|
||||
lines = v;
|
||||
lineSeparator = ls;
|
||||
undo_list = redo_list = null;
|
||||
had_undo = had_redo = false;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
undo_list = redo_list = null;
|
||||
had_undo = had_redo = false;
|
||||
}
|
||||
|
||||
private void updateMenus()
|
||||
{
|
||||
boolean got_undo;
|
||||
boolean got_redo;
|
||||
|
||||
got_undo = undo_list != null;
|
||||
got_redo = redo_list != null;
|
||||
|
||||
if ((had_undo != got_undo) || (had_redo != got_redo))
|
||||
canvas.updateUndoItems(got_undo, got_redo);
|
||||
|
||||
had_undo = got_undo;
|
||||
had_redo = got_redo;
|
||||
}
|
||||
|
||||
public TextPosition undo()
|
||||
{
|
||||
TextJournalItem temp;
|
||||
TextPosition tp = null;
|
||||
|
||||
if (undo_list != null)
|
||||
{
|
||||
temp = undo_list;
|
||||
undo_list = temp.next;
|
||||
|
||||
switch (temp.action)
|
||||
{
|
||||
case REPLACE_LINE:
|
||||
redo_line(temp);
|
||||
break;
|
||||
case SPLIT_LINE:
|
||||
split_or_join(temp,true);
|
||||
break;
|
||||
case JOIN_LINE:
|
||||
split_or_join(temp,false);
|
||||
break;
|
||||
case INSERT:
|
||||
copy_or_cut(temp,true);
|
||||
break;
|
||||
case DELETE:
|
||||
insert(temp);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
tp = new TextPosition(temp.line,temp.column);
|
||||
|
||||
temp.next = redo_list;
|
||||
redo_list = temp;
|
||||
}
|
||||
|
||||
updateMenus();
|
||||
return tp;
|
||||
}
|
||||
|
||||
public TextPosition redo()
|
||||
{
|
||||
TextJournalItem temp;
|
||||
TextPosition tp = null;
|
||||
int line, column;
|
||||
|
||||
if (redo_list != null)
|
||||
{
|
||||
temp = redo_list;
|
||||
redo_list = temp.next;
|
||||
|
||||
line = temp.line;
|
||||
column = temp.column;
|
||||
|
||||
switch (temp.action)
|
||||
{
|
||||
case REPLACE_LINE:
|
||||
column = temp.text.length();
|
||||
redo_line(temp);
|
||||
break;
|
||||
case SPLIT_LINE:
|
||||
split_or_join(temp,false);
|
||||
column = 0;
|
||||
break;
|
||||
case JOIN_LINE:
|
||||
split_or_join(temp,true);
|
||||
break;
|
||||
case INSERT:
|
||||
insert(temp);
|
||||
line = temp.eline;
|
||||
column = temp.ecolumn;
|
||||
break;
|
||||
case DELETE:
|
||||
copy_or_cut(temp,true);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
tp = new TextPosition(line,column);
|
||||
|
||||
temp.next = undo_list;
|
||||
undo_list = temp;
|
||||
}
|
||||
|
||||
updateMenus();
|
||||
return tp;
|
||||
}
|
||||
|
||||
public void insert_char(int line, int column, char c)
|
||||
{
|
||||
String s;
|
||||
|
||||
s = (String)lines.elementAt(line);
|
||||
|
||||
remember_line(line,column,s);
|
||||
|
||||
s = s.substring(0, column) + c + s.substring(column, s.length());
|
||||
lines.setElementAt(s,line);
|
||||
}
|
||||
|
||||
public void delete_prev_char(int line, int column)
|
||||
{
|
||||
String s;
|
||||
|
||||
s = (String)lines.elementAt(line);
|
||||
|
||||
remember_line(line,column,s);
|
||||
|
||||
s = s.substring(0, column-1) + s.substring(column, s.length());
|
||||
lines.setElementAt(s,line);
|
||||
}
|
||||
|
||||
public void delete_next_char(int line, int column)
|
||||
{
|
||||
String s;
|
||||
|
||||
s = (String)lines.elementAt(line);
|
||||
|
||||
remember_line(line,column,s);
|
||||
|
||||
s = s.substring(0, column) + s.substring(column+1, s.length());
|
||||
lines.setElementAt(s,line);
|
||||
}
|
||||
|
||||
private void remember_line(int line, int column, String s)
|
||||
{
|
||||
boolean new_line = true;
|
||||
|
||||
if (undo_list != null)
|
||||
new_line = (undo_list.action != REPLACE_LINE) || (undo_list.line != line);
|
||||
|
||||
if (new_line)
|
||||
{
|
||||
TextJournalItem new_journal = new TextJournalItem();
|
||||
new_journal.action = REPLACE_LINE;
|
||||
new_journal.line = line;
|
||||
new_journal.column = column;
|
||||
new_journal.text = new String(s);
|
||||
new_journal.next = undo_list;
|
||||
undo_list = new_journal;
|
||||
}
|
||||
|
||||
redo_list = null;
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
private void redo_line(TextJournalItem i)
|
||||
{
|
||||
String s;
|
||||
s = (String)lines.elementAt(i.line);
|
||||
lines.setElementAt(i.text,i.line);
|
||||
i.text = s;
|
||||
}
|
||||
|
||||
public void split_line(int line, int column)
|
||||
{
|
||||
TextJournalItem new_journal = new TextJournalItem();
|
||||
new_journal.action = SPLIT_LINE;
|
||||
new_journal.line = line;
|
||||
new_journal.column = column;
|
||||
|
||||
split_or_join(new_journal,false);
|
||||
|
||||
new_journal.next = undo_list;
|
||||
undo_list = new_journal;
|
||||
redo_list = null;
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
public void join_line(int line, int column)
|
||||
{
|
||||
TextJournalItem new_journal = new TextJournalItem();
|
||||
new_journal.action = JOIN_LINE;
|
||||
new_journal.line = line;
|
||||
new_journal.column = column;
|
||||
|
||||
split_or_join(new_journal,true);
|
||||
|
||||
new_journal.next = undo_list;
|
||||
undo_list = new_journal;
|
||||
redo_list = null;
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
public void split_or_join(TextJournalItem i, boolean join)
|
||||
{
|
||||
String s;
|
||||
int line = i.line;
|
||||
int column = i.column;
|
||||
|
||||
if (join)
|
||||
{
|
||||
s = (String)lines.elementAt(line);
|
||||
s = s.concat((String)lines.elementAt(line+1));
|
||||
lines.setElementAt(s,line);
|
||||
lines.removeElementAt(line+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (String)lines.elementAt(line);
|
||||
lines.setElementAt(s.substring(0,column),line);
|
||||
lines.insertElementAt(s.substring(column,s.length()),++line);
|
||||
}
|
||||
}
|
||||
|
||||
public TextPosition insert_section(int line, int column, String s)
|
||||
{
|
||||
int charCt;
|
||||
int saveCt;
|
||||
int charMax;
|
||||
char c,c2;
|
||||
String s2 = null;
|
||||
TextPosition tp;
|
||||
|
||||
// start creating journal item
|
||||
|
||||
TextJournalItem new_journal = new TextJournalItem();
|
||||
new_journal.action = INSERT;
|
||||
new_journal.text = new String(s);
|
||||
new_journal.line = line; // starting line and column
|
||||
new_journal.column = column;
|
||||
|
||||
// insert the text
|
||||
|
||||
tp = insert(new_journal);
|
||||
|
||||
// finish creating journal entry
|
||||
|
||||
new_journal.eline = tp.line; // updated line and column
|
||||
new_journal.ecolumn = tp.column;
|
||||
new_journal.next = undo_list;
|
||||
undo_list = new_journal;
|
||||
redo_list = null;
|
||||
updateMenus();
|
||||
|
||||
return tp;
|
||||
}
|
||||
|
||||
public TextPosition insert(TextJournalItem i)
|
||||
{
|
||||
int line = i.line;
|
||||
int column = i.column;
|
||||
String s = i.text;
|
||||
|
||||
int charCt;
|
||||
int saveCt;
|
||||
int charMax;
|
||||
char c,c2;
|
||||
String s2 = null;
|
||||
|
||||
// insert the text
|
||||
|
||||
charMax = s.length();
|
||||
charCt = saveCt = 0;
|
||||
|
||||
while (charCt < charMax)
|
||||
{
|
||||
c = s.charAt(charCt);
|
||||
charCt++;
|
||||
if ((c == '\r') || (c == '\n'))
|
||||
{
|
||||
s2 = (String)lines.elementAt(line);
|
||||
lines.setElementAt(s2.substring(0,column) + s.substring(saveCt,charCt-1),line);
|
||||
lines.insertElementAt(s2.substring(column,s2.length()),++line);
|
||||
column = 0;
|
||||
if (charCt < charMax)
|
||||
{
|
||||
c2 = s.charAt(charCt);
|
||||
if (((c == '\r') && (c2 == '\n')) || ((c2 == '\r') && (c == '\n')))
|
||||
charCt++;
|
||||
}
|
||||
saveCt = charCt;
|
||||
}
|
||||
}
|
||||
|
||||
if (saveCt < charCt)
|
||||
{
|
||||
s2 = (String)lines.elementAt(line);
|
||||
s = s.substring(saveCt,charCt);
|
||||
if (column == 0)
|
||||
s2 = s + s2;
|
||||
else
|
||||
s2 = s2.substring(0, column) + s + s2.substring(column, s2.length());
|
||||
column += s.length();
|
||||
lines.setElementAt(s2,line);
|
||||
}
|
||||
|
||||
return new TextPosition(line,column);
|
||||
}
|
||||
|
||||
public String delete_section(int line, int column, int eline, int ecolumn, boolean cut)
|
||||
{
|
||||
String text;
|
||||
|
||||
TextJournalItem new_journal = new TextJournalItem();
|
||||
new_journal.action = DELETE;
|
||||
new_journal.line = line;
|
||||
new_journal.column = column;
|
||||
new_journal.eline = eline;
|
||||
new_journal.ecolumn = ecolumn;
|
||||
|
||||
text = copy_or_cut(new_journal,cut);
|
||||
|
||||
if (cut)
|
||||
{
|
||||
new_journal.text = new String(text);
|
||||
new_journal.next = undo_list;
|
||||
undo_list = new_journal;
|
||||
redo_list = null;
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private String copy_or_cut(TextJournalItem i, boolean cut)
|
||||
{
|
||||
String s,s2;
|
||||
String text = null;
|
||||
|
||||
int line = i.line;
|
||||
int column = i.column;
|
||||
int eline = i.eline;
|
||||
int ecolumn = i.ecolumn;
|
||||
|
||||
if (line == eline)
|
||||
{
|
||||
s = (String)lines.elementAt(line);
|
||||
text = s.substring(column,ecolumn);
|
||||
if (cut)
|
||||
{
|
||||
s = s.substring(0, column) + s.substring(ecolumn, s.length());
|
||||
lines.setElementAt(s,line);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (String)lines.elementAt(line);
|
||||
text = s.substring(column,s.length());
|
||||
s = s.substring(0, column);
|
||||
|
||||
int diff = eline - line;
|
||||
int k = line + 1;
|
||||
|
||||
for (int j = 1; j < diff; j++)
|
||||
{
|
||||
s2 = (String)lines.elementAt(k);
|
||||
text = text + lineSeparator + s2;
|
||||
if (cut)
|
||||
lines.removeElementAt(k);
|
||||
else
|
||||
k++;
|
||||
}
|
||||
|
||||
if (k != lines.size())
|
||||
{
|
||||
s2 = (String)lines.elementAt(k);
|
||||
text = text + lineSeparator + s2.substring(0,ecolumn);
|
||||
s = s + s2.substring(ecolumn,s2.length());
|
||||
if (cut)
|
||||
lines.removeElementAt(k);
|
||||
}
|
||||
|
||||
if (cut)
|
||||
lines.setElementAt(s,line);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TextJournalItem
|
||||
{
|
||||
public TextJournalItem next;
|
||||
public String text;
|
||||
public int action;
|
||||
public int line;
|
||||
public int column;
|
||||
public int eline;
|
||||
public int ecolumn;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class TextMenu extends MenuBar implements ActionListener {
|
||||
// menus
|
||||
private Menu fileMenu;
|
||||
private Menu editMenu;
|
||||
private Menu fontMenu;
|
||||
private Menu sizeMenu;
|
||||
private Menu helpMenu;
|
||||
|
||||
// adaptors
|
||||
private EditMan editMan;
|
||||
private SizeMan sizeMan;
|
||||
private FontMan fontMan;
|
||||
|
||||
// allocate standard components of TextEdit as part of initialization:
|
||||
private String newString = new String("New");
|
||||
private String openString = new String("Open");
|
||||
private String saveString = new String("Save");
|
||||
private String saveAsString = new String("Save As");
|
||||
private String printString = new String("Print");
|
||||
private String quitString = new String("Quit");
|
||||
private String aboutString = new String("About");
|
||||
|
||||
// remember who our parents are
|
||||
|
||||
private TextEdit textEdit;
|
||||
private TextCanvas textCanvas;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public TextMenu(TextEdit parent) {
|
||||
super();
|
||||
|
||||
textEdit = parent;
|
||||
textCanvas = textEdit.getCanvas();
|
||||
|
||||
CheckboxMenuItem cbi;
|
||||
|
||||
editMan = new EditMan(parent);
|
||||
sizeMan = new SizeMan(parent);
|
||||
fontMan = new FontMan(parent);
|
||||
|
||||
fileMenu = new Menu("File");
|
||||
fileMenu.add(new MenuItem(newString));
|
||||
fileMenu.add(new MenuItem(openString));
|
||||
fileMenu.add(new MenuItem(saveString));
|
||||
fileMenu.add(new MenuItem(saveAsString));
|
||||
fileMenu.addSeparator();
|
||||
fileMenu.add(new MenuItem(printString));
|
||||
//fileMenu.addSeparator();
|
||||
//fileMenu.add(new MenuItem(quitString));
|
||||
fileMenu.addActionListener(this);
|
||||
add(fileMenu);
|
||||
|
||||
editMenu = new Menu("Edit");
|
||||
editMan.addItems(editMenu);
|
||||
add(editMenu);
|
||||
|
||||
fontMenu = new Menu("Font");
|
||||
String[] fontNames = parent.getToolkit().getFontList();
|
||||
for (int i = 0; i < fontNames.length; i++) {
|
||||
if (fontNames[i].equals("Courier")){
|
||||
cbi = add_checked(fontMenu, fontMan, fontNames[i]);
|
||||
fontMan.remember(cbi);
|
||||
}else{
|
||||
add_unchecked(fontMenu, fontMan, fontNames[i]);
|
||||
}
|
||||
}
|
||||
add(fontMenu);
|
||||
|
||||
sizeMenu = new Menu("Size");
|
||||
add_unchecked(sizeMenu, sizeMan, new String("10"));
|
||||
add_unchecked(sizeMenu, sizeMan, new String("11"));
|
||||
cbi = add_checked(sizeMenu, sizeMan, new String("12"));
|
||||
sizeMan.remember(cbi);
|
||||
add_unchecked(sizeMenu, sizeMan, new String("14"));
|
||||
add_unchecked(sizeMenu, sizeMan, new String("16"));
|
||||
add_unchecked(sizeMenu, sizeMan, new String("18"));
|
||||
add_unchecked(sizeMenu, sizeMan, new String("36"));
|
||||
add(sizeMenu);
|
||||
|
||||
helpMenu = new Menu("Help");
|
||||
helpMenu.add(new MenuItem(aboutString));
|
||||
helpMenu.addActionListener(this);
|
||||
setHelpMenu(helpMenu);
|
||||
}
|
||||
|
||||
private void add_unchecked( Menu menu, ItemListener adaptor, String string ) {
|
||||
CheckboxMenuItem cbi;
|
||||
|
||||
cbi = new CheckboxMenuItem(string);
|
||||
cbi.addItemListener(adaptor);
|
||||
menu.add(cbi);
|
||||
}
|
||||
|
||||
private CheckboxMenuItem add_checked( Menu menu, ItemListener adaptor, String string ) {
|
||||
CheckboxMenuItem cbi;
|
||||
|
||||
cbi = new CheckboxMenuItem(string);
|
||||
cbi.addItemListener(adaptor);
|
||||
cbi.setState(true);
|
||||
menu.add(cbi);
|
||||
return cbi;
|
||||
}
|
||||
|
||||
// action handler, part of std java event handling
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
int i;
|
||||
|
||||
Object source = evt.getSource();
|
||||
String cmd = evt.getActionCommand();
|
||||
|
||||
if (source == fileMenu)
|
||||
doFile(cmd);
|
||||
else
|
||||
if (source == helpMenu) {
|
||||
AboutDialog ab = new AboutDialog(textEdit);
|
||||
ab.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void doFile(String cmd){
|
||||
if (cmd.equals(newString))
|
||||
textEdit.cmdFileNew();
|
||||
else
|
||||
if (cmd.equals(openString))
|
||||
textEdit.cmdFileOpen();
|
||||
else
|
||||
if (cmd.equals(saveString))
|
||||
textEdit.cmdFileSave();
|
||||
else
|
||||
if (cmd.equals(saveAsString))
|
||||
textEdit.cmdFileSaveAs();
|
||||
else
|
||||
if (cmd.equals(printString))
|
||||
textEdit.cmdPrint();
|
||||
else
|
||||
if (cmd.equals(quitString))
|
||||
textEdit.cmdFileQuit();
|
||||
}
|
||||
}
|
||||
|
||||
class AboutDialog extends Dialog implements WindowListener, ActionListener {
|
||||
Button ok;
|
||||
public AboutDialog(Frame parent) {
|
||||
super(parent,"About TextEdit",true);
|
||||
|
||||
Panel center = new Panel(new GridLayout(0,1));
|
||||
center.add(new Label("GAG v0.1alpha", Label.CENTER));
|
||||
center.add(new Label("Copyright (c) 1997 Toshiaki Kodama"));
|
||||
center.add(new Label("Contact: toshiaki@naruto-u.ac.jp"));
|
||||
center.add(new Label("This GAG includs TextEditi. (c) 1997 John Jensen"));
|
||||
add("Center", center);
|
||||
|
||||
Panel p = new Panel();
|
||||
ok = new Button("Ok");
|
||||
ok.addActionListener(this);
|
||||
p.add(ok);
|
||||
add("South",p);
|
||||
//setSize(240,240);
|
||||
pack();
|
||||
addWindowListener(this);
|
||||
}
|
||||
|
||||
// dispose on 'ok'
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (event.getSource() == ok)
|
||||
dispose();
|
||||
}
|
||||
|
||||
// add the 1.1 WindowListener stuff
|
||||
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
public void windowClosing(WindowEvent event) {
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class SizeMan extends Object implements ItemListener {
|
||||
// remember stuff
|
||||
|
||||
private TextEdit textEdit;
|
||||
private CheckboxMenuItem lastSize = null;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public SizeMan(TextEdit parent) {
|
||||
textEdit = parent;
|
||||
}
|
||||
|
||||
public void remember( CheckboxMenuItem item ) {
|
||||
if (lastSize != null)
|
||||
lastSize.setState(false);
|
||||
lastSize = item;
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent evt) {
|
||||
remember((CheckboxMenuItem)evt.getSource());
|
||||
String cmd = (String)evt.getItem();
|
||||
Integer size = new Integer(cmd);
|
||||
textEdit.setFontSize(size.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
final class FontMan extends Object implements ItemListener {
|
||||
// remember stuff
|
||||
|
||||
private TextEdit textEdit;
|
||||
private CheckboxMenuItem lastTab = null;
|
||||
|
||||
// constructor puts together UI
|
||||
|
||||
public FontMan(TextEdit parent) {
|
||||
textEdit = parent;
|
||||
}
|
||||
|
||||
public void remember( CheckboxMenuItem item ) {
|
||||
if (lastTab != null)
|
||||
lastTab.setState(false);
|
||||
lastTab = item;
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent evt) {
|
||||
String cmd = (String)evt.getItem();
|
||||
remember((CheckboxMenuItem)evt.getSource());
|
||||
textEdit.setFont(cmd);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
class TextPosition
|
||||
{
|
||||
public int line;
|
||||
public int column;
|
||||
|
||||
public TextPosition(int l, int c)
|
||||
{
|
||||
line = l;
|
||||
column = c;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Jensen. All rights reserved.
|
||||
*
|
||||
* This software is FREE FOR COMMERCIAL AND NON-COMMERCIAL USE,
|
||||
* provided the following condition is met.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that any copy or derivative of this software or documentation
|
||||
* retaining the name "John Jensen" also retains this condition and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* CopyrightVersion 1.0
|
||||
*/
|
||||
|
||||
package TextEdit;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
class TextScroller extends Thread
|
||||
{
|
||||
private TextCanvas canvas;
|
||||
|
||||
public TextScroller(TextCanvas c)
|
||||
{
|
||||
canvas = c;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try { sleep(10); }
|
||||
catch(InterruptedException e) {}
|
||||
|
||||
canvas.mouseDragged(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,131 @@
|
||||
// jdk-1.1.3 (or later) + swing-1.0.2
|
||||
// JFileChooser is to be used soon.
|
||||
//
|
||||
package GAG;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.java.swing.text.*;
|
||||
import com.sun.java.swing.*;
|
||||
|
||||
class TextEditor extends JFrame implements ActionListener {
|
||||
private JMenuItem newf, open, save, cut, copy, paste;
|
||||
private JTextArea editor;
|
||||
private JToolBar toolbar;
|
||||
protected FileDialog fileDialog;
|
||||
|
||||
TextEditor() {
|
||||
super("GAG TextEditor");
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
editor = new JTextArea();
|
||||
editor.setFont(new Font("Serif", Font.BOLD, 12));
|
||||
JScrollPane scroller = new JScrollPane();
|
||||
//scroller.setVerticalScrollBarPolicy(JScrollPane.SCROLLBARS_ALWAYS);
|
||||
JViewport port = scroller.getViewport();
|
||||
port.add(editor);
|
||||
port.setBackingStoreEnabled(false);
|
||||
setJMenuBar( createMenubar() );
|
||||
getContentPane().add("Center", scroller);
|
||||
pack();
|
||||
setSize(500, 600);
|
||||
show();
|
||||
}
|
||||
JMenuBar createMenubar(){
|
||||
JMenu file, edit;
|
||||
JMenuBar mb = new JMenuBar();
|
||||
file = new JMenu("File");
|
||||
file.add(newf = new JMenuItem("New"));
|
||||
file.add(open = new JMenuItem("Open"));
|
||||
file.add(save = new JMenuItem("Save"));
|
||||
edit = new JMenu("Edit");
|
||||
edit.add(cut = new JMenuItem("Cut"));
|
||||
edit.add(copy = new JMenuItem("Copy"));
|
||||
edit.add(paste = new JMenuItem("Paste"));
|
||||
mb.add(file);
|
||||
mb.add(edit);
|
||||
newf.addActionListener(this);
|
||||
open.addActionListener(this);
|
||||
save.addActionListener(this);
|
||||
cut.addActionListener(this);
|
||||
copy.addActionListener(this);
|
||||
paste.addActionListener(this);
|
||||
return mb;
|
||||
}
|
||||
void writeString(String s){
|
||||
editor.append(s);
|
||||
}
|
||||
void writeLine(String s){
|
||||
editor.append(s+"\n");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TextEditor();
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object o = e.getSource();
|
||||
if (o == newf){newAction(); return;}
|
||||
if (o == open){openAction(); return;}
|
||||
if (o == save){saveAction(); return;}
|
||||
if (o == cut){editor.cut(); return;}
|
||||
if (o == copy){editor.copy(); return;}
|
||||
if (o == paste){editor.paste(); return;}
|
||||
}
|
||||
void newAction(){
|
||||
editor.setDocument(new PlainDocument());
|
||||
validate();
|
||||
}
|
||||
void openAction(){
|
||||
if (fileDialog == null) {
|
||||
fileDialog = new FileDialog(this);
|
||||
}
|
||||
fileDialog.setMode(FileDialog.LOAD);
|
||||
fileDialog.show();
|
||||
|
||||
String file = fileDialog.getFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
newAction();
|
||||
String directory = fileDialog.getDirectory();
|
||||
File f = new File(directory, file);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (f.exists()) {
|
||||
setTitle(file);
|
||||
try{
|
||||
Reader in = new FileReader(f);
|
||||
char[] buff = new char[4096];
|
||||
int nch;
|
||||
while ((nch = in.read(buff, 0, buff.length)) != -1) {
|
||||
sb.append(new String(buff, 0, nch));
|
||||
}
|
||||
}catch(IOException e){ System.err.println(e.getMessage()); }
|
||||
editor.setText(sb.toString());
|
||||
validate();
|
||||
}
|
||||
}
|
||||
void saveAction(){
|
||||
String saveText;
|
||||
if (fileDialog == null) {
|
||||
fileDialog = new FileDialog(this);
|
||||
}
|
||||
fileDialog.setMode(FileDialog.LOAD);
|
||||
fileDialog.show();
|
||||
|
||||
String file = fileDialog.getFile();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
String directory = fileDialog.getDirectory();
|
||||
File f = new File(directory, file);
|
||||
try{
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
PrintWriter outf = new PrintWriter(new DataOutputStream(fo));
|
||||
outf.println(editor.getText());
|
||||
outf.close();
|
||||
}catch(IOException e){ System.err.println(e.getMessage()); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
%!PS-Adobe-3.0 EPSF-3.0
|
||||
%%BoundingBox: 56.6929134 56.6929134 538.582677 785.19685
|
||||
% FILE: g4.eps
|
||||
|
||||
% DEFAULT FONT:
|
||||
/Times-Roman findfont 24 scalefont setfont
|
||||
|
||||
% DEFAULT COLOR:
|
||||
0 0 0 setrgbcolor
|
||||
|
||||
% DEFAULT LINE:
|
||||
0.283464567 setlinewidth
|
||||
[1.41732283] 0 setdash
|
||||
|
||||
% DEFINE PostScript Functions:
|
||||
/PATH
|
||||
{/POINT 0 def
|
||||
/X 0 def
|
||||
newpath
|
||||
{X 1 eq{POINT 0 eq{moveto
|
||||
/POINT 1 def
|
||||
}{lineto }ifelse
|
||||
/X 0 def
|
||||
}{/X X 1 add def}ifelse
|
||||
}forall
|
||||
} def
|
||||
/FILLPOLYGON{ PATH closepath fill }def
|
||||
/DRAWFILLPOLYGON{ PATH closepath gsave stroke grestore fill }def
|
||||
/DRAWPOLYGON{ PATH closepath stroke }def
|
||||
/DRAWPATH { PATH stroke } def
|
||||
/BOXPATH
|
||||
{/X 0 def
|
||||
{X 0 eq{/LLX exch def}if
|
||||
X 1 eq{/LLY exch def}if
|
||||
X 2 eq{/URX exch def}if
|
||||
X 3 eq{/URY exch def}if
|
||||
/X X 1 add def
|
||||
}forall
|
||||
LLX LLY moveto
|
||||
URX LLY lineto
|
||||
URX URY lineto
|
||||
LLX URY lineto
|
||||
closepath
|
||||
}def
|
||||
|
||||
% CLIPPING:
|
||||
[56.6929134 56.6929134 538.582677 785.19685] BOXPATH clip
|
||||
|
||||
% PARAMETERS:
|
||||
% Generated by Fukui Renderer DAWN version 3.29a-GL
|
||||
% O.x = 0
|
||||
% O.y = 0
|
||||
% O.z = 0
|
||||
% camera_d = 1558850
|
||||
% v_angle = 60
|
||||
% h_angle = 30
|
||||
% focal_d = 3458.17
|
||||
% e_2d = 1e-07
|
||||
% e_3d = 0.001
|
||||
|
||||
0 0.25 0.25 setrgbcolor
|
||||
0 setlinewidth
|
||||
[] 0 setdash
|
||||
[ 363.165918 408.693432 256.427578 377.879528 252.86612 375.752036 359.604152 406.565893 ] DRAWFILLPOLYGON
|
||||
0 0.343791747 0.343791747 setrgbcolor
|
||||
[ 342.407747 466.135989 235.669053 435.324424 239.816417 435.422276 346.555396 466.233966 ] DRAWFILLPOLYGON
|
||||
0 0.356663203 0.356663203 setrgbcolor
|
||||
[ 346.555396 466.233966 239.816417 435.422276 244.267157 433.483565 351.00638 464.295449 ] DRAWFILLPOLYGON
|
||||
0 0.25 0.25 setrgbcolor
|
||||
[ 365.899023 412.705817 259.160374 381.891948 256.427578 377.879528 363.165918 408.693432 ] DRAWFILLPOLYGON
|
||||
0 0.362265738 0.362265738 setrgbcolor
|
||||
[ 351.00638 464.295449 244.267157 433.483565 248.717958 429.640389 355.457366 460.452524 ] DRAWFILLPOLYGON
|
||||
0 0.25 0.25 setrgbcolor
|
||||
[ 367.617199 418.329626 260.878259 387.51587 259.160374 381.891948 365.899023 412.705817 ] DRAWFILLPOLYGON
|
||||
0 0.256866467 0.256866467 setrgbcolor
|
||||
[ 368.203339 425.181607 261.464149 394.368036 260.878259 387.51587 367.617199 418.329626 ] DRAWFILLPOLYGON
|
||||
0 0.360217548 0.360217548 setrgbcolor
|
||||
[ 355.457366 460.452524 248.717958 429.640389 252.865496 424.154646 359.605017 454.967071 ] DRAWFILLPOLYGON
|
||||
0 0.285689009 0.285689009 setrgbcolor
|
||||
[ 367.617491 432.794801 260.878106 401.981473 261.464149 394.368036 368.203339 425.181607 ] DRAWFILLPOLYGON
|
||||
0 0.350658214 0.350658214 setrgbcolor
|
||||
[ 359.605017 454.967071 252.865496 424.154646 256.427108 417.400182 363.166664 448.212916 ] DRAWFILLPOLYGON
|
||||
0 0.737185032 0.737185032 setrgbcolor
|
||||
[ 260.878259 387.51587 261.464149 394.368036 260.878106 401.981473 259.160064 409.837318 256.427108 417.400182 252.865496 424.154646 248.717958 429.640389 244.267157 433.483565 239.816417 435.422276 235.669053 435.324424 232.107697 433.196701 229.37504 429.184131 227.657293 423.560179 227.071504 416.708112 227.657584 409.094876 229.375589 401.23928 232.108444 393.676647 235.669918 386.922333 239.817317 381.436619 244.268017 377.593345 248.718719 375.654432 252.86612 375.752036 256.427578 377.879528 259.160374 381.891948 ] DRAWFILLPOLYGON
|
||||
0 0.33423919 0.33423919 setrgbcolor
|
||||
[ 363.166664 448.212916 256.427108 417.400182 259.160064 409.837318 365.899573 440.65036 ] DRAWFILLPOLYGON
|
||||
0 0.312079403 0.312079403 setrgbcolor
|
||||
[ 365.899573 440.65036 259.160064 409.837318 260.878106 401.981473 367.617491 432.794801 ] DRAWFILLPOLYGON
|
||||
0 0 0 setrgbcolor
|
||||
0.283464567 setlinewidth
|
||||
[ 256.427578 377.879528 252.86612 375.752036] DRAWPATH
|
||||
[ 252.86612 375.752036 359.604152 406.565893] DRAWPATH
|
||||
[ 359.604152 406.565893 363.165918 408.693432] DRAWPATH
|
||||
[ 342.407747 466.135989 235.669053 435.324424] DRAWPATH
|
||||
[ 235.669053 435.324424 239.816417 435.422276] DRAWPATH
|
||||
[ 346.555396 466.233966 342.407747 466.135989] DRAWPATH
|
||||
[ 239.816417 435.422276 244.267157 433.483565] DRAWPATH
|
||||
[ 351.00638 464.295449 346.555396 466.233966] DRAWPATH
|
||||
[ 259.160374 381.891948 256.427578 377.879528] DRAWPATH
|
||||
[ 363.165918 408.693432 365.899023 412.705817] DRAWPATH
|
||||
[ 244.267157 433.483565 248.717958 429.640389] DRAWPATH
|
||||
[ 355.457366 460.452524 351.00638 464.295449] DRAWPATH
|
||||
[ 260.878259 387.51587 259.160374 381.891948] DRAWPATH
|
||||
[ 365.899023 412.705817 367.617199 418.329626] DRAWPATH
|
||||
[ 261.464149 394.368036 260.878259 387.51587] DRAWPATH
|
||||
[ 367.617199 418.329626 368.203339 425.181607] DRAWPATH
|
||||
[ 248.717958 429.640389 252.865496 424.154646] DRAWPATH
|
||||
[ 359.605017 454.967071 355.457366 460.452524] DRAWPATH
|
||||
[ 260.878106 401.981473 261.464149 394.368036] DRAWPATH
|
||||
[ 368.203339 425.181607 367.617491 432.794801] DRAWPATH
|
||||
[ 252.865496 424.154646 256.427108 417.400182] DRAWPATH
|
||||
[ 363.166664 448.212916 359.605017 454.967071] DRAWPATH
|
||||
[ 260.878259 387.51587 261.464149 394.368036] DRAWPATH
|
||||
[ 261.464149 394.368036 260.878106 401.981473] DRAWPATH
|
||||
[ 260.878106 401.981473 259.160064 409.837318] DRAWPATH
|
||||
[ 259.160064 409.837318 256.427108 417.400182] DRAWPATH
|
||||
[ 256.427108 417.400182 252.865496 424.154646] DRAWPATH
|
||||
[ 252.865496 424.154646 248.717958 429.640389] DRAWPATH
|
||||
[ 248.717958 429.640389 244.267157 433.483565] DRAWPATH
|
||||
[ 244.267157 433.483565 239.816417 435.422276] DRAWPATH
|
||||
[ 239.816417 435.422276 235.669053 435.324424] DRAWPATH
|
||||
[ 235.669053 435.324424 232.107697 433.196701] DRAWPATH
|
||||
[ 232.107697 433.196701 229.37504 429.184131] DRAWPATH
|
||||
[ 229.37504 429.184131 227.657293 423.560179] DRAWPATH
|
||||
[ 227.657293 423.560179 227.071504 416.708112] DRAWPATH
|
||||
[ 227.071504 416.708112 227.657584 409.094876] DRAWPATH
|
||||
[ 227.657584 409.094876 229.375589 401.23928] DRAWPATH
|
||||
[ 229.375589 401.23928 232.108444 393.676647] DRAWPATH
|
||||
[ 232.108444 393.676647 235.669918 386.922333] DRAWPATH
|
||||
[ 235.669918 386.922333 239.817317 381.436619] DRAWPATH
|
||||
[ 239.817317 381.436619 244.268017 377.593345] DRAWPATH
|
||||
[ 244.268017 377.593345 248.718719 375.654432] DRAWPATH
|
||||
[ 248.718719 375.654432 252.86612 375.752036] DRAWPATH
|
||||
[ 252.86612 375.752036 256.427578 377.879528] DRAWPATH
|
||||
[ 256.427578 377.879528 259.160374 381.891948] DRAWPATH
|
||||
[ 259.160374 381.891948 260.878259 387.51587] DRAWPATH
|
||||
[ 256.427108 417.400182 259.160064 409.837318] DRAWPATH
|
||||
[ 365.899573 440.65036 363.166664 448.212916] DRAWPATH
|
||||
[ 259.160064 409.837318 260.878106 401.981473] DRAWPATH
|
||||
[ 367.617491 432.794801 365.899573 440.65036] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 264.328583 443.597384 259.895233 643.551148] DRAWPATH
|
||||
[ 279.166803 383.472354 415.444902 99.051835] DRAWPATH
|
||||
[ 262.437441 443.05148 -24.086577 565.879451] DRAWPATH
|
||||
[ 229.117341 412.249044 64.3088635 153.960869] DRAWPATH
|
||||
[ 272.827096 446.050595 24.9274199 748.650859] DRAWPATH
|
||||
[ 258.466551 390.987192 258.466551 390.987192] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 260.630197 389.493408 260.630197 389.493408] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 193.862307 404.896273 229.443349 415.167457] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 279.068678 383.677146 279.166803 383.472354] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 229.443349 415.167457 229.443349 415.167457] DRAWPATH
|
||||
[ 231.38415 415.724252 231.413979 415.732659] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 229.462547 415.154797 229.462547 415.154797] DRAWPATH
|
||||
[ 229.117341 412.249044 229.117341 412.249044] DRAWPATH
|
||||
[ 232.265397 419.631173 232.240701 419.678418] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 232.265397 419.631173 232.242895 419.67184] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 227.080395 416.812114 -88.0277439 381.44444] DRAWPATH
|
||||
[ 232.530793 433.449478 219.027456 833.512198] DRAWPATH
|
||||
[ 233.485721 405.157887 233.485721 405.157887] DRAWPATH
|
||||
[ 227.964937 424.567415 71.9497245 603.106657] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 231.950035 416.688529 231.950035 416.688529] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 229.414352 415.111112 229.414352 415.111112] DRAWPATH
|
||||
[ 228.56948 426.546707 159.16286 564.420323] DRAWPATH
|
||||
[ 235.10191 413.570282 235.10191 413.570282] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 227.566556 422.498821 226.343667 423.088111] DRAWPATH
|
||||
[ 254.056151 409.73393 254.056151 409.73393] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 229.432695 415.067496 229.432695 415.067496] DRAWPATH
|
||||
[ 229.397805 415.049856 229.397805 415.049856] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 238.550244 417.264691 238.524123 417.290028] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 229.541661 415.133287 229.541661 415.133287] DRAWPATH
|
||||
[ 229.443024 415.360964 229.443024 415.360964] DRAWPATH
|
||||
[ 229.557862 413.676111 229.557862 413.676111] DRAWPATH
|
||||
[ 229.474919 415.280559 229.474919 415.280559] DRAWPATH
|
||||
[ 243.206956 419.39126 243.200938 419.401456] DRAWPATH
|
||||
[ 229.833983 416.572518 229.833983 416.572518] DRAWPATH
|
||||
[ 243.510512 418.014941 243.537849 417.983114] DRAWPATH
|
||||
[ 229.277074 418.526291 229.277074 418.526291] DRAWPATH
|
||||
[ 229.362005 416.651469 229.362005 416.651469] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 247.784449 420.679525 247.784449 420.679525] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 248.338818 420.51525 248.329746 420.487606] DRAWPATH
|
||||
[ 247.940744 421.270645 247.953346 421.274654] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 229.132734 415.202853 229.132734 415.202853] DRAWPATH
|
||||
[ 227.427963 416.932831 227.427963 416.932831] DRAWPATH
|
||||
[ 348.447035 448.404037 348.759509 448.787024] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 249.017077 421.824763 249.017047 421.831449] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 348.759509 448.787024 573.846362 724.658576] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 249.518627 417.75022 249.518627 417.75022] DRAWPATH
|
||||
[ 249.498203 417.81173 249.518627 417.75022] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 251.141383 419.74193 251.150158 419.698439] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 228.972351 416.166003 228.972351 416.166003] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 253.657471 422.652695 253.680414 422.657931] DRAWPATH
|
||||
[ 228.490117 416.908859 228.490117 416.908859] DRAWPATH
|
||||
[ 254.136266 420.756403 254.117884 420.752679] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 231.435234 411.280743 231.435234 411.280743] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 226.630692 421.821743 226.487144 422.856886] DRAWPATH
|
||||
[ 226.343667 423.088111 226.630692 421.821743] DRAWPATH
|
||||
[ 226.487144 422.856886 226.671553 423.064338] DRAWPATH
|
||||
[ 226.671553 423.064338 226.601259 422.859458] DRAWPATH
|
||||
[ 226.601259 422.859458 226.598915 422.884838] DRAWPATH
|
||||
[ 226.343667 423.088111 96.1632207 485.477746] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 254.087015 418.842954 254.087015 418.842954] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 228.854869 403.620282 -79.9841558 192.435383] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 255.774357 419.827002 255.782155 419.830599] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 227.962616 424.559816 -64.1673552 510.023397] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 258.978899 423.615132 258.978899 423.615132] DRAWPATH
|
||||
[ 260.253232 421.981488 260.253232 421.981488] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 264.779562 427.715258 264.777309 427.715654] DRAWPATH
|
||||
[ 266.93389 428.488954 267.016701 428.51101] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 272.197483 428.099623 272.197483 428.099623] DRAWPATH
|
||||
[ 266.454545 424.031458 266.454545 424.031458] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 278.22765 447.609537 476.061991 811.345174] DRAWPATH
|
||||
[ 230.689664 431.114494 -84.0170457 483.276715] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 289.495085 432.665363 289.495085 432.665363] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 360.567866 453.141165 501.779623 494.053404] DRAWPATH
|
||||
[ 274.81961 382.089718 281.507704 278.709227] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 283.267243 433.30677 283.267243 433.30677] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 352.646892 462.879051 523.597944 535.650842] DRAWPATH
|
||||
[ 294.629734 452.34422 426.845285 796.63278] DRAWPATH
|
||||
[ 272.832964 446.052288 70.2896649 608.782654] DRAWPATH
|
||||
[ 365.624887 441.410478 520.031697 460.512511] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 293.898461 435.639168 293.898461 435.639168] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 294.741327 452.376433 279.243037 807.586243] DRAWPATH
|
||||
[ 367.683413 431.938129 529.254118 435.985576] DRAWPATH
|
||||
[ 321.863328 460.205565 366.946012 499.352072] DRAWPATH
|
||||
[ 323.720815 460.741754 514.68594 621.48418] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 303.642892 437.467347 303.642892 437.467347] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 353.092179 462.494596 482.719741 525.752758] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 318.759707 423.56244 318.759707 423.56244] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 315.180079 458.276355 432.087389 682.733455] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 315.088226 458.24984 440.26874 700.16838] DRAWPATH
|
||||
[ 351.0125 464.290165 530.525426 549.181302] DRAWPATH
|
||||
[ 364.889743 443.44478 525.442294 476.360298] DRAWPATH
|
||||
[ 319.695546 459.579805 480.094269 734.889045] DRAWPATH
|
||||
[ 350.758764 464.403292 543.776363 545.188437] DRAWPATH
|
||||
[ 296.626665 452.920661 286.817084 474.067408] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 228.962805 403.12674 219.945446 394.483225] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 235.976065 411.704248 236.002186 411.724193] DRAWPATH
|
||||
0 1 0 setrgbcolor
|
||||
[ 305.170023 390.85148 215.516274 196.797811] DRAWPATH
|
||||
[ 360.386023 453.486004 571.67512 510.756953] DRAWPATH
|
||||
[ 360.849831 452.606459 500.88611 527.200735] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 219.945446 394.483225 103.734142 273.199056] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 219.945446 394.483225 223.109363 392.98258] DRAWPATH
|
||||
[ 223.109363 392.98258 224.012389 390.623768] DRAWPATH
|
||||
[ 224.012389 390.623768 225.260273 389.63598] DRAWPATH
|
||||
[ 225.260273 389.63598 226.112176 386.927522] DRAWPATH
|
||||
[ 226.112176 386.927522 227.008066 385.971662] DRAWPATH
|
||||
[ 228.860937 380.110527 228.379431 378.702407] DRAWPATH
|
||||
[ 230.704864 380.981206 228.860937 380.110527] DRAWPATH
|
||||
[ 227.008066 385.971662 229.219277 384.992072] DRAWPATH
|
||||
[ 226.244777 379.24149 226.429013 378.94604] DRAWPATH
|
||||
[ 226.925635 379.459864 226.244777 379.24149] DRAWPATH
|
||||
[ 226.429013 378.94604 226.446446 378.904656] DRAWPATH
|
||||
[ 227.879853 379.54638 226.925635 379.459864] DRAWPATH
|
||||
[ 228.379431 378.702407 227.879853 379.54638] DRAWPATH
|
||||
[ 229.219277 384.992072 229.965354 384.227034] DRAWPATH
|
||||
[ 230.428695 382.924359 230.704864 380.981206] DRAWPATH
|
||||
[ 229.965354 384.227034 230.428695 382.924359] DRAWPATH
|
||||
[ 103.734142 273.199056 102.894987 274.236229] DRAWPATH
|
||||
0 0 1 setrgbcolor
|
||||
[ 103.734142 273.199056 26.9973037 206.282819] DRAWPATH
|
||||
1 0 0 setrgbcolor
|
||||
[ 102.894987 274.236229 102.51116 273.516345] DRAWPATH
|
||||
[ 102.560512 272.763499 102.923606 272.873917] DRAWPATH
|
||||
[ 102.923606 272.873917 103.206417 273.058928] DRAWPATH
|
||||
[ 103.206417 273.058928 103.131555 273.311725] DRAWPATH
|
||||
[ 103.131555 273.311725 103.132598 273.316082] DRAWPATH
|
||||
[ 102.51116 273.516345 102.026106 273.051121] DRAWPATH
|
||||
[ 102.026106 273.051121 102.560512 272.763499] DRAWPATH
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
// GAG (Geant4 Adaptive GUI)
|
||||
// Requires : JDK 1.1.3 (or later) + swing-1.0.2
|
||||
// Version : alpha 1998/Mar/30
|
||||
// GEANT4 GUI Group Toshiaki Kodama
|
||||
// 1998 July 6 GEANT4 Beta-01
|
||||
|
||||
import GAG.GAG;
|
||||
|
||||
public class gag {
|
||||
public static void main(String args[]){
|
||||
GAG gag = new GAG();
|
||||
gag.mainLoop(args);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
import java.awt.event.*;
|
||||
import com.sun.java.swing.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
abstract class AbstractGGEFrame extends JFrame implements WindowListener, Serializable {
|
||||
AbstractGGEFrame(String title){
|
||||
super(title);
|
||||
addWindowListener(this);
|
||||
}
|
||||
public void windowDeiconified(WindowEvent event) {}
|
||||
public void windowIconified(WindowEvent event) {}
|
||||
public void windowActivated(WindowEvent event) {}
|
||||
public void windowDeactivated(WindowEvent event) {}
|
||||
public void windowOpened(WindowEvent event) {}
|
||||
public void windowClosed(WindowEvent event) {}
|
||||
public void windowClosing(WindowEvent event) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user