Object with G4P window and UDP listener... not possible in Processing 3 ??

Dear gurus,
Code below uses G4P, UDP libraries and creates dial windows with their own udp handler.
Each window has a udp handler with unique port#, and when data is received on the port, udp hander set the dial value of that window.
This works well in Processing 2.2.1, but not in 3 (handler does not seem to be associated with each created window, but bunched up in the last window). Mouse handler seems to have the same problem too.

I don't know if this is supposed to be possible in the new PS3 environment, but I'd very much appreciate if someone could shed light on this.
Thank you in advance. E.K.

    import hypermedia.net.*;
    import g4p_controls.*;
    // etc..............

    dial d1,d2,d3, etc.....;

    setup () {
        createGUI (); // G4P creates main window
        d1 = new dial (this, "D1", port1); // create multiple dial windows
        d2 = new dial (this, "D2", port2);
        // etc.............
    }

    public class dial {
        PApplet pa;
        String title;
        int port;
        GWindow dialWin;
        GKnob knob; 

        dial (PApplet pa, String title, int port) {
            dialWin = new GWindow(pa, title, 0, 0, 100, 120, true, JAVA2D);
            dialWin.addMouseHandler (this, "hMouse");
            dialWin.addMouseHandler (pa, "windowMouse");

            // udp listener
            udp = new UDP (this, port);
            udp.listen (true);
            udp.setReceiveHandler ("udp_rcv");

            knob = new GKnob (dialWin.papplet, 21, 26, 60, 60, 0.8);
            //* other initial knob settings

            // other G4P controls

        } // end constructor

        public void hMouse (GWinApplet appc, GWinData data, MouseEvent event) {
            switch(event.getAction ()) {
            // process mouse actions
            }
        }

        public void udp_rcv (byte [] data, String ip, int port) {
            // sets dial value based on received data
            int dialVal = int (new String (data));
            knob.setValue (dialVal);
        }
    }

   windowMouse (GWinApplet appc, GWinData data, MouseEvent event) {
    // Global mouse handler
   }

Answers

  • Forgot to mention that the code in PS3 has the lines like
    dialWin = new GWindow(pa, title, 0, 0, 100, 120, true, JAVA2D);
    etc. modified for the new G4P version. E.K.

Sign In or Register to comment.