1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.swing.interop; 27 28 import java.awt.Component; 29 import java.awt.dnd.DragGestureRecognizer; 30 import java.awt.dnd.DragGestureListener; 31 import java.awt.dnd.DragSource; 32 import java.awt.dnd.DragGestureEvent; 33 import java.awt.dnd.InvalidDnDOperationException; 34 import java.awt.dnd.peer.DragSourceContextPeer; 35 import java.awt.dnd.DropTarget; 36 import javax.swing.JComponent; 37 import sun.swing.LightweightContent; 38 39 /** 40 * This class provides a wrapper over inner LightweightContentProxy class 41 * which implements jdk internal sun.swing.LightweightContent interface 42 * and provides APIs to be used by FX swing interop to access and use LightweightContent APIs. 43 */ 44 public class LightweightContentWrapper { 45 private LightweightContentProxy lwCnt; 46 47 public LightweightContentWrapper() { 48 lwCnt = new LightweightContentProxy(); 49 } 50 51 LightweightContentProxy getContent() { 52 return lwCnt; 53 } 54 55 public void imageBufferReset(int[] data, int x, int y, int width, 56 int height, int linestride) {} 57 58 public void imageBufferReset(int[] data, int x, int y, int width, int height, 59 int linestride, double scaleX, double scaleY) {} 60 61 public JComponent getComponent() { 62 return null; 63 } 64 65 public void paintLock() {} 66 67 public void paintUnlock() {} 68 69 public void imageReshaped(int x, int y, int width, int height) {} 70 71 public void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth, int dirtyHeight) {} 72 73 public void focusGrabbed() {} 74 75 public void focusUngrabbed() {} 76 77 public void preferredSizeChanged(int width, int height) {} 78 79 public void maximumSizeChanged(int width, int height) {} 80 81 public void minimumSizeChanged(int width, int height) {} 82 83 public <T extends DragGestureRecognizer> T createDragGestureRecognizer( 84 Class<T> abstractRecognizerClass, 85 DragSource ds, Component c, int srcActions, 86 DragGestureListener dgl) 87 { 88 return null; 89 } 90 91 public DragSourceContextWrapper createDragSourceContextPeer(DragGestureEvent dge) 92 throws InvalidDnDOperationException { 93 return null; 94 } 95 96 public void addDropTarget(DropTarget dt) { } 97 98 public void removeDropTarget(DropTarget dt) { } 99 100 private class LightweightContentProxy implements LightweightContent { 101 102 public JComponent getComponent() { 103 return LightweightContentWrapper.this.getComponent(); 104 } 105 106 public void paintLock() { 107 LightweightContentWrapper.this.paintLock(); 108 } 109 110 public void paintUnlock() { 111 LightweightContentWrapper.this.paintUnlock(); 112 } 113 114 public void imageBufferReset(int[] data, int x, int y, int width, int height, 115 int linestride) { 116 LightweightContentWrapper.this.imageBufferReset(data, x, y, width, 117 height, linestride); 118 } 119 120 public void imageBufferReset(int[] data, int x, int y, int width, int height, 121 int linestride, double scaleX, double scaleY) { 122 LightweightContentWrapper.this.imageBufferReset(data, x, y, width, height, 123 linestride, scaleX, scaleY); 124 } 125 126 public void imageReshaped(int x, int y, int width, int height) { 127 LightweightContentWrapper.this.imageReshaped(x, y, width, height); 128 } 129 130 public void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth, int dirtyHeight) { 131 LightweightContentWrapper.this.imageUpdated(dirtyX, dirtyY, dirtyWidth, dirtyHeight); 132 } 133 134 public void focusGrabbed() { 135 LightweightContentWrapper.this.focusGrabbed(); 136 } 137 138 public void focusUngrabbed() { 139 LightweightContentWrapper.this.focusUngrabbed(); 140 } 141 142 public void preferredSizeChanged(int width, int height) { 143 LightweightContentWrapper.this.preferredSizeChanged(width, height); 144 } 145 146 public void maximumSizeChanged(int width, int height) { 147 LightweightContentWrapper.this.maximumSizeChanged(width, height); 148 } 149 150 public void minimumSizeChanged(int width, int height) { 151 LightweightContentWrapper.this.minimumSizeChanged(width, height); 152 } 153 154 public <T extends DragGestureRecognizer> T createDragGestureRecognizer( 155 Class<T> abstractRecognizerClass, 156 DragSource ds, Component c, int srcActions, 157 DragGestureListener dgl) { 158 return LightweightContentWrapper.this.createDragGestureRecognizer( 159 abstractRecognizerClass, ds, c, srcActions, dgl); 160 } 161 162 public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) 163 throws InvalidDnDOperationException { 164 DragSourceContextWrapper peerWrapper = 165 LightweightContentWrapper.this.createDragSourceContextPeer(dge); 166 return peerWrapper.getPeer(); 167 } 168 169 public void addDropTarget(DropTarget dt) { 170 LightweightContentWrapper.this.addDropTarget(dt); 171 } 172 173 public void removeDropTarget(DropTarget dt) { 174 LightweightContentWrapper.this.removeDropTarget(dt); 175 } 176 } 177 }