Java Code Examples for com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection

The following examples show how to use com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection. These examples are extracted from open source projects. 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 Project: jdk1.8-source-analysis   Source File: UNIXToolkit.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
            TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: GTKEngine.java    License: Apache License 2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 3
Source Project: dragonwell8_jdk   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 4
Source Project: dragonwell8_jdk   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 5
Source Project: TencentKona-8   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 6
Source Project: TencentKona-8   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 7
Source Project: jdk8u60   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 8
Source Project: jdk8u60   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 9
Source Project: JDKSourceCode1.8   Source File: UNIXToolkit.java    License: MIT License 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
            TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 10
Source Project: JDKSourceCode1.8   Source File: GTKEngine.java    License: MIT License 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 11
Source Project: openjdk-jdk8u   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 12
Source Project: openjdk-jdk8u   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 13
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 14
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 15
Source Project: Bytecoder   Source File: GTKEngine.java    License: Apache License 2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 16
Source Project: openjdk-jdk9   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 17
Source Project: openjdk-jdk9   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. {@code "gtk.icon.gtk-add.4.rtl"}
 * @return an {@code Image} for the icon, or {@code null} if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 18
Source Project: jdk8u-jdk   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 19
Source Project: jdk8u-jdk   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 20
Source Project: hottub   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 21
Source Project: hottub   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 22
Source Project: openjdk-8-source   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 23
Source Project: openjdk-8-source   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 24
Source Project: openjdk-8   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 25
Source Project: openjdk-8   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 26
Source Project: jdk8u_jdk   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 27
Source Project: jdk8u_jdk   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 28
Source Project: jdk8u-jdk   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}
 
Example 29
Source Project: jdk8u-jdk   Source File: UNIXToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Load a native Gtk stock icon.
 *
 * @param longname a desktop property name. This contains icon name, size
 *        and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
 * @return an <code>Image</code> for the icon, or <code>null</code> if the
 *         icon could not be loaded
 */
protected Object lazilyLoadGTKIcon(String longname) {
    // Check if we have already loaded it.
    Object result = desktopProperties.get(longname);
    if (result != null) {
        return result;
    }

    // We need to have at least gtk.icon.<stock_id>.<size>.<orientation>
    String str[] = longname.split("\\.");
    if (str.length != 5) {
        return null;
    }

    // Parse out the stock icon size we are looking for.
    int size = 0;
    try {
        size = Integer.parseInt(str[3]);
    } catch (NumberFormatException nfe) {
        return null;
    }

    // Direction.
    TextDirection dir = ("ltr".equals(str[4]) ? TextDirection.LTR :
                                                TextDirection.RTL);

    // Load the stock icon.
    BufferedImage img = getStockIcon(-1, str[2], size, dir.ordinal(), null);
    if (img != null) {
        // Create the desktop property for the icon.
        setDesktopProperty(longname, img);
    }
    return img;
}
 
Example 30
Source Project: jdk8u-dev-jdk   Source File: GTKEngine.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static int getTextDirection(SynthContext context) {
    TextDirection dir = TextDirection.NONE;
    JComponent comp = context.getComponent();
    if (comp != null) {
        ComponentOrientation co = comp.getComponentOrientation();
        if (co != null) {
            dir = co.isLeftToRight() ?
                TextDirection.LTR : TextDirection.RTL;
        }
    }
    return dir.ordinal();
}