-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalias.java
159 lines (144 loc) · 6.48 KB
/
alias.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// alias.java
// alias
//
// Created by Damien Jeannerat on 1/29/07.
// Copyright (c) 2007 __MyCompanyName__. All rights reserved.
//
// A simple Java Swing applet
//
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
public class alias extends JApplet {
JTextField textfield;
private String mess;
private Dim dim = new Dim();
private int number_of_dimensions;
private Font font = new Font("serif", Font.ITALIC + Font.BOLD, 36);
private Label m_mess;
private JTextArea info = new JTextArea();
private ControlWindow controlwindow;
private DisplayWindow displaywindow;
private Cosa cosa = new Cosa();
int i;
public void init() {
// set the default look and feel
mess = getParameter("message");
number_of_dimensions=Integer.parseInt(getParameter("number_of_dimensions"));
/*String laf = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(laf);
} catch (UnsupportedLookAndFeelException exc) {
System.err.println ("Warning: UnsupportedLookAndFeel: " + laf);
} catch (Exception exc) {
System.err.println ("Error loading " + laf + exc);
}*/
setLayout (new FlowLayout());
m_mess = new Label("MessageApplet is Running... "+mess, Label.CENTER);
// add(m_mess);
add(info);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
System.err.println ("Changing ...");
controlwindow = new ControlWindow();//sfo, sw, full spectral widht (for limit in slider)
///////controlwindow.disppar.sw=-1d;controlwindow.disppar.cf=666.3d;controlwindow.disppar.sfo=666.1d;
controlwindow.setSize(350, 200); //controlwindow.pack();
controlwindow.setLocation(100, 100);
controlwindow.setTitle("Control window v1.0");
//controlwindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Not working !!
controlwindow.addMyEventListener(new MyEventListener() {
public void myEventOccurred(MyEvent evt) {
// MyEvent was fired
controlwindow.setTitle("Not ok CalcPos Control Window :"+controlwindow.Getsw()+" or "+evt.getTD()+" "+evt.getSW()+" "+evt.getOS());
dim.CalcPos(controlwindow.disppar);
controlwindow.setTitle("Not ok CalcWidth Control Window :"+controlwindow.Getsw()+" or "+evt.getTD()+" "+evt.getSW()+" "+evt.getOS());
dim.CalcWidth(controlwindow.disppar); controlwindow.setTitle("Not ok CalcOverlap Control Window :"+controlwindow.Getsw()+" or "+evt.getTD()+" "+evt.getSW()+" "+evt.getOS());
dim.CalcOverlap(controlwindow.disppar); controlwindow.setTitle("OK Control Window :"+controlwindow.Getsw()+" or "+evt.getTD()+" "+evt.getSW()+" "+evt.getOS());
dim.calcTicks(controlwindow.disppar);controlwindow.setTitle("Control window v1.0");
displaywindow.update();
// in case need access to the object :ControlWindow = evt.getControlWindow(); // http://www.cs.bgu.ac.il/~elhadad/se/events.html
}
});
controlwindow.setVisible(true);
m_mess.setText("Check dim : " +dim.ppm);
displaywindow = new DisplayWindow(dim);//sfo, sw, full spectral widht (for limit in slider)
displaywindow.setSize(350, 200); //controlwindow.pack();
displaywindow.setLocation(100, 300);
displaywindow.setTitle("Display window v1.0");
// displaywindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Not working !!
displaywindow.setVisible(true);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
}
public void adjustmentValueChanged(AdjustmentEvent e) {
controlwindow.setTitle("Tcho22.."+controlwindow.Getsw());
}
public void paint (Graphics g) {
super.paint(g);
// g.setColor(Color.blue);
// g.setFont(font);
// g.drawString(mess, 40, 80);
// g.drawString(""+getWidth(), 40, 120);
// g.drawLine(0,0,50,50);
}
public void Optimize(String param,String t1max) {
m_mess.setText("Optimizing...");
displaywindow.repaint();info.setText("Optimizing...");
if(Double.parseDouble(param) < 0.d ) info.setText( cosa.Optimize(dim,controlwindow,10.0d,-1 ,Double.parseDouble(t1max) ) );
if(Double.parseDouble(param) == 0.d ) info.setText( cosa.Optimize(dim,controlwindow,10.0d,0 ,Double.parseDouble(t1max) ) );
if(Double.parseDouble(param) == 1.d )info.setText( cosa.Optimize(dim,controlwindow,10.0d,controlwindow.Gettd(),Double.parseDouble(t1max) ) );
//control window to provide sfo
//10.0 is per, the percentage of added t1max allowed
//0 means optimize TD as well otherwise value of TD.
controlwindow.Setsw(cosa.sw);
controlwindow.Settd(cosa.td);
m_mess.setText("Opt"+Double.parseDouble(t1max)+"_");
displaywindow.repaint();
}
public void setdata1_5(String isfo,String ippm, String ilw, String ihppm1 ,String ihppm2) {
//Double.parseDouble(message2)
// m_mess.setText("setdata1_5 1: " + isfo+" - "+ippm);
controlwindow.disppar.sfo=Double.parseDouble(isfo);
// m_mess.setText("setdata1_5 2: " + sfo+" - "+ippm);
dim.ppm.clear();
dim.lw.clear();
dim.hppm1.clear();
dim.hppm2.clear();
for(i=0;i<ippm.split(",").length;i++){
dim.ppm.add(Double.parseDouble(ippm.split(",")[i]));
dim.lw.add(Double.parseDouble(ilw.split(",")[i]));
if(Double.parseDouble(ihppm1.split(",")[i]) > Double.parseDouble(ihppm2.split(",")[i])){
dim.hppm1.add(Double.parseDouble(ihppm1.split(",")[i]));
dim.hppm2.add(Double.parseDouble(ihppm2.split(",")[i]));
}else{
dim.hppm1.add(Double.parseDouble(ihppm2.split(",")[i]));
dim.hppm2.add(Double.parseDouble(ihppm1.split(",")[i]));
}
m_mess.setText("setdata1_5 4: " + dim.ppm.get(i)+"ok"+i);
// hppm[i][1]=Double.parseDouble(ihppm1.split(",")[i]);
// hppm[i][2]=Double.parseDouble(ihppm2.split(",")[i]);
}
if(controlwindow.disppar.sw==-1d){
dim.calcFWMW();
dim.calcTicks(controlwindow.disppar);
controlwindow.Setsw(dim.fullwidth);
controlwindow.Setcf(dim.midwind);
}
dim.CalcPos(controlwindow.disppar);
dim.CalcWidth(controlwindow.disppar);
dim.CalcOverlap(controlwindow.disppar);
dim.calcTicks(controlwindow.disppar);
displaywindow.update();
}
public void setMessag(String message2)
{
//process message
m_mess.setText("Selection:" + message2);
displaywindow.repaint();
}
}