I know you can change uppercase to lower and vise versa but I need to separate a string at each capital letter...
Is there a way I could do this without looping through an alphabet of capital letters to find a match?
I am looking at some sample code and noticing that processing takes both (double) numb and double(numb) as if they are the same but something like below has to be like the second one. I've seen this type of thing a couple of times now and don't get what the difference is so I don't know when to use it...
*WordItem is a classm words is a HashMap, word is a string
WordItem item = WordItem(words.get(word));<--NO WORK
(WordItem) words.get(word) <--WORKS
In the constructor I say this.file (referring to global file variable declared above) equals file (referring to the file variable name in the constructor). Then when I say addFolder(file) I get the error "The method addFolder(MainTab.Node) in the type MainTab is not applicable for the arguments (File)".
This makes sense because I am sending addFolder a file instead of a Node but when I was trying to figure out how to fix it I found out that it works with addFolder(this) but I don't understand why??? "this" should equal the same thing as file no?
I am using an integrator class to get a smooth zoom into a specific zone on a map (mine is only slightly modified from the one
here with
this code). With mine, when a person enters each character of a zip code the points on a map with that code highlight and zoom in a level closer without having to click to enable the zoom (and I don't use faders like the code linked above).
Problem I am having is I need the "bounds" variables to update (line 152) with new mins and max's (of the highlighted points) so that when I call calcZoom() (line 162) the span, target, etc. values update and I get the zoom effect. For some reason though, I can't get accurate new min's and max's of the highlighted points (I tried on line 306 first with test max and min variables but the max's and mins being found are not the maxes and mins of the highlighted/chosen xx and yy variables). I have no idea why.
PFont font;
String[] data;
String typedString = ""; //Why don't I have to say String typedString = new String("");
char typedChars[] = new char[5];
Place[] places;
int totalCount, zip, typedCount, foundCount;
int placeCount = 0;
int typedPartials[] = new int[6];
float Xmin, Xmax, Ymin, Ymax, x, y;
float mapX1, mapX2, mapY1, mapY2;
float textX, textY;
String name;
color backgroundColor = color(152, 151, 141);
color highlightedColor = color(247, 237, 25);
color dormantColor = color(162, 156, 30);
//Temporary troubleshooting variables
float XminTest;
float XmaxTest;
float YminTest;
float YmaxTest;
//Zoom
Integrator zoomDepth = new Integrator();
Integrator zoomX1;
Integrator zoomX2;
Integrator zoomY1;
Integrator zoomY2;
float targetX1[] = new float[6];
float targetX2[] = new float[6];
float targetY1[] = new float[6];
float targetY2[] = new float[6];
//Boundary of currently valid points at this typedCount
The original values of maxes and mins are correct (line 57-60) and the xx, yy values are correct so why wont lines 306-310 find the max and min of those?
Thank you for the help. I know this is a large chunk of code for a forum question.
I thought the difference between the two was the first is an array of 6 strings while the second was a string of size six in an array but I put a string in is larger than six so this cant be right. What, where, when to use which??? Same thing with i++ and ++i to increment and de-increment --i and i--...they both seem to do the same thing.
String[] target1 = new String[6]; //target1 is an array of 6 strings?
String target2[] = new String[6]; //target2 is a string of size 6?
I try to display these ellipses one after the other but the for loop calculates the positions of all of them then puts them up all at once. How do you get it to display one, then two, then three....etc.? I tried putting a delay() in the loop but that doesn't work.
There is no 'y' character in this code and I am not missing a semicolon anywhere yet line 19 is highlighted when I try to run and it suggests I am missing a semicolon. Troubleshooting techniques for this kind of error message?
For some reason the square grid isn't showing up even though I checked (via println) that the rect(x, y, size, size) function is getting the correct values...I don't understand why when I type rect(115, 115, 20, 20) I get the square come up but when I feed it those numbers with variables I get no square. Am I missing something really simple?
ElectrodeSq[][] s;
int numCols = 2;
int numRows = 3;
float gapX, gapY;
float electSize = 20;
float x, y;
float chunkX;
float chunkY;
color background0 = color(95,95,91);
color background1 = color(178, 172, 172);
color electColor = color(232, 210, 12);
void setup() {
size(600,400);
gapX = electSize/2 + 5;
gapY = electSize/2 + 5;
s = new ElectrodeSq[numCols][numRows];
for(int i=0;i<numCols; i++) {
for(int j=0; j<numRows; j++) {
s[i][j] = new ElectrodeSq(i, j);
}
}
noLoop();
}
void draw() {
for(int i=0; i<numCols; i++) {
for(int j=0; j<numRows; j++) {
x = 100 + gapX;
y = 100 + gapY;
s[i][j].display();
gapY+=electSize + 5;
}
gapX+= electSize + 5;
}
}
ElectrodeSq[][] s;
int numCols = 2;
int numRows = 3;
float gapX, gapY;
float electSize = 20;
float x, y;
float chunkX;
float chunkY;
color background0 = color(95,95,91);
color background1 = color(178, 172, 172);
color electColor = color(232, 210, 12);
void setup() {
size(600,400);
gapX = electSize/2 + 5;
gapY = electSize/2 + 5;
s = new ElectrodeSq[numCols][numRows];
for(int i=0;i<numCols; i++) {
for(int j=0; j<numRows; j++) {
s[i][j] = new ElectrodeSq(i, j);
}
}
noLoop();
}
void draw() {
for(int i=0; i<numCols; i++) {
for(int j=0; j<numRows; j++) {
x = 100 + gapX;
y = 100 + gapY;
s[i][j].display();
gapY+=electSize + 5;
}
gapX+= electSize + 5;
}
}
class ElectrodeSq {
float electSize;
float posX, posY;
ElectrodeSq(float posX, float posY){
this.electSize = electSize;
this.posX = posX;
this.posY = posY;
}
void display() {
fill(background0);
rectMode(CENTER);
rect(width/2, height/2, width-60, height-40);
fill(background1);
rectMode(CENTER);
rect(width/2, height/2, width-70, height-50);
fill(electColor);
rectMode(CENTER);
rect(x, y, electSize, electSize); //not working for some reason
println(x+" "+y); //using println I see that I am getting the right x and y values
rect(115, 115, 20, 20); //manually typing the values into rect() I get a rectangle show up
When I try and println an array of ~41,000 place objects my program crashes. I tried increasing the max available memory to 500MB when I got an "out of memory" error but it is still happening. Any brainstorms on how to fix it?
My system:
4GB RAM, Intel dual core, 64-bit
Thank you!
String[] data;
Place[] places;
int totalCount, zip;
int placeCount = 0;
float Xmin, Xmax, Ymin, Ymax, x, y;
float mapX1, mapX2, mapY1, mapY2;
String name;
color backgroundColor = color(152, 151, 141);
color highlightedColor = color(247, 237, 25);
color unhighlightedColor = backgroundColor;
void setup() {
size(720, 453, P3D);
mapX1 = 30.0;
mapX2 = width - mapX1;
mapY1 = 20.0;
mapY2 = height - mapY1;
readData(data); //output is Place(zip name x y)
}
public void draw() {
/*background(backgroundColor);
//for(int i=0; i<placeCount; i++) {
//places[i].draw();
}*/
}
float TX(float x) {
return map(x, Xmin, Xmax, mapX1, mapX2);
}
float TY(float y) {
return map(y, Ymin, Ymax, mapY1, mapY2);
}
void readData(String[] data) {
data = loadStrings("clean.tsv");
parseInfo(data[0]);
places = new Place[data.length];
for(int i=1; i<data.length; i++) {
places[placeCount] = parsePlace(data[i]);
placeCount++;
}
for(int j=0; j<places.length; j++) {
println(places[j]);
}
}
//read header line
void parseInfo(String head) {
String[] pieces = split(head, TAB);
//totalCount = int(pieces[0]); tC = 41859 but data.length = 41705
I am working on cleaning up some data to use and wanted to replace all the commas with tabs and save it as a .tsv file but for some reason the code didn't pick up on all the commas to replace with tabs and I cant find a pattern as to why is missed a few....anyone had this problem?
For example:
# 2051 Marshfield Hills in the .tsv file has no tab or comma but in the original .csv file there was a comma there...why wasn't it replaced by a tab?
A null pointer exception comes up only when I use the draw loop in code 2. But I am doing essentially the same thing I was doing in code 1. Why the difference? I assume it has to do with the draw loop??? But I traced it and cant find an issue...
//No error message--it just runs through the loop.
String flines[] = loadStrings("anotherTest.txt");
for(int i=0; i<flines.length; i++) {
println(flines[i]);
}
//This should be essentially the same this as above but I get a null pointer exception...
I am guessing this error refers to rotateCube not being called properly??? I read other people who got this error and checked my curly brackets and such but nothing...what does this error mean exactly?
/* 3D Cube movement with arrow keys
When user hits LEFT the cube rotates left till user hits
I want to declare the vine class without parameters but I am getting errors and wondering if maybe this is not possible??
My error is actually "unexpected token: {" in the part below in red but I don't see a problem with how I declared it.
Does anyone know why scale() and rotate() fctns don't work for the bezier shape I created? What don't I understand about the scale and rotate functions?