Howdy;
I'm a reasonably experienced programmer who's new to processing. I'm encountering a very frustrating error that occurred only after I tried to take some classes out of the original processing file (which works) and put them into their own files.
This code is posted below. As per my description above, basically all I've done is put each of the classes in their own file, and add one line to the main file:
Code:void setup() {}
When I attempt to run this code, I get this message:
Code:processing.app.debug.RunnerException: unexpected token: (
I haven't been able to figure out much about where this is coming from, other than that it happens whenever I attempt to call a method of one of the classes that I put in the other files. Any help on this would be very much appreciated!
Code:// SCRIPT
Axis xa = new Axis(400, 0, 0, 30, "test X");
Axis ya = new Axis(30, 0, 0, 5, "test Y");
Plot p = new Plot(1500, 800, 30, "test plot");
p.setAxes(xa, ya);
p.plot();
// CLASSES
// Axis class: used to define individual axes
class Axis {
// attributes
float aMax, aMin, aInt, aTick; // axis min, max, location of intersection with other axis, distance between ticks
// (in axis units)
String aLabel; // label to be displayed on plot
// constructor method
Axis(float ax, float in, float nt, float ti, String lab) {
aMax = ax;
aMin = in;
aInt = nt;
aTick = ti;
aLabel = lab;
}
}
// Axes class: used to define a set of axes for the plot
class Axes {
// attributes
Axis yAxis, xAxis; //axes
// constructor method
Axes(Axis x, Axis y) {
xAxis = x;
yAxis = y;
}
// plot method
void plot(int xDim, int yDim, int margin) {
// etc, etc... code deleted here to fit 6000 char limit!
}
} // plot method
} // Axes class
// Point class: used to define individual points to be plotted
class Point {
// attributes
float xVal, yVal; // x and y value of point
float nArm, sArm, eArm, wArm; // values of each "arm" of point; this is very specific to glazing ratio application
float armSize = 20; // value by which glazing ratios are divided when determing a point's "arm" length, in pixels
// constructor method
Point(float x, float y, float n, float s, float e, float w) {
xVal = x;
yVal = y;
nArm = n;
sArm = s;
eArm = e;
wArm = w;
}
// other methods
void plot() {
//point(put black point at actual value location, then coloured arms from point)
}
}
// Plot class: this is where all of the plot data lives
class Plot {
// attributes
int xSize, ySize, margin; // x and y size of plot, margin size, all in pixels
String title; // title of plot
Axes pAxes; // axes
Point[] points; // array of Point objects to be plotted
// constructor method
Plot(int x, int y, int m, String t) {
xSize = x;
ySize = y;
margin = m;
title = t;
}
// other methods
// set axes method
void setAxes(Axis x, Axis y) {
Axes a = new Axes (x, y);
pAxes = a;
}
// plot method
void plot() {
// prepare window
size(xSize, ySize);
background(255,255,255);
// load font
PFont font;
font = loadFont("Calibri-12.vlw");
textFont(font);
fill(0);
// plot axes
pAxes.plot(xSize, ySize, margin);
}
}