//This is how your Processing application would look like with OpenVisuals API
//Click to learn about their definitions
//THIS IS EXTENDED VERSION; which includes examples for all the API functions you can use
import openvisuals.*; //can be imported via menu Sketch-Import Library-openvisuals
OpenVisuals ov; //required: create an OpenVisuals object
void setup() {
size(800,500);
//required: Defining of the structure of you visualization: This section is to get OpenVisuals to understand how your
//visualization work. OpenVisuals needs to know what kind of dataset you would be working with in your visualization. You need to define what fields (and their types: String, float, etc..) you will use in your visualization.
ov = new OpenVisuals(this); //required: initialize OpenVisuals Object
String[] fields = { "title", "value" }; //create an array holding the field names that will be used in your visualization
int[] types = { OpenVisuals.STRING, OpenVisuals.FLOAT }; //define the types of the fields
ov.setFields(fields,types); //introduce fields of you visualization to the openvisuals.
ov.setMaxRows(1000); //introduce the max numbers of rows of a dataset your visualization can handle.
//end of required part
//load the dataset.
ov.loadDatasetXML("http://openvisuals.org/dataset/repository/dataseta367a47e80594d5384bc4c5ecd20dfc1.xml");//optional: OR you can create a random filled dataset instead.
// This dataset can be used to test your visualization with a random dataset
ov.createRandomTable();values = ov.getNormalized("Height",0,height-100); //normalize "Height" field values to the given min, max values
}
void draw() {
//...
//...your code here...
//...int total = ov.getTotalRowNumber(); //get total number of rows
while(ov.nextRow()){ // repeat for all the rows in the table
float myVariable1 = ov.getDataVar(0, "Height"); //get value from current row and "height" field
float myVariable2 = ov.getDataVar(0, "Branches"); //get value from current row and "branches" fieldint currentRowNumber = ov.getCurrentRowNumber(); //get the current row number
//...
//...your code here, whatever you want to repeat to draw for each row...
//...}
}