Java 2D is an API for drawing two-dimensional graphics using the Java programming language.
Questions tagged [java-2d]
1076 questions
5
votes
2 answers
Java 2D scene graph library for GUI
I'm looking for a 2D scene graph library for building GUI applications. It should be fast, using Java2D and be compatible with Swing (embeddable in a Swing app and also display Swing components). Support for animations is a plus.
Do you have any…

ziggystar
- 28,410
- 9
- 72
- 124
5
votes
4 answers
how can I convert an RGB image to CMYK and vice versa in Java?
our web app let users download dynamically generated images in different formats (bmp, png and jpeg). Some of our users download the images for printing, thus we would like to allow them to choose between RGB or CMYK.
Is there a way to specify the…

Olivier
- 305
- 1
- 4
- 17
5
votes
2 answers
Can't draw thin lines with Java2D
I'm trying to draw a polygon with a stroke of 1 pixel. Because the entire polygon is scaled by 100, I set the line width to 0.01. For some reason though, the polygon gets drawn with an on-screen line width of what looks to be 100 pixels instead of…

Bart van Heukelom
- 43,244
- 59
- 186
- 301
5
votes
4 answers
Measuring time spent in application / thread
I am writing a simulation in Java whereby objects act under Newtonian physics. An object may have a force applied to it and the resulting velocity causes it to move across the screen. The nature of the simulation means that objects move in…

Adamski
- 54,009
- 15
- 113
- 152
5
votes
2 answers
Rendering text in an image in Java
Are there any nice libraries to render text in an image for Java?
Java has a 2d text library, http://java.sun.com/docs/books/tutorial/2d/text/index.html but not sure if theres a better library to use.

JavaRocky
- 19,203
- 31
- 89
- 110
5
votes
2 answers
Drawing a bold line with drawLine() when extending Canvas
Given the following :
public class NavigationCanvas extends Canvas implements MouseListener,MouseMotionListener,KeyListener {
public void paint(Graphics g)
{
// some code
// more
// ...
…

JAN
- 21,236
- 66
- 181
- 318
5
votes
1 answer
How do I do double buffering in Java2D?
I'm drawing a bunch of primitives using Java2D on the screen and I'm getting a lot of tearing/flicker.
How can I enable/use double-buffering so it draws it off screen then shows the whole thing?

Scorcher84
- 423
- 1
- 6
- 9
5
votes
2 answers
Get intersection points of line and shape
I have a custom shape as shown in image.
Suppose the blue rectangle covering the shape in the image depicts the bounding box of that shape.
If I draw line at one of the diagonal of the bounding rectangle, how can I get the intersection points (in…

Mihir
- 2,480
- 7
- 38
- 57
5
votes
1 answer
How do I convert an enormous TIFF image to PNG/JPEG without out of memory error?
i have a tiff file 18000 * 18000 in Dimension and 1.20 GB in size. the tiff has 72 DPI.
I want to convert this TIFF to PNG/JPEG using 400 DPI.
I am using following code to do it
public static void ConvertTiffToJpg(String str_TiffUrl,
…

Mihir
- 2,480
- 7
- 38
- 57
5
votes
2 answers
Java Graphics drawArc with high precision
I'm trying to draw a high precision arc in Java using AWT/Swing. The Graphics class offers the "drawArc" method to do this and in most cases this is fine. However, when the arc has a large radius (I.e. The "width" and "height" parameters are large)…

Richard
- 162
- 1
- 4
- 11
5
votes
1 answer
Draw an Arc and gradient it
I would like to know if its possible to draw a Arc on a graphics Panel using a gradient and how I would go about it.
My end goal would be to rotate the arc in a full circle so it would be similar to a rotating loading circle. However it is not a…

Exikle
- 1,155
- 2
- 18
- 42
5
votes
4 answers
how can you make a progress bar without using JProgressBar?
i am looking at putting a progress bar into a game i am making with a count down from a random number between 5 and 20 down to 0. this is my code so far:
package Software;
import java.awt.Color;
import java.awt.Graphics;
import…

KrazyKat89
- 81
- 1
- 5
5
votes
5 answers
How to resize text in java
I have seen that in photoshop text can be easily resized just by dragging them. How can we do the same thing in Java? Any idea on how to resize text in java?
Added a snapshot of letter "A" resized in photoshop
Please let me know what is wrong…

user001
- 991
- 6
- 16
- 34
5
votes
1 answer
Scala: Affine Transformations
What's the best way to implement Affine Transformations in Scala? There don't seem to be any in the standard library or in Spire. The AWT AffineTransformation class is horribly mutable and I definitely don't want to mutate the Graphics2D class. Is…

Rich Oliver
- 6,001
- 4
- 34
- 57
5
votes
1 answer
How to disable the default painting behaviour of wheel scroll event on JScrollPane
I recently purchased the book Filthy Rich Clients and i found it really useful and fun. Building on one example from the book i tried implementing a custom ScrollPane that displays a "shadow" on the bottom of its view over the component to be…

Savvas Dalkitsis
- 11,476
- 16
- 65
- 104