1,081 questions
3
votes
0
answers
151
views
Why does Java FontMetrics return wrong string bounds (specially height) for some .ttf?
I’m generating text images for different .ttf fonts in a method using Java2D, most of the fonts it works fine. The issue is with some fonts it return wrong "Y" value.
// params
File ...
1
vote
1
answer
78
views
When running java against a jar java2d is not being found? [duplicate]
I am using client host commands from powershell to launch a Oracle forms FSAL via the following command:
java -jar "fsal jar location" -url "url"
This command works except there ...
0
votes
1
answer
104
views
How to include trailing space in text measurements using TextLayout?
I am using the java.awt.font.TextLayout class to measure the bounds of a text string. In this measurement I need to include any trailing whitespace. However it seems that by default, TextLayout ...
0
votes
1
answer
380
views
Is it possible to render image from a PDF using PDFBox in a Spring Boot Native application?
I am trying to figure out how to use PDFBox (2.0.30) to render image from a PDF document in a native application based on Spring Boot (3.2.1).
PDF generation works fine, but image rendering fails. ...
0
votes
1
answer
111
views
Java 2D graphics backgammon table (algorithm question)
My problem is I need to use only one drawLine. I couldn't figure out how am I supposed to make changes at the same time in x and y while not messing with one and another. I can't use a rectangle.
int ...
0
votes
1
answer
229
views
Java Swing 2D - Draw many small stars quickly
I'm trying to make a game, and in the game is a background that has many small stars that slowly travel from right to left. With a full screen I may have 170 stars being drawn each frame. The ...
-1
votes
1
answer
54
views
Unable to drawimage on null layout swing
I want to draw some images on screen alongside some JButtons placed in different places of the screen. However whenever I have setLayout(null); the images do not show up on screen. If i don't set it ...
0
votes
0
answers
51
views
Click inside a figure
How can I know if the user has clicked inside a Pentagon and a Ellipse? I was able to create a method for Circle, Triangle and Rect, but I got stucked in those two figures.
Rect:
public boolean ...
0
votes
1
answer
199
views
Create Polygon that update after the insertion of every point
I am having a problem with a school project in Which I create a Polygon that when I insert points the polygon update after the insertion of every point.
For example
My program:
The result I want:
...
1
vote
1
answer
48
views
Java2D method call without class
I just started to learn Java and tried to draw some rectangles.
I have run this example and can't understand one thing:
class ShapesDemo2D has a constructor:
public void init() {
//Initialize ...
-1
votes
1
answer
667
views
Java : read an image inside a binary file (or maybe more generally, from a stream)
I am making a java program that reads a binary file, which contains multiple images (in PNG format), and some binary data.
How can i load the images (specifically, as java.awt.Image's) ? So far the ...
1
vote
1
answer
207
views
How can I fill a java Shape in OpenGL
Well, lets say I have the Shape of an O and I want to render it.
Now my current rendering code is this:
public void fill(Shape shape, float xOffset, float yOffset) {
AffineTransform transform ...
0
votes
1
answer
1k
views
How to determine the java2d uiscale factor?
I know you can set the factor via -Dsun.java2d.uiScale=2 but what if I want to let the System choose the Value, how do I get the value set? Where is it saved?
0
votes
1
answer
399
views
Detecting a mouse hover over an object that is not a JComponent
As the title states, I am trying to detect a mouse hover over an object that is not a JComponent.
Right now I have a window with a green JPanel. When you left-click on this JPanel you create a point.
...
0
votes
2
answers
160
views
How to determine screen geometry
I have the following code.
import java.awt.*;
public class ShowScreenSize {
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
...
0
votes
0
answers
258
views
Java 2d painting problem in JavaFX SwingNode
I have a java application with old vector graphics editor written in pure Java Swing and Java2D.
Now I want to migrate the whole application to Javafx toolkit, except graphics editor. Graphics editor ...
0
votes
1
answer
93
views
Text rendering deformed upon updating MacOS to Catalina
The Java SE 8 app I'm developing needs to run on Win10 and MacOS, and I'm using a Font (Ariel) that renders well on both platforms:
Here is an example of how it normally looks (MacOS 10.13):
I was ...
0
votes
1
answer
189
views
Draw circle with lines in it and check if mouse is inside the circle- Java Graphics- Geometry
Using Java graphics, I tried to draw a circle, draw lines inside it, then check if the mouse is inside the circle and print the position of the mouse.
The lines I draw exceed the circle and when I ...
0
votes
0
answers
166
views
Gradually incrementing stroke width in java
I have to draw the figure on the link in java as an assignment.The assignment
So far I have been able to draw the first arc using CubicCurve2D, as seen on the picture on the second link, but now I ...
0
votes
1
answer
69
views
Curved Path2D becomes straight when increasing stroke size
I have this strange problem with Java2D. I have a Path2D.Double that I want to draw, but depending on the stroke size, all segments are drawn correctly (curved) but when the stroke size is greater or ...
-1
votes
2
answers
111
views
Java 2D rotate BufferedImage
This question was answered many time but I still can't apply it to my situation.
I want to rotate image on 90 degrees clockwise.
I'm currently having following code:
private void writeImage(...
1
vote
1
answer
64
views
Rotating a picture causes rotation of other pictures in a loop g2d.rotate
I'm trying to make a game like Tank Trouble.
The problem is that when I'm trying to rotate and draw a tank picture, all other tanks pictures will be rotated.
Here is my code:
// draw tanks
ArrayList&...
0
votes
0
answers
54
views
Correctly Sizing a Canvas inside a JFrame
my current project is a small desktop application in Java that functions like a room decorator similar to the IKEA software that lets you plan out your room before you go and buy furniture. When I ...
-1
votes
1
answer
456
views
Why is an image displayed with Graphics.drawImage() in Java not like I drew it
I have BufferedImage that stores .png image (320 x 240) and I draw it on Сanvas with Graphics.drawImage(). But if you look closely, for example, the cross 3 by 3 pixels is actually 4 by 3 pixels. Look ...
3
votes
1
answer
505
views
More efficient way to blend pixels (semi-transparency)?
I'm working on drawing semi-transparent images on top of other images for a small 2d game. To currently blend the images I'm using the formula found here: https://en.wikipedia.org/wiki/...