kumar
YaBB Newbies
Offline
Posts: 19
Re: rotate question
Reply #4 - Jun 5th , 2010, 4:33am
Hi can any one help me, how to rotate the ellipse for this code PImage mapImage; Table locationTable; //Table nameTable; int rowCount; Table dataTable; float dataMin; float dataMax; int col = 0 ; int temp; void setup( ) { size(640, 400); mapImage = loadImage("ireland.png"); locationTable = new Table("kumar.tsv"); rowCount = locationTable.getRowCount( ); // Read the data table. dataTable = new Table("update.tsv"); //nameTable = new Table("irelandname.tsv"); PFont font = loadFont("Arial-BoldMT-16.vlw"); textFont(font); // Find the minimum and maximum values. for (int row = 0; row < rowCount; row++) { float value = locationTable.getFloat(row, 3); if (value > dataMax) { dataMax = value; } if (value < dataMin) { dataMin = value; } } } // Global variables set in drawData( ) and read in draw( ) float closestDist; String closestText; float closestTextX; float closestTextY; void draw( ) { background(255); image(mapImage, 0, 0); closestDist = MAX_FLOAT; for (int row = 0; row < rowCount; row++) { String abbrev = locationTable.getRowName(row); float x = locationTable.getFloat(abbrev, 1); float y = locationTable.getFloat(abbrev, 2); drawData(x, y, abbrev); } // Use global variables set in drawData( ) // to draw text related to closest circle. if (closestDist != MAX_FLOAT) { fill(0); textAlign(CENTER); text(closestText, closestTextX, closestTextY); } fill(0); text("Emails Information",70,30); } void drawData(float x, float y, String abbrev) { float value = locationTable.getFloat(abbrev, 3); float radius = 0; if (value >= 0 && value<=55) { radius = map(value, 10, 55, 2, 15); fill(#4422CC); // blue } else { radius = map(value, 0, 180, 4, 30); fill(#FF4422); // red } ellipseMode(RADIUS); ellipse(x, y, radius*0.8, radius*0.8); float d = dist(x, y, mouseX, mouseY); // Because the following check is done each time a new // circle is drawn, we end up with the values of the // circle closest to the mouse. if ((d < radius + 2) && (d < closestDist)) { closestDist = d; String name = locationTable.getString(abbrev, 0); closestText = name + " " + value; closestTextX = x; closestTextY = y-radius-4; } } void keyPressed( ) { if (key == CODED) { try{ if (keyCode == RIGHT && col < 4 && col >= 0) { col = col+1; updateTable(); } /* if (keyCode == RIGHT && col ==4) { col=1; } */ if (keyCode == LEFT && col > 0 && col < 4){ col = col-1; updateTable(); } }catch(Exception e) { col=1; // println("Error here:"+e); } } } void updateTable(){ for (int row = 0; row < rowCount; row++) { float newValue = dataTable.getFloat(row, col); //float newValue = random(dataMin, dataMax); locationTable.setFloat(row, 3, newValue); } } thank you