Java Code Examples for java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap()
The following examples show how to use
java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropTarget.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Creates a new DropTarget given the <code>Component</code> * to associate itself with, an <code>int</code> representing * the default acceptable action(s) to * support, a <code>DropTargetListener</code> * to handle event processing, a <code>boolean</code> indicating * if the <code>DropTarget</code> is currently accepting drops, and * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>). * <P> * The Component will receive drops only if it is enabled. * @param c The <code>Component</code> with which this <code>DropTarget</code> is associated * @param ops The default acceptable actions for this <code>DropTarget</code> * @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code> * @param act Is the <code>DropTarget</code> accepting drops. * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } component = c; setDefaultActions(ops); if (dtl != null) try { addDropTargetListener(dtl); } catch (TooManyListenersException tmle) { // do nothing! } if (c != null) { c.setDropTarget(this); setActive(act); } if (fm != null) { flavorMap = fm; } else { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } }
Example 2
Source File: SetNativesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void doTest() { flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap(); // Get SystemFlavorMap Maps of String Natives and DataFlavors mapFlavors = flavorMap.getNativesForFlavors(null); mapNatives = flavorMap.getFlavorsForNatives(null); hashFlavors = new Hashtable(mapFlavors); hashNatives = new Hashtable(mapNatives); // Test setFlavorsForNative(String nat, DataFlavors[] flavors); // // Enumerate through all the system defined String natives, // and for each String native, define it again to the SystemFlavorMap // with a slightly modified String native (name). // // For verification, a seperate Hashtable will be maintained of the additions. String key; hashVerify = new Hashtable(); for (Enumeration e = hashNatives.keys() ; e.hasMoreElements() ;) { key = (String)e.nextElement(); java.util.List listFlavors = flavorMap.getFlavorsForNative(key); Vector vectorFlavors = new Vector(listFlavors); DataFlavor[] arrayFlavors = (DataFlavor[])vectorFlavors.toArray(new DataFlavor[0]); key = key.concat("TEST"); // construct a unique String native // define the new String native entry flavorMap.setFlavorsForNative(key, arrayFlavors); // keep track of this new native entry hashVerify.put(key, vectorFlavors); } // After establishing "new" mappings, verify that the defined // DataFlavors can be retrieved and that the List (order) is preserved. verifyNewMappings(); }
Example 3
Source File: DropTarget.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a new DropTarget given the <code>Component</code> * to associate itself with, an <code>int</code> representing * the default acceptable action(s) to * support, a <code>DropTargetListener</code> * to handle event processing, a <code>boolean</code> indicating * if the <code>DropTarget</code> is currently accepting drops, and * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>). * <P> * The Component will receive drops only if it is enabled. * @param c The <code>Component</code> with which this <code>DropTarget</code> is associated * @param ops The default acceptable actions for this <code>DropTarget</code> * @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code> * @param act Is the <code>DropTarget</code> accepting drops. * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } component = c; setDefaultActions(ops); if (dtl != null) try { addDropTargetListener(dtl); } catch (TooManyListenersException tmle) { // do nothing! } if (c != null) { c.setDropTarget(this); setActive(act); } if (fm != null) { flavorMap = fm; } else { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } }
Example 4
Source File: DragSource.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Deserializes this <code>DragSource</code>. This method first performs * default deserialization. Next, this object's <code>FlavorMap</code> is * deserialized by using the next object in the stream. * If the resulting <code>FlavorMap</code> is <code>null</code>, this * object's <code>FlavorMap</code> is set to the default FlavorMap for * this thread's <code>ClassLoader</code>. * Next, this object's listeners are deserialized by reading a * <code>null</code>-terminated sequence of 0 or more key/value pairs * from the stream: * <ul> * <li>If a key object is a <code>String</code> equal to * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is * deserialized using the corresponding value object and added to this * <code>DragSource</code>. * <li>If a key object is a <code>String</code> equal to * <code>dragSourceMotionListenerK</code>, a * <code>DragSourceMotionListener</code> is deserialized using the * corresponding value object and added to this <code>DragSource</code>. * <li>Otherwise, the key/value pair is skipped. * </ul> * * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap * @since 1.4 */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); // 'flavorMap' was written explicitly flavorMap = (FlavorMap)s.readObject(); // Implementation assumes 'flavorMap' is never null. if (flavorMap == null) { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } Object keyOrNull; while (null != (keyOrNull = s.readObject())) { String key = ((String)keyOrNull).intern(); if (dragSourceListenerK == key) { addDragSourceListener((DragSourceListener)(s.readObject())); } else if (dragSourceMotionListenerK == key) { addDragSourceMotionListener( (DragSourceMotionListener)(s.readObject())); } else { // skip value for unrecognized key s.readObject(); } } }
Example 5
Source File: DataFlavorSearcher.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static public DataFlavor getByteDataFlavorForNative(String[] nats) { FlavorTable flavorTable = (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); for (String nat : nats) { java.util.List<DataFlavor> flavors = flavorTable.getFlavorsForNative(nat); for (DataFlavor flavor : flavors) { if (flavor != null && flavor.getRepresentationClass().equals(byte[].class)) { return flavor; } } } throw new RuntimeException("No data flavor was found for natives: " + Arrays.toString(nats)); }
Example 6
Source File: ImageTransferTest.java From hottub with GNU General Public License v2.0 | 5 votes |
static String[] retrieveFormatsToTest() { SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap(); java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor); if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) { // for test failing on JDK without this fix ln.add("METAFILEPICT"); } return ln.toArray(new String[ln.size()]); }
Example 7
Source File: DataFlavorSearcher.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static public DataFlavor getByteDataFlavorForNative(String[] nats) { FlavorTable flavorTable = (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); for (String nat : nats) { java.util.List<DataFlavor> flavors = flavorTable.getFlavorsForNative(nat); for (DataFlavor flavor : flavors) { if (flavor != null && flavor.getRepresentationClass().equals(byte[].class)) { return flavor; } } } throw new RuntimeException("No data flavor was found for natives: " + Arrays.toString(nats)); }
Example 8
Source File: DragSource.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Deserializes this <code>DragSource</code>. This method first performs * default deserialization. Next, this object's <code>FlavorMap</code> is * deserialized by using the next object in the stream. * If the resulting <code>FlavorMap</code> is <code>null</code>, this * object's <code>FlavorMap</code> is set to the default FlavorMap for * this thread's <code>ClassLoader</code>. * Next, this object's listeners are deserialized by reading a * <code>null</code>-terminated sequence of 0 or more key/value pairs * from the stream: * <ul> * <li>If a key object is a <code>String</code> equal to * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is * deserialized using the corresponding value object and added to this * <code>DragSource</code>. * <li>If a key object is a <code>String</code> equal to * <code>dragSourceMotionListenerK</code>, a * <code>DragSourceMotionListener</code> is deserialized using the * corresponding value object and added to this <code>DragSource</code>. * <li>Otherwise, the key/value pair is skipped. * </ul> * * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap * @since 1.4 */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); // 'flavorMap' was written explicitly flavorMap = (FlavorMap)s.readObject(); // Implementation assumes 'flavorMap' is never null. if (flavorMap == null) { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } Object keyOrNull; while (null != (keyOrNull = s.readObject())) { String key = ((String)keyOrNull).intern(); if (dragSourceListenerK == key) { addDragSourceListener((DragSourceListener)(s.readObject())); } else if (dragSourceMotionListenerK == key) { addDragSourceMotionListener( (DragSourceMotionListener)(s.readObject())); } else { // skip value for unrecognized key s.readObject(); } } }
Example 9
Source File: SVGImageExporter.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public SvgClip(@Nonnull final String str) { this.supportedFlavors = new DataFlavor[] { SVG_FLAVOR,}; this.svgContent = str; SystemFlavorMap systemFlavorMap = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap(); DataFlavor dataFlavor = SVG_FLAVOR; systemFlavorMap.addUnencodedNativeForFlavor(dataFlavor, "image/svg+xml"); }
Example 10
Source File: DragSource.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Deserializes this <code>DragSource</code>. This method first performs * default deserialization. Next, this object's <code>FlavorMap</code> is * deserialized by using the next object in the stream. * If the resulting <code>FlavorMap</code> is <code>null</code>, this * object's <code>FlavorMap</code> is set to the default FlavorMap for * this thread's <code>ClassLoader</code>. * Next, this object's listeners are deserialized by reading a * <code>null</code>-terminated sequence of 0 or more key/value pairs * from the stream: * <ul> * <li>If a key object is a <code>String</code> equal to * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is * deserialized using the corresponding value object and added to this * <code>DragSource</code>. * <li>If a key object is a <code>String</code> equal to * <code>dragSourceMotionListenerK</code>, a * <code>DragSourceMotionListener</code> is deserialized using the * corresponding value object and added to this <code>DragSource</code>. * <li>Otherwise, the key/value pair is skipped. * </ul> * * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap * @since 1.4 */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); // 'flavorMap' was written explicitly flavorMap = (FlavorMap)s.readObject(); // Implementation assumes 'flavorMap' is never null. if (flavorMap == null) { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } Object keyOrNull; while (null != (keyOrNull = s.readObject())) { String key = ((String)keyOrNull).intern(); if (dragSourceListenerK == key) { addDragSourceListener((DragSourceListener)(s.readObject())); } else if (dragSourceMotionListenerK == key) { addDragSourceMotionListener( (DragSourceMotionListener)(s.readObject())); } else { // skip value for unrecognized key s.readObject(); } } }
Example 11
Source File: DropTarget.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new DropTarget given the <code>Component</code> * to associate itself with, an <code>int</code> representing * the default acceptable action(s) to * support, a <code>DropTargetListener</code> * to handle event processing, a <code>boolean</code> indicating * if the <code>DropTarget</code> is currently accepting drops, and * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>). * <P> * The Component will receive drops only if it is enabled. * @param c The <code>Component</code> with which this <code>DropTarget</code> is associated * @param ops The default acceptable actions for this <code>DropTarget</code> * @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code> * @param act Is the <code>DropTarget</code> accepting drops. * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } component = c; setDefaultActions(ops); if (dtl != null) try { addDropTargetListener(dtl); } catch (TooManyListenersException tmle) { // do nothing! } if (c != null) { c.setDropTarget(this); setActive(act); } if (fm != null) { flavorMap = fm; } else { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } }
Example 12
Source File: DropTarget.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a new DropTarget given the <code>Component</code> * to associate itself with, an <code>int</code> representing * the default acceptable action(s) to * support, a <code>DropTargetListener</code> * to handle event processing, a <code>boolean</code> indicating * if the <code>DropTarget</code> is currently accepting drops, and * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>). * <P> * The Component will receive drops only if it is enabled. * @param c The <code>Component</code> with which this <code>DropTarget</code> is associated * @param ops The default acceptable actions for this <code>DropTarget</code> * @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code> * @param act Is the <code>DropTarget</code> accepting drops. * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } component = c; setDefaultActions(ops); if (dtl != null) try { addDropTargetListener(dtl); } catch (TooManyListenersException tmle) { // do nothing! } if (c != null) { c.setDropTarget(this); setActive(act); } if (fm != null) { flavorMap = fm; } else { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } }
Example 13
Source File: AddFlavorTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void doTest() throws Exception { flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap(); // Test addFlavorForUnencodedNative(String nat, DataFlavor flav); // // Enumerate through all the system defined String natives, // and for each String native, define it again to the SystemFlavorMap // with a slightly modified String native (name). // // As a list of DataFlavors will be returned for each String native, // the method addFlavorForUnencodedNative will be called for each // DataFlavor in the list. hashVerify = new Hashtable(); for (String key : flavorMap.getFlavorsForNatives(null).keySet()) { Set<DataFlavor> flavorsSet = new HashSet<>(flavorMap.getFlavorsForNative(key)); // construct a unique String native key = key.concat("TEST"); for (DataFlavor element : flavorsSet) { flavorMap.addFlavorForUnencodedNative(key, element); } hashVerify.put(key, new Vector(flavorsSet)); } // Assertions: After establishing "new" mappings, verify that the defined // DataFlavors can be retrieved and that the List is preserved. verifyNewMappings(); }
Example 14
Source File: DropTarget.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Creates a new DropTarget given the <code>Component</code> * to associate itself with, an <code>int</code> representing * the default acceptable action(s) to * support, a <code>DropTargetListener</code> * to handle event processing, a <code>boolean</code> indicating * if the <code>DropTarget</code> is currently accepting drops, and * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>). * <P> * The Component will receive drops only if it is enabled. * @param c The <code>Component</code> with which this <code>DropTarget</code> is associated * @param ops The default acceptable actions for this <code>DropTarget</code> * @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code> * @param act Is the <code>DropTarget</code> accepting drops. * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> * @exception HeadlessException if GraphicsEnvironment.isHeadless() * returns true * @see java.awt.GraphicsEnvironment#isHeadless */ public DropTarget(Component c, int ops, DropTargetListener dtl, boolean act, FlavorMap fm) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } component = c; setDefaultActions(ops); if (dtl != null) try { addDropTargetListener(dtl); } catch (TooManyListenersException tmle) { // do nothing! } if (c != null) { c.setDropTarget(this); setActive(act); } if (fm != null) { flavorMap = fm; } else { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } }
Example 15
Source File: DragSource.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Deserializes this <code>DragSource</code>. This method first performs * default deserialization. Next, this object's <code>FlavorMap</code> is * deserialized by using the next object in the stream. * If the resulting <code>FlavorMap</code> is <code>null</code>, this * object's <code>FlavorMap</code> is set to the default FlavorMap for * this thread's <code>ClassLoader</code>. * Next, this object's listeners are deserialized by reading a * <code>null</code>-terminated sequence of 0 or more key/value pairs * from the stream: * <ul> * <li>If a key object is a <code>String</code> equal to * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is * deserialized using the corresponding value object and added to this * <code>DragSource</code>. * <li>If a key object is a <code>String</code> equal to * <code>dragSourceMotionListenerK</code>, a * <code>DragSourceMotionListener</code> is deserialized using the * corresponding value object and added to this <code>DragSource</code>. * <li>Otherwise, the key/value pair is skipped. * </ul> * * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap * @since 1.4 */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); // 'flavorMap' was written explicitly flavorMap = (FlavorMap)s.readObject(); // Implementation assumes 'flavorMap' is never null. if (flavorMap == null) { flavorMap = SystemFlavorMap.getDefaultFlavorMap(); } Object keyOrNull; while (null != (keyOrNull = s.readObject())) { String key = ((String)keyOrNull).intern(); if (dragSourceListenerK == key) { addDragSourceListener((DragSourceListener)(s.readObject())); } else if (dragSourceMotionListenerK == key) { addDragSourceMotionListener( (DragSourceMotionListener)(s.readObject())); } else { // skip value for unrecognized key s.readObject(); } } }
Example 16
Source File: SunClipboard.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static FlavorTable getDefaultFlavorTable() { return (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); }
Example 17
Source File: DropTarget.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Sets the <code>FlavorMap</code> associated * with this <code>DropTarget</code>. * <P> * @param fm the new <code>FlavorMap</code>, or null to * associate the default FlavorMap with this DropTarget. */ public void setFlavorMap(FlavorMap fm) { flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm; }
Example 18
Source File: DropTarget.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 2 votes |
/** * Sets the <code>FlavorMap</code> associated * with this <code>DropTarget</code>. * <P> * @param fm the new <code>FlavorMap</code>, or null to * associate the default FlavorMap with this DropTarget. */ public void setFlavorMap(FlavorMap fm) { flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm; }
Example 19
Source File: DropTarget.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Sets the <code>FlavorMap</code> associated * with this <code>DropTarget</code>. * <P> * @param fm the new <code>FlavorMap</code>, or null to * associate the default FlavorMap with this DropTarget. */ public void setFlavorMap(FlavorMap fm) { flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm; }
Example 20
Source File: DropTarget.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * Sets the <code>FlavorMap</code> associated * with this <code>DropTarget</code>. * <P> * @param fm the new <code>FlavorMap</code>, or null to * associate the default FlavorMap with this DropTarget. */ public void setFlavorMap(FlavorMap fm) { flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm; }