So I'm almost finished coding this layout for a group project. I've decided to make all of my buttons in the program RadioButtons because they are already grouped and have a built in array to hold those values, which is convenient within my program.
The problem is that I need the radiobutton group to be able to enable more than one button's boolean value at a time. I need the user to be able to enable multiple filters in a graph (these are what the radio buttons would be toggling) not just one filter value at a time. Something similiar to a group of controlp5 toggles. The problem is that I can't change my code to that because we only have 5 days until the project is due and it wouldn't be time efficient. I also need this version of radiobutton items to show what we have depressed (change color of the radiobutton items as we click them) but the default radiobutton only shows one button changed at a time.
So I'm pretty new to CP5 and so far I like how much time it can save me with laying controllers out. I'd like to become a little more adept with it though. Right now I am having trouble getting a button press event to show or hide a CP5 group.
I started this out by declaring a CP5 group and setting it's visibility to false. The groups visibility will turn to true when a button with the appropriate id is clicked.... However, I am getting a strange error whenever I click on the button, regardless of whether or not the group is visible at the point or not (I've tried turning it visible just to make sure it's where I want it.)
Here are the relevant code pieces (they do not share the same function span):
Also, I'd like to better understand how to get CP5 objects to talk to one another, can anyone tell me what plugTo() or setBroadcast() does? In what situations would I need to use either of these? I've tried the plugTo() example included in the cp5 library but the sketch is so similar to every other cp5 example sketch that I can't discern plugTo()'s it's utility.
So I've written this program that takes in 6 datasheets and graphs them as you click on the relevant tab. I thought that the plots looked a little strange before, but now that I look at what my program is printing to the console, I can see that something is wrong here...
I'm definitely looking at the same data that's supplied to my program, but for whatever reason the figures that populate the cells are coming back just a bit off. In the worst case, there are entire rows that won't show up in my graph.
If it's any help, I got these data sheets from a government website that allows you to download their data in the form of an Excel sheet. I was told to load it into Excel, then save as a tab delimited text file. So I've done all of that and here I am.
Any ideas on why many of my figures are just slightly off?
So I have a project due tomorrow, and this is one of the last hurdles. I have a large graph being drawn in my program that can show every country in the world, or filter them out. The polygons being drawn represent one country each, and the plotting values come from datasheets
The problem is that there are 231 countries and regions that the user can choose to see. I have tried to use a wide range of colors to distinguish each country from the other, but with such a huge number to fill, a lot of the countries' colors look the same. Also, each graphed shape has 32 vertices on it, so I don't know if such an odd shape can have a texture applied to it or not...
Anyways, I figured that I would diversify the graphed data and add five different patterns, working with a range of different colors, to represent each country. So I made the patterns, all with an alpha channel, hoping that I could easily apply the pattern PNG images to the drawn polygons. Here is the code so far...
noStroke();
beginShape();
textureMode(NORMAL);
texture(patternToUse);
for(int col = 0; col < columnCount; col++){
if( data.isValid(countryToGraph, col)){
float value = interpolators[countryToGraph][col].value;
float x = map(years[col], yearMin, yearMax, graphPlotX1, graphPlotX2);
float y = map(value, dataMin, graphMax, graphPlotY2, graphPlotY1);
vertex(x, y, 0, 0);
if((col == 0) || (col == columnCount -1))
vertex(x, y, 1, 0);
}
}
//draw the lower-right and lower-left corners
vertex(graphPlotX2, graphPlotY2, 1, 1);
vertex(graphPlotX1, graphPlotY2, 0, 1);
endShape(CLOSE);
I'm not getting an error here; the graphs just aren't drawing at all. I should mention that there is a conditional prior to this that just checks to see if the current row index applies to countries that I want to have a pattern on their graph, but I don't think that's the issue. Any suggestions? Should I be using texture for this? I tried to find a guide to masking by PhilHo, but it has been taken down, and I'm not sure what masking is.
Hopefully the thread title isn't too confusing... What I've done is placed a rect, which I am treating like a button, and checking to see if the touch event happens within it's boundaries. I then want to traverse an array of Strings that I already have established and see if any of the country names in that array match the title of the button I pressed (The title gets it's String from currentCountries[0][0], so I used it in the comparison).
So I'm curious... can I search an entire array of Strings (countries[] is 232 Strings long) within an event method to see if any of them contain the String I'm looking for?
If anyone is curious, I am ultimately trying to get an event method which will work for touching or clicking a row within two columns of country names. This will turn on or off an accompanying graph of data for that country; effectively this will work as a filter for the graph. Right now, I am just trying to get one, simple button to do this.
I'm using controlP5 for the first time and am trying to populate the fields of the ListBox's ListBoxItems. What I want to do is change the background of each listboxitem to a color that I have already defined in a String[], I then want to populate the textfield of each item with the name of a country that I have also stored in another array.
For some reason, the background of each listboxitem changes perfectly, but the text will not show up. It won't even show up if I pass it a something static like "dog"... I don't know what to do, I've tried everything! I've made sure to check that there is nothing masking the locaiton of the ListBox, so that it's not being drawn over, since I setup the ListBox in setup().
It's especially strange because the ListBox example from the cp5 library has the listboxitems loading text just fine!
I'm writing my first Processing program for a class project that is due in 4 days. So far I think I've done pretty well and am getting much more comfortable with Processing. I do however have one hang up at this moment, and it won't allow me to continue programming essential parts of my program, because I need to see what filters I'm enabling via labels of entries in a ListBox.
What I want the ListBox to do is to list ListBoxItems with the names of countries that I have stored in a String[]. I also want the ListBoxItems to be color coded. I already have the array of colors that I want, and they load up just fine into the listboxitems, but for some reason the text will not show up! I've tried everything!
I'm confused because I can load ControlP5's example code of a listbox just fine and the text on the ListBoxItems shows up perfectly. I've scanned my code for hours and can't figure this out. This is my first time posting on here, so I'm not sure if I should post my whole code for the main program or not... but here it is!
Thanks for any help.
Here are my my property initializations, setup(), and draw() methods:
import controlP5.*;
ControlP5 cp5;
//Listbox Properties
ListBox l;
int cnt = 0;
Range range;
int displayResolutionX = 1366;
int displayResolutionY = 768;
PImage bg;
//Need Array of Colors, pertaining to Country.
EntryTable data;
String[] arrayOfGraphs = new String[6];
String[] arrayOfFileNames = new String[6];
String[] unitsOfMeasure = new String[6];
float[][] arrayOfSmallestAreas; //holds country's index value within the original data table in column 1 and the total of that respective country's data
float dataMin, dataMax;
float graphMax;
/*
*
*Position variables intialized */
float graphPlotX1, graphPlotY1;//coordinate 1 of the graph table itself
float graphPlotX2, graphPlotY2;// coordinate 2 of the graph table itself
float graphLabelPosX, graphLabelPosY; //position variables for label of currently open graph
int filterGraphPlotX1, filterGraphPlotY1;//coordinate 1 of the graph table itself
int filterGraphPlotX2, filterGraphPlotY2;// coordinate 2 of the graph table itself
float filterLabelX, filterLabelY;
float axisLabelX, axisLabelY;
float[] tabLeft, tabRight; //holds left and right values, respectively, of all 6 graph tabs
float tabTop, tabBottom; //holds values of tab tops (unselected) and all tab bottoms
float selectedTabTop;// holds value of selected tabs height (it is taller than unselected tabs)
float tabPad = 10;
Integrator[][] interpolators; // Changed this to a two dimensional array because the interpolation will occur from graph to graph,
//where in each country(row) has multiple values; 1 per year(col) 1980 - 2009
/*
*
*Variables to hold count */
int rowCount;
int columnCount;
int currentGraph = 0;
/*
*
*Axis Unit Variables */
int yearMin, yearMax;
int[] years;
String[] countries;
boolean[] showCountries;
color[] colorsOfCountries;
int yearInterval = 5;
int roundAway = 10;
int yAxisMeasureMajor;
int yAxisMeasureMinor;
/*
*
*Graph Label Variables */
PFont plotFont; //font for in graph plot point text
PFont tabFont; //font for tabs
PFont axisUnitFont; //for numbers on axis
PFont axisLabelFont; //font for X & Y Labels
PFont countryFont; //font for the countries filter