src/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java

Print this page




  93         InputEvent         triggerEvent = trigger.getTriggerEvent();
  94 
  95         Point dragOrigin = new Point(trigger.getDragOrigin());
  96         int extModifiers = (triggerEvent.getModifiers() | triggerEvent.getModifiersEx());
  97         long timestamp   = triggerEvent.getWhen();
  98         int clickCount   = ((triggerEvent instanceof MouseEvent) ? (((MouseEvent) triggerEvent).getClickCount()) : 1);
  99 
 100         Component component = trigger.getComponent();
 101         // For a lightweight component traverse up the hierarchy to the root
 102         Point loc = component.getLocation();
 103         Component rootComponent = component;
 104         while (!(rootComponent instanceof Window)) {
 105             dragOrigin.translate(loc.x, loc.y);
 106             rootComponent = rootComponent.getParent();
 107             loc = rootComponent.getLocation();
 108         }
 109 
 110         //It sure will be LWComponentPeer instance as rootComponent is a Window
 111         PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
 112         long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);

 113 
 114         // If there isn't any drag image make one of default appearance:
 115         if (fDragImage == null)
 116             this.setDefaultDragImage(component);
 117 
 118         // Get drag image (if any) as BufferedImage and convert that to CImage:
 119         Point dragImageOffset;
 120 
 121         if (fDragImage != null) {
 122             try {
 123                 fDragCImage = CImage.getCreator().createFromImageImmediately(fDragImage);
 124             } catch(Exception e) {
 125                 // image creation may fail for any reason
 126                 throw new InvalidDnDOperationException("Drag image can not be created.");
 127             }
 128             if (fDragCImage == null) {
 129                 throw new InvalidDnDOperationException("Drag image is not ready.");
 130             }
 131 
 132             dragImageOffset = fDragImageOffset;




  93         InputEvent         triggerEvent = trigger.getTriggerEvent();
  94 
  95         Point dragOrigin = new Point(trigger.getDragOrigin());
  96         int extModifiers = (triggerEvent.getModifiers() | triggerEvent.getModifiersEx());
  97         long timestamp   = triggerEvent.getWhen();
  98         int clickCount   = ((triggerEvent instanceof MouseEvent) ? (((MouseEvent) triggerEvent).getClickCount()) : 1);
  99 
 100         Component component = trigger.getComponent();
 101         // For a lightweight component traverse up the hierarchy to the root
 102         Point loc = component.getLocation();
 103         Component rootComponent = component;
 104         while (!(rootComponent instanceof Window)) {
 105             dragOrigin.translate(loc.x, loc.y);
 106             rootComponent = rootComponent.getParent();
 107             loc = rootComponent.getLocation();
 108         }
 109 
 110         //It sure will be LWComponentPeer instance as rootComponent is a Window
 111         PlatformWindow platformWindow = ((LWComponentPeer)rootComponent.getPeer()).getPlatformWindow();
 112         long nativeViewPtr = CPlatformWindow.getNativeViewPtr(platformWindow);
 113         if (nativeViewPtr == 0L) return; // Unsupported
 114 
 115         // If there isn't any drag image make one of default appearance:
 116         if (fDragImage == null)
 117             this.setDefaultDragImage(component);
 118 
 119         // Get drag image (if any) as BufferedImage and convert that to CImage:
 120         Point dragImageOffset;
 121 
 122         if (fDragImage != null) {
 123             try {
 124                 fDragCImage = CImage.getCreator().createFromImageImmediately(fDragImage);
 125             } catch(Exception e) {
 126                 // image creation may fail for any reason
 127                 throw new InvalidDnDOperationException("Drag image can not be created.");
 128             }
 129             if (fDragCImage == null) {
 130                 throw new InvalidDnDOperationException("Drag image is not ready.");
 131             }
 132 
 133             dragImageOffset = fDragImageOffset;