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

Started by
12 comments, last by 5MinuteGaming 17 years, 8 months ago
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?
Advertisement
What are vector graphics and hotspots? I've never heard of/used them before.
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.
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?
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.
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.
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?
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!
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
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
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.

This topic is closed to new replies.

Advertisement