Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eti.radio.pr_inz;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.geom.*;
- import java.lang.Math;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- public class Licz extends JPanel implements ActionListener, MouseListener {
- private JButton wykresy;
- private JButton wyjscie;
- private JLabel tytul6, l_BS0, l_BS1, l_BS2, l_BS3, l_BS4, l_BS5, l_BS6, l_UT, f_cLabel;
- private JTextField f_cJT;
- //public JSlider f_cSlider;
- //public double xp = 470, yp = 400; //xp = 470, yp = 315;
- public Double[] xp = new Double[850];
- public Double[] yp = new Double[850];
- //public double xp = 0, yp = 0; //xp = 470, yp = 315;
- /*public Integer[] x = {0, -170, -170, 0, 170, 170, 0};
- public Integer[] y = {0, -80, 77, 170, 77, -80, -170};*/
- public Integer[] x = {470, 300, 300, 470, 640, 640, 470};
- public Integer[] y = {400, 480, 313, 230, 313, 480, 570};
- public BufferedImage tlo_dane;
- //public double UT_x, UT_y;
- public double BS0_x = x[0], BS0_y = y[0];
- String str_UT = "";
- int nw = 0, s = 1;
- //double f_c = 2.6; // [GHz] *Math.pow(10, 9);
- //double f_c = 10;
- double d_2D; //m
- double c = 3*Math.pow(10, 8);
- int d_2D_IN = 1;
- int h_BS = 25, h_UT = 1; ///zrobić jako Slidery
- int h_E = 1; // 1m
- int h = 5; //w metrach, do RMa
- int W = 20; //w metrach, do RMa
- double sigma_LOS, sigma_NLOS;
- public Double[][] PL_LOS= new Double[7][850];
- public Double[][] PL_NLOS= new Double[7][850];
- public Double[][] PL_NLOS2= new Double[7][850];
- double d_BP, d2_BP;
- //public Double[] p = {10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0};
- public Double[] d2D = {10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0};
- public Double[][] d_3D = new Double[7][850];
- public Double[] radius = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
- public Double[] SNR = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
- public Double[] SNR_WAT = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
- public double I_suma_NLOS = 0, I_suma_LOS = 0;
- double N = -174;
- double N_W = Math.pow(10, (N/10 - 3));
- Wykresy rysuj_wykresy;
- public Licz(Wykresy rysuj_wykresy){
- setLayout(null);
- this.rysuj_wykresy = rysuj_wykresy;
- File zdj_menu = new File("zdjecia/strona_logo.png");
- try{ tlo_dane = ImageIO.read(zdj_menu); }
- catch(IOException e){ System.err.println("Blad odczytu obrazków"); }
- wyjscie = new JButton("Wyjście");
- wyjscie.addActionListener(this);
- wyjscie.setBounds(100, 620, 200, 60);
- wyjscie.setFont(new Font("Sitka Text", Font.BOLD, 25));
- wyjscie.setBackground(Color.white);
- wykresy = new JButton("Wykresy");
- wykresy.addActionListener(this);
- wykresy.setBounds(724, 620, 200, 60);
- wykresy.setFont(new Font("Sitka Text", Font.BOLD, 25));
- wykresy.setBackground(Color.white);
- System.out.println("Wybrany model: " + s);
- System.out.println("Wybrany scenariusz O2I: " + nw);
- tytul6 = new JLabel( "Wskaż położenie terminala użytkownika w komórce zerowej", JLabel.CENTER);
- tytul6.setSize(1000, 100);
- tytul6.setLocation(5, 50);
- tytul6.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS0 = new JLabel( "BS0", JLabel.CENTER);
- l_BS0.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS1 = new JLabel( "BS1", JLabel.CENTER);
- l_BS1.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS2 = new JLabel( "BS2", JLabel.CENTER);
- l_BS2.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS3 = new JLabel( "BS3", JLabel.CENTER);
- l_BS3.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS4 = new JLabel( "BS4", JLabel.CENTER);
- l_BS4.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS5 = new JLabel( "BS5", JLabel.CENTER);
- l_BS5.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_BS6 = new JLabel( "BS6", JLabel.CENTER);
- l_BS6.setFont(new Font("Sitka Text", Font.BOLD, 23));
- l_UT = new JLabel( "UT", JLabel.CENTER);
- l_UT.setFont(new Font("Sitka Text", Font.BOLD,23));
- l_UT.setForeground(Color.RED);
- /*f_cSlider = new JSlider(3, 30, 3); // GHz
- f_cSlider.setMajorTickSpacing(5);
- f_cSlider.setMinorTickSpacing(1);
- f_cSlider.setPaintLabels(true);
- f_cSlider.setPaintTicks(true);
- f_cSlider.setBounds(385, 650, 250, 50);
- f_cSlider.setBackground(Color.WHITE);
- f_cSlider.addChangeListener(this);
- f_cLabel = new JLabel();
- f_cLabel.setBounds(450, 610, 200, 50);
- f_cLabel.setFont(new Font("Sitka Text", Font.PLAIN, 16));
- f_cLabel.setText("f = 3 GHz");*/
- f_cLabel = new JLabel("Podaj częstotliwość dla BS0 [GHz]:");
- f_cLabel.setBounds(720, 350, 300, 50);
- f_cLabel.setFont(new Font("Sitka Text", Font.BOLD, 16));
- f_cJT = new JTextField("");
- f_cJT.setBounds(800, 400, 100, 30);
- f_cJT.setFont(new Font("Sitka Text", Font.PLAIN, 20));
- add(tytul6); add(l_BS0); add(l_BS1); add(l_BS2); add(l_BS3); add(l_BS4); add(l_BS5); add(l_BS6); add(l_UT); add(wyjscie); add(wykresy);
- add(f_cLabel); add(f_cJT);
- addMouseListener(this);
- }
- public void actionPerformed(ActionEvent e){
- Object source = e.getSource();
- if(source == wykresy){
- CardLayout CL =(CardLayout)(Main.noweOkno.karty.getLayout());
- CL.show(Main.noweOkno.karty, "rysuj_wykresy");
- rysuj_wykresy.f_c = Double.parseDouble(f_cJT.getText());
- System.out.println("Wpisana częstotliwość f_c : " + rysuj_wykresy.f_c);
- rysuj_wykresy.pathLossDlaModelu(rysuj_wykresy.UT_x, rysuj_wykresy.UT_y, rysuj_wykresy.f_c, false);
- rysuj_wykresy.licz_SINR();
- rysuj_wykresy.daneNLOS();
- rysuj_wykresy.daneLOS();
- rysuj_wykresy.zaniki();
- rysuj_wykresy.daneNLOS_zaniki();
- rysuj_wykresy.daneLOS_zaniki();
- rysuj_wykresy.Rysuj_wykres();
- System.out.println("SINR dla NLOS : " + rysuj_wykresy.SINR_dB_NLOS[0]);
- System.out.println("SINR dla LOS : " + rysuj_wykresy.SINR_dB_LOS[0]);
- }
- else if(source == wyjscie){
- System.exit(0);
- }
- }
- public void mouseClicked(MouseEvent e) {}
- public void mousePressed(MouseEvent e) {
- rysuj_wykresy.UT_x = e.getX();
- rysuj_wykresy.UT_y = e.getY();
- str_UT = "UT";
- System.out.println("Nacisnięty punkt: x = " + rysuj_wykresy.UT_x + " y = " + rysuj_wykresy.UT_y);
- repaint();
- }
- public void mouseReleased(MouseEvent e) {}
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- public void paintComponent(Graphics graphic) {
- //int R = Math.round(Math.sqrt(3)*125);
- Graphics2D g2d = (Graphics2D) graphic;
- g2d.drawImage(tlo_dane, 0, 0, this);
- Ellipse2D circle0 = new Ellipse2D.Double(370, 300, 200, 200);
- Rectangle2D BS0 = new Rectangle2D.Double((int)circle0.getCenterX(), (int)circle0.getCenterY(), 5, 5);
- l_BS0.setBounds((int)BS0.getX()-15, (int)BS0.getY()-15, 100, 50);
- Ellipse2D circle1 = new Ellipse2D.Double(200, 380, 200, 200);
- Rectangle2D BS1 = new Rectangle2D.Double((int)circle1.getCenterX(), (int)circle1.getCenterY(), 5, 5);
- l_BS1.setBounds((int)BS1.getX()-15, (int)BS1.getY()-15, 100, 50);
- Ellipse2D circle2 = new Ellipse2D.Double(200, 213, 200, 200);
- Rectangle2D BS2 = new Rectangle2D.Double((int)circle2.getCenterX(), (int)circle2.getCenterY(), 5, 5);
- l_BS2.setBounds((int)BS2.getX()-15, (int)BS2.getY()-15, 100, 50);
- Ellipse2D circle3 = new Ellipse2D.Double(370, 130, 200, 200);
- Rectangle2D BS3 = new Rectangle2D.Double((int)circle3.getCenterX(), (int)circle3.getCenterY(), 5, 5);
- l_BS3.setBounds((int)BS3.getX()-15, (int)BS3.getY()-15, 100, 50);
- Ellipse2D circle4 = new Ellipse2D.Double(540, 213, 200, 200);
- Rectangle2D BS4 = new Rectangle2D.Double((int)circle4.getCenterX(), (int)circle4.getCenterY(), 5, 5);
- l_BS4.setBounds((int)BS4.getX()-15, (int)BS4.getY()-15, 100, 50);
- Ellipse2D circle5 = new Ellipse2D.Double(540, 380, 200, 200);
- Rectangle2D BS5 = new Rectangle2D.Double((int)circle5.getCenterX(), (int)circle5.getCenterY(), 5, 5);
- l_BS5.setBounds((int)BS5.getX()-15, (int)BS5.getY()-15, 100, 50);
- Ellipse2D circle6 = new Ellipse2D.Double(370, 470,200, 200);
- Rectangle2D BS6 = new Rectangle2D.Double((int)circle6.getCenterX(), (int)circle6.getCenterY(), 5, 5);
- l_BS6.setBounds((int)BS6.getX()-15, (int)BS6.getY()-15, 100, 50);
- Ellipse2D UT = new Ellipse2D.Double(rysuj_wykresy.UT_x, rysuj_wykresy.UT_y, 5, 5);
- l_UT.setBounds((int)UT.getX()-15, (int)UT.getY()-15, 80, 50);
- g2d.draw(UT); g2d.draw(BS0); g2d.draw(BS1); g2d.draw(BS2); g2d.draw(BS3); g2d.draw(BS4); g2d.draw(BS5); g2d.draw(BS6);
- g2d.draw(circle0); g2d.draw(circle1); g2d.draw(circle2); g2d.draw(circle3); g2d.draw(circle4); g2d.draw(circle5); g2d.draw(circle6);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement