There's a couple of things that you could improve really easily.
you have
Code: if (Serial.available())
{
data = Serial.read();
}
data = r;
You probably meant 'r = data;' rather than the other way around, no?
Also you're better off waiting for serial data to be available, since you need to receive all three bytes sequentially.
try something like:
Code:while(!Serial.available()); // wait
r = Serial.read(); // read
and repeat for the other three parameters. Note the semicolon after while() - it does nothing until there's data available.
However there's another problem. You're reading three bytes, one at a time, but sending Java ints which are 32 bits, or 4 bytes, long. So if you want to keep this protocol then you need to change your Java code to send bytes and to make sure that the data values don't exceed 255.
If you want to stick with ints then you need to change the arduino code to read them. The equivalent C datatype is a long.
Code:long r;
while(Serial.available() < 3); // wait
r = (Serial.read() << 3) | (Serial.read() << 2) | (Serial.read() << 1) | Serial.read();
At least I think that's right, provided Processing will send the most significant byte first... Otherwise turn the sequence around.
Now this will still not be a very robust implementation, partly because your arduino has no way of telling if it is reading the right byte. To do that you would have to use some sort of marker as part of the protocol, e. g. reserve the top 2 bits of every 4 bytes to say which colour you are sending.
Alternatively, if you prefer not to mess with any of the gory details of serial protocols you could try http://firmata.org, which has its own Processing library. Not sure if it does PWM but you could easily find out.
have fun,
/m