src/codeandchords/ModuleMenu.java
public void addColorSelect(int xVal, int[] yVals, String[] buttonLabels, String labelText, boolean canvas, String tabName)
	{
		// error checking
		if(yVals == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: int[] parameter is null.");
		}
		if(yVals.length == 0)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: int[] parameter " + yVals + " is empty.");
		}
		if(buttonLabels == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: String[] parameter is null.");
		}
		if(labelText == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: String parameter (labelText) is null.");
		}
		// Warn the user that the first String in buttonLabels will be canvas color (but only if they didn't title it "canvas"):
		if(canvas && !buttonLabels[0].equalsIgnoreCase("canvas"))
		{
			System.err.println("ModuleTemplate.addColorSelect: colorSelect Button with label text '" + buttonLabels[0] + "' will control the canvas color.");
		}

		// Position in rainbowColors:
		int	buttonLabelPos	= 0;
		int	colorSelectPos	= 0;

		if(canvas)
		{
			this.canvasColorSelectId	= this.nextColorWheelId;
			this.firstColorSelectCWId	= this.nextColorWheelId + 1;
			
		} else {
			this.firstColorSelectCWId	= this.nextColorWheelId;
		}

		int		buttonsPerRow	= Math.max((buttonLabels.length) / yVals.length, 1);	// Math.max keeps it from being 0
		// the "- (10 / buttonsPerRow)" adds [this.rightEdgeSpacer pixels] at the end of the row:
		int		buttonWidth		= ((this.sidebarWidth - this.leftAlign - this.rightEdgeSpacer) / buttonsPerRow) - this.spacer;

		int[]	xVals	= new int[buttonsPerRow];

		for(int i = 0; i < xVals.length; i++)
		{
			xVals[i]	= xVal + this.leftAlign + ((buttonWidth + this.spacer) * i);
		}

		this.controlP5.addTextlabel("colorSelectLabel")
		.setPosition(xVal + labelX, yVals[0] + 4)
		.moveTo(tabName)
		.setValue(labelText);

		// Loop through all
		for(int i = 0; i < yVals.length; i++)
		{
			// Loop through each row
			for(int j = 0; j < xVals.length; j++)
			{
				if(i == 0 && j == 0 && canvas)
				{
					System.out.println("j = " + j + "; xVals.length = " + xVals.length + "; i = " + i + "; yVals.length = " + yVals.length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels.length);
					this.addColorWheelGroup(xVals[j], yVals[i], buttonWidth, buttonLabels[buttonLabelPos], this.canvasColor, tabName);
				} else {
					System.out.println("colorSelectPos = " + colorSelectPos + "; colorSelect.length = " + colorSelect.length + "; j = " + j + "; xVals.length = " + xVals.length + "; i = " + i + "; yVals.length = " + yVals.length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels.length);
					this.colorSelect[colorSelectPos]	= (ColorWheel)(this.addColorWheelGroup(xVals[j], yVals[i], buttonWidth, buttonLabels[buttonLabelPos], this.colors[this.currentInput][colorSelectPos], tabName))[1];
					colorSelectPos	= colorSelectPos + 1;
				}

				buttonLabelPos	= buttonLabelPos + 1;

			} // for - j
		} // for - i

		this.fillHSBColors();
	}
/**
	 * Adds the Buttons, ColorWheels and Textfields for selecting custom colors.
	 * 
	 * @param yVals	yValue(s) for the row or rows of Buttons
	 * @param buttonLabels	String[] of labels for the color select Buttons; 
	 * 						length of this array determines the number of colorSelect Buttons;
	 * 						if including canvas in this row, the first element of this array must be "Canvas"
	 * @param tabName	String indicating to which Tab this group of Controllers should be added
	 * 					(for no Tab, use "default")
	 */
Adds the Buttons, ColorWheels and Textfields for selecting custom colors.

@param yVals yValue(s) for the row or rows of Buttons
@param buttonLabels  String[] of labels for the color select Buttons;
length of this array determines the number of colorSelect Buttons;
if including canvas in this row, the first element of this array must be "Canvas"
@param tabName       String indicating to which Tab this group of Controllers should be added
(for no Tab, use "default")
Adds the Buttons ColorWheels and Textfields for selecting custom colors . @param yVals yValue ( s ) for the row or rows of Buttons @param buttonLabels String [] of labels for the color select Buttons ; length of this array determines the number of colorSelect Buttons ; if including canvas in this row the first element of this array must be " Canvas " @param tabName String indicating to which Tab this group of Controllers should be added ( for no Tab use " default " )
public void addColorSelect(int xVal, int[] yVals, String[] buttonLabels, String labelText, boolean canvas, String tabName)
	{
		if(yVals == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: int[] parameter is null.");
		}
		if(yVals.length == 0)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: int[] parameter " + yVals + " is empty.");
		}
		if(buttonLabels == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: String[] parameter is null.");
		}
		if(labelText == null)	{
			throw new IllegalArgumentException("ModuleTemplate.addColorSelect: String parameter (labelText) is null.");
		}
		if(canvas && !buttonLabels[0].equalsIgnoreCase("canvas"))
		{
			System.err.println("ModuleTemplate.addColorSelect: colorSelect Button with label text '" + buttonLabels[0] + "' will control the canvas color.");
		}
		int	buttonLabelPos	= 0;
		int	colorSelectPos	= 0;
		if(canvas)
		{
			this.canvasColorSelectId	= this.nextColorWheelId;
			this.firstColorSelectCWId	= this.nextColorWheelId + 1;
		} else {
			this.firstColorSelectCWId	= this.nextColorWheelId;
		}
		int		buttonsPerRow	= Math.max((buttonLabels.length) / yVals.length, 1);	
		int		buttonWidth		= ((this.sidebarWidth - this.leftAlign - this.rightEdgeSpacer) / buttonsPerRow) - this.spacer;
		int[]	xVals	= new int[buttonsPerRow];
		for(int i = 0; i < xVals.length; i++)
		{
			xVals[i]	= xVal + this.leftAlign + ((buttonWidth + this.spacer) * i);
		}
		this.controlP5.addTextlabel("colorSelectLabel")
		.setPosition(xVal + labelX, yVals[0] + 4)
		.moveTo(tabName)
		.setValue(labelText);
		for(int i = 0; i < yVals.length; i++)
		{
			for(int j = 0; j < xVals.length; j++)
			{
				if(i == 0 && j == 0 && canvas)
				{
					System.out.println("j = " + j + "; xVals.length = " + xVals.length + "; i = " + i + "; yVals.length = " + yVals.length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels.length);
					this.addColorWheelGroup(xVals[j], yVals[i], buttonWidth, buttonLabels[buttonLabelPos], this.canvasColor, tabName);
				} else {
					System.out.println("colorSelectPos = " + colorSelectPos + "; colorSelect.length = " + colorSelect.length + "; j = " + j + "; xVals.length = " + xVals.length + "; i = " + i + "; yVals.length = " + yVals.length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels.length);
					this.colorSelect[colorSelectPos]	= (ColorWheel)(this.addColorWheelGroup(xVals[j], yVals[i], buttonWidth, buttonLabels[buttonLabelPos], this.colors[this.currentInput][colorSelectPos], tabName))[1];
					colorSelectPos	= colorSelectPos + 1;
				}
				buttonLabelPos	= buttonLabelPos + 1;
			} 
		} 
		this.fillHSBColors();
	}
public void addColorSelect ( int xVal , int [ ] yVals , String [ ] buttonLabels , String labelText , boolean canvas , String tabName ) { if ( yVals == null ) { throw new IllegalArgumentException ( "ModuleTemplate.addColorSelect: int[] parameter is null." ) ; } if ( yVals . length == 0 ) { throw new IllegalArgumentException ( "ModuleTemplate.addColorSelect: int[] parameter " + yVals + " is empty." ) ; } if ( buttonLabels == null ) { throw new IllegalArgumentException ( "ModuleTemplate.addColorSelect: String[] parameter is null." ) ; } if ( labelText == null ) { throw new IllegalArgumentException ( "ModuleTemplate.addColorSelect: String parameter (labelText) is null." ) ; } if ( canvas && ! buttonLabels [ 0 ] . equalsIgnoreCase ( "canvas" ) ) { System . err . println ( "ModuleTemplate.addColorSelect: colorSelect Button with label text '" + buttonLabels [ 0 ] + "' will control the canvas color." ) ; } int buttonLabelPos = 0 ; int colorSelectPos = 0 ; if ( canvas ) { this . canvasColorSelectId = this . nextColorWheelId ; this . firstColorSelectCWId = this . nextColorWheelId + 1 ; } else { this . firstColorSelectCWId = this . nextColorWheelId ; } int buttonsPerRow = Math . max ( ( buttonLabels . length ) / yVals . length , 1 ) ; int buttonWidth = ( ( this . sidebarWidth - this . leftAlign - this . rightEdgeSpacer ) / buttonsPerRow ) - this . spacer ; int [ ] xVals = new int [ buttonsPerRow ] ; for ( int i = 0 ; i < xVals . length ; i ++ ) { xVals [ i ] = xVal + this . leftAlign + ( ( buttonWidth + this . spacer ) * i ) ; } this . controlP5 . addTextlabel ( "colorSelectLabel" ) . setPosition ( xVal + labelX , yVals [ 0 ] + 4 ) . moveTo ( tabName ) . setValue ( labelText ) ; for ( int i = 0 ; i < yVals . length ; i ++ ) { for ( int j = 0 ; j < xVals . length ; j ++ ) { if ( i == 0 && j == 0 && canvas ) { System . out . println ( "j = " + j + "; xVals.length = " + xVals . length + "; i = " + i + "; yVals.length = " + yVals . length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels . length ) ; this . addColorWheelGroup ( xVals [ j ] , yVals [ i ] , buttonWidth , buttonLabels [ buttonLabelPos ] , this . canvasColor , tabName ) ; } else { System . out . println ( "colorSelectPos = " + colorSelectPos + "; colorSelect.length = " + colorSelect . length + "; j = " + j + "; xVals.length = " + xVals . length + "; i = " + i + "; yVals.length = " + yVals . length + "; buttonLabelPos = " + buttonLabelPos + "; buttonLabels.length = " + buttonLabels . length ) ; this . colorSelect [ colorSelectPos ] = ( ColorWheel ) ( this . addColorWheelGroup ( xVals [ j ] , yVals [ i ] , buttonWidth , buttonLabels [ buttonLabelPos ] , this . colors [ this . currentInput ] [ colorSelectPos ] , tabName ) ) [ 1 ] ; colorSelectPos = colorSelectPos + 1 ; } buttonLabelPos = buttonLabelPos + 1 ; } } this . fillHSBColors ( ) ; }
Adds the Buttons, ColorWheels and Textfields for selecting custom colors.
Adds the Buttons ColorWheels and Textfields for selecting custom colors .
// error checking // Warn the user that the first String in buttonLabels will be canvas color (but only if they didn't title it "canvas"): // Position in rainbowColors: // Math.max keeps it from being 0 // the "- (10 / buttonsPerRow)" adds [this.rightEdgeSpacer pixels] at the end of the row: // Loop through all // Loop through each row // for - j // for - i