We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Casting help
Page Index Toggle Pages: 1
Casting help (Read 828 times)
Casting help
Jun 16th, 2005, 11:18pm
 
Hi, I'm stuck on a problem..I'm trying to print out some ellipses and lines for a visualization I'm working on, but have run across some obstacles.

The code is as follows (minus the specifics from the classes):

Code:


import pitaru.sonia_v2_9.*;
import de.bezier.mysql.*;
import java.util.ArrayList;



int radius = 240;
float x,y;
int noderadius=10; // Sets radius of CHAPTER nodes
float kidx,kidy, kidx2, kidy2, kidx3, kidy3, kidx4, kidy4, kidx5, kidy5, kidx6, kidy6, kidx7, kidy7, kidx8, kidy8, kidx9, kidy9, kidx10, kidy10,
kidx11, kidy11, kidx12, kidy12, kidx13, kidy13, kidx14, kidy14;
float angle;
float r_center = 30;
boolean hover = false;
boolean locked = false;
boolean nucleusclicked = false;
int ctr1;
Nucleus centerNucleus;
Sample mySample;

// Mysql Information
MySQL mysql;
String user = "root";
String pass = "proyecto";
String database = "solaris";
String table = "content";

PImage a;
int count;
String chapterwords;
ArrayList listOfChapterNodes=new ArrayList();

void setup()
{
size(800,800);
framerate(30);
PFont metaBold;

metaBold = loadFont("Meta-Bold.vlw.gz");
textFont(metaBold, 12);
x = random(200,500);
y = random(250,300);
centerNucleus = new Nucleus(x,y,r_center);

a = loadImage("PROCESSING.jpg");
Sonia.start(this);
mySample = new Sample("ahkey.aiff");

// Mysql stuff
mysql = new MySQL( "localhost", database, user, pass, this);

ArrayList sections = new ArrayList();
String previoustitle = new String();
String tmptitle=new String();

if( mysql.connect() )
{

mysql.query("select chapter.chapter as ctitle, section.title as stitle FROM chapter, section WHERE chapter.id=section.chapter_id ");

while (mysql.next())
{
tmptitle=mysql.getString("ctitle");
if(tmptitle.equals(previoustitle)){
// this is the same chapter
// so just add to the section list
((Node) listOfChapterNodes.get(listOfChapterNodes.size()-1)).sections.add(mysql.getString("stitle"));
} else {
// this is a different chapter
// create temp nodes
ArrayList currentList=new ArrayList();
//Node tmpNode = new Node(tmptitle, currentList);
// add the section title
currentList.add(mysql.getString("stitle"));
// add example node
// ArrayList listofexamples=new ArrayList();
// currentList.add(new Example(mysql.getString("stitle"),listofexamples));
// add the node to the list of nodes
listOfChapterNodes.add(new Node(tmptitle, currentList));
// println(((Node) listOfChapterNodes.get(listOfChapterNodes.size()-1)).title);
//println(tmpNode.gettitle());
// update the variables
previoustitle=tmptitle;
}

}


}

else
{
// connection failed mofo!
}

angle=360/listOfChapterNodes.size();

for (int i=0; i< listOfChapterNodes.size(); i++)
{
// ((Node) listOfChapterNodes.get(i)).drawNucleus());
println("chapter: "+ ((Node) listOfChapterNodes.get(i)).title);
for (int j=0; j < ((Node) listOfChapterNodes.get(i)).sections.size(); j++)
{
println("has section : "+ (String) ((Node) listOfChapterNodes.get(i)).sections.get(j));
/*for (int k=0; k < ((Example) ((Node) listOfChapterNodes.get(i)).sections.get(j)).listOfExamples.size(); k++)
{
println("has example : "+ ((Example) ((Node) listOfChapterNodes.get(i)).sections.get(j)).listOfExamples.get(k));
}
*/
}
}

}


The errors I'm getting are:

Code:

Semantic Error: Type "ChapterNode" was not found.
<br><br>
No field named "index" was found in type "Temporary_6468_8413". However, there is an accessible field "INDEX" whose name closely matches the name "index".


I'm fairly new to casting, so this is a bit of a struggle for me..are there any suggestions or anybody that is very proficient enough with Java and Mysql?
Page Index Toggle Pages: 1