• Advertisement
Sign in to follow this  

[java] Do Applets support vector graphics and/or hotspots?

This topic is 4182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1) applets can scale images, but only at whole integer values. so i was wondering if applets support vector graphics? 2) do applets support hotspots like the way Flash supports hotspots for buttons and objects and stuff?

Share this post


Link to post
Share on other sites
Advertisement
Java allows you to draw shapes which scale nicely. More specifically, the Graphics class allows this.
As for hotspots, the best you could do is draw shapes, listen for a click event, and see if that event occurred within that shape. I suppose you could also do it with containers or custom buttons too, but that's a bit more work.

Share this post


Link to post
Share on other sites
Hi,

Quote:
1) applets can scale images, but only at whole integer values. so i was wondering if applets support vector graphics?

Yes java applets support vector graphics
Quote:
2) do applets support hotspots like the way Flash supports hotspots for buttons and objects and stuff?

Yes java applet support "hotspots"

Since Java is a programming language it supports many ways to implement both vector graphics and hotspots. The Java API which is a collection of already writen code contains a solution that allows you to use Vector graphics in your application or applet.

I hope this answers your questions?

Share this post


Link to post
Share on other sites
vector graphics: the use of geometric lines and i think even curves these days. doesnt use pixels to draw in the conventional sense of the word, but rather renders using shapes thus giving scaled images to be perfect representations of their original scale. in contrast a regular image, like a jpeg, will look pixelated when scaled out. ie. think asteroids the game.

hotspots: buttons (and objects) in Flash that throws an event when your mouse touches it (hoevers over it) at which point the button may change colors or animate. windows can do this and so can java. but i believe it is specifically called hotspots in Flash.

Share this post


Link to post
Share on other sites
I'm guessing what you're wanting is some kind of handy construct that acts like the hotspots in Flash. I know of no objects capable of this, but it shouldn't be too difficult to emulate.

Share this post


Link to post
Share on other sites
Whackjack

I looked deeper into the java API and i am not seeing a way to scale an image nicely to say 120%. the drawImage method that is available has int width and height parameters which are whole numbers, not floats.

Also, for vector graphics, are you suggesting using the 3d capabilities, by using polygons or shapes to draw?

Finally, for hotspots, i am specifically looking for mouse hover (or mouse entering) a small area (like a circle or a square). i thought about button components but i cant control the way the button looks (in other words, i've no choice but to have it look like a button). or am i wrong about this?

Share this post


Link to post
Share on other sites
Hi,

Quote:
Whackjack

I looked deeper into the java API and i am not seeing a way to scale an image nicely to say 120%. the drawImage method that is available has int width and height parameters which are whole numbers, not floats.

Also, for vector graphics, are you suggesting using the 3d capabilities, by using polygons or shapes to draw?

Finally, for hotspots, i am specifically looking for mouse hover (or mouse entering) a small area (like a circle or a square). i thought about button components but i cant control the way the button looks (in other words, i've no choice but to have it look like a button). or am i wrong about this?

You can control the way components look in java swing offers a wide range of configurable visual styles.

Look at javax.swing

JButton allows you to set a rollover image which will automatically trap mouseover events as well as a selected image, and a pressed image, as well as the regular idle image.

Also you might want to look at the shape interface
Look at "All Known Implementing Classes" list and to render any to a the screen look at Graphics2D.draw( Shape s )

There are shape primitives that do use double values so there is a lot more precision.

Hope, that helps!

Share this post


Link to post
Share on other sites
Also look at the java.awt.Graphics2D class. In all Java visual components in hte paint/paintComponent methods, the Graphics object is always a Graphics2D object. You can just cast it to use the more advanced features of Graphics2D. As well this will allow you to use AffineTransforms, among other things.

The following links should help.

http://java.sun.com/docs/books/tutorial/2d/index.html
http://java.sun.com/javase/6/docs/technotes/guides/2d/spec/j2d-bookTOC.html

Share this post


Link to post
Share on other sites
thanks.

i am aware of the button having a mouseOver event. but i didnt like the way buttons look in my drawing "canvas". but the Shape objefct intrigues me. ill look into it. can it be drawn as an image (ie. jpg) and can it detect mouseover events as well?

anyhow, i think i have made a decision to switch API's from Java Applets to Flash ActionScripts.

flash always seem to look better and react smoother. i wont be starting on the implementation of this project until a while. still gotta draw up the blue-prints and research the best API's to do this.

thanks all.

Share this post


Link to post
Share on other sites
Quote:
Original post by GekkoCube
thanks.

i am aware of the button having a mouseOver event. but i didnt like the way buttons look in my drawing "canvas". but the Shape objefct intrigues me. ill look into it. can it be drawn as an image (ie. jpg) and can it detect mouseover events as well?

anyhow, i think i have made a decision to switch API's from Java Applets to Flash ActionScripts.

flash always seem to look better and react smoother. i wont be starting on the implementation of this project until a while. still gotta draw up the blue-prints and research the best API's to do this.

thanks all.
Well which api you use is purely your perogative. Java offers more than ActionScript and I think it is easier to develop with but of course I've been using Java a lot longer than I've been doing Flash.

As far as the way things look. Java applets can look the same as flash though Sun's Java API was not meant specifically for the same problems space that Flash was meant for. For instance you can embed videos in a Flash animation much easier than you can in an Applet. But you can write complex logic much easier with Java than with ActionScript.

Just for the sake of curiosity what type of game are you going to be making?
Here is a java applet game that I'm currently working on to give you an idea of only a few things you can do with Java. Tech Wrecker

Share this post


Link to post
Share on other sites
i know that flash is more tuned for vector graphics, in addition to the fact that it plays movies. but i wonder why there are more flash games than java games on the internet. anyone know why???

im not really making a game. but it utilize a lot of game design patterns and technologies. for instance, i have a running loop, much like a game loop. i use double buffering...etc...etc.

i am going to give java one more chance.

is there a way to scale an image (zoom in and zoom out) smoothly?

Share this post


Link to post
Share on other sites
Quote:
Original post by GekkoCube
i know that flash is more tuned for vector graphics, in addition to the fact that it plays movies. but i wonder why there are more flash games than java games on the internet. anyone know why???

im not really making a game. but it utilize a lot of game design patterns and technologies. for instance, i have a running loop, much like a game loop. i use double buffering...etc...etc.

i am going to give java one more chance.

is there a way to scale an image (zoom in and zoom out) smoothly?


Did you look at the links I sent you? AffineTransform and Graphics2D should do what you want. Here is a game I made using vector graphics in Java. http://www.javaunlimited.net/games/view.php?id=51

If you read the tutorials in the links I sent you, you should be able to do what you want.

Share this post


Link to post
Share on other sites
Quote:
Original post by GekkoCube
i know that flash is more tuned for vector graphics, in addition to the fact that it plays movies. but i wonder why there are more flash games than java games on the internet. anyone know why???

im not really making a game. but it utilize a lot of game design patterns and technologies. for instance, i have a running loop, much like a game loop. i use double buffering...etc...etc.

i am going to give java one more chance.

is there a way to scale an image (zoom in and zoom out) smoothly?

Simply setup your double buffereing which you can do using the canvas or just using an Image. Then since a images in java are scaled using integer width and height properties just change them as time goes by. Here is some example code.


//setup code for timed events
Timer tmr = new Timer();
Graphics2D bkBuffer;

Image myImage = (new ImageIcon("myImage.gif")).getImage();

int width = myImage.getWidth();
int height = myImage.getHeight();

//change the width and height of the image to display
//every 500 milliseconds the first change will occur
//after 1 second.
tmr.schedule(
new TimerTask() {
public void run() {
if( width < myApplet.getWidth() && height < myAppley.getHeight() ) {
width++;
height++;
}
}
},1000,500);

//you will also need to draw the image to the backbuffer
//the following line should be in your paint( Graphics g ) function.
bkBuffer.drawImage(myImage,0,0,width,height,null);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement