@@ -598,17 +598,32 @@ private static final long setupCursorFromStyle(int style) {
598
598
}
599
599
}
600
600
601
- private static class ImageDataProviderCursorHandleProvider implements CursorHandleProvider {
602
- private final ImageDataProvider provider ;
601
+ private static abstract class HotspotAwareCursorHandleProvider implements CursorHandleProvider {
603
602
private final int hotspotX ;
604
603
private final int hotspotY ;
605
604
606
- public ImageDataProviderCursorHandleProvider (ImageDataProvider provider , int hotspotX , int hotspotY ) {
607
- this .provider = provider ;
605
+ public HotspotAwareCursorHandleProvider (int hotspotX , int hotspotY ) {
608
606
this .hotspotX = hotspotX ;
609
607
this .hotspotY = hotspotY ;
610
608
}
611
609
610
+ protected final int getHotpotXInPixels (int zoom ) {
611
+ return Win32DPIUtils .pointToPixel (hotspotX , zoom );
612
+ }
613
+
614
+ protected final int getHotpotYInPixels (int zoom ) {
615
+ return Win32DPIUtils .pointToPixel (hotspotY , zoom );
616
+ }
617
+ }
618
+
619
+ private static class ImageDataProviderCursorHandleProvider extends HotspotAwareCursorHandleProvider {
620
+ private final ImageDataProvider provider ;
621
+
622
+ public ImageDataProviderCursorHandleProvider (ImageDataProvider provider , int hotspotX , int hotspotY ) {
623
+ super (hotspotX , hotspotY );
624
+ this .provider = provider ;
625
+ }
626
+
612
627
@ Override
613
628
public long createHandle (Cursor cursor , int zoom ) {
614
629
ImageData source ;
@@ -619,36 +634,31 @@ public long createHandle(Cursor cursor, int zoom) {
619
634
source = tempImage .getImageData (zoom );
620
635
tempImage .dispose ();
621
636
}
622
- int hotspotXInPixels = Win32DPIUtils .pointToPixel (hotspotX , zoom );
623
- int hotspotYInPixels = Win32DPIUtils .pointToPixel (hotspotY , zoom );
624
- return setupCursorFromImageData (cursor .device , source , hotspotXInPixels , hotspotYInPixels );
637
+ return setupCursorFromImageData (cursor .device , source , getHotpotXInPixels (zoom ), getHotpotYInPixels (zoom ));
625
638
}
626
639
}
627
640
628
- private static class ImageDataCursorHandleProvider implements CursorHandleProvider {
641
+ private static class ImageDataCursorHandleProvider extends HotspotAwareCursorHandleProvider {
629
642
private final ImageData source ;
630
643
private final ImageData mask ;
631
- private final int hotspotX ;
632
- private final int hotspotY ;
633
644
634
645
public ImageDataCursorHandleProvider (ImageData source , ImageData mask , int hotspotX , int hotspotY ) {
646
+ super (hotspotX , hotspotY );
635
647
this .source = source ;
636
648
this .mask = mask ;
637
- this .hotspotX = hotspotX ;
638
- this .hotspotY = hotspotY ;
639
649
}
640
650
641
651
@ Override
642
652
public long createHandle (Cursor cursor , int zoom ) {
643
653
ImageData scaledSource = DPIUtil .scaleImageData (cursor .device , this .source , zoom , DEFAULT_ZOOM );
644
- int hotspotXInPixels = Win32DPIUtils .pointToPixel (hotspotX , zoom );
645
- int hotspotYInPixels = Win32DPIUtils .pointToPixel (hotspotY , zoom );
646
654
if (cursor .isIcon ) {
647
- return setupCursorFromImageData (cursor .device , scaledSource , hotspotXInPixels , hotspotYInPixels );
655
+ return setupCursorFromImageData (cursor .device , scaledSource , getHotpotXInPixels (zoom ),
656
+ getHotpotYInPixels (zoom ));
648
657
} else {
649
658
ImageData scaledMask = this .mask != null ? DPIUtil .scaleImageData (cursor .device , mask , zoom , DEFAULT_ZOOM )
650
659
: null ;
651
- return setupCursorFromImageData (scaledSource , scaledMask , hotspotXInPixels , hotspotYInPixels );
660
+ return setupCursorFromImageData (scaledSource , scaledMask , getHotpotXInPixels (zoom ),
661
+ getHotpotYInPixels (zoom ));
652
662
}
653
663
}
654
664
}
0 commit comments