📄 showfeedingnet.java
字号:
/*
* ShowFeedingNet
*
* Button action to read current taper and performances
* Calculate feeding line length then call the drawer to show on the screen
*
* Meirong He
* EEE Department
* University of Sheffield
* July 2005
*/
import java.awt.*;
import java.awt.event.*;
public class ShowFeedingNet implements ActionListener {
private Button button;
private AntennaDesigner taper;
public ShowFeedingNet (Button bb, AntennaDesigner tt) {
button=bb;
taper=tt;
}
public void actionPerformed (ActionEvent e) {
taper.screen.clear();
int N=taper.N;
int V=(int)Math.ceil(Math.log(N)/Math.log(2));
double mmdeg=taper.lamda/360.0;
double pitch=taper.lamda*Double.parseDouble(new String(taper.spacing.getText()));
double[] l=new double[N];
double [][] tl=new double[N][V];
double [][] sectl=new double[N][V];
double [][] s=new double[N][V];
double [][] d=new double[N][V];
//Set up variables necessary
for (int i=0; i<N; i++)
l[i]=mmdeg*Double.parseDouble(new String(taper.phase[i].getText()));
//Read current phases and obtain feeding length
for(int k=0;k<V;k++) {
for (int i=0; i<N; i++) {
tl[i][k]=0; s[i][k]=0; d[i][k]=0; sectl[i][k]=0;
}
}
////Calculation of feeding line lenth///////////////////
int shift1=0, shift2=0, P=N;
for (int k=0; k<V; k++) {
boolean odd=(P%2!=0);
if(odd) shift2=shift1+(int)Math.pow(2,k);
/////////Obtain elements feeding line length sums and differences//////////
for (int i=0; i<(int)Math.ceil(P/2.0); i++) {
if(odd) {
if(k==0) {
if(i==1) s[i][k]=0;
else s[i][k]=pitch;
if(i==0) d[i][k]=l[1]-l[0];
else if(i==1) d[i][k]=0;
else d[i][k]=l[2*i]-l[2*i-1];
}
else {
if(i==0) s[i][k]=s[0][k-1]+s[1][k-1]+pitch;
else if(i==1) s[i][k]=s[2][k-1];
else s[i][k]=s[i*2-1][k-1]+s[i*2][k-1]+pitch;
if(i==0) d[i][k]=l[(int)Math.pow(2,k+1)-1-shift1]-l[0];
else if(i==1) d[i][k]=d[2][k-1];
else d[i][k]=l[(i+1)*(int)Math.pow(2,k+1)-1-shift2]-l[i*(int)Math.pow(2,k+1)-shift2];
}
}
else {
if(k==0) s[i][k]=pitch;
else s[i][k]=s[i*2][k-1]+s[i*2+1][k-1]+pitch;
if(i==0) d[i][k]=l[(int)Math.pow(2,k+1)-1-shift1]-l[0];
else d[i][k]=l[(i+1)*(int)Math.pow(2,k+1)-1-shift2]-l[i*(int)Math.pow(2,k+1)-shift2];
}
}
/////////Obtain feeding line lengths from nodes to elements///////////////
if(k==0 && odd )
for (int i=0; i<P; i++)
if(i==0 || i==1) tl[i][k]=(s[0][0]-Math.pow(-1, i)*d[0][0])/2;
else if(i==2) tl[i][k]=0;
else tl[i][k]=(s[(int)Math.ceil(i/2.0)][0]+Math.pow(-1, i)*d[(int)Math.ceil(i/2.0)][0])/2;
else
for (int i=0; i<(int)Math.ceil(P/2.0)*2; i++)
tl[i][k]=(s[(int)(i/2.0)][k]-Math.pow(-1, i)*d[(int)(i/2.0)][k])/2;
//////////Obtain feeding line lengths in each sector////////////////
for (int i=0;i<P;i++)
if(k==0) sectl[i][k]=tl[i][k];
else if(odd) {
if(i==0) sectl[i][k]=tl[i][k]-tl[i][k-1];
else if(i==1) {
if(k==1 & N%2!=0 ) sectl[i][k]=tl[i][k]-tl[2][k-1];
else sectl[i][k]=tl[i][k]-tl[3][k-1];
}
else if(i==2) sectl[i][k]=0;
else
if(k==1) {
if( N%2!=0 & i%2==0) sectl[i][k]=tl[i+1][k]-tl[2*i][k-1];
else if(N%2!=0 & i%2!=0) sectl[i][k]=tl[i+1][k]-tl[2*i-1][k-1];
else if(N%2==0 & i%2==0) sectl[i][k]=tl[i+1][k]-tl[2*i+1][k-1];
else sectl[i][k]=tl[i+1][k]-tl[2*i][k-1];
}
else
if(i%2==0) sectl[i][k]=tl[i+1][k]-tl[2*i+1][k-1];
else sectl[i][k]=tl[i+1][k]-tl[2*i][k-1];
}
else {
if(k==1 & i>0 & N%2!=0)
if(i%2==0) sectl[i][k]=tl[i][k]-tl[2*i-1][k-1];
else sectl[i][k]=tl[i][k]-tl[2*i][k-1];
else
if(i%2==0) sectl[i][k]=tl[i][k]-tl[2*i][k-1];
else sectl[i][k]=tl[i][k]-tl[2*i+1][k-1];
}
if(odd) shift1=shift1+(int)Math.pow(2,k);
P=(int)Math.ceil(P/2.0);
}
taper.screen.drawFeedingNet(sectl, N, V);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -