Exemplo n.º 1
0
  private void initialize() {
    panel = new JPanel();
    frame = new JFrame();
    can.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            PointerInfo a = MouseInfo.getPointerInfo();
            Point b = a.getLocation();
            double x = b.getX();
            double y = b.getY();
            System.out.println("Entered x: " + x);
            System.out.println("Entered y: " + y);

            if (x == 950) {
              x = 0;
            } else if (x < 950) {
              x = (x / 950) - 1;
            } else if (x > 950) {
              x = (x / 950) - 1;
            }

            if (y == 563) {
              y = 0;
            } else if (y < 563) {
              y = 1 - (y / 563);
            } else if (y > 563) {
              y = 1 - (y / 563);
            }

            System.out.println("NEW NEW NEW NEW x: " + x);
            System.out.println("NEW NEW NEW NEW y: " + y);

            double inc = -2;
            var = new ArrayList<Double>();
            for (int i = -200; i < 200; i++) {
              var.add(new Equation(x, y).setEquationReturn(inc));
              inc = inc + .01;
            }

            double paintInc = -2;
            for (int dx = 0; dx < 200; dx++) {
              double dy = var.get(dx);
              theG.add(new Ellipse2D.Double(0 + paintInc, 540 - dy, 10, 10));
              paintInc = paintInc + 10;
            }

            /*This is to display the Y values for testing purposes
            Iterator<Double> it = var.iterator();
            while (it.hasNext()){
            	System.out.println(it.next());
            }*/

            can.repaint();
          }
        });
    JLabel xL = new JLabel();
    JLabel yL = new JLabel();
    JTextArea a = new JTextArea();
    a.setLocation(540, 540);
    a.setText("FFFFFFFFFFFUCK");
    a.setBackground(Color.white);
    yL.setText("Y");
    xL.setText("X");
    yL.setLocation(930, 10);
    yL.setSize(10, 10);
    yL.setBackground(Color.black);
    xL.setLocation(1900, 550);
    xL.setSize(10, 10);
    xL.setBackground(Color.black);
    xL.setOpaque(true);
    yL.setOpaque(true);

    panel.setBackground(Color.darkGray);
    can.setBackground(Color.black);
    can.setForeground(Color.black);
    frame.getContentPane().add(can);
    panel.setLayout(new GridLayout(1, 0, 0, 0));

    frame.add(xL);
    frame.add(yL);
    frame.add(can);
    frame.setBounds(0, 0, 1920, 1080);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }