src/codeandchords/MenuTemplate.java
public void controlEvent(ControlEvent controlEvent)
	{
//		System.out.println("MenuTemplate.controlEvent: controlEvent = " + controlEvent);
		
		int	id	= controlEvent.getController().getId();
		// Sliders
		if(id > -1 && id < 100)
		{
			// TODO: was catching a NullPointer here, but I think that's unnecessary; but if NPE errors, try doing that again.
				Slider	curSlider	= (Slider)this.controlP5.getController("slider" + id);

				float	sliderValFloat	= curSlider.getValue();

				if((Textfield)this.controlP5.getController("textfield" + (id + 100)) != null)
				{
					Textfield	curTextfield	= (Textfield)this.controlP5.getController("textfield" + (id + 100));

					String	sliderValString	= this.decimalFormat.format(curSlider.getValue());

					curTextfield.setText(sliderValString);			
				} // if connected to Textfield
				
				this.sliderEvent(id, sliderValFloat);
		} // Sliders
		
		// Textfields
		if(id > 99 && id < 200)
		{
			Textfield	curTextfield	= (Textfield)this.controlP5.getController("textfield" + id);
			Slider		curSlider		= (Slider)this.controlP5.getController("slider" + (id - 100));

			try	{
				curSlider.setValue(Float.parseFloat(curTextfield.getStringValue()));

			} catch(NumberFormatException nfe) {
				System.out.println("ModuleTemplate.controlEvent: string value " + curTextfield.getStringValue() + 
				"for controller " + curTextfield + " cannot be parsed to a float.  Please enter a number.");
			} // catch
		} // textField
		
		// Color Select Buttons (to show ColorWheel)
		if(id > 199 && id < 300)
		{
			Button	curButton	= (Button)controlEvent.getController();

			// draw slightly transparent rectangle:
			if(curButton.getBooleanValue())
			{

				this.controlP5.getGroup("leftBackground").setVisible(true);
				this.controlP5.getGroup("leftBackground").bringToFront();

			} else {

				//				this.fillHSBColors();
				// TODO: might need to fillOriginalColors here, too, at some point?				

				this.controlP5.setAutoDraw(true);
				this.controlP5.getGroup("leftBackground").setVisible(false);
				//				this.displaySidebar(false);
			}

			this.controlP5.getController("button" + (controlEvent.getId())).bringToFront();
			this.controlP5.getController("colorWheel" + (controlEvent.getId() + 100)).bringToFront();
			this.controlP5.getController("textfield" + (controlEvent.getId() + 200)).bringToFront();

			this.controlP5.getController("colorWheel" + (controlEvent.getId() + 100)).setVisible(curButton.getBooleanValue());
			this.controlP5.getController("textfield" + (controlEvent.getId() + 200)).setVisible(curButton.getBooleanValue());
			
			this.buttonEvent(id);
		} // CW Buttons
		
		// ColorWheels
		if(id > 299 && id < 400)
		{
			// get current color:
			ColorWheel	curCW	= (ColorWheel)controlEvent.getController();

			int	rgbColor	= curCW.getRGB();
			Color	color	= new Color(rgbColor);

			// Set corresponding Textfield with color value:
			Textfield	curColorTF	= (Textfield)this.controlP5.getController("textfield" + (controlEvent.getId() + 100));
			curColorTF.setText("rgb(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")");
			
			this.colorWheelEvent(id, color);
		} // ColorWheels

		// ColorWheel Textfields
		if(id > 399 && id < 500)
		{
			id	= controlEvent.getId();
			System.out.println("controlEvent: event for a ColorWheel Textfield, id " + id);

			// Getting color value from the Textfield:
			String[]	tfValues	= controlEvent.getStringValue().split("[(,)]");
			for(int i = 0; i < tfValues.length; i++)
			{
				tfValues[i]	= tfValues[i].trim().toLowerCase();
			} // for

			try
			{
				if(tfValues[0].equals("rgb"))
				{
					// Get color values:
					int	red		= Integer.parseInt(tfValues[1]);
					int	green	= Integer.parseInt(tfValues[2]);
					int	blue	= Integer.parseInt(tfValues[3]);

					// Constrain to 0-255:
					red		= Math.min(255, Math.max(0, red));
					green	= Math.min(255, Math.max(0, green));
					blue	= Math.min(255, Math.max(0, blue));

					// Set corresponding ColorWheel:
					Color	rgbColor	= new Color(red, green, blue);
					int		rgbInt		= rgbColor.getRGB();
					((ColorWheel)this.controlP5.getController("colorWheel" + (id - 100))).setRGB(rgbInt);

				} // if - rgb

			} catch(Exception e) {
				System.out.println("Sorry, '" + controlEvent.getStringValue() + "' is not recognized as a valid color (note that colors must be defined by Integer values). Exception message: "
						+ e.getMessage());
			} // catch
		} // ColorWheel Textfields
	}
/**
	 * This method should be called in children's controlEvent if they used addSliderGroup()
	 * or addColorWheelGroup and want to use the Slider/Textfield and Button/ColorWheel/Textfield 
	 * functionality.
	 * 
	 * It will be called automatically from Controllers.
	 * 
	 * @param controlEvent	event from the current Controller
	 */
This method should be called in children's controlEvent if they used addSliderGroup()
or addColorWheelGroup and want to use the Slider/Textfield and Button/ColorWheel/Textfield
functionality.

It will be called automatically from Controllers.

@param controlEvent  event from the current Controller
This method should be called in children ' s controlEvent if they used addSliderGroup () or addColorWheelGroup and want to use the Slider / Textfield and Button / ColorWheel / Textfield functionality . It will be called automatically from Controllers . @param controlEvent event from the current Controller
public void controlEvent(ControlEvent controlEvent)
	{
		int	id	= controlEvent.getController().getId();
		if(id > -1 && id < 100)
		{
				Slider	curSlider	= (Slider)this.controlP5.getController("slider" + id);
				float	sliderValFloat	= curSlider.getValue();
				if((Textfield)this.controlP5.getController("textfield" + (id + 100)) != null)
				{
					Textfield	curTextfield	= (Textfield)this.controlP5.getController("textfield" + (id + 100));
					String	sliderValString	= this.decimalFormat.format(curSlider.getValue());
					curTextfield.setText(sliderValString);			
				} 
				this.sliderEvent(id, sliderValFloat);
		} 
		if(id > 99 && id < 200)
		{
			Textfield	curTextfield	= (Textfield)this.controlP5.getController("textfield" + id);
			Slider		curSlider		= (Slider)this.controlP5.getController("slider" + (id - 100));
			try	{
				curSlider.setValue(Float.parseFloat(curTextfield.getStringValue()));
			} catch(NumberFormatException nfe) {
				System.out.println("ModuleTemplate.controlEvent: string value " + curTextfield.getStringValue() + 
				"for controller " + curTextfield + " cannot be parsed to a float.  Please enter a number.");
			} 
		} 
		if(id > 199 && id < 300)
		{
			Button	curButton	= (Button)controlEvent.getController();
			if(curButton.getBooleanValue())
			{
				this.controlP5.getGroup("leftBackground").setVisible(true);
				this.controlP5.getGroup("leftBackground").bringToFront();
			} else {
				this.controlP5.setAutoDraw(true);
				this.controlP5.getGroup("leftBackground").setVisible(false);
			}
			this.controlP5.getController("button" + (controlEvent.getId())).bringToFront();
			this.controlP5.getController("colorWheel" + (controlEvent.getId() + 100)).bringToFront();
			this.controlP5.getController("textfield" + (controlEvent.getId() + 200)).bringToFront();
			this.controlP5.getController("colorWheel" + (controlEvent.getId() + 100)).setVisible(curButton.getBooleanValue());
			this.controlP5.getController("textfield" + (controlEvent.getId() + 200)).setVisible(curButton.getBooleanValue());
			this.buttonEvent(id);
		} 
		if(id > 299 && id < 400)
		{
			ColorWheel	curCW	= (ColorWheel)controlEvent.getController();
			int	rgbColor	= curCW.getRGB();
			Color	color	= new Color(rgbColor);
			Textfield	curColorTF	= (Textfield)this.controlP5.getController("textfield" + (controlEvent.getId() + 100));
			curColorTF.setText("rgb(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")");
			this.colorWheelEvent(id, color);
		} 
		if(id > 399 && id < 500)
		{
			id	= controlEvent.getId();
			System.out.println("controlEvent: event for a ColorWheel Textfield, id " + id);
			String[]	tfValues	= controlEvent.getStringValue().split("[(,)]");
			for(int i = 0; i < tfValues.length; i++)
			{
				tfValues[i]	= tfValues[i].trim().toLowerCase();
			} 
			try
			{
				if(tfValues[0].equals("rgb"))
				{
					int	red		= Integer.parseInt(tfValues[1]);
					int	green	= Integer.parseInt(tfValues[2]);
					int	blue	= Integer.parseInt(tfValues[3]);
					red		= Math.min(255, Math.max(0, red));
					green	= Math.min(255, Math.max(0, green));
					blue	= Math.min(255, Math.max(0, blue));
					Color	rgbColor	= new Color(red, green, blue);
					int		rgbInt		= rgbColor.getRGB();
					((ColorWheel)this.controlP5.getController("colorWheel" + (id - 100))).setRGB(rgbInt);
				} 
			} catch(Exception e) {
				System.out.println("Sorry, '" + controlEvent.getStringValue() + "' is not recognized as a valid color (note that colors must be defined by Integer values). Exception message: "
						+ e.getMessage());
			} 
		} 
	}
public void controlEvent ( ControlEvent controlEvent ) { int id = controlEvent . getController ( ) . getId ( ) ; if ( id > - 1 && id < 100 ) { Slider curSlider = ( Slider ) this . controlP5 . getController ( "slider" + id ) ; float sliderValFloat = curSlider . getValue ( ) ; if ( ( Textfield ) this . controlP5 . getController ( "textfield" + ( id + 100 ) ) != null ) { Textfield curTextfield = ( Textfield ) this . controlP5 . getController ( "textfield" + ( id + 100 ) ) ; String sliderValString = this . decimalFormat . format ( curSlider . getValue ( ) ) ; curTextfield . setText ( sliderValString ) ; } this . sliderEvent ( id , sliderValFloat ) ; } if ( id > 99 && id < 200 ) { Textfield curTextfield = ( Textfield ) this . controlP5 . getController ( "textfield" + id ) ; Slider curSlider = ( Slider ) this . controlP5 . getController ( "slider" + ( id - 100 ) ) ; try { curSlider . setValue ( Float . parseFloat ( curTextfield . getStringValue ( ) ) ) ; } catch ( NumberFormatException nfe ) { System . out . println ( "ModuleTemplate.controlEvent: string value " + curTextfield . getStringValue ( ) + "for controller " + curTextfield + " cannot be parsed to a float.  Please enter a number." ) ; } } if ( id > 199 && id < 300 ) { Button curButton = ( Button ) controlEvent . getController ( ) ; if ( curButton . getBooleanValue ( ) ) { this . controlP5 . getGroup ( "leftBackground" ) . setVisible ( true ) ; this . controlP5 . getGroup ( "leftBackground" ) . bringToFront ( ) ; } else { this . controlP5 . setAutoDraw ( true ) ; this . controlP5 . getGroup ( "leftBackground" ) . setVisible ( false ) ; } this . controlP5 . getController ( "button" + ( controlEvent . getId ( ) ) ) . bringToFront ( ) ; this . controlP5 . getController ( "colorWheel" + ( controlEvent . getId ( ) + 100 ) ) . bringToFront ( ) ; this . controlP5 . getController ( "textfield" + ( controlEvent . getId ( ) + 200 ) ) . bringToFront ( ) ; this . controlP5 . getController ( "colorWheel" + ( controlEvent . getId ( ) + 100 ) ) . setVisible ( curButton . getBooleanValue ( ) ) ; this . controlP5 . getController ( "textfield" + ( controlEvent . getId ( ) + 200 ) ) . setVisible ( curButton . getBooleanValue ( ) ) ; this . buttonEvent ( id ) ; } if ( id > 299 && id < 400 ) { ColorWheel curCW = ( ColorWheel ) controlEvent . getController ( ) ; int rgbColor = curCW . getRGB ( ) ; Color color = new Color ( rgbColor ) ; Textfield curColorTF = ( Textfield ) this . controlP5 . getController ( "textfield" + ( controlEvent . getId ( ) + 100 ) ) ; curColorTF . setText ( "rgb(" + color . getRed ( ) + ", " + color . getGreen ( ) + ", " + color . getBlue ( ) + ")" ) ; this . colorWheelEvent ( id , color ) ; } if ( id > 399 && id < 500 ) { id = controlEvent . getId ( ) ; System . out . println ( "controlEvent: event for a ColorWheel Textfield, id " + id ) ; String [ ] tfValues = controlEvent . getStringValue ( ) . split ( "[(,)]" ) ; for ( int i = 0 ; i < tfValues . length ; i ++ ) { tfValues [ i ] = tfValues [ i ] . trim ( ) . toLowerCase ( ) ; } try { if ( tfValues [ 0 ] . equals ( "rgb" ) ) { int red = Integer . parseInt ( tfValues [ 1 ] ) ; int green = Integer . parseInt ( tfValues [ 2 ] ) ; int blue = Integer . parseInt ( tfValues [ 3 ] ) ; red = Math . min ( 255 , Math . max ( 0 , red ) ) ; green = Math . min ( 255 , Math . max ( 0 , green ) ) ; blue = Math . min ( 255 , Math . max ( 0 , blue ) ) ; Color rgbColor = new Color ( red , green , blue ) ; int rgbInt = rgbColor . getRGB ( ) ; ( ( ColorWheel ) this . controlP5 . getController ( "colorWheel" + ( id - 100 ) ) ) . setRGB ( rgbInt ) ; } } catch ( Exception e ) { System . out . println ( "Sorry, '" + controlEvent . getStringValue ( ) + "' is not recognized as a valid color (note that colors must be defined by Integer values). Exception message: " + e . getMessage ( ) ) ; } } }
This method should be called in children's controlEvent if they used addSliderGroup()
 or addColorWheelGroup and want to use the Slider/Textfield and Button/ColorWheel/Textfield
 functionality.
This method should be called in children ' s controlEvent if they used addSliderGroup () or addColorWheelGroup and want to use the Slider / Textfield and Button / ColorWheel / Textfield functionality .
//		System.out.println("MenuTemplate.controlEvent: controlEvent = " + controlEvent); // Sliders // TODO: was catching a NullPointer here, but I think that's unnecessary; but if NPE errors, try doing that again. // if connected to Textfield // Sliders // Textfields // catch // textField // Color Select Buttons (to show ColorWheel) // draw slightly transparent rectangle: //				this.fillHSBColors(); // TODO: might need to fillOriginalColors here, too, at some point?				 //				this.displaySidebar(false); // CW Buttons // ColorWheels // get current color: // Set corresponding Textfield with color value: // ColorWheels // ColorWheel Textfields // Getting color value from the Textfield: // for // Get color values: // Constrain to 0-255: // Set corresponding ColorWheel: // if - rgb // catch // ColorWheel Textfields