question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HiDPIUtils.scale can return a rectangle with zero dimensions

See original GitHub issue

There’s a bit of a setup to this, more specifically, to have a certain combination of rotation and translation (maybe just rotation) installed on the graphics context. I use that in Radiance to rotate the visuals of tabs in LEFT and RIGHT placement.

If you have these inputs to the scale method:

transform = AffineTransform[[-0.0, 2.5, 820.0], [-2.5, 0.0, 557.5]]
x = 0
y = 0
width = 54
height = 19

The rectangle returned is java.awt.geom.Rectangle2D$Double[x=820.25,y=557.25,w=0.0,h=0.0]

Notice it has zero width and height

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DevCharlycommented, Jul 1, 2022

This is now fixed in main branch. Rotation is now handled correctly.

There is also a small app that I used to test whether g.fillRect(...) and HiDPIUtils.paintAtScale1x( (...) -> g.fillRect(...) ) produce the same result.

image

Red rectangle is filled without HiDPIUtils and green rectangle is filled using HiDPIUtils.

0reactions
eirikbakkecommented, Jul 18, 2022

@DevCharly Yes! Fair enough for the non-90-degree scalings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rectangle (Java Platform SE 7 ) - Oracle Help Center
Methods which test if an empty Rectangle contains or intersects a point or rectangle will always return false if either dimension is zero....
Read more >
How do I scale one rectangle to the maximum size possible ...
I need to find the maximum scale to which the source can be scaled while fitting within the destination rectangle and maintaining its...
Read more >
Class java.awt.Rectangle - Washington
Constructor Summary. Rectangle() Constructs a new rectangle whose top-left corner is at (0, 0) in the coordinate space, and whose width and height...
Read more >
geometry - Is it possible to find the dimensions of a rectangle ...
The width of the rectangle will just be 2 times the inner radius and then you can use Pythagoras to get the length...
Read more >
java.awt Class Rectangle
A Rectangle whose width or height is negative is considered empty. If the Rectangle is empty, then the isEmpty method returns true ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found