Mike Miller

Greenhorn
+ Follow
since Mar 11, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Miller

Thanks for the help there... But I found a more elegant way to catch the issue.

Instead of translating the needed characters in code I've left it up to the processor by wrapping the text data in cdata tags.

<CustomerName>
<![CDATA[MR & MRS SMITH]]>
</CustomerName>

This means I don't have to write code for each special case character and hasn't impacted the speed of which the PDF is created.

Mike.
Hi Guys,

Sorry if this is posted elsewhere, i've had a look and can't find it.

I'm creating a PDF via FOP, from user data so I need to include provisions for < > & etc...

I know i need to encode the characters into &#xxxx; format, and I can write a class to do this.

However is there a built in method somewhere, like the URLEncode.Encode? or should i use this and a regular expression to replace %84 with the format i need?

I'm using the bog standard UTF-8 encoding.

Any Help / comments would be appreciated.
in the end i used this...
class mikes extends Object {
public static boolean handlesinglepixel(int x, int y, int pixel,Color c) {
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
int blue2,red2,green2;
//System.out.println(red+"|"+green+"|"+blue);
red2 = c.getRed();
green2 =c.getGreen();
blue2 = c.getBlue();
if (((red==255)&&(green==255)&&(blue==255)) || ((red==0)&&(green==0)&&(blue==0)) || ((red==red2)&&(green==green2)&&(blue==blue2)) )
return true;
else return false;
}
public static boolean handlepixels(Image img, int x, int y, int w, int h,Color c) {
int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
try {
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels!");
return false;
}/*
if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
System.err.println("image fetch aborted or errored");
return;
}*/
boolean white = true;
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
if (white) white = handlesinglepixel(x+i, y+j, pixels[j * w + i],c);
}
}
return white;
}
}

thanks to all for replying.
22 years ago
Could i use pixelGrabber? The screen is being drawn as an image.
22 years ago
I'm writing a little applet using awt that draws a number of line of the screen. The lines are drawn as single points and move around the screen using velocity vectors. When they hit the edge they bounce at random. I need to detect when a line hits another line. I thought that if i look ahead of the line to see if the color is not the default background then the line could bounce. So what i need is a method that accepts x,y co-ords and returns the color at those co-ords.
With thanks.
22 years ago