├── ALL.zip ├── Compile.sh ├── DirTree.md ├── LICENSE ├── MainWindow.java ├── Makefile ├── README.md ├── clean.sh ├── fwi.png ├── lib ├── include │ ├── README.txt │ ├── alloc.c │ ├── alloc.h │ ├── bhdr.h │ ├── cjbsegy.h │ ├── complex.c │ ├── complex.h │ ├── cwp.h │ ├── fft.c │ ├── fft.h │ ├── hdr.h │ └── mute_direct.h ├── seismic │ ├── README.txt │ ├── RungeKutta.h │ ├── libRungeKutta.so │ ├── src_seismic_RungeKutta.c │ └── src_seismic_RungeKutta.h └── src_seismic_RungeKutta.h ├── net └── java │ └── dev │ └── designgridlayout │ ├── AbstractClassBasedHeightGrowPolicy.java │ ├── AbstractNonGridRow.java │ ├── AbstractRow.java │ ├── AbstractRowItem.java │ ├── BarRow.java │ ├── BarRowItem.java │ ├── BaselineHelper.java │ ├── BasicItem.java │ ├── CenterRow.java │ ├── ClassBasedHeightGrowPolicy.java │ ├── ComponentGapsHelper.java │ ├── ComponentHelper.java │ ├── Componentizer.java │ ├── ComponentizerItem.java │ ├── ComponentizerLayout.java │ ├── ContainerHeightGrowPolicy.java │ ├── DefaultGrowPolicy.java │ ├── DesignGridLayout.java │ ├── DesignGridLayoutManager.java │ ├── EmptySubGrid.java │ ├── GridRow.java │ ├── HeightGrowPolicy.java │ ├── HeightGrowPolicyMapper.java │ ├── IBarRow.java │ ├── IExtractor.java │ ├── IGridRow.java │ ├── IHideable.java │ ├── IItem.java │ ├── INonGridRow.java │ ├── IRow.java │ ├── IRowCreator.java │ ├── IRowItem.java │ ├── ISpannableGridRow.java │ ├── ISubGrid.java │ ├── ISubGridStarter.java │ ├── JScrollPaneHeightGrowPolicy.java │ ├── JSliderHeightGrowPolicy.java │ ├── LabelAlignment.java │ ├── LayoutHelper.java │ ├── LeftRow.java │ ├── MarkerHelper.java │ ├── NonGridRowItem.java │ ├── OrientationPolicy.java │ ├── ParentWrapper.java │ ├── PlatformHelper.java │ ├── README.txt │ ├── RightRow.java │ ├── RowGroup.java │ ├── RowItem.java │ ├── RowIterator.java │ ├── SubGrid.java │ ├── SubList.java │ ├── Tag.java │ ├── UnitHeightGrowPolicy.java │ └── package-info.java ├── picture ├── Author │ ├── README.txt │ ├── rongtao.png │ └── rongtao2.png ├── BackGround │ ├── README.txt │ ├── background1.png │ ├── background2.png │ ├── background3.png │ ├── background4.png │ ├── background5.png │ └── background6.png ├── ButtonImg │ ├── bicycle16.png │ ├── bicycle32.png │ ├── bomb16.png │ ├── bomb32.png │ ├── close16.png │ ├── close32.png │ ├── color16.png │ ├── color32.png │ ├── computer16.png │ ├── computer32.png │ ├── copy16.png │ ├── copy32.png │ ├── curve16.png │ ├── curve32.png │ ├── curves16.png │ ├── curves32.png │ ├── cut16.png │ ├── cut32.png │ ├── ellipse16.png │ ├── ellipse32.png │ ├── exit16.png │ ├── exit32.png │ ├── folder16.png │ ├── folder32.png │ ├── font16.png │ ├── font32.png │ ├── fontbold16.png │ ├── fontbold32.png │ ├── fontitalic16.png │ ├── fontitalic32.png │ ├── fontstrike16.png │ ├── fontstrike32.png │ ├── fontunderline16.png │ ├── fontunderline32.png │ ├── freehand16.png │ ├── freehand32.png │ ├── image16.png │ ├── image32.png │ ├── java128.png │ ├── java16.png │ ├── java32.png │ ├── java64.png │ ├── movie16.png │ ├── movie32.png │ ├── newdocument16.png │ ├── newdocument32.png │ ├── newdocumentwithedit16.png │ ├── newdocumentwithedit32.png │ ├── ok116.png │ ├── ok132.png │ ├── ok16.png │ ├── ok32.png │ ├── opendocument16.png │ ├── opendocument32.png │ ├── paste16.png │ ├── paste32.png │ ├── pen16.png │ ├── pen32.png │ ├── person16.png │ ├── person32.png │ ├── printer16.png │ ├── printer32.png │ ├── raypath16.png │ ├── raypath32.png │ ├── raytracing16.png │ ├── raytracing32.png │ ├── rectangle16.png │ ├── rectangle32.png │ ├── save16.png │ ├── save32.png │ ├── select16.png │ ├── select32.png │ ├── shaped16.png │ ├── shaped32.png │ ├── soundmax16.png │ ├── soundmax32.png │ ├── tcurve32.png │ ├── tcurves32.png │ ├── text16.png │ ├── text32.png │ ├── textwithedit16.png │ ├── textwithedit32.png │ ├── timage32.png │ ├── tmovie1order32.png │ ├── tmovie2order32.png │ ├── tmovie32.png │ ├── traypath32.png │ ├── traytracing32.png │ ├── traytracingLG32.png │ └── traytracingRK32.png └── Expression │ ├── airplain.png │ ├── bomb.png │ ├── candle.png │ ├── candy.png │ ├── coffee.png │ ├── crying.png │ ├── gun.png │ ├── laugh.png │ ├── ok.png │ ├── pingpang.png │ ├── sad.png │ └── tea.png ├── raypath.jpg ├── screenshot ├── FD-vti.jpg ├── FileTree.jpg ├── author.jpg ├── mainWindows.jpg ├── newText.jpg ├── newTextWithEdit.jpg ├── openText.jpg ├── raypath.jpg ├── raypath2.jpg ├── raytracing.jpg ├── snap.jpg └── ximage.jpg └── src ├── about └── myAuthorAboutDialog.java ├── menu └── myMenu.java ├── myComponent └── myBorderJPanel.java ├── paint ├── myXMultiCurveAboutDialog.java ├── myXMultiCurveJFrame.java ├── myXMultiCurveJPanel.java ├── myXMutiCurveParasJFrame.java ├── myXcurveAboutDialog.java ├── myXcurveJFrame.java ├── myXcurveJPanel.java ├── myXcurveParasJFrame.java ├── myXimageAboutDialog.java ├── myXimageJFrame.java ├── myXimageJPanel.java ├── myXimageParasJFrame.java └── saveJPanel.java ├── seismic ├── Lagan.java ├── RungeKutta.java ├── cjbsegy.java ├── myLaganRayTracingAboutDialog.java ├── myLaganRayTracingJFrame.java ├── myLaganRayTracingJPanel.java ├── myLaganRayTracingParasJFrame.java ├── myRungeKuttaRayTracingAboutDialog.java ├── myRungeKuttaRayTracingJFrame.java ├── myRungeKuttaRayTracingJFrameParasJFrame.java ├── myRungeKuttaRayTracingJPanel.java ├── mySEGYJFrame.java ├── myXmovie1OrderPMLAboutDialog.java ├── myXmovie1OrderPMLJFrame.java ├── myXmovie1OrderPMLParasJFrame.java ├── myXmovie2OrderAbsAboutDialog.java ├── myXmovie2OrderAbsJFrame.java ├── myXmovie2OrderAbsParasJFrame.java ├── myXraypathDialog.java ├── myXraypathParasJFrame.java └── saveJPanel.java ├── swap └── Swap.java └── text ├── myJFrameTextNew.java ├── myJFrameTextNewWithEdit.java └── myJFrameTextOpenWithSaveAs.java /ALL.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/ALL.zip -------------------------------------------------------------------------------- /Compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | javac MainWindow.java -Xlint:deprecation 4 | 5 | javah -d ./lib/ src.seismic.RungeKutta 6 | gcc -shared -fpic -o lib/seismic/libRungeKutta.so \ 7 | -I$JAVA_HOME/include -I$JAVA_HOME/include/linux \ 8 | lib/seismic/src_seismic_RungeKutta.c 9 | 10 | java -Djava.library.path=lib/seismic/ MainWindow 11 | 12 | echo "Close the Software!" 13 | 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) Rong Tao, all right reserve. 2 | GCC = gcc 3 | JAVAC = javac 4 | JAVAH = javah 5 | JAVA = java 6 | 7 | WARNING = -Xlint:deprecation 8 | 9 | IJAVAINCLUDE = -I$JAVA_HOME/include 10 | IJAVAINCLUDElinux = -I$JAVA_HOME/include/linux 11 | 12 | CFILE = lib/seismic/src_seismic_RungeKutta.c 13 | OLIB = lib/seismic/libRungeKutta.so 14 | LIBPATH = lib/seismic/ 15 | 16 | MAINCLASS = MainWindow 17 | 18 | ALL: 19 | $(JAVAC) MainWindow.java $(WARNING) 20 | $(JAVAH) -d ./lib/ src.seismic.RungeKutta 21 | $(GCC) -shared -fpic -o $(OLIB) $(IJAVAINCLUDE) $(IJAVAINCLUDElinux) $(CFILE) 22 | $(JAVA) -Djava.library.path=$(LIBPATH) $(MAINCLASS) & 23 | clean: 24 | ./~/clean.sh 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 地震射线追踪与有限差分正演模拟软件 2 | 3 | Copyright (C) RongTao, All right reserve. 4 | 5 | 同步到了我的[GitEE](https://gitee.com/rtoax/Seismic-Processing) 6 | 7 | [Rong Tao](https://github.com/Rtoax) 8 | 9 | - 👋 Hi, I’m [@rtoax](https://github.com/Rtoax), you can see me in [@linux-visor](https://github.com/linux-visor) too. 10 | - 👀 I’m interested in [Linux](https://github.com/torvalds/linux) 11 | - 🌱 I’m currently learning [Linux](https://github.com/torvalds/linux) 12 | - 💞️ I’m looking to collaborate on [libcareplus](https://github.com/Rtoax/libcareplus), [test-linux](https://github.com/Rtoax/test-linux) and [more](https://github.com/Rtoax). 13 | - 📫 How to reach me [GitHub](https://github.com/Rtoax), [CSDN](https://rtoax.blog.csdn.net/), [Gitee](https://gitee.com/rtoax) and 哆啦Linux梦. 14 | 15 | ![哆啦Linux梦](fwi.png) 16 | 17 | # 详情 18 | 19 | This is a software that contains seismic forward modeling, ray tracing, text editing and plotting. You can get the whole diretory&files in ```ALL.zip``` 20 | 这是一个包含了地震正演模拟,射线追踪,文本编辑和绘制曲线图的软件 21 | 22 | ## Directory & file tree in file "DirTree.md" 23 | 24 | * simple directory tree as follows(Detail in DirTree.md) 25 | 26 | ```shell 27 | root 28 | ├── clean.sh 29 | ├── Compile.sh 30 | ├── lib 31 | │   ├── include 32 | │   └── seismic 33 | ├── MainWindow.java 34 | ├── Makefile 35 | ├── net 36 | │   └── java 37 | │   └── dev 38 | │   └── designgridlayout 39 | ├── picture 40 | │   ├── Author 41 | │   ├── BackGround 42 | │   ├── ButtonImg 43 | │   └── Expression 44 | └── src 45 | ├── about 46 | ├── menu 47 | ├── myComponent 48 | ├── paint 49 | ├── seismic 50 | ├── swap 51 | └── text 52 | 53 | 20 directories, 225 files 54 | ``` 55 | 56 | ## Compiled & RUN: 57 | 58 | ```shell 59 | $ make # or 60 | $ sh Compile.sh 61 | ``` 62 | 63 | * You can use clean.sh to clean all .class and other temp 64 | 65 | ```shell 66 | $ sh clean.sh 67 | ``` 68 | 69 | ### Denpendence 70 | 71 | * JDK 8+ 72 | * JNI 73 | * gcc 74 | * Linux is the best env. 75 | 76 | ## Software GUI 77 | 78 | * RayTracing 射线追踪 79 | 80 | ![raypath](raypath.jpg) 81 | 82 | * Main Window 83 | * 84 | ![main window](screenshot/mainWindows.jpg) 85 | * Buttons (from left to right) 86 | * New Text 87 | * 88 | ![new Text](screenshot/newText.jpg) 89 | * New Text with Edit 90 | * 91 | ![new Text with edit](screenshot/newTextWithEdit.jpg) 92 | * Open Text 93 | * 94 | ![open Text](screenshot/openText.jpg) 95 | * show a binary file into a picture 96 | * 97 | ![ximage](screenshot/ximage.jpg) 98 | * in the next two is drawing ling and lines, pass it 99 | * the next tow is Finite Difference (VTI media), for example 100 | * 101 | ![FD-vti](screenshot/FD-vti.jpg) 102 | * it result: 103 | * 104 | ![snap](screenshot/snap.jpg) 105 | * the next two is Ray tracing(isotropic and anisotropic) 106 | * 107 | ![raytracing](screenshot/raytracing.jpg) 108 | * result 1: velocity is constant value 109 | * 110 | ![raypath](screenshot/raypath.jpg) 111 | * result 2: velocity is not constant 112 | * 113 | * ![raypath](screenshot/raypath2.jpg) 114 | 115 | ## Vertical Tool Bar 116 | * first one is author (RongTao) introduction 117 | * 118 | ![author](screenshot/author.jpg) 119 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Rong Tao 2018.1.16 3 | 4 | clear 5 | 6 | filename=("*.class" "*.pyc" "*.h.gch" "*.o" "*~" "*.out") 7 | for name in ${filename[@]}; do 8 | #echo $name 9 | find . -name $name -type f -print -exec rm -rf {} \; 10 | done 11 | 12 | if [ $# -eq 0 ];then 13 | echo $* 14 | fi 15 | 16 | -------------------------------------------------------------------------------- /fwi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/fwi.png -------------------------------------------------------------------------------- /lib/include/README.txt: -------------------------------------------------------------------------------- 1 | 此文件夹内为C语言include头文件,版权归CWP所有Copyright@CWP 2 | -------------------------------------------------------------------------------- /lib/include/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLOC_H 2 | #define ALLOC_H 3 | 4 | #include "cwp.h" 5 | #include "complex.h" 6 | 7 | /* allocate and free multi-dimensional arrays */ 8 | void *alloc1 (size_t n1, size_t size); 9 | void *realloc1 (void *v, size_t n1, size_t size); 10 | void **alloc2 (size_t n1, size_t n2, size_t size); 11 | void ***alloc3 (size_t n1, size_t n2, size_t n3, size_t size); 12 | void ****alloc4 (size_t n1, size_t n2, size_t n3, size_t n4, size_t size); 13 | void *****alloc5 (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t size); 14 | void ******alloc6 (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6, 15 | size_t size); 16 | 17 | void free1 (void *p); 18 | void free2 (void **p); 19 | void free3 (void ***p); 20 | void free4 (void ****p); 21 | void free5 (void *****p); 22 | void free6 (void ******p); 23 | 24 | int *alloc1int (size_t n1); 25 | int *realloc1int (int *v, size_t n1); 26 | int **alloc2int (size_t n1, size_t n2); 27 | int ***alloc3int (size_t n1, size_t n2, size_t n3); 28 | float *alloc1float (size_t n1); 29 | float *realloc1float (float *v, size_t n1); 30 | float **alloc2float (size_t n1, size_t n2); 31 | float ***alloc3float (size_t n1, size_t n2, size_t n3); 32 | 33 | float ****alloc4float (size_t n1, size_t n2, size_t n3, size_t n4); 34 | void free4float (float ****p); 35 | float *****alloc5float (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5); 36 | void free5float (float *****p); 37 | float ******alloc6float (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5, size_t n6); 38 | void free6float (float ******p); 39 | int ****alloc4int (size_t n1, size_t n2, size_t n3, size_t n4); 40 | void free4int (int ****p); 41 | int *****alloc5int (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5); 42 | void free5int (int *****p); 43 | 44 | unsigned char ******alloc6uchar(size_t n1,size_t n2,size_t n3,size_t n4, 45 | size_t n5, size_t n6); 46 | unsigned char *****alloc5uchar(size_t n1,size_t n2,size_t n3,size_t n4, 47 | size_t n5); 48 | void free6uchar(unsigned char ******p); 49 | void free5uchar(unsigned char *****p); 50 | 51 | unsigned short ******alloc6ushort(size_t n1,size_t n2,size_t n3,size_t n4, 52 | size_t n5, size_t n6); 53 | unsigned short *****alloc5ushort(size_t n1,size_t n2,size_t n3,size_t n4, 54 | size_t n5); 55 | unsigned short ***alloc3ushort(size_t n1,size_t n2,size_t n3); 56 | unsigned short **alloc2ushort(size_t n1,size_t n2); 57 | 58 | void free2ushort(unsigned short **p); 59 | void free3ushort(unsigned short ***p); 60 | void free5ushort(unsigned short *****p); 61 | void free6ushort(unsigned short ******p); 62 | 63 | double *alloc1double (size_t n1); 64 | double *realloc1double (double *v, size_t n1); 65 | double **alloc2double (size_t n1, size_t n2); 66 | double ***alloc3double (size_t n1, size_t n2, size_t n3); 67 | complex *alloc1complex (size_t n1); 68 | complex *realloc1complex (complex *v, size_t n1); 69 | complex **alloc2complex (size_t n1, size_t n2); 70 | complex ***alloc3complex (size_t n1, size_t n2, size_t n3); 71 | complex ****alloc4complex (size_t n1, size_t n2, size_t n3, size_t n4); 72 | complex *****alloc5complex (size_t n1, size_t n2, size_t n3, size_t n4, size_t n5); 73 | 74 | void free1int (int *p); 75 | void free2int (int **p); 76 | void free3int (int ***p); 77 | 78 | void free1float (float *p); 79 | void free2float (float **p); 80 | void free3float (float ***p); 81 | 82 | void free1double (double *p); 83 | void free2double (double **p); 84 | void free3double (double ***p); 85 | 86 | void free1complex (complex *p); 87 | void free2complex (complex **p); 88 | void free3complex (complex ***p); 89 | void free4complex (complex ****p); 90 | void free5complex (complex *****p); 91 | 92 | void zero1int(int *p, size_t n1); 93 | void zero2int(int **p, size_t n1, size_t n2); 94 | void zero3int(int ***p, size_t n1, size_t n2, size_t n3); 95 | 96 | void zero2ushort(unsigned short **p, size_t n1, size_t n2); 97 | 98 | void zero3ushort(unsigned short ***p, size_t n1, size_t n2, size_t n3); 99 | 100 | void zero1float(float *p, size_t n1); 101 | void zero2float(float **p, size_t n1, size_t n2); 102 | void zero3float(float ***p, size_t n1, size_t n2, size_t n3); 103 | void zero4float(float ****p, size_t n1, size_t n2, size_t n3, size_t n4); 104 | 105 | void zero1double (double *p, size_t n1); 106 | void zero2double (double **p, size_t n1, size_t n2); 107 | void zero3double (double ***p, size_t n1, size_t n2, size_t n3); 108 | 109 | void zero1complex (complex *p, size_t n1); 110 | void zero2complex (complex **p, size_t n1, size_t n2); 111 | void zero3complex (complex ***p, size_t n1, size_t n2, size_t n3); 112 | void zero4complex (complex ****p, size_t n1, size_t n2, size_t n3, size_t n4); 113 | void zero5complex (complex *****p, size_t n1, size_t n2, size_t n3, size_t n4, size_t n5); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /lib/include/bhdr.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Colorado School of Mines, 2008.*/ 2 | /* All rights reserved. */ 3 | 4 | /* 5 | * bhdr.h - include file for bhed offset array 6 | * THIS HEADER FILE IS FIXED FOR ALL MACHINES BY THE SEG_Y STANDARD 7 | */ 8 | 9 | #ifndef BHDR_H 10 | #define BHDR_H 11 | 12 | static struct { 13 | char *key; char *type; int offs; 14 | } bhdr[] = { 15 | {"jobid", "i", 0}, 16 | {"lino", "i", 4}, 17 | {"reno", "i", 8}, 18 | {"ntrpr", "h", 12}, 19 | {"nart", "h", 14}, 20 | {"hdt", "h", 16}, 21 | {"dto", "h", 18}, 22 | {"hns", "h", 20}, 23 | {"nso", "h", 22}, 24 | {"format", "h", 24}, 25 | {"fold", "h", 26}, 26 | {"tsort", "h", 28}, 27 | {"vscode", "h", 30}, 28 | {"hsfs", "h", 32}, 29 | {"hsfe", "h", 34}, 30 | {"hslen", "h", 36}, 31 | {"hstyp", "h", 38}, 32 | {"schn", "h", 40}, 33 | {"hstas", "h", 42}, 34 | {"hstae", "h", 44}, 35 | {"htatyp", "h", 46}, 36 | {"hcorr", "h", 48}, 37 | {"bgrcv", "h", 50}, 38 | {"rcvm", "h", 52}, 39 | {"mfeet", "h", 54}, 40 | {"polyt", "h", 56}, 41 | {"vpol", "h", 58} 42 | }; 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/include/complex.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Colorado School of Mines, 2005.*/ 2 | /* All rights reserved. */ 3 | 4 | /*********************** self documentation **********************/ 5 | /***************************************************************************** 6 | COMPLEX - Functions to manipulate complex numbers 7 | 8 | cadd add two complex numbers 9 | csub subtract two complex numbers 10 | cmul multiply two complex numbers 11 | cdiv divide two complex numbers 12 | cmplx make a complex number from two real numbers 13 | conjg complex conjugate of a complex number 14 | cneg negate a complex number 15 | cinv invert a complex number 16 | csqrt complex square root of a complex number 17 | cexp complex exponential of a complex number 18 | crmul multiply a complex number by a real number 19 | rcabs real magnitude of a complex number 20 | 21 | ****************************************************************************** 22 | Structure: 23 | typedef struct _complexStruct { complex number 24 | float r,i; 25 | } complex; 26 | 27 | ****************************************************************************** 28 | Function Prototypes: 29 | complex cadd (complex a, complex b); 30 | complex csub (complex a, complex b); 31 | complex cmul (complex a, complex b); 32 | complex cdiv (complex a, complex b); 33 | float rcabs (complex z); 34 | complex cmplx (float re, float im); 35 | complex conjg (complex z); 36 | complex cneg (complex z); 37 | complex cinv (complex z); 38 | complex csqrt (complex z); 39 | complex cexp (complex z); 40 | complex crmul (complex a, float x); 41 | 42 | ****************************************************************************** 43 | Notes: 44 | The function "rcabs" was originally called "fcabs". This produced 45 | a collision on some systems so a new name was chosen. 46 | 47 | ****************************************************************************** 48 | Reference: 49 | Adapted from Press et al, 1988, Numerical Recipes in C (Appendix E). 50 | 51 | ****************************************************************************** 52 | Author: Dave Hale, Colorado School of Mines, 06/02/89 53 | Modified: Dave Hale, Colorado School of Mines, 04/26/90 54 | Added function cinv(). 55 | *****************************************************************************/ 56 | /**************** end self doc ********************************/ 57 | 58 | #include "complex.h" 59 | 60 | complex cadd(complex a, complex b) 61 | { 62 | complex c; 63 | c.r = a.r+b.r; 64 | c.i = a.i+b.i; 65 | return c; 66 | } 67 | 68 | complex csub(complex a, complex b) 69 | { 70 | complex c; 71 | c.r = a.r-b.r; 72 | c.i = a.i-b.i; 73 | return c; 74 | } 75 | 76 | complex cmul(complex a, complex b) 77 | { 78 | complex c; 79 | c.r = a.r*b.r-a.i*b.i; 80 | c.i = a.i*b.r+a.r*b.i; 81 | return c; 82 | } 83 | 84 | complex cdiv(complex a, complex b) 85 | { 86 | complex c; 87 | float r,den; 88 | if (fabs(b.r)>=fabs(b.i)) { 89 | r = b.i/b.r; 90 | den = b.r+r*b.i; 91 | c.r = (a.r+r*a.i)/den; 92 | c.i = (a.i-r*a.r)/den; 93 | } else { 94 | r = b.r/b.i; 95 | den = b.i+r*b.r; 96 | c.r = (a.r*r+a.i)/den; 97 | c.i = (a.i*r-a.r)/den; 98 | } 99 | return c; 100 | } 101 | 102 | complex cmplx(float re, float im) 103 | { 104 | complex c; 105 | c.r = re; 106 | c.i = im; 107 | return c; 108 | } 109 | 110 | complex conjg(complex z) 111 | { 112 | complex c; 113 | c.r = z.r; 114 | c.i = -z.i; 115 | return c; 116 | } 117 | 118 | complex cneg(complex z) 119 | { 120 | complex c; 121 | c.r = -z.r; 122 | c.i = -z.i; 123 | return c; 124 | } 125 | 126 | complex cinv(complex z) 127 | { 128 | complex c; 129 | float s; 130 | s = 1.0/(z.r*z.r+z.i*z.i); 131 | c.r = z.r*s; 132 | c.i = -z.i*s; 133 | return c; 134 | } 135 | 136 | complex ccsqrt(complex z)//+++++++=change the "c" to "cc" 137 | { 138 | complex c; 139 | float x,y,w,r; 140 | if (z.r==0.0 && z.i==0.0) { 141 | c.r = c.i = 0.0; 142 | return c; 143 | } else { 144 | x = fabs(z.r); 145 | y = fabs(z.i); 146 | if (x>=y) { 147 | r = y/x; 148 | w = sqrt(x)*sqrt(0.5*(1.0+sqrt(1.0+r*r))); 149 | } else { 150 | r = x/y; 151 | w = sqrt(y)*sqrt(0.5*(r+sqrt(1.0+r*r))); 152 | } 153 | if (z.r>=0.0) { 154 | c.r = w; 155 | c.i = z.i/(2.0*w); 156 | } else { 157 | c.i = (z.i>=0.0) ? w : -w; 158 | c.r = z.i/(2.0*c.i); 159 | } 160 | return c; 161 | } 162 | } 163 | 164 | complex ccexp(complex z)//+++++++=change the "c" to "cc" 165 | { 166 | float a; 167 | complex c; 168 | a = exp(z.r); 169 | c.r = a*cos(z.i); 170 | c.i = a*sin(z.i); 171 | return c; 172 | } 173 | 174 | complex crmul(complex a, float x) 175 | { 176 | complex c; 177 | c.r = x*a.r; 178 | c.i = x*a.i; 179 | return c; 180 | } 181 | 182 | float rcabs(complex z) 183 | { 184 | float x,y,ans,temp; 185 | x = fabs(z.r); 186 | y = fabs(z.i); 187 | if (x==0.0) 188 | ans = y; 189 | else if (y==0.0) 190 | ans = x; 191 | else if (x>y) { 192 | temp = y/x; 193 | ans = x*sqrt(1.0+temp*temp); 194 | } else { 195 | temp =x/y; 196 | ans = y*sqrt(1.0+temp*temp); 197 | } 198 | return ans; 199 | } 200 | 201 | -------------------------------------------------------------------------------- /lib/include/complex.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPLEX_H 2 | #define COMPLEX_H 3 | 4 | /* TYPEDEFS */ 5 | #ifdef CRAY 6 | typedef struct _complexStruct { /* complex number */ 7 | float r,i; 8 | } cwp_complex; 9 | typedef struct _dcomplexStruct { /* double-precision complex number */ 10 | double r,i; 11 | } cwp_dcomplex; 12 | #define complex cwp_complex 13 | #define dcomplex cwp_dcomplex 14 | #define cadd cwp_cadd 15 | #define csub cwp_csub 16 | #define cmul cwp_cmul 17 | #define cdiv cwp_cdiv 18 | #define rcabs cwp_rcabs 19 | #define cmplx cwp_cmplx 20 | #define conjg cwp_conjg 21 | #define cneg cwp_cneg 22 | #define cinv cwp_cinv 23 | #define csqrt cwp_csqrt 24 | #define cexp cwp_cexp 25 | #define crmul cwp_crmul 26 | #define cipow cwp_cipow 27 | #define crpow cwp_crpow 28 | #define rcpow cwp_rcpow 29 | #define ccpow cwp_ccpow 30 | #define ccos cwp_ccos 31 | #define csin cwp_csin 32 | #define ccosh cwp_ccosh 33 | #define csinh cwp_csinh 34 | #define cexp1 cwp_cexp1 35 | #define clog cwp_clog 36 | 37 | #else 38 | 39 | #ifndef __cplusplus /* if not C++, define the C struct complex */ 40 | #ifndef complex 41 | typedef struct _complexStruct 42 | { /* complex number */ 43 | float r,i; 44 | } complex; 45 | #endif/* complex */ 46 | #else /* if C++, define the C++ class complex */ 47 | #include "Complex.h" 48 | #endif /* C++ */ 49 | 50 | #endif 51 | 52 | /* FUNCTION PROTOTYPES */ 53 | 54 | #ifndef __cplusplus /* if not C++, declare C complex functions */ 55 | /* complex number manipulation */ 56 | complex cadd (complex a, complex b); 57 | complex csub (complex a, complex b); 58 | complex cmul (complex a, complex b); 59 | complex cdiv (complex a, complex b); 60 | float rcabs (complex z); 61 | complex cmplx (float re, float im); 62 | complex conjg (complex z); 63 | complex cneg (complex z); 64 | complex cinv (complex z); 65 | complex ccsqrt (complex z); //+++++++=change the "c" to "cc" 66 | complex ccexp (complex z); //+++++++=change the "c" to "cc" 67 | complex crmul (complex a, float x); 68 | 69 | /* complex functions */ 70 | complex cipow(complex a, int p); 71 | complex crpow(complex a, float p); 72 | complex rcpow(float a, complex p); 73 | complex ccpow (complex a, complex p); 74 | complex cccos(complex a);//+++++++=change the "c" to "cc" 75 | complex ccsin(complex a);//+++++++=change the "c" to "cc" 76 | complex cccosh(complex a);//+++++++=change the "c" to "cc" 77 | complex ccsinh(complex a);//+++++++=change the "c" to "cc" 78 | complex cexp1(complex a); 79 | complex cclog(complex a);//+++++++=change the "c" to "cc" 80 | #endif 81 | 82 | #endif /* Complex.h */ 83 | -------------------------------------------------------------------------------- /lib/include/cwp.h: -------------------------------------------------------------------------------- 1 | /* cjb.h - include file for general purpose CWP stuff */ 2 | 3 | #ifndef CWP_H 4 | #define CWP_H 5 | 6 | 7 | /* INCLUDES */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef CADDR_T_NOT_DEFINED 19 | typedef char * caddr_t; 20 | #endif 21 | 22 | #ifndef size_t 23 | #define size_t int 24 | #endif 25 | #ifndef NULL 26 | #define NULL ((void *)0) 27 | #endif 28 | #ifndef PI 29 | #define PI (3.141592653589793) 30 | #endif 31 | #ifndef SEEK_SET 32 | #define SEEK_SET (0) 33 | #endif 34 | #ifndef SEEK_CUR 35 | #define SEEK_CUR (1) 36 | #endif 37 | #ifndef SEEK_END 38 | #define SEEK_END (2) 39 | #endif 40 | #ifndef ABS 41 | #define ABS(x) ((x) < 0 ? -(x) : (x)) 42 | #endif 43 | #ifndef SGN 44 | #define SGN(x) ((x) < 0 ? -1.0 : 1.0) 45 | #endif 46 | #define NINT(x) ((int)((x)>0.0?(x)+0.5:(x)-0.5)) 47 | #define ISIZE sizeof(int) 48 | #define FSIZE sizeof(float) 49 | #define DSIZE sizeof(double) 50 | 51 | #ifndef MAX 52 | #define MAX(x,y) ((x) > (y) ? (x) : (y)) 53 | #endif 54 | #ifndef MIN 55 | #define MIN(x,y) ((x) < (y) ? (x) : (y)) 56 | #endif 57 | #ifndef TRUE 58 | #define TRUE (1) 59 | #endif 60 | #ifndef FALSE 61 | #define FALSE (0) 62 | #endif 63 | #ifndef YES 64 | #define YES (1) 65 | #endif 66 | #ifndef NO 67 | #define NO (0) 68 | #endif 69 | 70 | #define STREQ(s,t) (strcmp(s,t) == 0) 71 | #define STRLT(s,t) (strcmp(s,t) < 0) 72 | #define STRGT(s,t) (strcmp(s,t) > 0) 73 | #define DIM(a) (sizeof(a)/sizeof(a[0])) 74 | #endif /*CWP_H*/ 75 | -------------------------------------------------------------------------------- /lib/include/fft.h: -------------------------------------------------------------------------------- 1 | /* fft.h -- FFT transform head file */ 2 | /********************************************************************** 3 | PFAFFT - Functions to perform Prime Factor (PFA) FFT's, in place 4 | 5 | npfa return valid n for complex-to-complex PFA 6 | npfar return valid n for real-to-complex/complex-to-real PFA 7 | npfao return optimal n for complex-to-complex PFA 8 | npfaro return optimal n for real-to-complex/complex-to-real PFA 9 | pfacc 1D PFA complex to complex 10 | pfacr 1D PFA complex to real 11 | pfarc 1D PFA real to complex 12 | pfamcc multiple PFA complex to real 13 | pfa2cc 2D PFA complex to complex 14 | pfa2cr 2D PFA complex to real 15 | pfa2rc 2D PFA real to complex 16 | **********************************************************************/ 17 | #ifndef FFT_H 18 | #define FFT_H 19 | 20 | #include "cwp.h" 21 | #include "complex.h" 22 | 23 | /* Prime Factor FFTs */ 24 | int npfa (int nmin); 25 | int npfao (int nmin, int nmax); 26 | int npfar (int nmin); 27 | int npfaro (int nmin, int nmax); 28 | void pfacc (int isign, int n, complex z[]); 29 | void pfarc (int isign, int n, float rz[], complex cz[]); 30 | void pfacr (int isign, int n, complex cz[], float rz[]); 31 | void pfa2cc (int isign, int idim, int n1, int n2, complex z[]); 32 | void pfa2rc (int isign, int idim, int n1, int n2, float rz[], complex cz[]); 33 | void pfa2cr (int isign, int idim, int n1, int n2, complex cz[], float rz[]); 34 | void pfamcc (int isign, int n, int nt, int k, int kt, complex z[]); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/include/hdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hdr.h - include file for segy offset array 3 | * THIS HEADER FILE IS GENERATED AUTOMATICALLY - 4 | * see the makefile in this directory 5 | */ 6 | 7 | #ifndef HDR_H 8 | #define HDR_H 9 | 10 | static struct { 11 | char *key; char *type; int offs; 12 | } hdr[] = { 13 | { "tracl", "i", 0}, 14 | { "tracr", "i", 4}, 15 | { "fldr", "i", 8}, 16 | { "tracf", "i", 12}, 17 | { "ep", "i", 16}, 18 | { "cdp", "i", 20}, 19 | { "cdpt", "i", 24}, 20 | { "trid", "h", 28}, 21 | { "nvs", "h", 30}, 22 | { "nhs", "h", 32}, 23 | { "duse", "h", 34}, 24 | { "offset", "i", 36}, 25 | { "gelev", "i", 40}, 26 | { "selev", "i", 44}, 27 | { "sdepth", "i", 48}, 28 | { "gdel", "i", 52}, 29 | { "sdel", "i", 56}, 30 | { "swdep", "i", 60}, 31 | { "gwdep", "i", 64}, 32 | { "scalel", "h", 68}, 33 | { "scalco", "h", 70}, 34 | { "sx", "i", 72}, 35 | { "sy", "i", 76}, 36 | { "gx", "i", 80}, 37 | { "gy", "i", 84}, 38 | { "counit", "h", 88}, 39 | { "wevel", "h", 90}, 40 | { "swevel", "h", 92}, 41 | { "sut", "h", 94}, 42 | { "gut", "h", 96}, 43 | { "sstat", "h", 98}, 44 | { "gstat", "h", 100}, 45 | { "tstat", "h", 102}, 46 | { "laga", "h", 104}, 47 | { "lagb", "h", 106}, 48 | { "delrt", "h", 108}, 49 | { "muts", "h", 110}, 50 | { "mute", "h", 112}, 51 | { "ns", "u", 114}, 52 | { "dt", "u", 116}, 53 | { "gain", "h", 118}, 54 | { "igc", "h", 120}, 55 | { "igi", "h", 122}, 56 | { "corr", "h", 124}, 57 | { "sfs", "h", 126}, 58 | { "sfe", "h", 128}, 59 | { "slen", "h", 130}, 60 | { "styp", "h", 132}, 61 | { "stas", "h", 134}, 62 | { "stae", "h", 136}, 63 | { "tatyp", "h", 138}, 64 | { "afilf", "h", 140}, 65 | { "afils", "h", 142}, 66 | { "nofilf", "h", 144}, 67 | { "nofils", "h", 146}, 68 | { "lcf", "h", 148}, 69 | { "hcf", "h", 150}, 70 | { "lcs", "h", 152}, 71 | { "hcs", "h", 154}, 72 | { "year", "h", 156}, 73 | { "day", "h", 158}, 74 | { "hour", "h", 160}, 75 | { "minute", "h", 162}, 76 | { "sec", "h", 164}, 77 | { "timbas", "h", 166}, 78 | { "trwf", "h", 168}, 79 | { "grnors", "h", 170}, 80 | { "grnofr", "h", 172}, 81 | { "grnlof", "h", 174}, 82 | { "gaps", "h", 176}, 83 | { "otrav", "h", 178}, 84 | { "d1", "f", 180}, 85 | { "f1", "f", 184}, 86 | { "d2", "f", 188}, 87 | { "f2", "f", 192}, 88 | { "ungpow", "f", 196}, 89 | { "unscale", "f", 200}, 90 | { "ntr", "i", 204}, 91 | { "mark", "h", 208}, 92 | {"shortpad", "h", 210}, 93 | }; 94 | #endif 95 | -------------------------------------------------------------------------------- /lib/include/mute_direct.h: -------------------------------------------------------------------------------- 1 | /************* mute direct-wave on one trace **********/ 2 | 3 | void mute_direct(float *trace, int nt, float dt, float vel_direct, 4 | float offset, float t0, int nttaper) 5 | { 6 | /*** t0--------- direct-wave starting time of zero-offset ****/ 7 | /*** nttaper---- taper point number beyond direct-wave starting time ****/ 8 | 9 | int it, jt, kt, jt1; 10 | float t, rc; 11 | 12 | t=fabs(offset)/vel_direct+t0; 13 | jt=t/dt; 14 | kt=jt+nttaper; 15 | jt1=jt-1; 16 | rc=1.0/nttaper; 17 | 18 | for(it=0;it 3 | /* Header for class RungeKutta */ 4 | 5 | #ifndef _Included_RungeKutta 6 | #define _Included_RungeKutta 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: RungeKutta 12 | * Method: rungekutta 13 | * Signature: ([Ljava/lang/String;[I[F)[F 14 | */ 15 | JNIEXPORT jfloatArray JNICALL Java_src_seismic_RungeKutta_rungekutta 16 | (JNIEnv *, jclass, jobjectArray, jintArray, jfloatArray); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/seismic/libRungeKutta.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/lib/seismic/libRungeKutta.so -------------------------------------------------------------------------------- /lib/seismic/src_seismic_RungeKutta.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class src_seismic_RungeKutta */ 4 | 5 | #ifndef _Included_src_seismic_RungeKutta 6 | #define _Included_src_seismic_RungeKutta 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: src_seismic_RungeKutta 12 | * Method: rungekutta 13 | * Signature: ([Ljava/lang/String;[I[F)[F 14 | */ 15 | JNIEXPORT jfloatArray JNICALL Java_src_seismic_RungeKutta_rungekutta 16 | (JNIEnv *, jclass, jobjectArray, jintArray, jfloatArray); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /lib/src_seismic_RungeKutta.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class src_seismic_RungeKutta */ 4 | 5 | #ifndef _Included_src_seismic_RungeKutta 6 | #define _Included_src_seismic_RungeKutta 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: src_seismic_RungeKutta 12 | * Method: rungekutta 13 | * Signature: ([Ljava/lang/String;[I[F)[F 14 | */ 15 | JNIEXPORT jfloatArray JNICALL Java_src_seismic_RungeKutta_rungekutta 16 | (JNIEnv *, jclass, jobjectArray, jintArray, jfloatArray); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/AbstractClassBasedHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | 19 | abstract class AbstractClassBasedHeightGrowPolicy 20 | implements ClassBasedHeightGrowPolicy 21 | { 22 | protected AbstractClassBasedHeightGrowPolicy(Class componentClass) 23 | { 24 | _componentClass = componentClass; 25 | } 26 | 27 | @Override final public Class getComponentClass() 28 | { 29 | return _componentClass; 30 | } 31 | 32 | @Override final public boolean canGrowHeight(Component component) 33 | { 34 | return componentCanGrowHeight(_componentClass.cast(component)); 35 | } 36 | 37 | @Override final public int computeExtraHeight(Component component, int extraHeight) 38 | { 39 | return componentComputeExtraHeight( 40 | _componentClass.cast(component), extraHeight); 41 | } 42 | 43 | // Should be overridden if T components might not always be growable in height 44 | protected boolean componentCanGrowHeight(T component) 45 | { 46 | return true; 47 | } 48 | 49 | // Should be overridden if T components have special requirements in height 50 | protected int componentComputeExtraHeight(T component, int extraHeight) 51 | { 52 | return extraHeight; 53 | } 54 | 55 | private final Class _componentClass; 56 | } 57 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/AbstractNonGridRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import javax.swing.JComponent; 21 | 22 | abstract class AbstractNonGridRow extends AbstractRow implements INonGridRow 23 | { 24 | @Override public INonGridRow add(JComponent... children) 25 | { 26 | for (JComponent component: children) 27 | { 28 | checkAddedComponent(component); 29 | _items.add(new NonGridRowItem(component)); 30 | parent().add(component); 31 | } 32 | return this; 33 | } 34 | 35 | @Override public INonGridRow addMulti(JComponent... children) 36 | { 37 | for (JComponent component: children) 38 | { 39 | checkAddedComponent(component); 40 | } 41 | return add(Componentizer.create().fixedPref(children).component()); 42 | } 43 | 44 | @Override public INonGridRow indent() 45 | { 46 | return indent(1); 47 | } 48 | 49 | @Override public INonGridRow indent(int n) 50 | { 51 | if (n >= 0) 52 | { 53 | _indent = ComponentGapsHelper.instance().getHorizontalIndent() * n; 54 | } 55 | return this; 56 | } 57 | 58 | @Override public INonGridRow fill() 59 | { 60 | _fill = true; 61 | return this; 62 | } 63 | 64 | @Override public INonGridRow withOwnRowWidth() 65 | { 66 | _ownRowWidth = true; 67 | return this; 68 | } 69 | 70 | @Override List items() 71 | { 72 | return _items; 73 | } 74 | 75 | @Override int totalNonGridWidth(int hgap, int unrelhgap) 76 | { 77 | int count = _items.size(); 78 | int totalWidth = _compWidth * count + (hgap * (count - 1)) + _indent; 79 | return totalWidth; 80 | } 81 | 82 | @Override int componentNonGridWidth() 83 | { 84 | return (_ownRowWidth ? 0 : actualComponentNonGridWidth()); 85 | } 86 | 87 | private int actualComponentNonGridWidth() 88 | { 89 | return ComponentHelper.maxValues(_items, PrefWidthExtractor.INSTANCE); 90 | } 91 | 92 | @Override void forceComponentNonGridWidth(int width) 93 | { 94 | _compWidth = (width > 0 && !_ownRowWidth ? width : actualComponentNonGridWidth()); 95 | } 96 | 97 | //CSOFF: ParameterNumber 98 | @Override int layoutRow(LayoutHelper helper, int left, int hgap, int gridgap, 99 | int unrelhgap, int rowWidth, int gridsWidth, List labelsWidth) 100 | { 101 | // Calculate various needed widths & origin 102 | int x = left + _indent; 103 | int count = _items.size(); 104 | int width = _compWidth; 105 | 106 | int leftFiller = width; 107 | int rightFiller = width; 108 | if (!_fill) 109 | { 110 | int usedWidth = width * count + ((count - 1) * hgap) + _indent; 111 | x += xOffset(rowWidth, usedWidth); 112 | } 113 | else 114 | { 115 | int availableWidth = rowWidth - _indent - (count - 1) * hgap; 116 | leftFiller = leftFiller(count, width, availableWidth); 117 | rightFiller = rightFiller(count, width, availableWidth); 118 | } 119 | 120 | return layoutRow(helper, x, hgap, width, leftFiller, rightFiller); 121 | } 122 | //CSON: ParameterNumber 123 | 124 | protected int layoutRow(LayoutHelper helper, int left, int hgap, int width, 125 | int leftFiller, int rightFiller) 126 | { 127 | int x = left; 128 | int count = _items.size(); 129 | int i = 0; 130 | int actualHeight = 0; 131 | for (NonGridRowItem item: _items) 132 | { 133 | int compWidth; 134 | if (i == 0) 135 | { 136 | compWidth = leftFiller; 137 | } 138 | else if (i == count - 1) 139 | { 140 | compWidth = rightFiller; 141 | } 142 | else 143 | { 144 | compWidth = width; 145 | } 146 | actualHeight = Math.max(actualHeight, helper.setSizeLocation( 147 | item.component(), x, compWidth, height(), baseline())); 148 | x += compWidth + hgap; 149 | i++; 150 | } 151 | return actualHeight; 152 | } 153 | 154 | abstract protected int xOffset(int rowWidth, int usedWidth); 155 | 156 | abstract protected int leftFiller(int count, int width, int availableWidth); 157 | 158 | abstract protected int rightFiller(int count, int width, int availableWidth); 159 | 160 | private final List _items = new ArrayList(); 161 | private boolean _fill = false; 162 | private boolean _ownRowWidth = false; 163 | private int _compWidth = 0; 164 | private int _indent = 0; 165 | } 166 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/AbstractRowItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | abstract class AbstractRowItem extends BasicItem implements IRowItem 20 | { 21 | protected AbstractRowItem(JComponent component) 22 | { 23 | super(component); 24 | } 25 | 26 | @Override public void hide() 27 | { 28 | if (isFirstSpanRow()) 29 | { 30 | _isVisible = component().isVisible(); 31 | component().setVisible(false); 32 | } 33 | } 34 | 35 | @Override public void show() 36 | { 37 | if (isFirstSpanRow()) 38 | { 39 | component().setVisible(_isVisible); 40 | } 41 | } 42 | 43 | private boolean _isVisible = true; 44 | } 45 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/BarRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Collections; 19 | import java.util.Iterator; 20 | import java.util.List; 21 | 22 | import javax.swing.JComponent; 23 | 24 | final class BarRow extends AbstractRow implements IBarRow 25 | { 26 | @Override public IBarRow add(JComponent child, Tag tag) 27 | { 28 | if (child != null) 29 | { 30 | checkAddedComponent(child); 31 | _items.add(new BarRowItem(child, (tag == null ? Tag.OTHER : tag))); 32 | parent().add(child); 33 | } 34 | return this; 35 | } 36 | 37 | @Override public IBarRow center(JComponent... children) 38 | { 39 | return add(Tag.OTHER, children); 40 | } 41 | 42 | @Override public IBarRow left(JComponent... children) 43 | { 44 | return add(Tag.LEFT, children); 45 | } 46 | 47 | @Override public IBarRow right(JComponent... children) 48 | { 49 | return add(Tag.RIGHT, children); 50 | } 51 | 52 | private IBarRow add(Tag tag, JComponent... children) 53 | { 54 | for (JComponent child: children) 55 | { 56 | add(child, tag); 57 | } 58 | return this; 59 | } 60 | 61 | @Override public IBarRow gap() 62 | { 63 | _items.add(null); 64 | return this; 65 | } 66 | 67 | @Override public IBarRow withOwnRowWidth() 68 | { 69 | _ownRowWidth = true; 70 | return this; 71 | } 72 | 73 | @Override List items() 74 | { 75 | if (_leftItems == null) 76 | { 77 | // First of all split into 3 lists: left, center and right 78 | _leftItems = PlatformHelper.extractLeftItems(_items); 79 | _centerItems = PlatformHelper.extractCenterItems(_items); 80 | _rightItems = PlatformHelper.extractRightItems(_items); 81 | 82 | // Then rebuild _items to only include all but non-null items 83 | _items.clear(); 84 | _items.addAll(_leftItems); 85 | _items.addAll(_centerItems); 86 | _items.addAll(_rightItems); 87 | // Calculate total number of extra gaps 88 | _numUnrelatedGaps = numGapsBetweenParts(); 89 | Iterator i = _items.iterator(); 90 | while (i.hasNext()) 91 | { 92 | if (i.next() == null) 93 | { 94 | i.remove(); 95 | _numUnrelatedGaps++; 96 | } 97 | } 98 | } 99 | return _items; 100 | } 101 | 102 | @Override int totalNonGridWidth(int hgap, int unrelhgap) 103 | { 104 | int leftWidth = computePartWidth(_leftItems, hgap, unrelhgap); 105 | int rightWidth = computePartWidth(_rightItems, hgap, unrelhgap); 106 | int centerWidth = computePartWidth(_centerItems, hgap, unrelhgap); 107 | int sidesWidth = Math.max(leftWidth, rightWidth); 108 | if (centerWidth != 0 && (leftWidth != 0 || rightWidth != 0)) 109 | { 110 | sidesWidth *= 2; 111 | } 112 | int totalWidth = centerWidth + sidesWidth + unrelhgap * numGapsBetweenParts(); 113 | return totalWidth; 114 | } 115 | 116 | @Override int componentNonGridWidth() 117 | { 118 | return (_ownRowWidth ? 0 : actualComponentNonGridWidth()); 119 | } 120 | 121 | private int actualComponentNonGridWidth() 122 | { 123 | return ComponentHelper.maxValues(_items, PrefWidthExtractor.INSTANCE); 124 | } 125 | 126 | @Override void forceComponentNonGridWidth(int width) 127 | { 128 | _compWidth = ((width > 0 && !_ownRowWidth) ? width : actualComponentNonGridWidth()); 129 | } 130 | 131 | //CSOFF: ParameterNumber 132 | @Override int layoutRow(LayoutHelper helper, int left, int hgap, int gridgap, 133 | int unrelhgap, int rowWidth, int gridsWidth, List labelsWidth) 134 | { 135 | // Layout each part of the row individually 136 | int x = left; 137 | int actualHeight = layoutOnePart(helper, x, hgap, unrelhgap, _leftItems); 138 | 139 | x = left + (rowWidth - computePartWidth(_centerItems, hgap, unrelhgap)) / 2; 140 | actualHeight = Math.max( 141 | actualHeight, layoutOnePart(helper, x, hgap, unrelhgap, _centerItems)); 142 | 143 | x = left + rowWidth - computePartWidth(_rightItems, hgap, unrelhgap); 144 | actualHeight = Math.max( 145 | actualHeight, layoutOnePart(helper, x, hgap, unrelhgap, _rightItems)); 146 | 147 | return actualHeight; 148 | } 149 | //CSON: ParameterNumber 150 | 151 | private int computePartWidth(List items, int hgap, int unrelhgap) 152 | { 153 | if (!items.isEmpty()) 154 | { 155 | int numUnrelGaps = Collections.frequency(items, null); 156 | int numComponents = items.size() - numUnrelGaps; 157 | int numGaps = numComponents - numUnrelGaps - 1; 158 | int width = numComponents * _compWidth + numGaps * hgap + numUnrelGaps * unrelhgap; 159 | return width; 160 | } 161 | else 162 | { 163 | return 0; 164 | } 165 | } 166 | 167 | private int numGapsBetweenParts() 168 | { 169 | // Calculate total number of extra gaps 170 | int numParts = (_leftItems.isEmpty() ? 0 : 1) + 171 | (_centerItems.isEmpty() ? 0 : 1) + 172 | (_rightItems.isEmpty() ? 0 : 1); 173 | return (numParts > 0 ? numParts - 1 : 0); 174 | } 175 | 176 | private int layoutOnePart( 177 | LayoutHelper helper, int xOrigin, int hgap, int unrelhgap, List items) 178 | { 179 | int x = xOrigin; 180 | int actualHeight = 0; 181 | for (BarRowItem item: items) 182 | { 183 | if (item != null) 184 | { 185 | actualHeight = Math.max(actualHeight, helper.setSizeLocation( 186 | item.component(), x, _compWidth, height(), baseline())); 187 | x += _compWidth + hgap; 188 | } 189 | else 190 | { 191 | x += unrelhgap - hgap; 192 | } 193 | } 194 | return actualHeight; 195 | } 196 | 197 | private final List _items = new ArrayList(); 198 | private List _leftItems = null; 199 | private List _centerItems = null; 200 | private List _rightItems = null; 201 | private int _numUnrelatedGaps = 0; 202 | private boolean _ownRowWidth = false; 203 | private int _compWidth = 0; 204 | } 205 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/BarRowItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | class BarRowItem extends NonGridRowItem 20 | { 21 | BarRowItem(JComponent component, Tag tag) 22 | { 23 | super(component); 24 | _tag = tag; 25 | } 26 | 27 | Tag tag() 28 | { 29 | return _tag; 30 | } 31 | 32 | final private Tag _tag; 33 | } 34 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/BaselineHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | import java.awt.Dimension; 19 | import java.util.HashSet; 20 | import java.util.Set; 21 | 22 | import javax.swing.JComponent; 23 | import javax.swing.JProgressBar; 24 | import javax.swing.JSeparator; 25 | 26 | // This helper solves an issue with baselines in Windows XP LAF on Java 5 27 | final class BaselineHelper 28 | { 29 | private BaselineHelper() 30 | { 31 | } 32 | 33 | static public int getBaseline(Component comp) 34 | { 35 | Dimension size = comp.getPreferredSize(); 36 | int baseline = getBaseline(comp, size.width, size.height); 37 | if (baseline < 0) 38 | { 39 | boolean isCenter = false; 40 | // Special fix for some components with -1 baselines 41 | for (Class clazz: _centerAlignedComponents) 42 | { 43 | if (clazz.isInstance(comp)) 44 | { 45 | isCenter = true; 46 | break; 47 | } 48 | } 49 | if (!isCenter) 50 | { 51 | baseline = 0; 52 | } 53 | } 54 | return baseline; 55 | } 56 | 57 | static private int getBaseline(Component comp, int width, int height) 58 | { 59 | return comp.getBaseline(width, height); 60 | } 61 | 62 | static private final Set> _centerAlignedComponents = 63 | new HashSet>(); 64 | 65 | static 66 | { 67 | _centerAlignedComponents.add(JSeparator.class); 68 | _centerAlignedComponents.add(JProgressBar.class); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/BasicItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | class BasicItem implements IItem 20 | { 21 | public BasicItem(JComponent component) 22 | { 23 | _component = component; 24 | } 25 | 26 | protected void setComponent(JComponent component) 27 | { 28 | _component = component; 29 | } 30 | 31 | @Override public JComponent component() 32 | { 33 | return _component; 34 | } 35 | 36 | @Override public int preferredHeight() 37 | { 38 | return component().getPreferredSize().height; 39 | } 40 | 41 | @Override public int minimumWidth() 42 | { 43 | return component().getMinimumSize().width; 44 | } 45 | 46 | @Override public int preferredWidth() 47 | { 48 | return component().getPreferredSize().width; 49 | } 50 | 51 | @Override public int baseline() 52 | { 53 | return BaselineHelper.getBaseline(component()); 54 | } 55 | 56 | private JComponent _component; 57 | } 58 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/CenterRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | final class CenterRow extends AbstractNonGridRow 18 | { 19 | @Override protected int xOffset(int rowWidth, int usedWidth) 20 | { 21 | return (rowWidth - usedWidth) / 2; 22 | } 23 | 24 | @Override protected int leftFiller(int count, int width, int availableWidth) 25 | { 26 | int fillers = (count > 1 ? 2 : 1); 27 | return (availableWidth - (count - fillers) * width) / fillers; 28 | } 29 | 30 | @Override protected int rightFiller(int count, int width, int availableWidth) 31 | { 32 | int fillers = (count > 1 ? 2 : 1); 33 | int rightFiller = (availableWidth - (count - fillers) * width) / fillers; 34 | if (((availableWidth - (count - fillers) * width) % fillers) > 0) 35 | { 36 | rightFiller++; 37 | } 38 | return rightFiller; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ClassBasedHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | 19 | interface ClassBasedHeightGrowPolicy extends HeightGrowPolicy 20 | { 21 | /** 22 | * Returns the class of the {@link Component} supported by this policy. 23 | * @return the class of Component that this policy supports 24 | */ 25 | public Class getComponentClass(); 26 | } 27 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ComponentGapsHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Container; 18 | 19 | import javax.swing.JComponent; 20 | import javax.swing.JLabel; 21 | import javax.swing.LayoutStyle; 22 | import javax.swing.LayoutStyle.ComponentPlacement; 23 | import javax.swing.SwingConstants; 24 | 25 | final class ComponentGapsHelper 26 | { 27 | static public ComponentGapsHelper instance() 28 | { 29 | return new ComponentGapsHelper(); 30 | } 31 | 32 | public int getHorizontalIndent() 33 | { 34 | if (_indent == -1) 35 | { 36 | JLabel label1 = new JLabel("Top label"); 37 | JLabel label2 = new JLabel("Bottom label"); 38 | _indent = _style.getPreferredGap( 39 | label1, label2, ComponentPlacement.INDENT, SwingConstants.SOUTH, null); 40 | } 41 | return _indent; 42 | } 43 | 44 | public int getVerticalGap(JComponent component1, JComponent component2, 45 | ComponentPlacement type, Container parent) 46 | { 47 | return _style.getPreferredGap( 48 | component1, component2, type, SwingConstants.SOUTH, parent); 49 | } 50 | 51 | public int getHorizontalGap(JComponent component1, JComponent component2, 52 | ComponentPlacement type, Container parent) 53 | { 54 | return _style.getPreferredGap( 55 | component1, component2, type, SwingConstants.EAST, parent); 56 | } 57 | 58 | public int getNorthContainerGap(JComponent component, Container parent) 59 | { 60 | return _style.getContainerGap(component, SwingConstants.NORTH, parent); 61 | } 62 | 63 | public int getSouthContainerGap(JComponent component, Container parent) 64 | { 65 | return _style.getContainerGap(component, SwingConstants.SOUTH, parent); 66 | } 67 | 68 | public int getWestContainerGap(JComponent component, Container parent) 69 | { 70 | return _style.getContainerGap(component, SwingConstants.WEST, parent); 71 | } 72 | 73 | public int getEastContainerGap(JComponent component, Container parent) 74 | { 75 | return _style.getContainerGap(component, SwingConstants.EAST, parent); 76 | } 77 | 78 | private final LayoutStyle _style = LayoutStyle.getInstance(); 79 | private int _indent = -1; 80 | } 81 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ComponentHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Container; 18 | import java.util.List; 19 | 20 | import javax.swing.JComponent; 21 | import javax.swing.LayoutStyle.ComponentPlacement; 22 | 23 | final class ComponentHelper 24 | { 25 | private ComponentHelper() 26 | { 27 | } 28 | 29 | static int maxValues(Iterable items, IExtractor extractor) 30 | { 31 | int max = 0; 32 | for (IItem item: items) 33 | { 34 | max = Math.max(max, extractor.value(item)); 35 | } 36 | return max; 37 | } 38 | 39 | static int sumValues(Iterable items, IExtractor extractor) 40 | { 41 | int sum = 0; 42 | for (IItem item: items) 43 | { 44 | sum += extractor.value(item); 45 | } 46 | return sum; 47 | } 48 | 49 | static int unrelhgap(List items, Container parent) 50 | { 51 | return hgap( 52 | ComponentGapsHelper.instance(), items, parent, ComponentPlacement.UNRELATED); 53 | } 54 | 55 | static int hgap(List items, Container parent) 56 | { 57 | return hgap( 58 | ComponentGapsHelper.instance(), items, parent, ComponentPlacement.RELATED); 59 | } 60 | 61 | static int hgap(JComponent first, List items, Container parent) 62 | { 63 | ComponentGapsHelper helper = ComponentGapsHelper.instance(); 64 | int hgap = 0; 65 | if (first != null && !items.isEmpty()) 66 | { 67 | hgap = hgap(helper, first, items.get(0).component(), parent, 68 | ComponentPlacement.RELATED); 69 | } 70 | return Math.max(hgap, hgap(helper, items, parent, ComponentPlacement.RELATED)); 71 | } 72 | 73 | static boolean isFixedHeight( 74 | HeightGrowPolicy policy, Iterable items) 75 | { 76 | for (IRowItem item: items) 77 | { 78 | if (policy.canGrowHeight(item.component()) && item.isLastSpanRow()) 79 | { 80 | return false; 81 | } 82 | } 83 | return true; 84 | } 85 | 86 | static private int hgap(ComponentGapsHelper helper, List items, 87 | Container parent, ComponentPlacement placement) 88 | { 89 | int hgap = 0; 90 | int size = items.size() - 1; 91 | for (int nth = 0; nth < size; nth++) 92 | { 93 | JComponent left = items.get(nth).component(); 94 | JComponent right = items.get(nth + 1).component(); 95 | int gap = hgap(helper, left, right, parent, placement); 96 | hgap = Math.max(hgap, gap); 97 | } 98 | return hgap; 99 | } 100 | 101 | static private int hgap(ComponentGapsHelper helper, JComponent left, JComponent right, 102 | Container parent, ComponentPlacement placement) 103 | { 104 | return helper.getHorizontalGap(left, right, placement, parent); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ComponentizerItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | import net.java.dev.designgridlayout.Componentizer.WidthPolicy; 20 | 21 | // Used for all components added to a Componentizer 22 | class ComponentizerItem extends BasicItem 23 | { 24 | public ComponentizerItem(JComponent component, WidthPolicy widthPolicy) 25 | { 26 | super(component); 27 | _widthPolicy = widthPolicy; 28 | } 29 | 30 | @Override public int minimumWidth() 31 | { 32 | switch (_widthPolicy) 33 | { 34 | case PREF_FIXED: 35 | case PREF_AND_MORE: 36 | return preferredWidth(); 37 | 38 | case MIN_TO_PREF: 39 | case MIN_AND_MORE: 40 | default: 41 | return super.minimumWidth(); 42 | } 43 | } 44 | 45 | public WidthPolicy widthPolicy() 46 | { 47 | return _widthPolicy; 48 | } 49 | 50 | final private WidthPolicy _widthPolicy; 51 | } 52 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ContainerHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | import java.awt.Container; 19 | 20 | class ContainerHeightGrowPolicy extends AbstractClassBasedHeightGrowPolicy 21 | { 22 | public ContainerHeightGrowPolicy(HeightGrowPolicy defaultPolicy) 23 | { 24 | super(Container.class); 25 | _defaultPolicy = defaultPolicy; 26 | } 27 | 28 | @Override protected boolean componentCanGrowHeight(Container panel) 29 | { 30 | for (Component child: panel.getComponents()) 31 | { 32 | if (_defaultPolicy.canGrowHeight(child)) 33 | { 34 | return true; 35 | } 36 | } 37 | return false; 38 | } 39 | 40 | @Override protected int componentComputeExtraHeight(Container panel, int extraHeight) 41 | { 42 | int actualHeight = 0; 43 | for (Component child: panel.getComponents()) 44 | { 45 | if (_defaultPolicy.canGrowHeight(child)) 46 | { 47 | actualHeight = Math.max(actualHeight, 48 | _defaultPolicy.computeExtraHeight(child, extraHeight)); 49 | } 50 | } 51 | return actualHeight; 52 | } 53 | 54 | private final HeightGrowPolicy _defaultPolicy; 55 | } 56 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/DefaultGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | class DefaultGrowPolicy extends HeightGrowPolicyMapper 18 | { 19 | public DefaultGrowPolicy() 20 | { 21 | addPolicy(new JScrollPaneHeightGrowPolicy()); 22 | addPolicy(new JSliderHeightGrowPolicy()); 23 | addPolicy(new ContainerHeightGrowPolicy(this)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/EmptySubGrid.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | // Fake subgrid that is used whenever a real SubGrid spans several grids 18 | final class EmptySubGrid implements ISubGrid 19 | { 20 | @Override public int gridColumns() 21 | { 22 | return 0; 23 | } 24 | 25 | @Override public int labelWidth() 26 | { 27 | return 0; 28 | } 29 | 30 | @Override public int maxColumnWidth(int maxColumns, IExtractor extractor) 31 | { 32 | return 0; 33 | } 34 | 35 | @Override public int gridspan() 36 | { 37 | return 1; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/HeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | 19 | interface HeightGrowPolicy 20 | { 21 | /** 22 | * Checks if a {@link Component} can grow in height. 23 | * @param component the component to test 24 | * @return {@code true} if {@code component} has a variable height; 25 | * {@code false} if {@code component} has a fixed height. 26 | */ 27 | public boolean canGrowHeight(Component component); 28 | 29 | /** 30 | * Computes the maximum amount of extra height that a {@link Component} can 31 | * use. 32 | * @param component the component to test 33 | * @param extraHeight the amount of available extra height 34 | * @return the maximum amount of extra height that {@code component} can use 35 | * without exceeding {@code extraHeight} 36 | */ 37 | public int computeExtraHeight(Component component, int extraHeight); 38 | } 39 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/HeightGrowPolicyMapper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | class HeightGrowPolicyMapper implements HeightGrowPolicy 22 | { 23 | public HeightGrowPolicyMapper addPolicy(ClassBasedHeightGrowPolicy policy) 24 | { 25 | return addPolicy(policy.getComponentClass(), policy); 26 | } 27 | 28 | public HeightGrowPolicyMapper addPolicy( 29 | Class componentClass, HeightGrowPolicy policy) 30 | { 31 | _policies.put(componentClass, policy); 32 | return this; 33 | } 34 | 35 | @Override public boolean canGrowHeight(Component component) 36 | { 37 | HeightGrowPolicy policy = findPolicy(component); 38 | return (policy != null ? policy.canGrowHeight(component) : false); 39 | } 40 | 41 | @Override public int computeExtraHeight(Component component, int extraHeight) 42 | { 43 | HeightGrowPolicy policy = findPolicy(component); 44 | return (policy != null 45 | ? policy.computeExtraHeight(component, extraHeight) : extraHeight); 46 | } 47 | 48 | protected final HeightGrowPolicy findPolicy(Component component) 49 | { 50 | // Lookup the most specialized policy for this component based on 51 | // the class hierarchy of that component 52 | Class clazz = component.getClass(); 53 | while (true) 54 | { 55 | HeightGrowPolicy policy = _policies.get(clazz); 56 | if (policy != null) 57 | { 58 | return policy; 59 | } 60 | if (clazz == Component.class) 61 | { 62 | break; 63 | } 64 | clazz = clazz.getSuperclass().asSubclass(Component.class); 65 | } 66 | // No policy was found for concrete classed in this component class hierarchy 67 | return null; 68 | } 69 | 70 | protected final Map, HeightGrowPolicy> _policies = 71 | new HashMap, HeightGrowPolicy>(); 72 | } 73 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IBarRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | /** 20 | * Any row created by {@code DesignGridLayout.row().bar()} implements this 21 | * interface. Through this interface, you can add components to the current row. 22 | *

23 | * All added components share the same width (the maximum of all components 24 | * preferred widths) and can be aligned on the left, center or right depending on 25 | * which method is called to add them, or the {@link Tag} they are assigned when 26 | * added. 27 | *

28 | * The actual position of added components depends on the current platform; 29 | * standard buttons (as determined by their assigned {@link Tag}) will always follow 30 | * the guidelines for the current platform. 31 | * 32 | * @author Jean-Francois Poilpret 33 | */ 34 | public interface IBarRow extends IHideable 35 | { 36 | /** 37 | * Adds components to the left of this row. Components are added left to 38 | * right, in the same order as they appear in the arguments list. 39 | *

40 | * This method is equivalent to: 41 | *

 42 | 	 * for (JComponent child: children)
 43 | 	 * {
 44 | 	 *     add(child, Tag.LEFT);
 45 | 	 * }
 46 | 	 * 
47 | * 48 | * @param children components to add to the left of this row 49 | * @return {@code this} row (to allow chaining other methods for the current 50 | * row) 51 | */ 52 | public abstract IBarRow left(JComponent... children); 53 | 54 | /** 55 | * Adds components to the center of this row. Components are added left to 56 | * right, in the same order as they appear in the arguments list. 57 | *

58 | * This method is equivalent to: 59 | *

 60 | 	 * for (JComponent child: children)
 61 | 	 * {
 62 | 	 *     add(child, Tag.OTHER);
 63 | 	 * }
 64 | 	 * 
65 | * 66 | * @param children components to add to the center of this row 67 | * @return {@code this} row (to allow chaining other methods for the current 68 | * row) 69 | */ 70 | public abstract IBarRow center(JComponent... children); 71 | 72 | /** 73 | * Adds components to the right of this row. Components are added left to 74 | * right, in the same order as they appear in the arguments list. 75 | *

76 | * This method is equivalent to: 77 | *

 78 | 	 * for (JComponent child: children)
 79 | 	 * {
 80 | 	 *     add(child, Tag.RIGHT);
 81 | 	 * }
 82 | 	 * 
83 | * 84 | * @param children components to add to the right of this row 85 | * @return {@code this} row (to allow chaining other methods for the current 86 | * row) 87 | */ 88 | public abstract IBarRow right(JComponent... children); 89 | 90 | /** 91 | * Adds a tagged component to this row. The component is placed in the row at a 92 | * location determined by guidelines for the current platform, based on its 93 | * {@link Tag}. 94 | * 95 | * @param child the component to add to this row 96 | * @param tag the tag to assign to {@code child} that will determine the 97 | * actual position of {@code child} in the row 98 | * @return {@code this} row (to allow chaining other methods for the current 99 | * row) 100 | */ 101 | public abstract IBarRow add(JComponent child, Tag tag); 102 | 103 | /** 104 | * Adds a larger gap (see {@link javax.swing.LayoutStyle.ComponentPlacement#UNRELATED}) 105 | * after the component that has been added just before this method is called. Has no 106 | * effect if no component was added before. Multiple consecutive calls have the same 107 | * effect as only one call, DesignGridLayout will never accumulate consecutive gaps. 108 | * 109 | * @return {@code this} row (to allow chaining other methods for the current 110 | * row) 111 | */ 112 | public abstract IBarRow gap(); 113 | 114 | /** 115 | * Makes this row independent of other non-grid rows in terms of component 116 | * width. By default, DesignGridLayout ensures that all non-grid rows in a 117 | * layout use the same width for all components of all these rows. In general, 118 | * this is the behavior expected by end-users; however, there may be some 119 | * situations where this behavior is not desirable. 120 | *

121 | * Note that you can disable DesignGridLayout feature of consistent widths across 122 | * non-grid rows with {@link DesignGridLayout#withoutConsistentWidthAcrossNonGridRows()}. 123 | * 124 | * @return {@code this} row (to allow chaining other methods for the current 125 | * row) 126 | */ 127 | public abstract IBarRow withOwnRowWidth(); 128 | } 129 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IExtractor.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | // Utility to factor out similar code dealing with common JComponent properties 18 | interface IExtractor 19 | { 20 | int value(IItem item); 21 | } 22 | 23 | abstract class AbstractExtractor implements IExtractor 24 | { 25 | protected AbstractExtractor() 26 | { 27 | } 28 | } 29 | 30 | final class MinWidthExtractor extends AbstractExtractor 31 | { 32 | static final IExtractor INSTANCE = new MinWidthExtractor(); 33 | 34 | @Override public int value(IItem item) 35 | { 36 | return item.minimumWidth(); 37 | } 38 | } 39 | 40 | final class PrefWidthExtractor implements IExtractor 41 | { 42 | static final IExtractor INSTANCE = new PrefWidthExtractor(); 43 | 44 | @Override public int value(IItem item) 45 | { 46 | return item.preferredWidth(); 47 | } 48 | } 49 | 50 | final class PrefHeightExtractor implements IExtractor 51 | { 52 | static final IExtractor INSTANCE = new PrefHeightExtractor(); 53 | 54 | @Override public int value(IItem item) 55 | { 56 | return item.preferredHeight(); 57 | } 58 | } 59 | 60 | final class BaselineExtractor implements IExtractor 61 | { 62 | static final IExtractor INSTANCE = new BaselineExtractor(); 63 | 64 | @Override public int value(IItem item) 65 | { 66 | return item.baseline(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IGridRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | /** 20 | * Any row created by {@code DesignGridLayout.row().grid()} implements this 21 | * interface. Through this interface, you can add components to the current row; 22 | * position and size of components will use the canonical grid calculated for 23 | * the whole layout. 24 | * 25 | * @author Jean-Francois Poilpret 26 | */ 27 | public interface IGridRow extends IRow, ISubGridStarter 28 | { 29 | /* 30 | * (non-Javadoc) 31 | * @see IRow#add(javax.swing.JComponent[]) 32 | */ 33 | @Override public abstract IGridRow add(JComponent... children); 34 | 35 | /** 36 | * Adds one component to this row and allows it to span several columns of 37 | * the canonical grid. 38 | *

39 | * The order of calls match the order in which the components will be added 40 | * to this row. Components are added left to right, in the same order as 41 | * they appear in the arguments list. 42 | * 43 | * @param child component to add to this row; it is added to the right of 44 | * the component that was added by the nearest previous call to an add 45 | * method. 46 | * @param span the number of columns to span (must be > 0) 47 | * @return {@code this} row (to allow chaining other methods for the current 48 | * row) 49 | */ 50 | public abstract IGridRow add(JComponent child, int span); 51 | 52 | /** 53 | * Adds an empty column to the current row. 54 | * 55 | * @return {@code this} row (to allow chaining other methods for the current 56 | * row) 57 | */ 58 | public abstract IGridRow empty(); 59 | 60 | /** 61 | * Adds one or more empty columns to the current row. 62 | * 63 | * @param span the number of columns to span (must be > 0) 64 | * @return {@code this} row (to allow chaining other methods for the current 65 | * row) 66 | */ 67 | public abstract IGridRow empty(int span); 68 | 69 | /* 70 | * (non-Javadoc) 71 | * @see IRow#addMulti(javax.swing.JComponent[]) 72 | */ 73 | @Override public abstract IGridRow addMulti(JComponent... children); 74 | 75 | /* 76 | * (non-Javadoc) 77 | * @see net.java.dev.designgridlayout.IRow#indent() 78 | */ 79 | @Override public abstract IGridRow indent(); 80 | 81 | /* 82 | * (non-Javadoc) 83 | * @see net.java.dev.designgridlayout.IRow#indent(int) 84 | */ 85 | @Override public abstract IGridRow indent(int n); 86 | 87 | /** 88 | * Adds components to this row; all components are "assembled" as one 89 | * global component and span a given number of columns in the row. 90 | *

91 | * Note that the width of each individual component will never grow bigger 92 | * than its preferred width. 93 | * 94 | * @param span the number of columns to span (must be > 0) 95 | * @param children components to assemble and add to this row 96 | * @return {@code this} row (to allow chaining other methods for the current 97 | * row) 98 | * 99 | * @deprecated Use {@link #add(JComponent, int)} with {@link Componentizer} instead. 100 | */ 101 | @Deprecated 102 | public abstract IGridRow addMulti(int span, JComponent... children); 103 | } 104 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IHideable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | /** 18 | * Any row created by {@link DesignGridLayout} implements this minimal 19 | * interface. Through this interface you can hide or show the row. 20 | * 21 | * @author Jean-Francois Poilpret 22 | */ 23 | public interface IHideable 24 | { 25 | /** 26 | * Hides the whole row, ie all its components, forcing its visible height to 0. 27 | * This allows to handle dynamic layouts where some rows appear or disappear based 28 | * on some user settings or actions. 29 | *

30 | * An {@code IRow} that has been hidden can be shown again by calling {@link #show()}. 31 | *

32 | * Note that you can call {@code hide()} several times, but you must then call 33 | * {@link #show()} the same number of times to make the row visible again. 34 | *

35 | * When a row containing a spanned component (see {@link ISpannableGridRow#spanRow()}) 36 | * is hidden, resize behavior is not well handled unless all rows containing the same 37 | * spanning component are also hidden altogether (which is the common use case). 38 | */ 39 | public abstract void hide(); 40 | 41 | /** 42 | * Restores the whole row to a visible state, ie all its components' visibilities 43 | * are restored to their original state prior to calling {@link #hide()}. 44 | *

45 | * Note that calling {@code show()} on an already visible row has no effect at all. 46 | *

47 | * Also, if {@link #hide()} has been called several times, then {@code show()} will 48 | * have to be called the same number of times for the row to become visible again. 49 | */ 50 | public abstract void show(); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | interface IItem 20 | { 21 | public JComponent component(); 22 | public int preferredHeight(); 23 | public int minimumWidth(); 24 | public int preferredWidth(); 25 | public int baseline(); 26 | } 27 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/INonGridRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | /** 20 | * Any row created by one of {@code DesignGridLayout.row().left()}, 21 | * {@code DesignGridLayout.row().center()} or {@code DesignGridLayout.row().right()} 22 | * implements this interface. Through this interface, you can add components to 23 | * the current row. 24 | *

25 | * All added components share the same width (the maximum of all components 26 | * preferred widths) and are aligned on the left, center or right depending on 27 | * which {@link IRowCreator} (returned by {@link DesignGridLayout#row()}) method 28 | * was called to create this row. 29 | * 30 | * @author Jean-Francois Poilpret 31 | */ 32 | public interface INonGridRow extends IRow 33 | { 34 | /* 35 | * (non-Javadoc) 36 | * @see IRow#add(javax.swing.JComponent[]) 37 | */ 38 | @Override public abstract INonGridRow add(JComponent... children); 39 | 40 | /* 41 | * (non-Javadoc) 42 | * @see IRow#addMulti(javax.swing.JComponent[]) 43 | */ 44 | @Override public abstract INonGridRow addMulti(JComponent... children); 45 | 46 | /* 47 | * (non-Javadoc) 48 | * @see net.java.dev.designgridlayout.IRow#indent() 49 | */ 50 | @Override public abstract INonGridRow indent(); 51 | 52 | /* 53 | * (non-Javadoc) 54 | * @see net.java.dev.designgridlayout.IRow#indent(int) 55 | */ 56 | @Override public abstract INonGridRow indent(int n); 57 | 58 | /** 59 | * Sets the "extreme" component(s) of this row to fill the whole space 60 | * towards the container border. Extreme components are defined as follows: 61 | *

    62 | *
  • For a left-aligned row: the rightmost component
  • 63 | *
  • For a centered row: the leftmost and rightmost components
  • 64 | *
  • For a right-aligned row: the leftmost component
  • 65 | *
66 | * This proves useful for implementing "group separators" as advised by 67 | * Karsten Lentzsch (JLabel + JSeparator). 68 | * 69 | * @return {@code this} row (to allow chaining other methods for the current 70 | * row) 71 | */ 72 | public abstract INonGridRow fill(); 73 | 74 | /** 75 | * Makes this row independent of other non-grid rows in terms of component 76 | * width. By default, DesignGridLayout ensures that all non-grid rows in a 77 | * layout use the same width for all components of all these rows. In general, 78 | * this is the behavior expected by end-users; however, there are some 79 | * situations where this behavior is not desirable, e.g. when using 80 | * {@link #fill()} to create a "group separator" where we want the group 81 | * JLabel to be exactly at its preferred width. 82 | *
83 | 	 * DesignGridLayout layout = new DesignGridLayout(this);
84 | 	 * //...
85 | 	 * layout.row().left().add(addressLabel, new JSeparator()).fill().withOwnRowWidth();
86 | 	 * //...
87 | 	 * 
88 | *

89 | * Note that you can disable DesignGridLayout feature of consistent widths across 90 | * non-grid rows with {@link DesignGridLayout#withoutConsistentWidthAcrossNonGridRows()}. 91 | * 92 | * @return {@code this} row (to allow chaining other methods for the current 93 | * row) 94 | */ 95 | public abstract INonGridRow withOwnRowWidth(); 96 | } 97 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | /** 20 | * Any row created by {@link DesignGridLayout} implements this minimal 21 | * interface. Through this interface you can add components to the row. 22 | *

23 | * Subsequent calls to methods that add components result in adding components 24 | * left to right, i.e. the last added component is positioned to the right of 25 | * the previously last added component. 26 | *

27 | * Note that {@code DesignGridLayout} methods will return more specific 28 | * interfaces (that extend {@code IRow}). 29 | * 30 | * @author Jean-Francois Poilpret 31 | */ 32 | public interface IRow extends IHideable 33 | { 34 | /** 35 | * Adds components to this row; each component has its own "column" in the 36 | * row. Components are added left to right, in the same order as they appear 37 | * in the arguments list. 38 | * 39 | * @param children components to add to this row 40 | * @return {@code this} row (to allow chaining other methods for the current 41 | * row) 42 | */ 43 | public abstract IRow add(JComponent... children); 44 | 45 | /** 46 | * Adds components to this row; all components are "assembled" as one 47 | * global component and use only one "column" in the row. 48 | *

49 | * Note that the width of each individual component will never grow bigger 50 | * than its preferred width. 51 | * 52 | * @param children components to assemble and add to this row 53 | * @return {@code this} row (to allow chaining other methods for the current 54 | * row) 55 | * 56 | * @deprecated Use {@link #add} with {@link Componentizer} instead. 57 | */ 58 | @Deprecated 59 | public abstract IRow addMulti(JComponent... children); 60 | 61 | /** 62 | * Add one indentation space (size is platform-dependent) before the left-most 63 | * component of the row. 64 | * 65 | * @return {@code this} row (to allow chaining other methods for the current 66 | * row) 67 | */ 68 | public abstract IRow indent(); 69 | 70 | /** 71 | * Add some indentation space (size is platform-dependent) before the left-most 72 | * component of the row. To obtain visually correct layouts, you should ensure 73 | * that, if you use {@code n > 1} for the current row, there is another row, 74 | * above the current one, which is indented with a level of {@code n - 1}. 75 | *

76 | * If this method is called several times for the same row, only the last call 77 | * takes effect. 78 | * 79 | * @param n the number of indentation levels required; has no effect if {@code n < 0}. 80 | * @return {@code this} row (to allow chaining other methods for the current 81 | * row) 82 | */ 83 | public abstract IRow indent(int n); 84 | } 85 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IRowCreator.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | /** 18 | * Interface returned by {@link DesignGridLayout#row()} in order to specify the 19 | * type of row to be actually added to the current layout (grid, centered, left- 20 | * or right-aligned). 21 | * 22 | * @author Jean-Francois Poilpret 23 | */ 24 | public interface IRowCreator extends ISubGridStarter 25 | { 26 | /** 27 | * Adds the current row to a given {@code group}. Grouping rows is useful 28 | * when you want to show or hide several rows at a time. 29 | *

30 | * It is also possible to add one row to several groups. 31 | * 32 | * @param group the group to which the current row must be added 33 | * @return {@code this} instance of IRowCreator, allowing for chained 34 | * calls to other methods (also known as "fluent API") 35 | */ 36 | public abstract IRowCreator group(RowGroup group); 37 | 38 | /** 39 | * Creates a center-aligned row. Center-aligned rows are NOT canonical grids 40 | * but avoid the otherwise mandatory use of several {@code LayoutManager}s 41 | * for one single dialog. 42 | *

43 | * The new row is located under the previously created row, which means that 44 | * each line of code using this method creates a new row and all lines can 45 | * be read as defining the visual UI of the container. 46 | * 47 | * @return a new center-aligned row which API is used in a chained-way 48 | * (fluent API) to add components to the row. 49 | */ 50 | public abstract INonGridRow center(); 51 | 52 | /** 53 | * Creates a left-aligned row. Left-aligned rows are NOT canonical grids but 54 | * avoid the otherwise mandatory use of several {@code LayoutManager}s for 55 | * one single dialog. 56 | *

57 | * The new row is located under the previously created row, which means that 58 | * each line of code using this method creates a new row and all lines can 59 | * be read as defining the visual UI of the container. 60 | * 61 | * @return a new left-aligned row which API is used in a chained-way (fluent 62 | * API) to add components to the row. 63 | */ 64 | public abstract INonGridRow left(); 65 | 66 | /** 67 | * Creates a right-aligned row. Right-aligned rows are NOT canonical grids 68 | * but avoid the otherwise mandatory use of several {@code LayoutManager} 69 | * for one single dialog. 70 | *

71 | * The new row is located under the previously created row, which means that 72 | * each line of code using this method creates a new row and all lines can 73 | * be read as defining the visual UI of the container. 74 | * 75 | * @return a new right-aligned row which API is used in a chained-way (fluent 76 | * API) to add components to the row. 77 | */ 78 | public abstract INonGridRow right(); 79 | 80 | /** 81 | * Creates a "command bar" row. This kind of row is NOT a canonical grid and is 82 | * specially dedicated to layout rows with command buttons such as "OK", "Cancel", 83 | * "Apply", "Help"... 84 | *

85 | * Command bar rows place standard components (marked with {@link Tag}) based on 86 | * platform preferences. This means that you don't have to care about where you 87 | * must locate "OK" and "Cancel" if your application must run on both Windows and 88 | * Mac OS. 89 | *

90 | * These rows are split into 3 sub-rows: one on the left, one 91 | * in the center and one on the right. 92 | *

93 | * The new row is located under the previously created row, which means that 94 | * each line of code using this method creates a new row and all lines can 95 | * be read as defining the visual UI of the container. 96 | * 97 | * @return a new command-bar row which API is used in a chained-way (fluent 98 | * API) to add components to the row. 99 | */ 100 | public abstract IBarRow bar(); 101 | } 102 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/IRowItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.List; 18 | 19 | interface IRowItem extends IItem 20 | { 21 | public void hide(); 22 | public void show(); 23 | 24 | public void setSpannedRows(List rows); 25 | public int rowSpan(); 26 | public boolean isFirstSpanRow(); 27 | public boolean isLastSpanRow(); 28 | } 29 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ISpannableGridRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JComponent; 18 | 19 | /** 20 | * Rows created by {@code DesignGridLayout.row().grid()} and 21 | * {@code DesignGridLayout.row().grid(JLabel)} implement this interface. 22 | * Through this interface, in addition to methods inherited from {@link IGridRow}, 23 | * you can specify components spanning multiple rows with the new 24 | * {@link #spanRow()} method. 25 | * 26 | * @author Jean-Francois Poilpret 27 | */ 28 | public interface ISpannableGridRow extends IGridRow 29 | { 30 | /** 31 | * Specifies that the next grid column will be filled with the same 32 | * component in the same column location in the row above this row. 33 | *

34 | * Calling {@code spanRow()} in one row behaves as follows: 35 | *

    36 | *
  1. the component on the previous row at the same column position in the 37 | * same sub-grid will span this row
  2. 38 | *
  3. the horizontal span of this component will be the same as the column 39 | * span defined for that same component on the previous row
  4. 40 | *
  5. the sub-grid in which {@code spanRow()} appears will have its 41 | * gridspan forced to the same value as the sub-grid in the same position of 42 | * the previous row
  6. 43 | *
  7. if the matching component in the previous row is {@link IGridRow#empty()} 44 | * or {@link IGridRow#empty(int)}, then {@code spanRow()} is also {@code empty()} 45 | * or {@code empty(int)}
  8. 46 | *
  9. if this is the first row in the layout, then {@code spanRow()} is 47 | * replaced with a marker component, used for fixing the layout
  10. 48 | *
  11. if there is no grid row above {@code this} row, then {@code spanRow()} 49 | * will be replaced with a marker component, used for fixing the layout
  12. 50 | *
  13. if there is no matching subgrid (same position) in the above row, then 51 | * {@code spanRow()} will be replaced with a marker component, used for 52 | * fixing the layout
  14. 53 | *
  15. if there is no matching component (same position) in the matching 54 | * subgrid of the above row, then {@code spanRow()} will be replaced with a 55 | * marker component, used for fixing the layout
  16. 56 | *
  17. if the matching subgrid in the above row does not have the same number 57 | * of columns of the current subgrid in {@code this} row, then 58 | * {@code spanRow()} will be replaced with a marker component, used for 59 | * fixing the layout
  18. 60 | *
61 | *

62 | * A marker component is used to show bad calls to {@code spanRow()} which 63 | * could not be avoided at compile-time. This marker is a "spanRow()" 64 | * label with a red background and a tooltip giving more details about the 65 | * actual problem. 66 | * 67 | * @return {@code this} row (to allow chaining other methods for the current 68 | * row) 69 | */ 70 | public abstract ISpannableGridRow spanRow(); 71 | 72 | /* 73 | * (non-Javadoc) 74 | * @see net.java.dev.designgridlayout.IGridRow#add(javax.swing.JComponent[]) 75 | */ 76 | @Override public abstract ISpannableGridRow add(JComponent... children); 77 | 78 | /* 79 | * (non-Javadoc) 80 | * @see net.java.dev.designgridlayout.IGridRow#add(javax.swing.JComponent, int) 81 | */ 82 | @Override public abstract ISpannableGridRow add(JComponent child, int span); 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see net.java.dev.designgridlayout.IGridRow#empty() 87 | */ 88 | @Override public abstract ISpannableGridRow empty(); 89 | 90 | /* 91 | * (non-Javadoc) 92 | * @see net.java.dev.designgridlayout.IGridRow#empty(int) 93 | */ 94 | @Override public abstract ISpannableGridRow empty(int span); 95 | 96 | /* 97 | * (non-Javadoc) 98 | * @see net.java.dev.designgridlayout.IGridRow#addMulti(javax.swing.JComponent[]) 99 | */ 100 | @Override public abstract ISpannableGridRow addMulti(JComponent... children); 101 | 102 | /* 103 | * (non-Javadoc) 104 | * @see net.java.dev.designgridlayout.IGridRow#addMulti(int, javax.swing.JComponent[]) 105 | */ 106 | @Override public abstract ISpannableGridRow addMulti(int span, JComponent... children); 107 | 108 | /* 109 | * (non-Javadoc) 110 | * @see net.java.dev.designgridlayout.IGridRow#indent() 111 | */ 112 | @Override public abstract ISpannableGridRow indent(); 113 | 114 | /* 115 | * (non-Javadoc) 116 | * @see net.java.dev.designgridlayout.IGridRow#indent(int) 117 | */ 118 | @Override public abstract ISpannableGridRow indent(int n); 119 | } 120 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ISubGrid.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | interface ISubGrid 18 | { 19 | int labelWidth(); 20 | int gridColumns(); 21 | int gridspan(); 22 | int maxColumnWidth(int maxColumns, IExtractor extractor); 23 | } 24 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ISubGridStarter.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JLabel; 18 | 19 | /** 20 | * This interface is used to start a new canonical grid row (when called from 21 | * {@link DesignGridLayout#row()}), or to start a new canonical sub-grid in the 22 | * current grid row (when called from {@link IGridRow}). 23 | *

24 | * Using one of the {@code grid()} methods of this interface is mandatory 25 | * before adding any further component to the current row. 26 | *

27 | * Every time {@code grid()} is called for the current row, a new sub-grid is 28 | * started, with its own specific label column, and additional gap from the 29 | * previous sub-grid. 30 | * 31 | * @author Jean-Francois Poilpret 32 | */ 33 | public interface ISubGridStarter 34 | { 35 | /** 36 | * Starts a new sub-grid in the row, starting with a label. 37 | *

38 | * Labels have a special treatment: they are not a part of the canonical 39 | * grid but use a fixed-width on the left of the canonical grid. Labels 40 | * are automatically right-aligned. 41 | *

42 | * The new sub-grid initiated by this call will span all space on its right 43 | * unless another call to a {@code grid()} method occurs in the same row. 44 | *

45 | * That sub-grid also allows adding span components, i.e. components that 46 | * have been added to a row above {@code this} row. 47 | * 48 | * @param label the label to add to this row 49 | * @return {@code this} row (to allow chaining other methods for the current 50 | * row) 51 | * @see ISpannableGridRow#spanRow() 52 | */ 53 | public abstract ISpannableGridRow grid(JLabel label); 54 | 55 | /** 56 | * Starts a new sub-grid in the row, starting with a label. 57 | *

58 | * Labels have a special treatment: they are not a part of the canonical 59 | * grid but use a fixed-width on the left of the canonical grid. Labels 60 | * are automatically right-aligned. 61 | *

62 | * The new sub-grid initiated by this call will span a certain number of 63 | * sub-grids on its right, as determined by {@code gridspan}. 64 | * 65 | * @param label the label to add to this row 66 | * @param gridspan the number of sub-grids this new sub-grid should span; 67 | * if {@code <= 0}, then the behavior is the same as {@link #grid(JLabel)}. 68 | * @return {@code this} row (to allow chaining other methods for the current 69 | * row) 70 | */ 71 | public abstract IGridRow grid(JLabel label, int gridspan); 72 | 73 | /** 74 | * Starts a new sub-grid in the row, starting with an empty label. 75 | *

76 | * Labels (empty or not) have a special treatment: they are not a part of 77 | * the canonical grid but use a fixed-width on the left of the canonical 78 | * grid. Labels are automatically right-aligned. 79 | *

80 | * The new sub-grid initiated by this call will span all space on its right 81 | * unless another call to a {@code grid()} method occurs in the same row. 82 | *

83 | * That sub-grid also allows adding span components, i.e. components that 84 | * have been added to a row above {@code this} row. 85 | * 86 | * @return {@code this} row (to allow chaining other methods for the current 87 | * row) 88 | * @see ISpannableGridRow#spanRow() 89 | */ 90 | public abstract ISpannableGridRow grid(); 91 | 92 | /** 93 | * Starts a new sub-grid in the row, starting with an empty label. 94 | *

95 | * Labels (empty or not) have a special treatment: they are not a part of 96 | * the canonical grid but use a fixed-width on the left of the canonical 97 | * grid. Labels are automatically right-aligned. 98 | *

99 | * The new sub-grid initiated by this call will span a certain number of 100 | * sub-grids on its right, as determined by {@code gridspan}. 101 | * 102 | * @param gridspan the number of sub-grids this new sub-grid should span; 103 | * if {@code <= 0}, then the behavior is the same as {@link #grid()}. 104 | * @return {@code this} row (to allow chaining other methods for the current 105 | * row) 106 | */ 107 | public abstract IGridRow grid(int gridspan); 108 | } 109 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/JScrollPaneHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | 19 | import javax.swing.JList; 20 | import javax.swing.JScrollPane; 21 | 22 | class JScrollPaneHeightGrowPolicy 23 | extends AbstractClassBasedHeightGrowPolicy 24 | { 25 | public JScrollPaneHeightGrowPolicy() 26 | { 27 | super(JScrollPane.class); 28 | } 29 | 30 | @Override protected int componentComputeExtraHeight(JScrollPane component, int extraHeight) 31 | { 32 | int unit = component.getVerticalScrollBar().getUnitIncrement(+1); 33 | // Fix for issue #28 34 | // TODO prepare a more extensible fix that can deal with any specific 35 | // component (only if needed: wait until other components require a fix) 36 | Component view = component.getViewport().getView(); 37 | if (unit == 0 && view instanceof JList) 38 | { 39 | JList list = (JList) view; 40 | int visibleRows = list.getVisibleRowCount(); 41 | if (visibleRows > 0) 42 | { 43 | unit = list.getPreferredScrollableViewportSize().height / visibleRows; 44 | } 45 | } 46 | // Make sure unit cannot be <= 0 47 | unit = Math.max(1, unit); 48 | // Return an integral number of units pixels 49 | return (extraHeight / unit) * unit; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/JSliderHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JSlider; 18 | 19 | class JSliderHeightGrowPolicy 20 | extends AbstractClassBasedHeightGrowPolicy 21 | { 22 | public JSliderHeightGrowPolicy() 23 | { 24 | super(JSlider.class); 25 | } 26 | 27 | @Override protected boolean componentCanGrowHeight(JSlider component) 28 | { 29 | return component.getOrientation() == JSlider.VERTICAL; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/LabelAlignment.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import javax.swing.JLabel; 18 | 19 | /** 20 | * Defines how components located in a sub-grid label column can be aligned inside 21 | * this column. 22 | * 23 | * @see DesignGridLayout#labelAlignment(LabelAlignment) 24 | * @author Jean-Francois Poilpret 25 | */ 26 | public enum LabelAlignment 27 | { 28 | /** 29 | * Components in label column should be left-aligned; note that "left" means 30 | * left only in left-to-right Locale orientation, otherwise it means right. 31 | */ 32 | LEFT(JLabel.LEADING), 33 | 34 | /** 35 | * Components in label column should be right-aligned; note that "right" means 36 | * right only in left-to-right Locale orientation, otherwise it means left. 37 | */ 38 | RIGHT(JLabel.TRAILING), 39 | 40 | /** 41 | * Components in label column should be aligned according to guidelines for the 42 | * current platform; eg on MacOS, platform alignment is right, whereas on 43 | * Windows, it is left. 44 | */ 45 | PLATFORM(PlatformHelper.getDefaultAlignment()); 46 | 47 | private LabelAlignment(int align) 48 | { 49 | _align = align; 50 | } 51 | 52 | int alignment() 53 | { 54 | return _align; 55 | } 56 | 57 | final private int _align; 58 | } 59 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/LayoutHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.List; 18 | 19 | import javax.swing.JComponent; 20 | 21 | final class LayoutHelper 22 | { 23 | LayoutHelper(HeightGrowPolicy tester, int parentWidth, boolean rtl) 24 | { 25 | this(tester, parentWidth, rtl, null); 26 | } 27 | 28 | LayoutHelper( 29 | HeightGrowPolicy tester, int parentWidth, boolean rtl, List rows) 30 | { 31 | _tester = tester; 32 | _parentWidth = parentWidth; 33 | _rtl = rtl; 34 | _rows = rows; 35 | } 36 | 37 | void setRowAvailableHeight(int availableHeight) 38 | { 39 | _availableHeight = availableHeight; 40 | } 41 | 42 | void setY(int y) 43 | { 44 | _y = y; 45 | } 46 | 47 | // Called for mutiple row-span components 48 | void setHeight(int rowIndex, JComponent component, int spannedRows) 49 | { 50 | // Calculate the total available height 51 | int availableHeight = 0; 52 | for (int i = 0; i < spannedRows; i++) 53 | { 54 | AbstractRow row = _rows.get(rowIndex + i); 55 | availableHeight += row.actualHeight(); 56 | if (i + 1 < spannedRows) 57 | { 58 | availableHeight += row.vgap(); 59 | } 60 | } 61 | // Keep smart vertical resize behavior in any case 62 | int height = getComponentHeight(component); 63 | int usedExtraHeight = 0; 64 | if (MarkerHelper.isMarker(component)) 65 | { 66 | // spanRow() error markers are special, they must take all available height 67 | usedExtraHeight = availableHeight - height; 68 | } 69 | else if (_tester.canGrowHeight(component)) 70 | { 71 | // Checks how much extra height this component can really use 72 | usedExtraHeight = 73 | _tester.computeExtraHeight(component, availableHeight - height); 74 | } 75 | component.setSize(component.getWidth(), height + usedExtraHeight); 76 | } 77 | 78 | // Returns the actual extra height used by this component 79 | int setSizeLocation(JComponent component, int x, int width, 80 | int maxHeight, int maxBaseline) 81 | { 82 | int height = component.getPreferredSize().height; 83 | int usedExtraHeight = 0; 84 | if (_tester.canGrowHeight(component)) 85 | { 86 | // Checks how much extra height this component can really use 87 | usedExtraHeight = 88 | _tester.computeExtraHeight(component, _availableHeight - height); 89 | } 90 | component.setSize(width, height + usedExtraHeight); 91 | 92 | int baseline = BaselineHelper.getBaseline(component); 93 | int yy; 94 | if (baseline > 0) 95 | { 96 | yy = maxBaseline - baseline; 97 | } 98 | else if (baseline == 0) 99 | { 100 | // if zero baseline for component, then align component on the top 101 | yy = 0; 102 | } 103 | else 104 | { 105 | // if no baseline defined (-1), then align component in its middle 106 | yy = (maxHeight - height) / 2; 107 | } 108 | component.setLocation((_rtl ? _parentWidth - x - width : x), _y + yy); 109 | return usedExtraHeight; 110 | } 111 | 112 | static private int getComponentHeight(JComponent component) 113 | { 114 | int height = component.getHeight(); 115 | return (height > 0 ? height : component.getPreferredSize().height); 116 | } 117 | 118 | private final HeightGrowPolicy _tester; 119 | private final int _parentWidth; 120 | private final boolean _rtl; 121 | private final List _rows; 122 | private int _availableHeight; 123 | private int _y; 124 | } 125 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/LeftRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | final class LeftRow extends AbstractNonGridRow 18 | { 19 | @Override protected int xOffset(int rowWidth, int usedWidth) 20 | { 21 | return 0; 22 | } 23 | 24 | @Override protected int leftFiller(int count, int width, int availableWidth) 25 | { 26 | return (count > 1 ? width : rightFiller(count, width, availableWidth)); 27 | } 28 | 29 | @Override protected int rightFiller(int count, int width, int availableWidth) 30 | { 31 | return (availableWidth - (count - 1) * width); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/MarkerHelper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Color; 18 | 19 | import javax.swing.JComponent; 20 | import javax.swing.JLabel; 21 | 22 | final class MarkerHelper 23 | { 24 | private MarkerHelper() 25 | { 26 | } 27 | 28 | static JComponent createMarker(int span, String tooltip) 29 | { 30 | JLabel marker = new JLabel(MARKER_LABEL); 31 | marker.setName(MARKER_NAME); 32 | marker.setHorizontalAlignment(JLabel.CENTER); 33 | marker.setOpaque(true); 34 | marker.setBackground(Color.RED); 35 | marker.setToolTipText(tooltip); 36 | return marker; 37 | } 38 | 39 | static boolean isMarker(JComponent component) 40 | { 41 | return (component instanceof JLabel) 42 | && (MARKER_NAME.equals(component.getName())); 43 | } 44 | 45 | static final private String MARKER_LABEL = "spanRow()"; 46 | static final private String MARKER_NAME = "DesignGridLayout.spanRow-Marker"; 47 | } 48 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/NonGridRowItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.List; 18 | 19 | import javax.swing.JComponent; 20 | 21 | // Used for all components added to a non-grid row 22 | class NonGridRowItem extends AbstractRowItem 23 | { 24 | // Used to create an item holding a real component (that may span several 25 | // rows below or not) 26 | public NonGridRowItem(JComponent component) 27 | { 28 | super(component); 29 | } 30 | 31 | @Override public void setSpannedRows(List rows) 32 | { 33 | } 34 | 35 | @Override public boolean isFirstSpanRow() 36 | { 37 | return true; 38 | } 39 | 40 | @Override public boolean isLastSpanRow() 41 | { 42 | return true; 43 | } 44 | 45 | @Override public int rowSpan() 46 | { 47 | return 1; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/OrientationPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.ComponentOrientation; 18 | import java.awt.Container; 19 | 20 | class OrientationPolicy 21 | { 22 | public OrientationPolicy(Container parent) 23 | { 24 | _parent = parent; 25 | } 26 | 27 | public boolean isRightToLeft() 28 | { 29 | // Check layout orientation 30 | ComponentOrientation orientation = _parent.getComponentOrientation(); 31 | return orientation.isHorizontal() && !orientation.isLeftToRight(); 32 | } 33 | 34 | private final Container _parent; 35 | } 36 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/ParentWrapper.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | import java.awt.Container; 19 | 20 | import javax.swing.JComponent; 21 | 22 | final class ParentWrapper 23 | { 24 | ParentWrapper(T parent) 25 | { 26 | _parent = parent; 27 | } 28 | 29 | void checkParent(Container parent) 30 | { 31 | if (parent != _parent) 32 | { 33 | throw new IllegalArgumentException( 34 | "Must use layout instance with original parent container"); 35 | } 36 | } 37 | 38 | void add(Component child) 39 | { 40 | try 41 | { 42 | _addChild = true; 43 | _parent.add(child); 44 | } 45 | finally 46 | { 47 | _addChild = false; 48 | } 49 | } 50 | 51 | void checkAddedComponent(JComponent component) 52 | { 53 | Container parent = component; 54 | while (parent != null) 55 | { 56 | if (parent == _parent) 57 | { 58 | throw new IllegalArgumentException("Do not add the same component twice"); 59 | } 60 | parent = parent.getParent(); 61 | } 62 | } 63 | 64 | void checkAdd() 65 | { 66 | if (!_addChild) 67 | { 68 | //TODO better message 69 | throw new IllegalArgumentException("Do not use this method"); 70 | } 71 | } 72 | 73 | T parent() 74 | { 75 | return _parent; 76 | } 77 | 78 | final private T _parent; 79 | private boolean _addChild = false; 80 | } 81 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/README.txt: -------------------------------------------------------------------------------- 1 | 此文件夹内为AWT\swing布局,非本人编写,在此做声明。 2 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/RightRow.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | final class RightRow extends AbstractNonGridRow 18 | { 19 | @Override protected int xOffset(int rowWidth, int usedWidth) 20 | { 21 | return rowWidth - usedWidth; 22 | } 23 | 24 | @Override protected int leftFiller(int count, int width, int availableWidth) 25 | { 26 | return (availableWidth - (count - 1) * width); 27 | } 28 | 29 | @Override protected int rightFiller(int count, int width, int availableWidth) 30 | { 31 | return width; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/RowGroup.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.lang.ref.WeakReference; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * This class is used to group several rows from a layout, in order to show or 23 | * hide them all in a single call. 24 | *

25 | * This allows to handle dynamic layouts where some rows appear or disappear based 26 | * on some user settings or actions. 27 | *

28 | * Rows can be added at the time they are defined by calling {@link IRowCreator#group}. 29 | *

30 | * The following snippet shows {@code RowGroup} usage: 31 | *

32 |  * // Set the layout
33 |  * ...
34 |  * RowGroup addressGroup = new RowGroup();
35 |  * layout.row().group(group).grid(label("Address 1")).add(field(""));
36 |  * layout.row().group(group).grid(label("Address 2")).add(field(""));
37 |  * layout.row().group(group).grid(label("Zip")).add(field("")).empty(3);
38 |  * layout.row().group(group).grid(label("City")).add(field(""));
39 |  * ...
40 |  * // Later on, depending on some user action or some other setting
41 |  * addressGroup.hide();
42 |  * 
43 | * 44 | * @author Jean-Francois Poilpret 45 | */ 46 | public final class RowGroup 47 | { 48 | void add(IHideable row) 49 | { 50 | _rows.add(new WeakReference(row)); 51 | } 52 | 53 | /** 54 | * Hides all rows in this {@code RowGroup}, by calling {@link IHideable#hide()} 55 | * on each of them. 56 | */ 57 | public void hide() 58 | { 59 | for (WeakReference rowRef: _rows) 60 | { 61 | IHideable row = rowRef.get(); 62 | if (row != null) 63 | { 64 | row.hide(); 65 | } 66 | } 67 | } 68 | 69 | /** 70 | * Restores all rows to their initial visible state, by calling 71 | * {@link IHideable#show()} for each of them. 72 | */ 73 | public void show() 74 | { 75 | for (WeakReference rowRef: _rows) 76 | { 77 | IHideable row = rowRef.get(); 78 | if (row != null) 79 | { 80 | row.show(); 81 | } 82 | } 83 | } 84 | 85 | final private List> _rows = 86 | new ArrayList>(); 87 | } 88 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/RowItem.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.Collections; 18 | import java.util.List; 19 | 20 | import javax.swing.JComponent; 21 | 22 | // Used for all components added to a SubGrid, real or spanned 23 | // Instances are mutable but only under some conditions 24 | class RowItem extends AbstractRowItem 25 | { 26 | // Used to create an item holding a real component (that may span several 27 | // rows below or not) 28 | public RowItem(int span, JComponent component) 29 | { 30 | super(component); 31 | _span = span; 32 | } 33 | 34 | // Used to create a placeholder for a component spanning a row 35 | public RowItem(RowItem original) 36 | { 37 | super(null); 38 | _spanPrevious = original; 39 | original._spanNext = this; 40 | } 41 | 42 | @Override public JComponent component() 43 | { 44 | return (_spanPrevious != null ? _spanPrevious.component() : super.component()); 45 | } 46 | 47 | // NB: Don't try to optimize this method by caching the calculated preferred 48 | // height because it may change across calls, hence it would become wrong! 49 | @Override public int preferredHeight() 50 | { 51 | if (_spanPrevious == null && _spanNext == null) 52 | { 53 | // Component spanning no rows at all 54 | return super.preferredHeight(); 55 | } 56 | else if (_spanNext == null) 57 | { 58 | // Multi row-span component on the last spanned row 59 | // Calculate the preferred height less the height of all previous rows 60 | int height = 0; 61 | for (int i = 0; i < _rows.size() - 1; i++) 62 | { 63 | AbstractRow row = _rows.get(i); 64 | height += row.height() + row.vgap(); 65 | } 66 | return Math.max(0, super.preferredHeight() - height); 67 | } 68 | else 69 | { 70 | // Multi row-span component on any row but the last spanned row 71 | return 0; 72 | } 73 | } 74 | 75 | @Override public void setSpannedRows(List rows) 76 | { 77 | _rows = rows; 78 | if (_spanNext != null) 79 | { 80 | _spanNext.setSpannedRows(_rows); 81 | } 82 | } 83 | 84 | @Override public boolean isFirstSpanRow() 85 | { 86 | return _spanPrevious == null; 87 | } 88 | 89 | @Override public boolean isLastSpanRow() 90 | { 91 | return _spanNext == null; 92 | } 93 | 94 | @Override public int rowSpan() 95 | { 96 | int rows = 1; 97 | RowItem next = _spanNext; 98 | while (next != null) 99 | { 100 | rows++; 101 | next = next._spanNext; 102 | } 103 | return rows; 104 | } 105 | 106 | // Used to replace a rowspan placeholder with a real component (error marker) 107 | public void replace(JComponent component) 108 | { 109 | setComponent(component); 110 | _span = _spanPrevious.span(); 111 | _spanPrevious._spanNext = null; 112 | _spanPrevious = null; 113 | } 114 | 115 | public int span() 116 | { 117 | return (_spanPrevious != null ? _spanPrevious.span() : _span); 118 | } 119 | 120 | private int _span = 1; 121 | private RowItem _spanPrevious = null; 122 | private RowItem _spanNext = null; 123 | private List _rows = Collections.emptyList(); 124 | } 125 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/RowIterator.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.Iterator; 18 | import java.util.List; 19 | import java.util.NoSuchElementException; 20 | 21 | final class RowIterator implements Iterator 22 | { 23 | static public Iterable each(final List rows) 24 | { 25 | return new Iterable() 26 | { 27 | @Override public Iterator iterator() 28 | { 29 | return new RowIterator(rows); 30 | } 31 | }; 32 | } 33 | 34 | private RowIterator(List rows) 35 | { 36 | _rows = rows; 37 | } 38 | 39 | @Override public AbstractRow next() 40 | { 41 | int index = findNext(); 42 | if (index != -1) 43 | { 44 | _index = index + 1; 45 | return _rows.get(index); 46 | } 47 | else 48 | { 49 | throw new NoSuchElementException(); 50 | } 51 | } 52 | 53 | @Override public boolean hasNext() 54 | { 55 | return findNext() != -1; 56 | } 57 | 58 | @Override public void remove() 59 | { 60 | throw new UnsupportedOperationException(); 61 | } 62 | 63 | private int findNext() 64 | { 65 | for (int i = _index; i < _rows.size(); i++) 66 | { 67 | AbstractRow row = _rows.get(i); 68 | if (!row.isEmpty()) 69 | { 70 | return i; 71 | } 72 | } 73 | return -1; 74 | } 75 | 76 | private final List _rows; 77 | private int _index = 0; 78 | } 79 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/SubList.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.util.AbstractList; 18 | import java.util.List; 19 | import java.util.RandomAccess; 20 | 21 | // Simplified sublist implementation tailored for managing RowItem lists in 22 | // SubGrid/GridRow. 23 | // This implementation is definitly not complete for external use but perfectly 24 | // fulfills its goals in the required context. 25 | final class SubList extends AbstractList implements RandomAccess 26 | { 27 | SubList(List source) 28 | { 29 | _source = source; 30 | _from = source.size(); 31 | } 32 | 33 | @Override public void add(int index, RowItem element) 34 | { 35 | _source.add(_from + index, element); 36 | _size++; 37 | } 38 | 39 | @Override public RowItem get(int index) 40 | { 41 | return _source.get(_from + index); 42 | } 43 | 44 | @Override public int size() 45 | { 46 | return _size; 47 | } 48 | 49 | private final List _source; 50 | private final int _from; 51 | private int _size = 0; 52 | } 53 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/Tag.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | /** 18 | * Tag that can be assigned to a {@code JComponent} (normally a {@code JButton}) so 19 | * that DesignGridLayout know where to locate it in an {@link IBarRow}, based on the 20 | * UI guidelines for the current platform. 21 | * 22 | * @see IBarRow#add(javax.swing.JComponent, Tag) 23 | * @author Jean-Francois Poilpret 24 | */ 25 | public enum Tag 26 | { 27 | /** 28 | * Tag for the "Help" button. 29 | */ 30 | HELP('H'), 31 | 32 | /** 33 | * Tag for the "Yes" button typically used in a message box. 34 | */ 35 | YES('Y'), 36 | 37 | /** 38 | * Tag for the "No" button typically used in a message box. 39 | */ 40 | NO('N'), 41 | 42 | /** 43 | * Tag for the "Next >" button typically used in a wizard dialog. 44 | */ 45 | NEXT('>'), 46 | 47 | /** 48 | * Tag for the "Previous <" button typically used in a wizard dialog. 49 | */ 50 | PREVIOUS('<'), 51 | 52 | /** 53 | * Tag for the "Finish" button typically used in a wizard dialog in order 54 | * to validate the wizard sequence and close the wizard dialog. 55 | */ 56 | FINISH('F'), 57 | 58 | /** 59 | * Tag for the "Apply" button typically used in a dialog to validate 60 | * user input without closing the dialog. 61 | */ 62 | APPLY('A'), 63 | 64 | /** 65 | * Tag for the "Cancel" button typically used in a dialog to cancel 66 | * user input and close the dialog. 67 | */ 68 | CANCEL('C'), 69 | 70 | /** 71 | * Tag for the "OK" button typically used in a dialog to validate 72 | * user input and then close the dialog. 73 | */ 74 | OK('O'), 75 | 76 | /** 77 | * Special tag for any non-standard button to be located on the left of 78 | * a {@link IBarRow}. 79 | */ 80 | LEFT('L'), 81 | 82 | /** 83 | * Special tag for any non-standard button to be located in the middle of 84 | * a {@link IBarRow}. 85 | */ 86 | OTHER('X'), 87 | 88 | /** 89 | * Special tag for any non-standard button to be located on the rigth of 90 | * a {@link IBarRow}. 91 | */ 92 | RIGHT('R'); 93 | 94 | private Tag(char code) 95 | { 96 | _code = code; 97 | } 98 | 99 | static Tag fromCode(char value) 100 | { 101 | for (Tag tag: Tag.values()) 102 | { 103 | if (tag._code == value) 104 | { 105 | return tag; 106 | } 107 | } 108 | return null; 109 | } 110 | 111 | final private char _code; 112 | } 113 | -------------------------------------------------------------------------------- /net/java/dev/designgridlayout/UnitHeightGrowPolicy.java: -------------------------------------------------------------------------------- 1 | // Copyright 2005-2011 Jason Aaron Osgood, Jean-Francois Poilpret 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package net.java.dev.designgridlayout; 16 | 17 | import java.awt.Component; 18 | 19 | final class UnitHeightGrowPolicy implements HeightGrowPolicy 20 | { 21 | public UnitHeightGrowPolicy(HeightGrowPolicy delegate) 22 | { 23 | _delegate = delegate; 24 | } 25 | 26 | @Override public boolean canGrowHeight(Component component) 27 | { 28 | return _delegate.canGrowHeight(component); 29 | } 30 | 31 | @Override public int computeExtraHeight(Component component, int extraHeight) 32 | { 33 | return extraHeight; 34 | } 35 | 36 | private final HeightGrowPolicy _delegate; 37 | } 38 | -------------------------------------------------------------------------------- /picture/Author/README.txt: -------------------------------------------------------------------------------- 1 | 本人的皂片!!!! 2 | -------------------------------------------------------------------------------- /picture/Author/rongtao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Author/rongtao.png -------------------------------------------------------------------------------- /picture/Author/rongtao2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Author/rongtao2.png -------------------------------------------------------------------------------- /picture/BackGround/README.txt: -------------------------------------------------------------------------------- 1 | 软件的背景图片。 2 | -------------------------------------------------------------------------------- /picture/BackGround/background1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background1.png -------------------------------------------------------------------------------- /picture/BackGround/background2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background2.png -------------------------------------------------------------------------------- /picture/BackGround/background3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background3.png -------------------------------------------------------------------------------- /picture/BackGround/background4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background4.png -------------------------------------------------------------------------------- /picture/BackGround/background5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background5.png -------------------------------------------------------------------------------- /picture/BackGround/background6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/BackGround/background6.png -------------------------------------------------------------------------------- /picture/ButtonImg/bicycle16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/bicycle16.png -------------------------------------------------------------------------------- /picture/ButtonImg/bicycle32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/bicycle32.png -------------------------------------------------------------------------------- /picture/ButtonImg/bomb16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/bomb16.png -------------------------------------------------------------------------------- /picture/ButtonImg/bomb32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/bomb32.png -------------------------------------------------------------------------------- /picture/ButtonImg/close16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/close16.png -------------------------------------------------------------------------------- /picture/ButtonImg/close32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/close32.png -------------------------------------------------------------------------------- /picture/ButtonImg/color16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/color16.png -------------------------------------------------------------------------------- /picture/ButtonImg/color32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/color32.png -------------------------------------------------------------------------------- /picture/ButtonImg/computer16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/computer16.png -------------------------------------------------------------------------------- /picture/ButtonImg/computer32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/computer32.png -------------------------------------------------------------------------------- /picture/ButtonImg/copy16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/copy16.png -------------------------------------------------------------------------------- /picture/ButtonImg/copy32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/copy32.png -------------------------------------------------------------------------------- /picture/ButtonImg/curve16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/curve16.png -------------------------------------------------------------------------------- /picture/ButtonImg/curve32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/curve32.png -------------------------------------------------------------------------------- /picture/ButtonImg/curves16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/curves16.png -------------------------------------------------------------------------------- /picture/ButtonImg/curves32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/curves32.png -------------------------------------------------------------------------------- /picture/ButtonImg/cut16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/cut16.png -------------------------------------------------------------------------------- /picture/ButtonImg/cut32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/cut32.png -------------------------------------------------------------------------------- /picture/ButtonImg/ellipse16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ellipse16.png -------------------------------------------------------------------------------- /picture/ButtonImg/ellipse32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ellipse32.png -------------------------------------------------------------------------------- /picture/ButtonImg/exit16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/exit16.png -------------------------------------------------------------------------------- /picture/ButtonImg/exit32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/exit32.png -------------------------------------------------------------------------------- /picture/ButtonImg/folder16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/folder16.png -------------------------------------------------------------------------------- /picture/ButtonImg/folder32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/folder32.png -------------------------------------------------------------------------------- /picture/ButtonImg/font16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/font16.png -------------------------------------------------------------------------------- /picture/ButtonImg/font32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/font32.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontbold16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontbold16.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontbold32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontbold32.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontitalic16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontitalic16.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontitalic32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontitalic32.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontstrike16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontstrike16.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontstrike32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontstrike32.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontunderline16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontunderline16.png -------------------------------------------------------------------------------- /picture/ButtonImg/fontunderline32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/fontunderline32.png -------------------------------------------------------------------------------- /picture/ButtonImg/freehand16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/freehand16.png -------------------------------------------------------------------------------- /picture/ButtonImg/freehand32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/freehand32.png -------------------------------------------------------------------------------- /picture/ButtonImg/image16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/image16.png -------------------------------------------------------------------------------- /picture/ButtonImg/image32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/image32.png -------------------------------------------------------------------------------- /picture/ButtonImg/java128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/java128.png -------------------------------------------------------------------------------- /picture/ButtonImg/java16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/java16.png -------------------------------------------------------------------------------- /picture/ButtonImg/java32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/java32.png -------------------------------------------------------------------------------- /picture/ButtonImg/java64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/java64.png -------------------------------------------------------------------------------- /picture/ButtonImg/movie16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/movie16.png -------------------------------------------------------------------------------- /picture/ButtonImg/movie32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/movie32.png -------------------------------------------------------------------------------- /picture/ButtonImg/newdocument16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/newdocument16.png -------------------------------------------------------------------------------- /picture/ButtonImg/newdocument32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/newdocument32.png -------------------------------------------------------------------------------- /picture/ButtonImg/newdocumentwithedit16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/newdocumentwithedit16.png -------------------------------------------------------------------------------- /picture/ButtonImg/newdocumentwithedit32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/newdocumentwithedit32.png -------------------------------------------------------------------------------- /picture/ButtonImg/ok116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ok116.png -------------------------------------------------------------------------------- /picture/ButtonImg/ok132.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ok132.png -------------------------------------------------------------------------------- /picture/ButtonImg/ok16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ok16.png -------------------------------------------------------------------------------- /picture/ButtonImg/ok32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/ok32.png -------------------------------------------------------------------------------- /picture/ButtonImg/opendocument16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/opendocument16.png -------------------------------------------------------------------------------- /picture/ButtonImg/opendocument32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/opendocument32.png -------------------------------------------------------------------------------- /picture/ButtonImg/paste16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/paste16.png -------------------------------------------------------------------------------- /picture/ButtonImg/paste32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/paste32.png -------------------------------------------------------------------------------- /picture/ButtonImg/pen16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/pen16.png -------------------------------------------------------------------------------- /picture/ButtonImg/pen32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/pen32.png -------------------------------------------------------------------------------- /picture/ButtonImg/person16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/person16.png -------------------------------------------------------------------------------- /picture/ButtonImg/person32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/person32.png -------------------------------------------------------------------------------- /picture/ButtonImg/printer16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/printer16.png -------------------------------------------------------------------------------- /picture/ButtonImg/printer32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/printer32.png -------------------------------------------------------------------------------- /picture/ButtonImg/raypath16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/raypath16.png -------------------------------------------------------------------------------- /picture/ButtonImg/raypath32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/raypath32.png -------------------------------------------------------------------------------- /picture/ButtonImg/raytracing16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/raytracing16.png -------------------------------------------------------------------------------- /picture/ButtonImg/raytracing32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/raytracing32.png -------------------------------------------------------------------------------- /picture/ButtonImg/rectangle16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/rectangle16.png -------------------------------------------------------------------------------- /picture/ButtonImg/rectangle32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/rectangle32.png -------------------------------------------------------------------------------- /picture/ButtonImg/save16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/save16.png -------------------------------------------------------------------------------- /picture/ButtonImg/save32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/save32.png -------------------------------------------------------------------------------- /picture/ButtonImg/select16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/select16.png -------------------------------------------------------------------------------- /picture/ButtonImg/select32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/select32.png -------------------------------------------------------------------------------- /picture/ButtonImg/shaped16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/shaped16.png -------------------------------------------------------------------------------- /picture/ButtonImg/shaped32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/shaped32.png -------------------------------------------------------------------------------- /picture/ButtonImg/soundmax16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/soundmax16.png -------------------------------------------------------------------------------- /picture/ButtonImg/soundmax32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/soundmax32.png -------------------------------------------------------------------------------- /picture/ButtonImg/tcurve32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/tcurve32.png -------------------------------------------------------------------------------- /picture/ButtonImg/tcurves32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/tcurves32.png -------------------------------------------------------------------------------- /picture/ButtonImg/text16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/text16.png -------------------------------------------------------------------------------- /picture/ButtonImg/text32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/text32.png -------------------------------------------------------------------------------- /picture/ButtonImg/textwithedit16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/textwithedit16.png -------------------------------------------------------------------------------- /picture/ButtonImg/textwithedit32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/textwithedit32.png -------------------------------------------------------------------------------- /picture/ButtonImg/timage32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/timage32.png -------------------------------------------------------------------------------- /picture/ButtonImg/tmovie1order32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/tmovie1order32.png -------------------------------------------------------------------------------- /picture/ButtonImg/tmovie2order32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/tmovie2order32.png -------------------------------------------------------------------------------- /picture/ButtonImg/tmovie32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/tmovie32.png -------------------------------------------------------------------------------- /picture/ButtonImg/traypath32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/traypath32.png -------------------------------------------------------------------------------- /picture/ButtonImg/traytracing32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/traytracing32.png -------------------------------------------------------------------------------- /picture/ButtonImg/traytracingLG32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/traytracingLG32.png -------------------------------------------------------------------------------- /picture/ButtonImg/traytracingRK32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/ButtonImg/traytracingRK32.png -------------------------------------------------------------------------------- /picture/Expression/airplain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/airplain.png -------------------------------------------------------------------------------- /picture/Expression/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/bomb.png -------------------------------------------------------------------------------- /picture/Expression/candle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/candle.png -------------------------------------------------------------------------------- /picture/Expression/candy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/candy.png -------------------------------------------------------------------------------- /picture/Expression/coffee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/coffee.png -------------------------------------------------------------------------------- /picture/Expression/crying.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/crying.png -------------------------------------------------------------------------------- /picture/Expression/gun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/gun.png -------------------------------------------------------------------------------- /picture/Expression/laugh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/laugh.png -------------------------------------------------------------------------------- /picture/Expression/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/ok.png -------------------------------------------------------------------------------- /picture/Expression/pingpang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/pingpang.png -------------------------------------------------------------------------------- /picture/Expression/sad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/sad.png -------------------------------------------------------------------------------- /picture/Expression/tea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/picture/Expression/tea.png -------------------------------------------------------------------------------- /raypath.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/raypath.jpg -------------------------------------------------------------------------------- /screenshot/FD-vti.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/FD-vti.jpg -------------------------------------------------------------------------------- /screenshot/FileTree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/FileTree.jpg -------------------------------------------------------------------------------- /screenshot/author.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/author.jpg -------------------------------------------------------------------------------- /screenshot/mainWindows.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/mainWindows.jpg -------------------------------------------------------------------------------- /screenshot/newText.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/newText.jpg -------------------------------------------------------------------------------- /screenshot/newTextWithEdit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/newTextWithEdit.jpg -------------------------------------------------------------------------------- /screenshot/openText.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/openText.jpg -------------------------------------------------------------------------------- /screenshot/raypath.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/raypath.jpg -------------------------------------------------------------------------------- /screenshot/raypath2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/raypath2.jpg -------------------------------------------------------------------------------- /screenshot/raytracing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/raytracing.jpg -------------------------------------------------------------------------------- /screenshot/snap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/snap.jpg -------------------------------------------------------------------------------- /screenshot/ximage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rtoax/Seismic-Processing/d5ce674e51510246656507a2e11c8950c12a5d9c/screenshot/ximage.jpg -------------------------------------------------------------------------------- /src/menu/myMenu.java: -------------------------------------------------------------------------------- 1 | package src.menu; 2 | /** 3 | * 4 | * Author: Rong Tao 5 | * Location: UPC 6 | * Time: 2017.04 7 | * Modify by: Rong Tao 8 | */ 9 | -------------------------------------------------------------------------------- /src/myComponent/myBorderJPanel.java: -------------------------------------------------------------------------------- 1 | package src.myComponent; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | import javax.swing.JColorChooser; 35 | import javax.swing.JComponent; 36 | import javax.swing.ImageIcon; 37 | import javax.swing.JFrame; 38 | import javax.swing.JLabel; 39 | import javax.swing.JPanel; 40 | import javax.swing.JTextPane; 41 | import javax.swing.JEditorPane; 42 | import javax.swing.JButton; 43 | import javax.swing.JMenu; 44 | import javax.swing.JPopupMenu; 45 | import javax.swing.JMenuBar; 46 | import javax.swing.JMenuItem; 47 | import javax.swing.JProgressBar; 48 | import javax.swing.JToolBar; 49 | import javax.swing.JList; 50 | import javax.swing.JTextArea; 51 | import javax.swing.JTextField; 52 | import javax.swing.JScrollPane; 53 | import javax.swing.JSeparator; 54 | import javax.swing.JDialog; 55 | import javax.swing.JComboBox; 56 | import javax.swing.JCheckBox; 57 | import javax.swing.JCheckBoxMenuItem; 58 | import javax.swing.UIManager; 59 | import javax.swing.BorderFactory; 60 | import javax.swing.border.Border; 61 | import javax.swing.border.TitledBorder; 62 | import javax.swing.border.EtchedBorder; 63 | import javax.swing.event.ListSelectionEvent; 64 | import javax.swing.event.ListSelectionListener; 65 | import javax.swing.Box; 66 | import javax.swing.BoxLayout; 67 | import javax.swing.Timer; 68 | import javax.swing.JOptionPane; 69 | import javax.swing.JFileChooser; 70 | import javax.swing.filechooser.FileFilter; 71 | import javax.swing.filechooser.FileNameExtensionFilter; 72 | import javax.swing.text.Style; 73 | import javax.swing.text.StyleConstants; 74 | import javax.swing.text.StyledDocument; 75 | import javax.swing.text.SimpleAttributeSet; 76 | import javax.swing.text.MutableAttributeSet; 77 | import javax.swing.text.AttributeSet; 78 | import javax.swing.border.EmptyBorder; 79 | import javax.swing.event.DocumentEvent; 80 | import javax.swing.event.DocumentListener; 81 | 82 | import javax.swing.JInternalFrame; 83 | import javax.swing.JTable; 84 | import javax.swing.SwingUtilities; 85 | import javax.swing.table.DefaultTableModel; 86 | 87 | 88 | import java.text.DateFormat; 89 | 90 | import java.util.Calendar; 91 | import java.util.Date; 92 | import java.util.Locale; 93 | import java.util.Scanner; 94 | 95 | import java.io.BufferedReader; 96 | import java.io.BufferedWriter; 97 | import java.io.Writer; 98 | import java.io.File; 99 | import java.io.FileReader; 100 | import java.io.FileWriter; 101 | import java.io.IOException; 102 | import java.io.DataInputStream; 103 | import java.io.FileInputStream; 104 | import java.io.FileNotFoundException; 105 | 106 | import java.nio.file.Path; 107 | 108 | import javax.imageio.ImageIO; 109 | 110 | import net.java.dev.designgridlayout.DesignGridLayout; 111 | 112 | import java.lang.reflect.Field; 113 | 114 | import java.util.ArrayList; 115 | import java.util.Vector; 116 | 117 | 118 | //a######################################### 119 | //a## 120 | //a## myBorderJPanel 121 | //a## 122 | //a######################################### 123 | /** 124 | * 125 | * Author: Rong Tao 126 | * Location: UPC 127 | * Time: 2017.04 128 | * Modify by: Rong Tao 129 | */ 130 | class myBorderJPanel extends JPanel{ 131 | 132 | private TitledBorder titledborder; 133 | 134 | private JPanel panel = new JPanel(); 135 | 136 | private GridBagConstraints gc = new GridBagConstraints(); 137 | 138 | private GridBagLayout gridbag = new GridBagLayout(); 139 | 140 | myBorderJPanel(String title){ 141 | 142 | titledborder = BorderFactory.createTitledBorder( 143 | BorderFactory.createEtchedBorder( 144 | EtchedBorder.LOWERED), title); 145 | titledborder.setTitleFont(new Font("Georgia",Font.BOLD,20)); 146 | titledborder.setTitleJustification(TitledBorder.LEFT); 147 | titledborder.setTitlePosition(TitledBorder.DEFAULT_POSITION); 148 | 149 | setBorder(BorderFactory.createEmptyBorder(6,6,6,6)); 150 | 151 | panel.setLayout(gridbag); 152 | panel.setBorder(titledborder); 153 | 154 | JPanel tmp = new JPanel(); 155 | tmp.add(panel); 156 | add(tmp); 157 | } 158 | void addC(JComponent c, int gridx, int gridy,int gridwidth,int gridheight){ 159 | 160 | gc.gridx = gridx; //x grid position 161 | gc.gridy = gridy; //y grid position 162 | gc.gridwidth = gridwidth; 163 | gc.gridheight = gridheight; 164 | gridbag.setConstraints(c, gc); 165 | c.setFont(new Font("Georgia",Font.BOLD,25)); 166 | panel.add(c); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/paint/myXMultiCurveJFrame.java: -------------------------------------------------------------------------------- 1 | package src.paint; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | 35 | import javax.swing.JColorChooser; 36 | import javax.swing.JComponent; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JFrame; 39 | import javax.swing.JLabel; 40 | import javax.swing.JPanel; 41 | import javax.swing.JTextPane; 42 | import javax.swing.JEditorPane; 43 | import javax.swing.JButton; 44 | import javax.swing.JMenu; 45 | import javax.swing.JPopupMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JProgressBar; 49 | import javax.swing.JToolBar; 50 | import javax.swing.JList; 51 | import javax.swing.JTextArea; 52 | import javax.swing.JTextField; 53 | import javax.swing.JScrollPane; 54 | import javax.swing.JSeparator; 55 | import javax.swing.JDialog; 56 | import javax.swing.JComboBox; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JCheckBoxMenuItem; 59 | import javax.swing.UIManager; 60 | import javax.swing.BorderFactory; 61 | import javax.swing.border.Border; 62 | import javax.swing.border.TitledBorder; 63 | import javax.swing.border.EtchedBorder; 64 | import javax.swing.event.ListSelectionEvent; 65 | import javax.swing.event.ListSelectionListener; 66 | import javax.swing.Box; 67 | import javax.swing.BoxLayout; 68 | import javax.swing.Timer; 69 | import javax.swing.JOptionPane; 70 | import javax.swing.JFileChooser; 71 | import javax.swing.filechooser.FileFilter; 72 | import javax.swing.filechooser.FileNameExtensionFilter; 73 | import javax.swing.text.Style; 74 | import javax.swing.text.StyleConstants; 75 | import javax.swing.text.StyledDocument; 76 | import javax.swing.text.SimpleAttributeSet; 77 | import javax.swing.text.MutableAttributeSet; 78 | import javax.swing.text.AttributeSet; 79 | import javax.swing.border.EmptyBorder; 80 | import javax.swing.event.DocumentEvent; 81 | import javax.swing.event.DocumentListener; 82 | 83 | import javax.swing.JInternalFrame; 84 | import javax.swing.JTable; 85 | import javax.swing.SwingUtilities; 86 | import javax.swing.table.DefaultTableModel; 87 | 88 | 89 | import java.text.DateFormat; 90 | 91 | import java.util.Calendar; 92 | import java.util.Date; 93 | import java.util.Locale; 94 | import java.util.Scanner; 95 | 96 | import java.io.BufferedReader; 97 | import java.io.BufferedWriter; 98 | import java.io.Writer; 99 | import java.io.File; 100 | import java.io.FileReader; 101 | import java.io.FileWriter; 102 | import java.io.IOException; 103 | import java.io.DataInputStream; 104 | import java.io.FileInputStream; 105 | import java.io.FileNotFoundException; 106 | 107 | import java.nio.file.Path; 108 | 109 | import javax.imageio.ImageIO; 110 | 111 | import net.java.dev.designgridlayout.DesignGridLayout; 112 | 113 | 114 | 115 | import java.lang.reflect.Field; 116 | 117 | 118 | 119 | import java.util.ArrayList; 120 | import java.util.Vector; 121 | 122 | 123 | 124 | //a################################# 125 | //a## 126 | //a## myXMultiCurveJFrame 127 | //a## 128 | //a################################# 129 | /** 130 | * 131 | * Author: Rong Tao 132 | * Location: UPC 133 | * Time: 2017.04 134 | * Modify by: Rong Tao 135 | */ 136 | public class myXMultiCurveJFrame extends JFrame{ 137 | 138 | private Toolkit toolkit; 139 | 140 | private myXMultiCurveJPanel myxmulticurveJPanel; 141 | 142 | private File FileSave; 143 | 144 | 145 | public myXMultiCurveJFrame(int n, String[] txtfile, int[] linewidth, int[] linecolor){ 146 | 147 | 148 | setTitle("Multi-Curve"); 149 | setSize(800, 500); 150 | setLocationRelativeTo(null); 151 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 152 | 153 | toolkit = getToolkit(); 154 | Dimension size = toolkit.getScreenSize(); 155 | setLocation((size.width/2 - getWidth())/2, (size.height - getWidth())/2); 156 | 157 | 158 | /* menu: save, close */ 159 | JMenuBar JMenuBarSave; 160 | final JMenu JMenuSave; 161 | JMenuItem JMenuItemSaveClose,JMenuItemSaveSave; 162 | 163 | JMenuBarSave=new JMenuBar(); 164 | JMenuSave=new JMenu("File"); 165 | JMenuSave.setFont(new Font("Georgia", Font.BOLD, 20)); 166 | JMenuItemSaveSave=new JMenuItem("Save as Image"); 167 | JMenuItemSaveSave.setFont(new Font("Georgia", Font.BOLD, 15)); 168 | JMenuItemSaveClose=new JMenuItem("Close"); 169 | JMenuItemSaveClose.setFont(new Font("Georgia", Font.BOLD, 15)); 170 | 171 | JMenuSave.add(JMenuItemSaveSave); 172 | JMenuSave.add(JMenuItemSaveClose); 173 | JMenuBarSave.add(JMenuSave); 174 | 175 | setJMenuBar(JMenuBarSave); 176 | 177 | 178 | /* xmulticurve show panel in xmulticurveJFrame */ 179 | myxmulticurveJPanel = new myXMultiCurveJPanel(n,txtfile, linewidth, linecolor); 180 | 181 | 182 | JMenuItemSaveClose.addActionListener(new ActionListener() { 183 | public void actionPerformed(ActionEvent e) { 184 | dispose(); 185 | } 186 | }); 187 | JMenuItemSaveSave.addActionListener(new ActionListener() { 188 | @Override 189 | public void actionPerformed(ActionEvent e) { 190 | saveJPanel.saveImage(myxmulticurveJPanel, JMenuSave); 191 | } 192 | }); 193 | 194 | add(myxmulticurveJPanel); 195 | 196 | 197 | setVisible(true); 198 | } 199 | 200 | } 201 | 202 | -------------------------------------------------------------------------------- /src/paint/myXcurveJFrame.java: -------------------------------------------------------------------------------- 1 | package src.paint; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | 35 | import javax.swing.JColorChooser; 36 | import javax.swing.JComponent; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JFrame; 39 | import javax.swing.JLabel; 40 | import javax.swing.JPanel; 41 | import javax.swing.JTextPane; 42 | import javax.swing.JEditorPane; 43 | import javax.swing.JButton; 44 | import javax.swing.JMenu; 45 | import javax.swing.JPopupMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JProgressBar; 49 | import javax.swing.JToolBar; 50 | import javax.swing.JList; 51 | import javax.swing.JTextArea; 52 | import javax.swing.JTextField; 53 | import javax.swing.JScrollPane; 54 | import javax.swing.JSeparator; 55 | import javax.swing.JDialog; 56 | import javax.swing.JComboBox; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JCheckBoxMenuItem; 59 | import javax.swing.UIManager; 60 | import javax.swing.BorderFactory; 61 | import javax.swing.border.Border; 62 | import javax.swing.border.TitledBorder; 63 | import javax.swing.border.EtchedBorder; 64 | import javax.swing.event.ListSelectionEvent; 65 | import javax.swing.event.ListSelectionListener; 66 | import javax.swing.Box; 67 | import javax.swing.BoxLayout; 68 | import javax.swing.Timer; 69 | import javax.swing.JOptionPane; 70 | import javax.swing.JFileChooser; 71 | import javax.swing.filechooser.FileFilter; 72 | import javax.swing.filechooser.FileNameExtensionFilter; 73 | import javax.swing.text.Style; 74 | import javax.swing.text.StyleConstants; 75 | import javax.swing.text.StyledDocument; 76 | import javax.swing.text.SimpleAttributeSet; 77 | import javax.swing.text.MutableAttributeSet; 78 | import javax.swing.text.AttributeSet; 79 | import javax.swing.border.EmptyBorder; 80 | import javax.swing.event.DocumentEvent; 81 | import javax.swing.event.DocumentListener; 82 | 83 | import javax.swing.JInternalFrame; 84 | import javax.swing.JTable; 85 | import javax.swing.SwingUtilities; 86 | import javax.swing.table.DefaultTableModel; 87 | 88 | 89 | import java.text.DateFormat; 90 | 91 | import java.util.Calendar; 92 | import java.util.Date; 93 | import java.util.Locale; 94 | import java.util.Scanner; 95 | 96 | import java.io.BufferedReader; 97 | import java.io.BufferedWriter; 98 | import java.io.Writer; 99 | import java.io.File; 100 | import java.io.FileReader; 101 | import java.io.FileWriter; 102 | import java.io.IOException; 103 | import java.io.DataInputStream; 104 | import java.io.FileInputStream; 105 | import java.io.FileNotFoundException; 106 | 107 | import java.nio.file.Path; 108 | 109 | import javax.imageio.ImageIO; 110 | 111 | import net.java.dev.designgridlayout.DesignGridLayout; 112 | 113 | 114 | 115 | import java.lang.reflect.Field; 116 | 117 | 118 | 119 | import java.util.ArrayList; 120 | import java.util.Vector; 121 | 122 | 123 | //a################################# 124 | //a## 125 | //a## myXcurveJFrame 126 | //a## 127 | //a################################# 128 | /** 129 | * 130 | * Author: Rong Tao 131 | * Location: UPC 132 | * Time: 2017.04 133 | * Modify by: Rong Tao 134 | */ 135 | public class myXcurveJFrame extends JFrame{ 136 | 137 | private Toolkit toolkit; 138 | 139 | private myXcurveJPanel myxcurveJPanel; 140 | 141 | private File FileSave; 142 | 143 | 144 | public myXcurveJFrame(int n, String txtfile, int linewidth, int linecolor){ 145 | 146 | 147 | setTitle(txtfile); 148 | setSize(800, 500); 149 | setLocationRelativeTo(null); 150 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 151 | 152 | toolkit = getToolkit(); 153 | Dimension size = toolkit.getScreenSize(); 154 | setLocation((size.width/2 - getWidth())/2, (size.height - getWidth())/2); 155 | 156 | /* menu: save, close */ 157 | JMenuBar JMenuBarSave; 158 | final JMenu JMenuSave; 159 | JMenuItem JMenuItemSaveClose,JMenuItemSaveSave; 160 | 161 | JMenuBarSave=new JMenuBar(); 162 | JMenuSave=new JMenu("File"); 163 | JMenuSave.setFont(new Font("Georgia", Font.BOLD, 20)); 164 | JMenuItemSaveSave=new JMenuItem("Save as Image"); 165 | JMenuItemSaveSave.setFont(new Font("Georgia", Font.BOLD, 15)); 166 | JMenuItemSaveClose=new JMenuItem("Close"); 167 | JMenuItemSaveClose.setFont(new Font("Georgia", Font.BOLD, 15)); 168 | 169 | JMenuSave.add(JMenuItemSaveSave); 170 | JMenuSave.add(JMenuItemSaveClose); 171 | JMenuBarSave.add(JMenuSave); 172 | 173 | setJMenuBar(JMenuBarSave); 174 | 175 | 176 | 177 | 178 | /* xcurve show panel in xcurveJFrame */ 179 | myxcurveJPanel = new myXcurveJPanel(n,txtfile, linewidth, linecolor); 180 | 181 | 182 | JMenuItemSaveClose.addActionListener(new ActionListener() { 183 | public void actionPerformed(ActionEvent e) { 184 | dispose(); 185 | } 186 | }); 187 | JMenuItemSaveSave.addActionListener(new ActionListener() { 188 | @Override 189 | public void actionPerformed(ActionEvent e) { 190 | saveJPanel.saveImage(myxcurveJPanel, JMenuSave); 191 | } 192 | }); 193 | 194 | add(myxcurveJPanel); 195 | 196 | 197 | setVisible(true); 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /src/paint/saveJPanel.java: -------------------------------------------------------------------------------- 1 | package src.paint; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | 35 | import javax.swing.JColorChooser; 36 | import javax.swing.JComponent; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JFrame; 39 | import javax.swing.JLabel; 40 | import javax.swing.JPanel; 41 | import javax.swing.JTextPane; 42 | import javax.swing.JEditorPane; 43 | import javax.swing.JButton; 44 | import javax.swing.JMenu; 45 | import javax.swing.JPopupMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JProgressBar; 49 | import javax.swing.JToolBar; 50 | import javax.swing.JList; 51 | import javax.swing.JTextArea; 52 | import javax.swing.JTextField; 53 | import javax.swing.JScrollPane; 54 | import javax.swing.JSeparator; 55 | import javax.swing.JDialog; 56 | import javax.swing.JComboBox; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JCheckBoxMenuItem; 59 | import javax.swing.UIManager; 60 | import javax.swing.BorderFactory; 61 | import javax.swing.border.Border; 62 | import javax.swing.border.TitledBorder; 63 | import javax.swing.border.EtchedBorder; 64 | import javax.swing.event.ListSelectionEvent; 65 | import javax.swing.event.ListSelectionListener; 66 | import javax.swing.Box; 67 | import javax.swing.BoxLayout; 68 | import javax.swing.Timer; 69 | import javax.swing.JOptionPane; 70 | import javax.swing.JFileChooser; 71 | import javax.swing.filechooser.FileFilter; 72 | import javax.swing.filechooser.FileNameExtensionFilter; 73 | import javax.swing.text.Style; 74 | import javax.swing.text.StyleConstants; 75 | import javax.swing.text.StyledDocument; 76 | import javax.swing.text.SimpleAttributeSet; 77 | import javax.swing.text.MutableAttributeSet; 78 | import javax.swing.text.AttributeSet; 79 | import javax.swing.border.EmptyBorder; 80 | import javax.swing.event.DocumentEvent; 81 | import javax.swing.event.DocumentListener; 82 | 83 | import javax.swing.JInternalFrame; 84 | import javax.swing.JTable; 85 | import javax.swing.SwingUtilities; 86 | import javax.swing.table.DefaultTableModel; 87 | 88 | 89 | import java.text.DateFormat; 90 | 91 | import java.util.Calendar; 92 | import java.util.Date; 93 | import java.util.Locale; 94 | import java.util.Scanner; 95 | 96 | import java.io.BufferedReader; 97 | import java.io.BufferedWriter; 98 | import java.io.Writer; 99 | import java.io.File; 100 | import java.io.FileReader; 101 | import java.io.FileWriter; 102 | import java.io.IOException; 103 | import java.io.DataInputStream; 104 | import java.io.FileInputStream; 105 | import java.io.FileNotFoundException; 106 | 107 | import java.nio.file.Path; 108 | 109 | import javax.imageio.ImageIO; 110 | 111 | import net.java.dev.designgridlayout.DesignGridLayout; 112 | 113 | 114 | 115 | import java.lang.reflect.Field; 116 | 117 | 118 | 119 | import java.util.ArrayList; 120 | import java.util.Vector; 121 | 122 | 123 | //a############################################################################################# 124 | //a## 125 | //a## saveJPanel 126 | //a## 127 | //a############################################################################################# 128 | /** 129 | * 130 | * Author: Rong Tao 131 | * Location: UPC 132 | * Time: 2017.04 133 | * Modify by: Rong Tao 134 | */ 135 | public class saveJPanel{ 136 | 137 | static public void saveImage(JPanel panel, JMenu parent) { 138 | /*https://stackoverflow.com/questions/19621105/save-image-from-jpanel-after-draw */ 139 | BufferedImage img = new BufferedImage(panel.getWidth(), 140 | panel.getHeight(), BufferedImage.TYPE_INT_RGB); 141 | panel.paint(img.getGraphics()); 142 | JFileChooser jFile = new JFileChooser(); 143 | jFile.showSaveDialog(parent); 144 | Path pth = jFile.getSelectedFile().toPath(); 145 | JOptionPane.showMessageDialog(parent, pth.toString()); 146 | try { 147 | ImageIO.write(img, "png", new File(pth.toString())); 148 | System.out.println("panel saved as image"); 149 | 150 | } catch (Exception e) { 151 | System.out.println("panel not saved" + e.getMessage()); 152 | } 153 | } 154 | } 155 | 156 | -------------------------------------------------------------------------------- /src/seismic/RungeKutta.java: -------------------------------------------------------------------------------- 1 | package src.seismic; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | 35 | import javax.swing.JColorChooser; 36 | import javax.swing.JComponent; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JFrame; 39 | import javax.swing.JLabel; 40 | import javax.swing.JPanel; 41 | import javax.swing.JTextPane; 42 | import javax.swing.JEditorPane; 43 | import javax.swing.JButton; 44 | import javax.swing.JMenu; 45 | import javax.swing.JPopupMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JProgressBar; 49 | import javax.swing.JToolBar; 50 | import javax.swing.JList; 51 | import javax.swing.JTextArea; 52 | import javax.swing.JTextField; 53 | import javax.swing.JScrollPane; 54 | import javax.swing.JSeparator; 55 | import javax.swing.JDialog; 56 | import javax.swing.JComboBox; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JCheckBoxMenuItem; 59 | import javax.swing.UIManager; 60 | import javax.swing.BorderFactory; 61 | import javax.swing.border.Border; 62 | import javax.swing.border.TitledBorder; 63 | import javax.swing.border.EtchedBorder; 64 | import javax.swing.event.ListSelectionEvent; 65 | import javax.swing.event.ListSelectionListener; 66 | import javax.swing.Box; 67 | import javax.swing.BoxLayout; 68 | import javax.swing.Timer; 69 | import javax.swing.JOptionPane; 70 | import javax.swing.JFileChooser; 71 | import javax.swing.filechooser.FileFilter; 72 | import javax.swing.filechooser.FileNameExtensionFilter; 73 | import javax.swing.text.Style; 74 | import javax.swing.text.StyleConstants; 75 | import javax.swing.text.StyledDocument; 76 | import javax.swing.text.SimpleAttributeSet; 77 | import javax.swing.text.MutableAttributeSet; 78 | import javax.swing.text.AttributeSet; 79 | import javax.swing.border.EmptyBorder; 80 | import javax.swing.event.DocumentEvent; 81 | import javax.swing.event.DocumentListener; 82 | 83 | import javax.swing.JInternalFrame; 84 | import javax.swing.JTable; 85 | import javax.swing.SwingUtilities; 86 | import javax.swing.table.DefaultTableModel; 87 | 88 | 89 | import java.text.DateFormat; 90 | 91 | import java.util.Calendar; 92 | import java.util.Date; 93 | import java.util.Locale; 94 | import java.util.Scanner; 95 | 96 | import java.io.BufferedReader; 97 | import java.io.BufferedWriter; 98 | import java.io.Writer; 99 | import java.io.File; 100 | import java.io.FileReader; 101 | import java.io.FileWriter; 102 | import java.io.IOException; 103 | import java.io.DataInputStream; 104 | import java.io.FileInputStream; 105 | import java.io.FileNotFoundException; 106 | 107 | import java.nio.file.Path; 108 | 109 | import javax.imageio.ImageIO; 110 | 111 | import net.java.dev.designgridlayout.DesignGridLayout; 112 | 113 | 114 | 115 | import java.lang.reflect.Field; 116 | 117 | 118 | 119 | import java.util.ArrayList; 120 | import java.util.Vector; 121 | 122 | 123 | //a############################################################################################# 124 | //a## 125 | //a## myRungeKuttaRayTracingJFrameParasJFrame -> the parameters basic frame 126 | //a## 127 | //a## myRungeKuttaRayTracingJFrame -> the frame include a image panel 128 | //a## 129 | //a## myRungeKuttaRayTracingJPanel -> the panel to paint 130 | //a## 131 | //a## myRungeKuttaTracingAboutDialog -> About dialog 132 | //a## 133 | //a############################################################################################# 134 | /** 135 | * 136 | * Author: Rong Tao 137 | * Location: UPC 138 | * Time: 2017.04 139 | * Modify by: Rong Tao 140 | */ 141 | //a######################################################## 142 | //a## 143 | //a## RungeKutta Raytracing 144 | //a## 145 | //a######################################################## 146 | /** 147 | * 148 | * Author: Rong Tao 149 | * Location: UPC 150 | * Time: 2017.04 151 | * Modify by: Rong Tao 152 | */ 153 | public class RungeKutta{ 154 | 155 | public static native float[] rungekutta(String[] file, int[] parasint, float[] parasfloat); 156 | 157 | private static float[][][] raypath; 158 | 159 | public static float[][][] makeRay(String[] file, int[] parasint,float[] parasfloat){ 160 | 161 | System.loadLibrary("RungeKutta"); 162 | 163 | int nsx = parasint[4]; 164 | int na = parasint[3]; 165 | int nt = parasint[0]; 166 | 167 | raypath = new float[nsx*na][2][nt]; 168 | 169 | 170 | float[]tmp = rungekutta(file,parasint,parasfloat); 171 | 172 | for(int iray=0;iray innerclass 6 | //a## 7 | //a################################# 8 | /** 9 | * 10 | * Author: Rong Tao 11 | * Location: UPC 12 | * Time: 2017.04 13 | * Modify by: Rong Tao 14 | */ 15 | public class cjbsegy{ 16 | /* reference: cjbsegy.h */ 17 | 18 | public int tracl, tracr, fldr, tracf, ep, cdp, cdpt;/* int (0-6) */ 19 | public short trid, nvs, nhs, duse;/* short (7-10) */ 20 | public int offset, gelev, selev, sdepth, gdel, sdel, swdep, gwdep;/* int (11-18) */ 21 | public short scalel, scalco;/* short (19-20) */ 22 | public int sx, sy, gx, gy;/* int (21-24) */ 23 | public short counit, wevel, swevel, sut, gut;/* short (25-70) */ 24 | public short sstat, gstat, tstat, laga, lagb; 25 | public short delrt, muts, mute, ns, dt; 26 | public short gain, igc, igi, corr, sfs; 27 | public short sfe, slen, styp, stas, stae; 28 | public short tatyp, afilf, afils, nofilf, nofils; 29 | public short lcf, hcf, lcs, hcs, year; 30 | public short day, hour, minute, sec, timbas; 31 | public short trwf, grnors, grnofr, grnlof, gaps; 32 | public short otrav; 33 | public float d1, f1, d2, f2, ungpow, unscale;/* float (71-76) */ 34 | public int ntr; /* int (77) */ 35 | public short mark, shortpad;/* short (78-79) */ 36 | public int line3d, cdp3d;/* int (80-81) */ 37 | public short unass0,unass1,unass2,unass3,unass4 ; 38 | public short unass5,unass6,unass7,unass8,unass9 ; 39 | 40 | static public String[] segy = {"tracl", "tracr", "fldr", "tracf", "ep", 41 | "cdp", "cdpt", "trid", "nvs", "nhs", 42 | "duse", "offset", "gelev", "selev", "sdepth", 43 | "gdel", "sdel", "swdep", "gwdep", "scalel", 44 | "scalco", "sx", "sy", "gx", "gy", 45 | "counit", "wevel", "swevel", "sut", "gut", 46 | "sstat", "gstat", "tstat", "laga", "lagb", 47 | "delrt", "muts", "mute", "ns", "dt", 48 | "gain", "igc", "igi", "corr", "sfs", 49 | "sfe", "slen", "styp", "stas", "stae", 50 | "tatyp", "afilf", "afils", "nofilf", "nofils", 51 | "lcf", "hcf", "lcs", "hcs", "year", 52 | "day", "hour", "minute", "sec", "timbas", 53 | "trwf", "grnors", "grnofr", "grnlof", "gaps", 54 | "otrav", "d1", "f1", "d2", "f2", 55 | "ungpow", "unscale", "ntr", "mark", "shortpad", 56 | "line3d", "cdp3d", 57 | "unass0", "unass1", "unass2", "unass3", "unass4", 58 | "unass5", "unass6", "unass7", "unass8", "unass9"}; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/seismic/saveJPanel.java: -------------------------------------------------------------------------------- 1 | package src.seismic; 2 | 3 | 4 | import java.awt.event.ActionEvent; 5 | import java.awt.event.ActionListener; 6 | import java.awt.event.MouseListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.WindowAdapter; 9 | import java.awt.event.KeyEvent; 10 | import java.awt.event.MouseEvent; 11 | import java.awt.event.WindowAdapter; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.Toolkit; 14 | import java.awt.Dimension; 15 | import java.awt.BorderLayout; 16 | import java.awt.GridLayout; 17 | import java.awt.FlowLayout; 18 | import java.awt.Font; 19 | import java.awt.Color; 20 | import java.awt.FileDialog; 21 | import java.awt.Color; 22 | import java.awt.GraphicsEnvironment; 23 | import java.awt.event.ItemEvent; 24 | import java.awt.event.ItemListener; 25 | import java.awt.Graphics; 26 | import java.awt.Graphics2D; 27 | import java.awt.Insets; 28 | import java.awt.GridBagConstraints; 29 | import java.awt.GridBagLayout; 30 | import java.awt.BasicStroke; 31 | import java.awt.Image; 32 | import java.awt.image.BufferedImage; 33 | 34 | 35 | import javax.swing.JColorChooser; 36 | import javax.swing.JComponent; 37 | import javax.swing.ImageIcon; 38 | import javax.swing.JFrame; 39 | import javax.swing.JLabel; 40 | import javax.swing.JPanel; 41 | import javax.swing.JTextPane; 42 | import javax.swing.JEditorPane; 43 | import javax.swing.JButton; 44 | import javax.swing.JMenu; 45 | import javax.swing.JPopupMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JProgressBar; 49 | import javax.swing.JToolBar; 50 | import javax.swing.JList; 51 | import javax.swing.JTextArea; 52 | import javax.swing.JTextField; 53 | import javax.swing.JScrollPane; 54 | import javax.swing.JSeparator; 55 | import javax.swing.JDialog; 56 | import javax.swing.JComboBox; 57 | import javax.swing.JCheckBox; 58 | import javax.swing.JCheckBoxMenuItem; 59 | import javax.swing.UIManager; 60 | import javax.swing.BorderFactory; 61 | import javax.swing.border.Border; 62 | import javax.swing.border.TitledBorder; 63 | import javax.swing.border.EtchedBorder; 64 | import javax.swing.event.ListSelectionEvent; 65 | import javax.swing.event.ListSelectionListener; 66 | import javax.swing.Box; 67 | import javax.swing.BoxLayout; 68 | import javax.swing.Timer; 69 | import javax.swing.JOptionPane; 70 | import javax.swing.JFileChooser; 71 | import javax.swing.filechooser.FileFilter; 72 | import javax.swing.filechooser.FileNameExtensionFilter; 73 | import javax.swing.text.Style; 74 | import javax.swing.text.StyleConstants; 75 | import javax.swing.text.StyledDocument; 76 | import javax.swing.text.SimpleAttributeSet; 77 | import javax.swing.text.MutableAttributeSet; 78 | import javax.swing.text.AttributeSet; 79 | import javax.swing.border.EmptyBorder; 80 | import javax.swing.event.DocumentEvent; 81 | import javax.swing.event.DocumentListener; 82 | 83 | import javax.swing.JInternalFrame; 84 | import javax.swing.JTable; 85 | import javax.swing.SwingUtilities; 86 | import javax.swing.table.DefaultTableModel; 87 | 88 | 89 | import java.text.DateFormat; 90 | 91 | import java.util.Calendar; 92 | import java.util.Date; 93 | import java.util.Locale; 94 | import java.util.Scanner; 95 | 96 | import java.io.BufferedReader; 97 | import java.io.BufferedWriter; 98 | import java.io.Writer; 99 | import java.io.File; 100 | import java.io.FileReader; 101 | import java.io.FileWriter; 102 | import java.io.IOException; 103 | import java.io.DataInputStream; 104 | import java.io.FileInputStream; 105 | import java.io.FileNotFoundException; 106 | 107 | import java.nio.file.Path; 108 | 109 | import javax.imageio.ImageIO; 110 | 111 | import net.java.dev.designgridlayout.DesignGridLayout; 112 | 113 | 114 | 115 | import java.lang.reflect.Field; 116 | 117 | 118 | 119 | import java.util.ArrayList; 120 | import java.util.Vector; 121 | 122 | 123 | //a############################################################################################# 124 | //a## 125 | //a## saveJPanel 126 | //a## 127 | //a############################################################################################# 128 | /** 129 | * 130 | * Author: Rong Tao 131 | * Location: UPC 132 | * Time: 2017.04 133 | * Modify by: Rong Tao 134 | */ 135 | public class saveJPanel{ 136 | 137 | static public void saveImage(JPanel panel, JMenu parent) { 138 | /*https://stackoverflow.com/questions/19621105/save-image-from-jpanel-after-draw */ 139 | BufferedImage img = new BufferedImage(panel.getWidth(), 140 | panel.getHeight(), BufferedImage.TYPE_INT_RGB); 141 | panel.paint(img.getGraphics()); 142 | JFileChooser jFile = new JFileChooser(); 143 | jFile.showSaveDialog(parent); 144 | Path pth = jFile.getSelectedFile().toPath(); 145 | JOptionPane.showMessageDialog(parent, pth.toString()); 146 | try { 147 | ImageIO.write(img, "png", new File(pth.toString())); 148 | System.out.println("panel saved as image"); 149 | 150 | } catch (Exception e) { 151 | System.out.println("panel not saved" + e.getMessage()); 152 | } 153 | } 154 | } 155 | 156 | -------------------------------------------------------------------------------- /src/swap/Swap.java: -------------------------------------------------------------------------------- 1 | package src.swap; 2 | 3 | //a################################# 4 | //a## 5 | //a## Swap --> innerclass 6 | //a## 7 | //a################################# 8 | /** 9 | * 10 | * Author: Rong Tao 11 | * Location: UPC 12 | * Time: 2017.04 13 | * Modify by: Rong Tao 14 | */ 15 | public class Swap{ 16 | /* float */ 17 | public static float swap (float value){ 18 | int intValue = Float.floatToRawIntBits (value); 19 | intValue = swap (intValue); 20 | return Float.intBitsToFloat (intValue); 21 | } 22 | /* int */ 23 | public static int swap (int value){ 24 | int b1 = (value >> 0) & 0xff; 25 | int b2 = (value >> 8) & 0xff; 26 | int b3 = (value >> 16) & 0xff; 27 | int b4 = (value >> 24) & 0xff; 28 | return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0; 29 | } 30 | /* short */ 31 | public static short swap (short value){ 32 | int b1 = value & 0xff; 33 | int b2 = (value >> 8) & 0xff; 34 | return (short) (b1 << 8 | b2 << 0); 35 | } 36 | /* long */ 37 | public static long swap (long value){ 38 | long b1 = (value >> 0) & 0xff; 39 | long b2 = (value >> 8) & 0xff; 40 | long b3 = (value >> 16) & 0xff; 41 | long b4 = (value >> 24) & 0xff; 42 | long b5 = (value >> 32) & 0xff; 43 | long b6 = (value >> 40) & 0xff; 44 | long b7 = (value >> 48) & 0xff; 45 | long b8 = (value >> 56) & 0xff; 46 | return b1 << 56 | b2 << 48 | b3 << 40 | b4 << 32 | 47 | b5 << 24 | b6 << 16 | b7 << 8 | b8 << 0; 48 | } 49 | /* double */ 50 | public static double swap (double value){ 51 | long longValue = Double.doubleToLongBits (value); 52 | longValue = swap (longValue); 53 | return Double.longBitsToDouble (longValue); 54 | } 55 | /* short array */ 56 | public static void swap (short[] array){ 57 | for (int i = 0; i < array.length; i++) 58 | array[i] = swap (array[i]); 59 | } 60 | /* int array */ 61 | public static void swap (int[] array){ 62 | for (int i = 0; i < array.length; i++) 63 | array[i] = swap (array[i]); 64 | } 65 | /* long array */ 66 | public static void swap (long[] array){ 67 | for (int i = 0; i < array.length; i++) 68 | array[i] = swap (array[i]); 69 | } 70 | /* float array */ 71 | public static void swap (float[] array){ 72 | for (int i = 0; i < array.length; i++) 73 | array[i] = swap (array[i]); 74 | } 75 | /* double array */ 76 | public static void swap (double[] array){ 77 | for (int i = 0; i < array.length; i++) 78 | array[i] = swap (array[i]); 79 | } 80 | } 81 | --------------------------------------------------------------------------------