@@ -137,31 +137,31 @@ public static Point pixelToPointAsConservativeSize(Point point, int zoom) {
137137
138138	private  static  Point  pixelToPoint (Point  point , int  zoom , RoundingMode  mode ) {
139139		if  (zoom  == 100  || point  == null ) return  point ;
140- 		Point .OfFloat  fPoint  = Point .OfFloat .from (point );
140+ 		Point .OfFloat  floatPoint  = Point .OfFloat .from (point );
141+ 		return  pixelToPoint (new  Point .OfFloat (floatPoint .getX (), floatPoint .getY (), mode ), zoom );
142+ 	}
143+ 
144+ 	private  static  Point .OfFloat  pixelToPoint (Point .OfFloat  point , int  zoom ) {
145+ 		Point .OfFloat  scaledPoint  = point .clone ();
141146		float  scaleFactor  = DPIUtil .getScalingFactor (zoom );
142- 		float   scaledX  =  fPoint . getX () / scaleFactor ;
143- 		float   scaledY  =  fPoint . getY () / scaleFactor ;
144- 		return  new   Point . OfFloat ( scaledX ,  scaledY ,  mode ) ;
147+ 		scaledPoint . setX ( point . getX () / scaleFactor ) ;
148+ 		scaledPoint . setY ( point . getY () / scaleFactor ) ;
149+ 		return  scaledPoint ;
145150	}
146151
147152	public  static  Rectangle  pixelToPoint (Rectangle  rect , int  zoom ) {
148153		if  (zoom  == 100  || rect  == null ) return  rect ;
149- 		if  (rect  instanceof  Rectangle .OfFloat  rectOfFloat ) return  pixelToPoint (rectOfFloat , zoom );
150- 		Rectangle  scaledRect  = new  Rectangle .OfFloat  (0 ,0 ,0 ,0 );
151- 		Point  scaledTopLeft  = pixelToPointAsLocation (new  Point  (rect .x , rect .y ), zoom );
152- 		Point  scaledBottomRight  = pixelToPointAsSize (new  Point  (rect .x  + rect .width , rect .y  + rect .height ), zoom );
153- 
154- 		scaledRect .x  = scaledTopLeft .x ;
155- 		scaledRect .y  = scaledTopLeft .y ;
156- 		scaledRect .width  = scaledBottomRight .x  - scaledTopLeft .x ;
157- 		scaledRect .height  = scaledBottomRight .y  - scaledTopLeft .y ;
154+ 		Rectangle .OfFloat  floatRect  = Rectangle .OfFloat .from (rect );
155+ 		Point .OfFloat  scaledTopLeft  = pixelToPoint (floatRect .getTopLeft (), zoom );
156+ 		Point .OfFloat  scaledBottomRight  = pixelToPoint (floatRect .getBottomRight (), zoom );
157+ 		Rectangle .OfFloat  scaledRect  = floatRect .clone ();
158+ 		scaledRect .setX (scaledTopLeft .getX ());
159+ 		scaledRect .setY (scaledTopLeft .getY ());
160+ 		scaledRect .setWidth (scaledBottomRight .getX () - scaledTopLeft .getX ());
161+ 		scaledRect .setHeight (scaledBottomRight .getY () - scaledTopLeft .getY ());
158162		return  scaledRect ;
159163	}
160164
161- 	private  static  Rectangle  pixelToPoint (Rectangle .OfFloat  rect , int  zoom ) {
162- 		return  scaleBounds (rect , 100 , zoom );
163- 	}
164- 
165165	public  static  Rectangle  pixelToPoint (Drawable  drawable , Rectangle  rect , int  zoom ) {
166166		if  (drawable  != null  && !drawable .isAutoScalable ()) return  rect ;
167167		return  pixelToPoint  (rect , zoom );
@@ -229,11 +229,16 @@ public static float pointToPixel(Drawable drawable, float size, int zoom) {
229229
230230	private  static  Point  pointToPixel (Point  point , int  zoom , RoundingMode  mode ) {
231231		if  (zoom  == 100  || point  == null ) return  point ;
232- 		Point .OfFloat  fPoint  = Point .OfFloat .from (point );
232+ 		Point .OfFloat  floatPoint  = Point .OfFloat .from (point );
233+ 		return  pointToPixel (new  Point .OfFloat (floatPoint .getX (), floatPoint .getY (), mode ), zoom );
234+ 	}
235+ 
236+ 	private  static  Point .OfFloat  pointToPixel (Point .OfFloat  point , int  zoom ) {
237+ 		Point .OfFloat  scaledPoint  = point .clone ();
233238		float  scaleFactor  = DPIUtil .getScalingFactor (zoom );
234- 		float   scaledX  =  fPoint . getX () * scaleFactor ;
235- 		float   scaledY  =  fPoint . getY () * scaleFactor ;
236- 		return  new   Point . OfFloat ( scaledX ,  scaledY ,  mode ) ;
239+ 		scaledPoint . setX ( point . getX () * scaleFactor ) ;
240+ 		scaledPoint . setY ( point . getY () * scaleFactor ) ;
241+ 		return  scaledPoint ;
237242	}
238243
239244	public  static  Point  pointToPixelAsSize (Drawable  drawable , Point  point , int  zoom ) {
@@ -256,22 +261,17 @@ public static Point pointToPixelAsLocation(Point point, int zoom) {
256261
257262	public  static  Rectangle  pointToPixel (Rectangle  rect , int  zoom ) {
258263		if  (zoom  == 100  || rect  == null ) return  rect ;
259- 		if  (rect  instanceof  Rectangle .OfFloat  rectOfFloat ) return  pointToPixel (rectOfFloat , zoom );
260- 		Rectangle  scaledRect  = new  Rectangle .OfFloat (0 ,0 ,0 ,0 );
261- 		Point  scaledTopLeft  = pointToPixelAsLocation  (new  Point (rect .x , rect .y ), zoom );
262- 		Point  scaledBottomRight  = pointToPixelAsLocation  (new  Point (rect .x  + rect .width , rect .y  + rect .height ), zoom );
263- 
264- 		scaledRect .x  = scaledTopLeft .x ;
265- 		scaledRect .y  = scaledTopLeft .y ;
266- 		scaledRect .width  = scaledBottomRight .x  - scaledTopLeft .x ;
267- 		scaledRect .height  = scaledBottomRight .y  - scaledTopLeft .y ;
264+ 		Rectangle .OfFloat  floatRect  = Rectangle .OfFloat .from (rect );
265+ 		Point .OfFloat  scaledTopLeft  = pointToPixel (floatRect .getTopLeft (), zoom );
266+ 		Point .OfFloat  scaledBottomRight  = pointToPixel (floatRect .getBottomRight (), zoom );
267+ 		Rectangle .OfFloat  scaledRect  = floatRect .clone ();
268+ 		scaledRect .setX (scaledTopLeft .getX ());
269+ 		scaledRect .setY (scaledTopLeft .getY ());
270+ 		scaledRect .setWidth (scaledBottomRight .getX () - scaledTopLeft .getX ());
271+ 		scaledRect .setHeight (scaledBottomRight .getY () - scaledTopLeft .getY ());
268272		return  scaledRect ;
269273	}
270274
271- 	private  static  Rectangle  pointToPixel (Rectangle .OfFloat  rect , int  zoom ) {
272- 		return  scaleBounds (rect , zoom , 100 );
273- 	}
274- 
275275	public  static  Rectangle  pointToPixel (Drawable  drawable , Rectangle  rect , int  zoom ) {
276276		if  (drawable  != null  && !drawable .isAutoScalable ()) return  rect ;
277277		return  pointToPixel  (rect , zoom );
0 commit comments