Questions tagged [java-2d]

Java 2D is an API for drawing two-dimensional graphics using the Java programming language.

1076 questions
13
votes
3 answers

AffineTransform without transforming Stroke?

When using the Graphics2D scale() function with two different parameters (scaling by different ratios in x- and y-direction), everything drawn later on this Graphics2D object is scaled too. This has the strange effect that lines drawn in one…
Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
13
votes
1 answer

How can i work around the ClassCastException in java2d (Bug-ID 7172749)

I have the bad luck of suffering from a bug in java8, that doesn't seem to be a big issue for anybody else, so Oracle is not going to fix it before java9. The bug has Bug-ID 7172749 (also note the related and duplicate bugs) and it just happens all…
tobi42
  • 805
  • 10
  • 18
13
votes
3 answers

setOpaque(true/false); Java

In Java2D when you use setOpaque I am a little confused on what the true and false does. For example I know that in Swing Opaque means that when painting Swing wont paint what is behind the component. Or is this backwards? Which one is it? Thanks
anon235370
13
votes
5 answers

Best API for simple 2D graphics with Java

I'm not sure what the best api for simple 2d graphics with Java is. I know java.awt.Graphics2D was the standard but has it been replaced? Swing is the new API for Java GUI apps but it seems a bit heavy for what I want. What I really want is…
bjwbell
  • 553
  • 1
  • 6
  • 18
12
votes
3 answers

How can I create a hardware-accelerated image with Java2D?

I'm trying to create a fast image generator that does lots of 2d transformations and shape rendering, so I'm trying to use a BufferedImage and then acquire the Graphics2D object to perform all my drawing. My main concern now is to make is really…
Paulo Lopes
  • 5,845
  • 22
  • 31
12
votes
2 answers

Increasing screen capture speed when using Java and awt.Robot

Edit: If anyone also has any other recommendations for increasing performance of screen capture please feel free to share as it might fully address my problem! Hello Fellow Developers, I'm working on some basic screen capture software for myself. As…
EthanLWillis
  • 930
  • 4
  • 14
  • 27
10
votes
5 answers

Detecting self crossing in closed Bezier curves

I've created a "blob" shape by patching cubic Bezier curves together (screenshot below). I'd like to be able to detect the situation where a curve has crossed over either itself or another curve and was wondering if there's a recommended approach…
Adamski
  • 54,009
  • 15
  • 113
  • 152
10
votes
6 answers

Java graphics are flashing

Okay, I understand your need for an SSCCE, so I created (my first) one. I managed to replicate the problem with under 200 lines of code. On my system this demo compiled and ran perfectly (only the flickering was still there of course). I stripped…
Jori
  • 1,122
  • 2
  • 18
  • 36
10
votes
6 answers

Changing the colour of text in drawstring()

I'm trying to add emphasis to one work in a string im drawing using swing. I was advised to use HTML with the following code: Graphics2D g2 = (Graphics2D) g; g.drawString("this is something I want people to

NOTICE

", x, y); I…
Chris Headleand
  • 6,003
  • 16
  • 51
  • 69
10
votes
2 answers

Inside clipping with Java Graphics

I need to draw a line using java.awt.Graphics, but only the portion of the line that lies outside of a rectangle should be rendered. Is it possible to use the Graphics clipping support or do I need to calculate the intersection and clip the line…
tuler
  • 3,339
  • 7
  • 34
  • 44
9
votes
1 answer

How do I specify fallback fonts in Java2D/Graphics2D

I'm using g.drawString(str, x, y) to draw a String with a Graphics2D object g. The current font of g does not cover all the characters of str (I have e.g. Chinese chars in there). On Mac OS X, a fallback font seems to be automatically used, but not…
Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234
9
votes
2 answers

How to serialize Java 2D Shape objects as XML?

The Shape interface is implemented by objects of Java 2D (Arc2D, Area, CubicCurve2D, Ellipse2D, GeneralPath etc..). Some of the concrete objects are marked as Serializable and can be stored and restored using object serialization, but others like…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
9
votes
1 answer

Is it possible to detect window occlusion

Using AWT, I would like to save resources like flash does, by stopping draws to the screen when the window is hidden. But first, I need a method to detect if the Frame is completely covered by one or more other windows. Windows that are likely not…
warren
  • 563
  • 2
  • 13
9
votes
4 answers

Scala 2D Animation library

Can anyone recommend a good 2D animation package for Scala? I prefer something which already have some basic events handling, more like JavaFX than like processing.org.
Elazar Leibovich
  • 32,750
  • 33
  • 122
  • 169
9
votes
3 answers

about drawing a Polygon in java

hi there i'm trying to improve myself about java2D and first of all i'm dealing with drawing polygons. However, i can not see the polygon on frame. I read some tutorials and examples but as i said i face with problems. here is the sample code of…
quartaela
  • 2,579
  • 16
  • 63
  • 99
1
2
3
71 72