sun.awt.windows.ThemeReader Java Examples

The following examples show how to use sun.awt.windows.ThemeReader. 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: XPStyle.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    boolean accEnabled = false;
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #2
Source File: XPStyle.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #3
Source File: XPStyle.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    boolean accEnabled = false;
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #4
Source File: XPStyle.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;
    w = bi.getWidth();
    h = bi.getHeight();

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #5
Source File: XPStyle.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Get the singleton instance of this class
 *
 * @return the singleton instance of this class or null if XP styles
 * are not active or if this is not Windows XP
 */
static synchronized XPStyle getXP() {
    if (themeActive == null) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        themeActive =
            (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
        if (themeActive == null) {
            themeActive = Boolean.FALSE;
        }
        if (themeActive.booleanValue()) {
            GetPropertyAction propertyAction =
                new GetPropertyAction("swing.noxp");
            if (AccessController.doPrivileged(propertyAction) == null &&
                ThemeReader.isThemed() &&
                !(UIManager.getLookAndFeel()
                  instanceof WindowsClassicLookAndFeel)) {

                xp = new XPStyle();
            }
        }
    }
    return ThemeReader.isXPStyleEnabled() ? xp : null;
}
 
Example #6
Source File: XPStyle.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    boolean accEnabled = false;
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #7
Source File: XPStyle.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #8
Source File: XPStyle.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #9
Source File: XPStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #10
Source File: XPStyle.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Get the singleton instance of this class
 *
 * @return the singleton instance of this class or null if XP styles
 * are not active or if this is not Windows XP
 */
static synchronized XPStyle getXP() {
    if (themeActive == null) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        themeActive =
            (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
        if (themeActive == null) {
            themeActive = Boolean.FALSE;
        }
        if (themeActive.booleanValue()) {
            GetPropertyAction propertyAction =
                new GetPropertyAction("swing.noxp");
            if (AccessController.doPrivileged(propertyAction) == null &&
                ThemeReader.isThemed() &&
                !(UIManager.getLookAndFeel()
                  instanceof WindowsClassicLookAndFeel)) {

                xp = new XPStyle();
            }
        }
    }
    return ThemeReader.isXPStyleEnabled() ? xp : null;
}
 
Example #11
Source File: XPStyle.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #12
Source File: XPStyle.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #13
Source File: XPStyle.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/** Get a named <code>Color</code> value from the current style
 *
 * @param part a <code>Part</code>
 * @return a <code>Color</code> or null if key is not found
 *    in the current style
 */
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
    String key = skin.toString() + "." + prop.name();
    Part part = skin.part;
    Color color = colorMap.get(key);
    if (color == null) {
        color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
                                     State.getValue(part, skin.state),
                                     prop.getValue());
        if (color != null) {
            color = new ColorUIResource(color);
            colorMap.put(key, color);
        }
    }
    return (color != null) ? color : fallback;
}
 
Example #14
Source File: XPStyle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    boolean accEnabled = false;
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #15
Source File: XPStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;
    w = bi.getWidth();
    h = bi.getHeight();

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #16
Source File: XPStyle.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void paintToImage(Component c, Image image, Graphics g,
                            int w, int h, Object[] args) {
    boolean accEnabled = false;
    Skin skin = (Skin)args[0];
    Part part = skin.part;
    State state = (State)args[1];
    if (state == null) {
        state = skin.state;
    }
    if (c == null) {
        c = skin.component;
    }
    BufferedImage bi = (BufferedImage)image;

    WritableRaster raster = bi.getRaster();
    DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
    // Note that stealData() requires a markDirty() afterwards
    // since we modify the data in it.
    ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
                                part.getControlName(c), part.getValue(),
                                State.getValue(part, state),
                                0, 0, w, h, w);
    SunWritableRaster.markDirty(dbi);
}
 
Example #17
Source File: XPStyle.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Paint a skin at a defined position and size
 *  This method supports animation.
 *
 * @param g   the graphics context to use for painting
 * @param dx  the destination <i>x</i> coordinate
 * @param dy  the destination <i>y</i> coordinate
 * @param dw  the width of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param dh  the height of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param state which state to paint
 */
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
    if (XPStyle.getXP() == null) {
        return;
    }
    if (ThemeReader.isGetThemeTransitionDurationDefined()
          && component instanceof JComponent
          && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
                                               component) == null) {
        AnimationController.paintSkin((JComponent) component, this,
                                      g, dx, dy, dw, dh, state);
    } else {
        paintSkinRaw(g, dx, dy, dw, dh, state);
    }
}
 
Example #18
Source File: XPStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Paint a skin at a defined position and size
 *  This method supports animation.
 *
 * @param g   the graphics context to use for painting
 * @param dx  the destination <i>x</i> coordinate
 * @param dy  the destination <i>y</i> coordinate
 * @param dw  the width of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param dh  the height of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param state which state to paint
 */
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
    if (XPStyle.getXP() == null) {
        return;
    }
    if (ThemeReader.isGetThemeTransitionDurationDefined()
          && component instanceof JComponent
          && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
                                               component) == null) {
        AnimationController.paintSkin((JComponent) component, this,
                                      g, dx, dy, dw, dh, state);
    } else {
        paintSkinRaw(g, dx, dy, dw, dh, state);
    }
}
 
Example #19
Source File: XPStyle.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
Insets getContentMargin() {
    /* idk: it seems margins are the same for all 'big enough'
     * bounding rectangles.
     */
    int boundingWidth = 100;
    int boundingHeight = 100;

    Insets insets = ThemeReader.getThemeBackgroundContentMargins(
        part.getControlName(null), part.getValue(),
        0, boundingWidth, boundingHeight);
    return (insets != null) ? insets : new Insets(0, 0, 0, 0);
}
 
Example #20
Source File: XPStyle.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
long getThemeTransitionDuration(Component c, Part part, State stateFrom,
                                State stateTo, Prop prop) {
     return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
                                      part.getValue(),
                                      State.getValue(part, stateFrom),
                                      State.getValue(part, stateTo),
                                      (prop != null) ? prop.getValue() : 0);
}
 
Example #21
Source File: XPStyle.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
long getThemeTransitionDuration(Component c, Part part, State stateFrom,
                                State stateTo, Prop prop) {
     return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
                                      part.getValue(),
                                      State.getValue(part, stateFrom),
                                      State.getValue(part, stateTo),
                                      (prop != null) ? prop.getValue() : 0);
}
 
Example #22
Source File: XPStyle.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** Paint a skin at a defined position and size
 *  This method supports animation.
 *
 * @param g   the graphics context to use for painting
 * @param dx  the destination <i>x</i> coordinate
 * @param dy  the destination <i>y</i> coordinate
 * @param dw  the width of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param dh  the height of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param state which state to paint
 */
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
    if (XPStyle.getXP() == null) {
        return;
    }
    if (ThemeReader.isGetThemeTransitionDurationDefined()
          && component instanceof JComponent
          && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
                                               component) == null) {
        AnimationController.paintSkin((JComponent) component, this,
                                      g, dx, dy, dw, dh, state);
    } else {
        paintSkinRaw(g, dx, dy, dw, dh, state);
    }
}
 
Example #23
Source File: XPStyle.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Insets getContentMargin() {
    /* idk: it seems margins are the same for all 'big enough'
     * bounding rectangles.
     */
    int boundingWidth = 100;
    int boundingHeight = 100;

    Insets insets = ThemeReader.getThemeBackgroundContentMargins(
        part.getControlName(null), part.getValue(),
        0, boundingWidth, boundingHeight);
    return (insets != null) ? insets : new Insets(0, 0, 0, 0);
}
 
Example #24
Source File: XPStyle.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String getTypeEnumName(Component c, Part part, State state, Prop prop) {
    int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
                                        State.getValue(part, state),
                                        prop.getValue());
    if (enumValue == -1) {
        return null;
    }
    return TypeEnum.getTypeEnum(prop, enumValue).getName();
}
 
Example #25
Source File: XPStyle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
long getThemeTransitionDuration(Component c, Part part, State stateFrom,
                                State stateTo, Prop prop) {
     return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
                                      part.getValue(),
                                      State.getValue(part, stateFrom),
                                      State.getValue(part, stateTo),
                                      (prop != null) ? prop.getValue() : 0);
}
 
Example #26
Source File: XPStyle.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Paint a skin at a defined position and size
 *  This method supports animation.
 *
 * @param g   the graphics context to use for painting
 * @param dx  the destination <i>x</i> coordinate
 * @param dy  the destination <i>y</i> coordinate
 * @param dw  the width of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param dh  the height of the area to fill, may cause
 *                  the image to be stretched or tiled
 * @param state which state to paint
 */
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
    if (XPStyle.getXP() == null) {
        return;
    }
    if (ThemeReader.isGetThemeTransitionDurationDefined()
          && component instanceof JComponent
          && SwingUtilities.getAncestorOfClass(CellRendererPane.class,
                                               component) == null) {
        AnimationController.paintSkin((JComponent) component, this,
                                      g, dx, dy, dw, dh, state);
    } else {
        paintSkinRaw(g, dx, dy, dw, dh, state);
    }
}
 
Example #27
Source File: XPStyle.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Insets getContentMargin() {
    /* idk: it seems margins are the same for all 'big enough'
     * bounding rectangles.
     */
    int boundingWidth = 100;
    int boundingHeight = 100;

    Insets insets = ThemeReader.getThemeBackgroundContentMargins(
        part.getControlName(null), part.getValue(),
        0, boundingWidth, boundingHeight);
    return (insets != null) ? insets : new Insets(0, 0, 0, 0);
}
 
Example #28
Source File: XPStyle.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String getTypeEnumName(Component c, Part part, State state, Prop prop) {
    int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
                                        State.getValue(part, state),
                                        prop.getValue());
    if (enumValue == -1) {
        return null;
    }
    return TypeEnum.getTypeEnum(prop, enumValue).getName();
}
 
Example #29
Source File: XPStyle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
Insets getContentMargin() {
    /* idk: it seems margins are the same for all 'big enough'
     * bounding rectangles.
     */
    int boundingWidth = 100;
    int boundingHeight = 100;

    Insets insets = ThemeReader.getThemeBackgroundContentMargins(
        part.getControlName(null), part.getValue(),
        0, boundingWidth, boundingHeight);
    return (insets != null) ? insets : new Insets(0, 0, 0, 0);
}
 
Example #30
Source File: XPStyle.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
long getThemeTransitionDuration(Component c, Part part, State stateFrom,
                                State stateTo, Prop prop) {
     return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
                                      part.getValue(),
                                      State.getValue(part, stateFrom),
                                      State.getValue(part, stateTo),
                                      (prop != null) ? prop.getValue() : 0);
}