JAERI-Data/Code 2002-003 Japan Atomic Energy Research Institute - (x 319-1195 ^J^*g|55lfi5*-/SWB*J|f^^W^3fFti)) T?1fi^C «k This report is issued irregularly. Inquiries about availability of the reports should be addressed to Research Information Division, Department of Intellectual Resources, Japan Atomic Energy Research Institute, Tokai-mura, Naka-gun, Ibaraki-ken T 319-1195, Japan. © Japan Atomic Energy Research Institute, 2002 JAERI- Data/Code 2002-003 Java \Z w-mm n ( 2002 %. 1 ^ 31 B Java *ffitt, -f >*- —tf—T -7x-x (GUI) •fi3.t>*> Java ff , Java #t : T619-0215 ^^^ 8-1 JAERI-Data/Code 2002-003 Visualization Program Development Using Java Akira SASAKI, Keiko SUTO and Hisashi YOKOTA* Advanced Photon Research Center Kansai Research Establishment Japan Atomic Energy Research Institute Kizu-cho, Souraku-gun, Kyoto-fu ( Received January 31, 2002 ) Method of visualization programs using Java for the PC with the graphical user interface (GUI) is discussed, and applied to the visualization and analysis of ID and 2D data from experiments and numerical simulations. Based on an investigation of programming techniques such as drawing graphics and event driven program, example codes are provided in which GUI is implemented using the Abstract Window Toolkit (AWT). The marked advantage of Java comes from the inclusion of library routines for graphics and networking as its language specification, which enables ordinary scientific programmers to make interactive visualization a part of their simulation codes. Moreover, the Java programs are machine independent at the source level. Object oriented programming (OOP) methods used in Java programming will be useful for developing large scientific codes which includes number of modules with better maintenance ability. Keywords: Java, Visualization, Object Oriented Programming, High Performance Computing •Research Organization for Information Science & Technology JAERI-Data/Code 2002-003 1. \ZCtblz l 2. »1MimffitLX(DJavamm 2 3. Java IZk&nJMik-fu if? l±(Dmi& 4 3. i *~7P^>7bmfii-7°n>fy^>ynm 4 3. 2 JavaBi§tCck5^>higI)!i:/a^A 10 3. 3 Abstract Window Toolkit (AWT) (Dffifa 14 4. 2&7LmMm*7°W7A<Dn$m 19 5. l&K>?yy%i*-7u>f;7A<D^$im 2 6 6. £<h& 5 3 5 4 5 4 Contents 1. Introduction 1 2. Java Language for Visualization 2 3. Designing Program Using Java 4 3. 1 Introduction to the Object Oriented Programming 4 3. 2 Event Driven Programming Using Java 10 3. 3 The Abstract Window Toolkit (AWT) 14 4. Application to a Program for Displaying 2D Image Data 19 5. Application to a Program for Displaying ID Hydrodynamics Data--- 2 6 6. Summary 5 3 Acknowledgment 5 4 References 5 4 JAERI-Data/Code 2002-003 1 . PC PC <D BASIC * PC -* (GUI) - t iffy < o ^IJx.!f Kaleidagraph "Cti, 7, -y a -17if- »L, Kaleidagraph ^ Kaleidagraph Excel -C\ ft¥®ffi %t}tf*>Z>o Igor (± 1 t) &*£&%<?>r~ 9 ? unix gnuplot 75 ^<f$^tL^0 gnuplot (± v Lf 'J 7°)^ awk ^ perl 4t 9^7 h L"C(± ft, AVS tf it\ AVS s, 757 ^ 7 ^ <h, -5 u 1 V7 L - 1 - JAERI-Data/Code 2002-003 2 . L T (7) Java Wl PC ^ tti:ii, si fit Lfc Fortran W U «t -6 7 >f 7*7 U £ ft LT 7°U y ? ggfc Tfalk tfi T V PC Ti PC 7 ? ?- 5 - BASIC i" 640x480 77 ~? l y PC Oft^^^|7l?|p]±1-*Uon-C, #^S#ffti:ffli: Fortran B'i 7 X&feZtitzZ h i>$><3tzo 1984 ^C Macintosh ^?JJ,tl, -fCOfg Llf<b < LT PC C Windows *?^ «t 1 IZ tfl: § < ggffc L ^[2]o Macintosh CO®® li If -y b v y 7°T -f X 7° U >f t Pf if 7 v*W -sir, 7^^ t'^ilLTtfd <t -5 i: •? \Z LT PC li^*7 7 >^-7i-x (GUI) ^H£^=t •? i:i GUI colffflii, -feco PC +P'i Ltitzo - cii: i:, 7°n ^7 A GUI 7°or7A(±, i-f- 7 7 --> 3 Z. t LT, GUI y 7n y \£ a.- M* 4 s<y Y tnif, GUI vrv^Ti* (os) *m% - 2 - JAERI-Data/Code 2002-003 90 -f * , , T?< -y 1ftf-Mt L £, ^ A * J: C * Pascal h ^^imBl^io I) s , GUI ^'^ ililtt- »^n/77i:toTli 1R*fe Ut ic^Ti^ < , ffi ^ #ff 0' Java 7°n Java \±4y >?-^-y \ X'fefrtiZ Z. t £& < S;I v^0 ^ijx.li\ Java W iU|Jf^i;3»A$tL^«^-e$)^ Applet (i, Web - y tl y~yJ+X\ Web P'i^ Applet Java 7 *-|TO Java WBP^> 7-X7°O^*7 A 9 - Y -f ;K7) U, 7°7 7 h 7 t-Ai:f#Liv> Java >*4 F-i^tltl^ JavafSS-Vv> (VM) C ojl), Java Wl§ /«-( ;l/HI£ t >f >^ 7°'J ^W Windows, Macintosh, unix 7 b 7 t-A-ci^i: tz;U h 3- K^Uffnr Windows, Macintosh, unix <7)*p 4 > K7 v^-r A (±-?-;fl-f ft GUI 7° (Abstract Window Toolkit) t ^ n /i y Y- V &A,T*Z. t T\ !: Java t JDKl.3 Java2 hf 2001 ^ II Macintosh <T> OS 9.x t B"''v >li JDK1.1 ES L"CV^V>O Windows Java2 H^ttT-LT C, PC Kfc Visual J++75WS L Java ss Java , Java Ml - 3 - JAERI- Data/Code 2002-003 3. , Java H§[n]7°a f [3-5], ^!; (GUI) ^# t: GUI £ft AWT (Abstract Window Toolkit) ? y 7*y 'J 3. tz (: Fortran77 Fortran77 a \ 2 ^9 V struct vector2 { double x,y; struct vector2 velocity; a=velocity.x; velocity.y=b; calc(velocity); Fortran77 f - f- > 11 o (Common L 7 O -A;U^ h&Uvr- 9 zvt'o<D$\&ili$ ktbx - 4 - JAERI-Data/Code 2002-003 Pascal C, C++, Java ^ - <T> X 1 & :x—f- L7C IE z t t w ffiW3 fc'- L ^ Vector2 Java «t d IZ public class Vector2 { private double xx,yy; Vector2 (){ // constructor xx=0.0; yy=0.0; } public Vector2 mult(double d){ // mathematics Vector2 v=new Vector2() v.xx=d*xx; v.yy=d*yy; return v; public Vector2 sum(Vector2 v){ Vector2 v=new Vector2(); xx=v.x+xx; yy=y-x+yy; return v; } public double prod(Vector2 v){ double val; val=xx*v.xx+yy*v.yy; return val; } public double square(){ double val; val=xx*xx+yy*yy; return val; } public void write(Vector2 v){ // access functions xx=v.x; yy=v.y; } public void write(double x0, double yO){ xx=x0; yy=yo ,- } public double x(){ return xx; } public double y(){ return yy; mmi c JAERI-Data/Code 2002-003 Vector2 ?7>UiN xx t yy mult, sum, prod £#JA 11 h I»£#o0 Java TJi> >A- Vector2 ?7 Vector2 w=new Vector2 () ; Vector2 wO=new Vector2 () Vector2 vvl=new Vector2() double ax,ay,b; w. write (ax, ay) ; wl=w.mult (b) ; wl =w. sum (wO) ; wl = w. prod (wO ) ; Java W new U «t Fortran77 i: ^V\ ~fu f v A ji flX fr c TO malloc fortran77 Java f|t«t7'yx^ Mi new < £4 i "Cj new isjiir b1)iM^X\<*&%Z&$:f£tltz%i&%£'lZ$>tz2>o Java < i , C Hl o Cl^tf- ^ £{RJJ£ tl*») iS LT n n - ^i; public -CK - 6 - JAERI-Data/Code 2002-003 h 7&J#£f<S 7°o z. Z> ff, private t Vector2 ?7 a=v.x(); a=v.xx; private X-t public tflL/:, X (7) e< ; ^ -6 3, Vector2 ^ 7 PJT' O Vector2 ^V'/ new (Vector2()) <7) i t h 7 <7 $ t mi o Fortran77 v-y K write >V? KU1±, Vector2 ^ 7 X <7) public void write(Vector2 v) public void write(double xO, double yO) L tz it <nr\ Wtitfrtofr tfffl - 7 - JAERI-Data/Code 2002-003 t Fortran alf "C & M{i&^M&W?l»75 #*»SH&^O;H&ffiJ£fl&& WJW3 X o Tis ? ^9 «t i i:ft , Vector2 9yZ&&%iLtz Velocity ^7^t Java Tiii^TW«t n class Velocity2 extends Vector2 { double ke; Velocity2(){ ke=0.0; } double kinetic_energy(double mass){ ke=square()/2.0 *raass; return ke; } void write(Velocity vel){ write(vel.x(),vel.y()); Velocity2 vel=new Velocity2 t LT$f LV^Velocity2 Velocity2 vel=new Velocity2(); Velocity2 velO=new Velocity2(); double vx,vy,energy,mass; ( + •&) vel.write(vx,vy); vel.write(velO); vxl=vel.x(); vyl^vel.y(); energy=vel.kinetic_energy(mass); - 8 JAERI-Data/Code 2002-003 t Vector2 (i Velocity2 T* #> & i: H" V \ Velocity2 (i Vector2 (is a 691$) TWS V7KWT*,, public iL < (i protected ff $ tl/c t CO ^ , ii^^^ h;Ki Vector2 Velocity2 ^ y X Off L V^ t, - write(vx,vy)x x(), y()> V 7 Kli, Hcflil^ot Vector2 ?7^>V7 KTJ jiffil^^^^'-Oft^: (kinetic_energy(mass)> V-y K) <i, Velocity2 Velocity2 ^ 7 X write > V y KU Vector2 ^7X(I*^ write x.*V>o -e^T\ Velocity2 V7 L Java ~fu^f 1 -{ Jj )l> J. — *f — j V 9 - 7 x. r- n - h z. biz**? rmm - 9 - JAERI- Data/Code 2002-003 3. 2 Java W 3.2.1) IZ^fy -7i-X (GUI) (OS) \Z htz File a — file ^»tf, / Tirr«{sis 1) 1 20&--U9 2; 1 220e 0<3 3S i C-1DH 09 4) 5 3 0,-0, *tftE+? (jainiwrfit-i 0.90- 0.80" 3 60* 0.70" 0.60- 0.40- Q.30- i.oo- o.atr o.io- IK,, , ... O.OQ 0.0! 0.02 0.03 D.34 0 00 0.0! • 0 02 0.05 0 riemj xl° rkm) l 1 la-: 4B t«r tio« for si cs I si C6 2 ter t.ss for bl t«- tip* for- si .flf t.»a for si C4 3 :«•• i-is*r\ CHK SX [«)} tar- sain and x f/ca ronsition) Hi-lik«e dS4d3iei..6e -s S ti9*pSi01.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages61 Page
-
File Size-