public class KSKB extends JFrame {
Double a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14;
Double tf1, tf2, tf3 , tf4, tf5, tf6, tf7, tf8, tf9, tf10, tf11, tf12, tf13, tf14, tf15, tf16, tf17, tf18, tf19, tf20, tf21, tf22, tf23, tf24, tf25, tf26, tf27, tf28, tf29, tf30, tf31, tf32, tf33, tf34, tf35, tf36;
Double avpro1, avpro2, avpro3, avpro4, avpro5, avpro6, avpro7, avpro8, avpro9, avpro10, avpro11, avpro12, avpro13, avpro14, avpro15, avpro16, avpro17, avpro18, avpro19, avpro20, avpro21, avpro22, avpro23, avpro24, avpro25, avpro26, avpro27, avpro28, avpro29, avpro30, avpro31, avpro32, avpro33, avpro34, avpro35;
Double vol1, vol2, vol3, vol4, vol5, vol6, vol7, vol8, vol9, vol10, vol11, vol12, vol13, vol14, vol15, vol16, vol17, vol18, vol19, vol20, vol21, vol22, vol23, vol24, vol25, vol26, vol27, vol28, vol29, vol30, vol31, vol32, vol33, vol34, vol35, vol36;
Double ha1, ha2, ha3, ha4, ha5, ha6, ha7, ha8, ha9, ha10, ha11, ha12, ha13, ha14, ha15, ha16, ha17, ha18, ha19, ha20, ha21, ha22, ha23, ha24, ha25, ha26, ha27, ha28, ha29, ha30, ha31, ha32, ha33, ha34, ha35, ha36;
String comboperiod;
JPanel RiskAnalysispanel;
JPanel Gridpanel;
JPanel JPanel1, JPanel2, JPanel3;
XYSeries series1, series2, series3;
XYSeriesCollection dataset1, dataset2, dataset3;
JFreeChart chart1, chart2, chart3;
ChartPanel chPanel1, chaPanel2, chPanel3;
JButton convert;
JButton bpricechart;
JButton bavprochart;
JButton bvolachart;
JLabel Periods;
JLabel intervals;
JLabel period;
JLabel vola;
JLabel avola;
JLabel averageprofit;
JLabel aaverageprofit;
JTextField TF1;
//...
JTextField TF36;
public KSKB() {
setVisible(true);
setSize(800, 600);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setTitle("Phalanx Value Screener");
setResizable(false);
setLayout(null);
RiskAnalysispanel = new JPanel();
RiskAnalysispanel.setVisible(false);
RiskAnalysispanel.setBounds(0, 25, 800, 575);
RiskAnalysispanel.setBackground(Color.WHITE);
RiskAnalysispanel.setLayout(null);
add (RiskAnalysispanel);
Gridpanel = new JPanel();
Gridpanel.setVisible(true);
Gridpanel.setBounds(10, 25, 390, 515);
Gridpanel.setBackground(Color.WHITE);
Gridpanel.setLayout(new java.awt.GridLayout( 18, 2, 6, 10 ));
RiskAnalysispanel.add (Gridpanel);
bpricechart = new JButton("Chart 1");
bpricechart.setBounds(420, 190, 106, 20);
bpricechart.addActionListener(new cpricechartlistener());
RiskAnalysispanel.add(bpricechart);
bavprochart = new JButton("Chart 2");
bavprochart.setBounds(546, 190, 107, 20);
bavprochart.addActionListener(new cavprochartlistener());
RiskAnalysispanel.add(bavprochart);
bvolachart = new JButton("Chart 3");
bvolachart.setBounds(675, 190, 106, 20);
bvolachart.addActionListener(new cvolachartlistener());
RiskAnalysispanel.add(bvolachart);
//Combobox Volatility................................................
//Textfelder---------------------------------------------------------
TF1 = new JTextField();
TF1.addCaretListener(new TF1Listener());
Gridpanel.add (TF1);
//...
TF36 = new JTextField();
TF36.setVisible(false);
TF36.addCaretListener(new TF36Listener());
Gridpanel.add (TF36);
repaint();
}
public class TF1Listener implements CaretListener {
@Override
public void caretUpdate(CaretEvent e) {
TF2.setVisible(true);
tf1 = Double.parseDouble(TF1.getText());
String aa2 = String.valueOf(tf1);
aaverageprofit.setText(aa2+" %");
}
}
public class TF2Listener implements CaretListener {
@Override
public void caretUpdate(CaretEvent e) {
TF3.setVisible(true);
tf2 = Double.parseDouble(TF2.getText());
avpro1 = ((((tf2-tf1)/tf1)*100));
String aa2 = String.valueOf(avpro1);
aaverageprofit.setText(aa2+" %");
vol2 = Math.pow(((((tf2-tf1)/tf1)*100)-avpro1), 2);
String aa3 = String.valueOf(Math.sqrt(vol2));
avola.setText(aa3);
}
}
public class TF3Listener implements CaretListener {
@Override
public void caretUpdate(CaretEvent e) {
TF4.setVisible(true);
tf3 = Double.parseDouble(TF3.getText());
avpro2 = (((((tf2-tf1)/tf1)*100)+(((tf3-tf2)/tf2)*100))/2);
String aa2 = String.valueOf(avpro2);
aaverageprofit.setText(aa2+" %");
ha1 = Math.pow(((((tf2-tf1)/tf1)*100)-avpro2), 2);
ha2 = Math.pow(((((tf3-tf2)/tf2)*100)-avpro2), 2);
vol3 = ((ha1+ha2)/2);
String aa3 = String.valueOf(Math.sqrt(vol3));
avola.setText(aa3);
}
}
//so fortlaufend weiter geschrieben bis TF36LISTENER
public class TF36Listener implements CaretListener {
@Override
public void caretUpdate(CaretEvent e) {
// als Beispiel
tf36 = Double.parseDouble(TF36.getText());
avpro35 = (((((tf2-tf1)/tf1)*100)+(((tf3-tf2)/tf2)*100)+(((tf4-tf3)/tf3)*100)+(((tf5-tf4)/tf4)*100)+(((tf6-tf5)/tf5)*100)+(((tf7-tf6)/tf6)*100)+(((tf8-tf7)/tf7)*100)+(((tf9-tf8)/tf8)*100)+(((tf10-tf9)/tf9)*100)+(((tf11-tf10)/tf10)*100)+(((tf12-tf11)/tf11)*100)+(((tf13-tf12)/tf12)*100)+(((tf14-tf13)/tf13)*100)+(((tf15-tf14)/tf14)*100)+(((tf16-tf15)/tf15)*100)+(((tf17-tf16)/tf16)*100)+(((tf18-tf17)/tf17)*100)+(((tf19-tf18)/tf18)*100)+(((tf20-tf19)/tf19)*100)+(((tf21-tf20)/tf20)*100)+(((tf22-tf21)/tf21)*100)+(((tf23-tf22)/tf22)*100)+(((tf24-tf23)/tf23)*100)+(((tf25-tf24)/tf24)*100)+(((tf26-tf25)/tf25)*100)+(((tf27-tf26)/tf26)*100)+(((tf28-tf27)/tf27)*100)+(((tf29-tf28)/tf28)*100)+(((tf30-tf29)/tf29)*100)+(((tf31-tf30)/tf30)*100)+(((tf32-tf31)/tf31)*100)+(((tf33-tf32)/tf32)*100)+(((tf34-tf33)/tf33)*100)+(((tf35-tf34)/tf34)*100)+(((tf36-tf35)/tf35)*100))/35);
String aa2 = String.valueOf(avpro35);
aaverageprofit.setText(aa2+" %");
ha1 = Math.pow(((((tf2-tf1)/tf1)*100)-avpro35), 2);
ha2 = Math.pow(((((tf3-tf2)/tf2)*100)-avpro35), 2);
ha3 = Math.pow(((((tf4-tf3)/tf3)*100)-avpro35), 2);
ha4 = Math.pow(((((tf5-tf4)/tf4)*100)-avpro35), 2);
ha5 = Math.pow(((((tf6-tf5)/tf5)*100)-avpro35), 2);
ha6 = Math.pow(((((tf7-tf6)/tf6)*100)-avpro35), 2);
ha7 = Math.pow(((((tf8-tf7)/tf7)*100)-avpro35), 2);
ha8 = Math.pow(((((tf9-tf8)/tf8)*100)-avpro35), 2);
ha9 = Math.pow(((((tf10-tf9)/tf9)*100)-avpro35), 2);
ha10 = Math.pow(((((tf11-tf10)/tf10)*100)-avpro35), 2);
ha11 = Math.pow(((((tf12-tf11)/tf11)*100)-avpro35), 2);
ha12 = Math.pow(((((tf13-tf12)/tf12)*100)-avpro35), 2);
ha13 = Math.pow(((((tf14-tf13)/tf13)*100)-avpro35), 2);
ha14 = Math.pow(((((tf15-tf14)/tf14)*100)-avpro35), 2);
ha15 = Math.pow(((((tf16-tf15)/tf15)*100)-avpro35), 2);
ha16 = Math.pow(((((tf17-tf16)/tf16)*100)-avpro35), 2);
ha17 = Math.pow(((((tf18-tf17)/tf17)*100)-avpro35), 2);
ha18 = Math.pow(((((tf19-tf18)/tf18)*100)-avpro35), 2);
ha19 = Math.pow(((((tf20-tf19)/tf19)*100)-avpro35), 2);
ha20 = Math.pow(((((tf21-tf20)/tf20)*100)-avpro35), 2);
ha21 = Math.pow(((((tf22-tf21)/tf21)*100)-avpro35), 2);
ha22 = Math.pow(((((tf23-tf22)/tf22)*100)-avpro35), 2);
ha23 = Math.pow(((((tf24-tf23)/tf23)*100)-avpro35), 2);
ha24 = Math.pow(((((tf25-tf24)/tf24)*100)-avpro35), 2);
ha25 = Math.pow(((((tf26-tf25)/tf25)*100)-avpro35), 2);
ha26 = Math.pow(((((tf27-tf26)/tf26)*100)-avpro35), 2);
ha27 = Math.pow(((((tf28-tf27)/tf27)*100)-avpro35), 2);
ha28 = Math.pow(((((tf29-tf28)/tf28)*100)-avpro35), 2);
ha29 = Math.pow(((((tf30-tf29)/tf29)*100)-avpro35), 2);
ha30 = Math.pow(((((tf31-tf30)/tf30)*100)-avpro35), 2);
ha31 = Math.pow(((((tf32-tf31)/tf31)*100)-avpro35), 2);
ha32 = Math.pow(((((tf33-tf32)/tf32)*100)-avpro35), 2);
ha33 = Math.pow(((((tf34-tf33)/tf33)*100)-avpro35), 2);
ha34 = Math.pow(((((tf35-tf34)/tf34)*100)-avpro35), 2);
ha35 = Math.pow(((((tf36-tf35)/tf35)*100)-avpro35), 2);
vol36 = ((ha1+ha2+ha3+ha4+ha5+ha6+ha7+ha8+ha9+ha10+ha11+ha12+ha13+ha14+ha15+ha16+ha17+ha18+ha19+ha20+ha21+ha22+ha23+ha24+ha25+ha26+ha27+ha28+ha29+ha30+ha31+ha32+ha33+ha34+ha35)/35);
String aa3 = String.valueOf(Math.sqrt(vol36));
avola.setText(aa3);
}
}
public class cpricechartlistener implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
String s1 = TF1.getText().trim();
if ((s1).isEmpty()) {}else {
series1.add(0, tf1);}
String s2 = TF2.getText().trim();
if ((s2).isEmpty()) {}else {
series1.add(1, tf2);}
String s3 = TF3.getText().trim();
if ((s3).isEmpty()) {}else {
series1.add(2, tf3);}
String s4 = TF4.getText().trim();
if ((s4).isEmpty()) {}else {
series1.add(3, tf4);}
String s5 = TF5.getText().trim();
if ((s5).isEmpty()) {}else {
series1.add(4, tf5);}
String s6 = TF6.getText().trim();
if ((s6).isEmpty()) {}else {
series1.add(5, tf6);}
String s7 = TF7.getText().trim();
if ((s7).isEmpty()) {}else {
series1.add(6, tf7);}
String s8 = TF8.getText().trim();
if ((s8).isEmpty()) {}else {
series1.add(7, tf8);}
String s9 = TF9.getText().trim();
if ((s9).isEmpty()) {}else {
series1.add(8, tf9);}
String s10 = TF10.getText().trim();
if ((s10).isEmpty()) {}else {
series1.add(9, tf10);}
String s11 = TF11.getText().trim();
if ((s11).isEmpty()) {}else {
series1.add(10, tf11);}
String s12 = TF12.getText().trim();
if ((s12).isEmpty()) {}else {
series1.add(11, tf12);}
String s13 = TF13.getText().trim();
if ((s13).isEmpty()) {}else {
series1.add(12, tf13);}
String s14 = TF14.getText().trim();
if ((s14).isEmpty()) {}else {
series1.add(13, tf14);}
String s15 = TF15.getText().trim();
if ((s15).isEmpty()) {}else {
series1.add(14, tf15);}
String s16 = TF16.getText().trim();
if ((s16).isEmpty()) {}else {
series1.add(15, tf16);}
String s17 = TF17.getText().trim();
if ((s17).isEmpty()) {}else {
series1.add(16, tf17);}
String s18 = TF18.getText().trim();
if ((s18).isEmpty()) {}else {
series1.add(17, tf18);}
String s19 = TF19.getText().trim();
if ((s19).isEmpty()) {}else {
series1.add(18, tf19);}
String s20 = TF20.getText().trim();
if ((s20).isEmpty()) {}else {
series1.add(19, tf20);}
String s21 = TF21.getText().trim();
if ((s21).isEmpty()) {}else {
series1.add(20, tf21);}
String s22 = TF22.getText().trim();
if ((s22).isEmpty()) {}else {
series1.add(21, tf22);}
String s23 = TF23.getText().trim();
if ((s23).isEmpty()) {}else {
series1.add(22, tf23);}
String s24 = TF24.getText().trim();
if ((s24).isEmpty()) {}else {
series1.add(23, tf24);}
String s25 = TF25.getText().trim();
if ((s25).isEmpty()) {}else {
series1.add(24, tf25);}
String s26 = TF26.getText().trim();
if ((s26).isEmpty()) {}else {
series1.add(25, tf26);}
String s27 = TF27.getText().trim();
if ((s27).isEmpty()) {}else {
series1.add(26, tf27);}
String s28 = TF28.getText().trim();
if ((s28).isEmpty()) {}else {
series1.add(27, tf28);}
String s29 = TF29.getText().trim();
if ((s29).isEmpty()) {}else {
series1.add(28, tf29);}
String s30 = TF30.getText().trim();
if ((s30).isEmpty()) {}else {
series1.add(29, tf30);}
String s31 = TF31.getText().trim();
if ((s31).isEmpty()) {}else {
series1.add(30, tf31);}
String s32 = TF32.getText().trim();
if ((s32).isEmpty()) {}else {
series1.add(31, tf32);}
String s33 = TF33.getText().trim();
if ((s33).isEmpty()) {}else {
series1.add(32, tf33);}
String s34 = TF34.getText().trim();
if ((s34).isEmpty()) {}else {
series1.add(33, tf34);}
String s35 = TF35.getText().trim();
if ((s35).isEmpty()) {}else {
series1.add(34, tf35);}
String s36 = TF36.getText().trim();
if ((s36).isEmpty()) {}else {
series1.add(35, tf36);}
dataset1.addSeries(series1);
JFreeChart chart1 = ChartFactory.createXYLineChart(
"Price Chart", "period in "+comboperiod, "share price", dataset1, PlotOrientation.VERTICAL, false, false, true);
ChartPanel chPanel1 = new ChartPanel(chart1); //creating the chart panel, which extends JPanel
chPanel1.setPreferredSize(new Dimension(300, 300)); //size according to my window
JPanel jPanel1 = new JPanel();
jPanel1.setBounds(400, 225, 400, 375);
jPanel1.setBackground(Color.WHITE);
jPanel1.add(chPanel1, BorderLayout.NORTH);
RiskAnalysispanel.add(jPanel1);
try {
ChartUtilities.saveChartAsJPEG(new File("chart1.png"), chart1, 300, 300);
} catch (IOException e) {
System.err.println("Problem occurred creating chart.");
}
repaint();
}
}
}