I'm using AffineTransform to manipulate your drawing using graphics 2D Java to go to any component I am here. Graphics2D provides a conversion for a method, which takes an AffineTransform.
Occasionally I have to spill the point manually without using Biltine-Transformation, but when I try to change a point by using the same change which I used to do with Graphics 2D Transforms were given, sometimes the resultant number is not the same.
The following code reproduces the problem (this is Scala code, but I think you can visualize Java code):.
var transformationMatrix = new AffineTransform () / * * has been modified during transformationMatrix program * ... * / def override paintComponent (g: Graphics2D) = {super .paintComponent (g) / * 1. changing using graphics * / g.transform (transformationMatrix) g.setColor (Color.RED) g.fill (new Rectangle (0, 0, 1, 1)) / * 2. change to change it manually * / GksetTransform (new AffineTransform) // standard val = P0 changes to the new reset point (0, 0) Val pDest = new Point () TransformationMatrixktransform (P0, PDest) GksetColor (ColorkBLUE) Gkfill (New rectangle (pditex, pdeti, 1, 1)} A Painted behavior Blue rectangle (manually calculated) red one overdraws (calculated by transform).
Experienced behavior
I believe my conversion metrics Actually not an integer, but this should not be a problem, should it be?
affineTransform = 1.1, 0.0, 520.55 0.0, 1.1, 182.54999999999995 0.0, 0.0, 1.0 Is this a bug or do I get a deep insight Having been?
Edit : You can reproduce the bug, you transformationMatrix = transformationMatrix to the new AffineTransform (1.1, 0.0, 0.0, 1.1, 521.55, 183.54999999999995) At the beginning of the color Please note, the G graphic is of 2D type.
OK, you're doing two different things. In
(1) you have a shape (and it is irrelevant that it is rectangle and not is Rectangle2D.Double ) to make a change Which generates partial coordinates. It is only painted aliased, because you have specific rendering signal ( RenderingHints.KEY_ANTIALIASING is not set - & gt; RenderingHints.VALUE_ANTIALIAS_ON , and RenderingHints.KEY_STROKE_CONTROL -> RenderingHints.VALUE_STROKE_PURE ) (2) You are subject to changing a point , and forced it To do in the aliased coordinate ( point instead of Point2D.Double ). Then make a rectangle from that point respectively. Clearly, there may be very different things under the hood, and I do not expect to create an integer point vs. creating an aligning graphics reference to get the same result.
(without trial) I think there will be a valid equivalent statement for (1)
g.fill (transformationMatrix.createTransformedShape (new rectangle (0, 0, 1, 1)))
Comments
Post a Comment