Home pageFind It!Contact PJAPJA documentation

PJA

 PJA Toolkit forum

This forum is dedicated to PJA Toolkit.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject Running PJA on unix server

damar

Member since : Feb 18, 2004
Messages : 3
 Feb 18, 2004 at 5:07 PM
Hi,

I am running sun-jdk1.3.1 under gentoo linux.

In my PJAToolkitDemo1.2.sh, I have the following:

/opt/java/bin/java -Xbootclasspath/a:/usr/local/enhydra5.0/lib/pja.jar \
-Dawt.toolkit=com.eteks.awt.PJAToolkit \
-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment \
-Djava2d.font.usePlatformFont=false \
-Djava.awt.fonts=/opt/java/jre/lib/fonts \
-Duser.home=/opt/pja_2.4/lib/ \
-classpath /usr/local/enhydra5.0/lib/pjatools.jar \
ToolkitDemo

When I run the above, no graphics comes. It ends with:

Toolkit class in use is com.eteks.awt.PJAToolkit
Disabling platform fonts
Computing ArcDrawer image (instance of com.eteks.java2d.PJABufferedImage)
Saving image to PJAToolkitArcDrawer.gif
Computing PolygonDrawer image (instance of com.eteks.java2d.PJABufferedImage)
Saving image to PJAToolkitPolygonDrawer.gif
Computing TextDrawer image (instance of com.eteks.java2d.PJABufferedImage)
Saving image to PJAToolkitTextDrawer.gif
Computing ImageDrawer image (instance of com.eteks.java2d.PJABufferedImage)
Saving image to PJAToolkitImageDrawer.gif

Iam trying to compile my web, using ant, where I have:

java -Xmx300M -cp $ANTJARS:$ENHYDRA_CLASSES:$JDKDIR/lib/tools.jar -Dant.home=$$

Should the options of PJAToolkitDemo1.2.sh works fine, I assume that I can place them in the above ant script line. Am I correct?

I have put both pja.jar and pjatools.jar in my CLASSPATH env variable.

Any pointers would be highly appreciated.

Damar

[Moderator moved this message to the other subject created by damar]

ruzer

Location : Dublin, Ireland
Member since : Feb 21, 2004
Messages : 1
 Feb 21, 2004 at 2:00 AM
Hi,

Trying to get the following code to work on a UNIX server running tomcat. I have a servlet which uploads an image, and then I try to use the following code to scale the image

System.setProperty ("awt.toolkit", "com.eteks.awt.PJAToolkit");
System.setProperty ("java.awt.graphicsenv", "com.eteks.java2d.PJAGraphicsEnvironment");
Image image = Toolkit.getDefaultToolkit().getImage(inFile);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
.
.
.
... and so on.

But I get the message:
java.awt.AWTError: Toolkit not found: com.eteks.awt.PJAToolkit

I read a message on this forum saying that I have to do something with -Xbootclasspath. Where & when can I specify this bootclasspath?

Thanks in advance
Ruzer

---
I wanna be your dog

ruzer

Location : Dublin, Ireland
Member since : Feb 21, 2004
Messages : 1
 Feb 21, 2004 at 2:13 AM
Hi,

Just read a few more posts to this forum, and I'm beginning to doubt if my code will work with PJA. It reads an image file, and makes two copies, one small and one large. I think that it probably uses the JPEG encoder & decoder. Does anyone know if it will work with PJA?

Here's the code:



import com.sun.image.codec.jpeg.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
//import javax.imageio.*;

public class ImageUtils {

public ImageUtils() {

}

public static void scaleImage(String inFile, String outFile, int width, int height, int quality) {
try {

System.setProperty ("awt.toolkit", "com.eteks.awt.PJAToolkit");
System.setProperty ("java.awt.graphicsenv", "com.eteks.java2d.PJAGraphicsEnvironment");

Image image = Toolkit.getDefaultToolkit().getImage(inFile);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);

int scaleWidth = width;
int scaleHeight = height;
double scaleRatio = (double)scaleWidth / (double)scaleHeight;
int imageWidth = image.getWidth(null);
int imageHeight = image.getHeight(null);
double imageRatio = (double)imageWidth / (double)imageHeight;

if (scaleRatio < imageRatio) {
scaleHeight = (int)(scaleWidth / imageRatio);
} else {
scaleWidth = (int)(scaleHeight * imageRatio);
}

BufferedImage scaleImage = new BufferedImage(scaleWidth, scaleHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = scaleImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(image, 0, 0, scaleWidth, scaleHeight, null);

//Need to look up how to use this method
//ImageIO.write(scaleImage, "jpg", new File(outFile));

//In the mean time, just use this approach
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outFile));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(scaleImage);
quality = Math.max(0, Math.min(quality, 100));
param.setQuality((float)quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(scaleImage);
}
catch(Exception e) {
System.out.println("Error scaling image: "+e);
}
}

public static void main(String args[]) {
ImageUtils.scaleImage("images.jpg", "outimage.jpg", 100, 100, 100);
}
}

Cheers for any help!
Ruadhan
---
I wanna be your dog

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Feb 24, 2004 at 8:06 AM
> I read a message on this forum saying that I have to do something with -Xbootclasspath. Where & when can I specify this bootclasspath?

At Java command line.
If you can't modify Java command line, please read the following subjects to perform the image operations :
http://www.eteks.com/pja/en/forum/viewSubject.jsp?subjectId=285
http://java.sun.com/products/jimi/
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2023 eTeks - All rights reserved

PJAPJA documentation