Java 类javax.swing.plaf.ColorUIResource 实例源码

项目:jdk8u-jdk    文件:GTKColorType.java   
/**
 * Creates and returns a new color derived from the passed in color.
 * The transformation is done in the HLS color space using the specified
 * arguments to scale.
 *
 * @param color Color to alter
 * @param hFactory Amount to scale the hue
 * @param lFactor Amount to scale the lightness
 * @param sFactory Amount to sacle saturation
 * @return newly created color
 */
static Color adjustColor(Color color, float hFactor, float lFactor,
                         float sFactor) {
    float h;
    float l;
    float s;

    synchronized(HLS_COLOR_LOCK) {
        float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS);
        h = hls[0];
        l = hls[1];
        s = hls[2];
    }
    h = Math.min(360, hFactor * h);
    l = Math.min(1, lFactor * l);
    s = Math.min(1, sFactor * s);
    return new ColorUIResource(hlsToRGB(h, l, s));
}
项目:openjdk-jdk10    文件:GTKColorType.java   
/**
 * Creates and returns a new color derived from the passed in color.
 * The transformation is done in the HLS color space using the specified
 * arguments to scale.
 *
 * @param color Color to alter
 * @param hFactor Amount to scale the hue
 * @param lFactor Amount to scale the lightness
 * @param sFactor Amount to sacle saturation
 * @return newly created color
 */
static Color adjustColor(Color color, float hFactor, float lFactor,
                         float sFactor) {
    float h;
    float l;
    float s;

    synchronized(HLS_COLOR_LOCK) {
        float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS);
        h = hls[0];
        l = hls[1];
        s = hls[2];
    }
    h = Math.min(360, hFactor * h);
    l = Math.min(1, lFactor * l);
    s = Math.min(1, sFactor * s);
    return new ColorUIResource(hlsToRGB(h, l, s));
}
项目:jdk8u-jdk    文件:ColorCustomizationTest.java   
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
项目:jdk8u-jdk    文件:PropertiesMetalTheme.java   
/**
 * parse a comma delimited list of 3 strings into a Color
 */
private ColorUIResource parseColor(String s) {
    int red = 0;
    int green = 0;
    int blue = 0;
    try {
        StringTokenizer st = new StringTokenizer(s, ",");

        red = Integer.parseInt(st.nextToken());
        green = Integer.parseInt(st.nextToken());
        blue = Integer.parseInt(st.nextToken());

    } catch (Exception e) {
        System.out.println(e);
        System.out.println("Couldn't parse color :" + s);
    }

    return new ColorUIResource(red, green, blue);
}
项目:openjdk-jdk10    文件:WrongBackgroundColor.java   
public static void main(final String[] args)
        throws InvocationTargetException, InterruptedException {
    SwingUtilities.invokeAndWait(() -> {
        UIDefaults ui = UIManager.getDefaults();
        ui.put("control", new ColorUIResource(54, 54, 54));
        final JDialog dialog = new JDialog();
        final JFrame frame = new JFrame();
        frame.pack();
        dialog.pack();
        final Color dialogBackground = dialog.getBackground();
        final Color frameBackground = frame.getBackground();
        frame.dispose();
        dialog.dispose();
        if (!dialogBackground.equals(frameBackground)) {
            System.err.println("Expected:" + frameBackground);
            System.err.println("Actual:" + dialogBackground);
            throw new RuntimeException("Wrong background color");
        }
    });
}
项目:OpenJSharp    文件:PropertiesMetalTheme.java   
/**
 * parse a comma delimited list of 3 strings into a Color
 */
private ColorUIResource parseColor(String s) {
    int red = 0;
    int green = 0;
    int blue = 0;
    try {
        StringTokenizer st = new StringTokenizer(s, ",");

        red = Integer.parseInt(st.nextToken());
        green = Integer.parseInt(st.nextToken());
        blue = Integer.parseInt(st.nextToken());

    } catch (Exception e) {
        System.out.println(e);
        System.out.println("Couldn't parse color :" + s);
    }

    return new ColorUIResource(red, green, blue);
}
项目:openjdk-jdk10    文件:PropertiesMetalTheme.java   
/**
 * parse a comma delimited list of 3 strings into a Color
 */
private ColorUIResource parseColor(String s) {
    int red = 0;
    int green = 0;
    int blue = 0;
    try {
        StringTokenizer st = new StringTokenizer(s, ",");

        red = Integer.parseInt(st.nextToken());
        green = Integer.parseInt(st.nextToken());
        blue = Integer.parseInt(st.nextToken());

    } catch (Exception e) {
        System.out.println(e);
        System.out.println("Couldn't parse color :" + s);
    }

    return new ColorUIResource(red, green, blue);
}
项目:openjdk-jdk10    文件:ColorCustomizationTest.java   
void testNames() {
    Color defaultColor = label.getBackground();

    UIManager.put("\"BlueLabel\"[Enabled].background",
            new ColorUIResource(Color.BLUE));
    UIManager.put("\"RedLabel\"[Enabled].background",
            new ColorUIResource(Color.RED));
    nimbus.register(Region.LABEL, "\"BlueLabel\"");
    nimbus.register(Region.LABEL, "\"RedLabel\"");

    label.setName("BlueLabel");
    check(Color.BLUE);
    label.setName("RedLabel");
    check(Color.RED);

    // remove name, color goes back to default
    label.setName(null);
    check(defaultColor);
}
项目:incubator-netbeans    文件:VistaLFCustoms.java   
/**
 * Takes a UIManager color key and ensures that it is stored as a 
 * ColorUIResource, not a Color. 
 */
private static void convert (String key) {
    Color c = UIManager.getColor(key);
    if (c != null && !(c instanceof ColorUIResource)) {
        UIManager.put (key, new ColorUIResource(c));
    }
}
项目:rapidminer    文件:Item.java   
public static void updateVirtualItemForTheme(Colors currentTheme) {
    if (currentTheme == null) {
        selectedThumbBorder = BorderFactory.createLineBorder(new ColorUIResource(122, 170, 233), 2);
    } else {
        selectedThumbBorder = BorderFactory.createLineBorder(currentTheme.getFileChooserColors()[1], 2);
    }
}
项目:rapidminer    文件:SplitPaneBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    g.translate(x, y);
    g.setColor(new ColorUIResource(90, 90, 90));
    g.drawLine(0, 0, w - 1, 0);
    g.drawLine(0, 0, 0, h - 1);
    g.setColor(new ColorUIResource(255, 255, 255));
    g.drawLine(w - 1, 1, w - 1, h - 1);
    g.drawLine(1, h - 1, w - 1, h - 1);
    g.translate(-x, -y);
}
项目:rapidminer    文件:ScrollPaneBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    g.translate(x, y);
    g.setColor(new ColorUIResource(190, 190, 190));
    g.drawLine(0, 0, w - 1, 0);
    g.drawLine(0, 0, 0, h - 1);
    g.setColor(new ColorUIResource(220, 220, 220));
    g.drawLine(w - 1, 1, w - 1, h - 1);
    g.drawLine(1, h - 1, w - 1, h - 1);
    g.translate(-x, -y);
}
项目:rapidminer    文件:MenuBarBorder.java   
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    g.translate(x, y);
    g.setColor(new ColorUIResource(220, 220, 220));
    g.drawLine(0, 0, w, 0);
    g.drawLine(0, h - 1, w, h - 1);
    g.setColor(new ColorUIResource(200, 200, 200));
    g.drawLine(0, 1, w, 1);
    g.drawLine(0, h - 2, w, h - 2);
    g.translate(-x, -y);
}
项目:rapidminer    文件:MenuBarBackgroundPainter.java   
@Override
protected void paintToImage(Component c, Graphics g, int w, int h, Object[] args) {
    g.setColor(new ColorUIResource(252, 252, 252));
    g.fillRect(0, 0, w, 3);

    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(new GradientPaint(0, 3, new ColorUIResource(252, 252, 252), 0, h - 3, new ColorUIResource(232, 232, 232)));
    g2.fillRect(0, 3, w, h - 3);
}
项目:TransparentDiscord    文件:TransparentDiscord.java   
private static void configureUI() {
    UIManager.put("ScrollBarUI", "com.transparentdiscord.UI.Custom.CustomScrollBarUI");

    System.setProperty("awt.useSystemAAFontSettings", "on");
    System.setProperty("swing.aatext", "true");

    UIManager.put("ScrollBar.width", 4);
    UIManager.put("ScrollBar.track", new ColorUIResource(new Color(0,0,0,0)));
    UIManager.put("ScrollBar.thumb", new ColorUIResource(Color.decode("#99AAB5")));
    UIManager.put("ScrollBar.thumbDarkShadow", new ColorUIResource(Color.decode("#99AAB5")));
    UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(Color.decode("#99AAB5")));
    UIManager.put("ScrollBar.thumbHighlight", new ColorUIResource(Color.decode("#99AAB5")));
}
项目:xdman    文件:XDMTheme.java   
public void addCustomEntriesToTable(UIDefaults table) {
    super.addCustomEntriesToTable(table);
    // table.put("Button.gradient", Arrays.asList(new Object[] {
    // new Float(.3f), new Float(0f), new ColorUIResource(light_gray),// new
    // // ColorUIResource(0xDDE8F3),
    // new ColorUIResource(new Color(245,245,245)), getSecondary2() }));

    // Color cccccc = new ColorUIResource(0xCCCCCC);
    Color dadada = new ColorUIResource(0xDADADA);
    // Color c8ddf2 = new ColorUIResource(0xC8DDF2);

    List<Object> buttonGradient = Arrays.asList(new Object[] {
            new Float(1f), new Float(0f), getWhite(), dadada,
            new ColorUIResource(dadada) });
    // Arrays.asList(new Object[] {
    // new Float(.3f),
    // new Float(0f),
    // new ColorUIResource(new Color(230, 230, 230)),// new
    // // ColorUIResource(0xDDE8F3),
    // new ColorUIResource(new Color(235, 235, 235)),
    // new ColorUIResource(new Color(180, 180, 180)) });
    table.put("Button.gradient", buttonGradient);

    table.put("ScrollBar.gradient", buttonGradient);

    table.put("RadioButton.gradient", buttonGradient);
    table.put("RadioButtonMenuItem.gradient", buttonGradient);
    // table.put("ScrollBar.gradient", buttonGradient);

    //      
    // table.put("Button.gradient", Arrays.asList(new Object[] {
    // new Float(.3f), new Float(0f), new ColorUIResource(Color.black),//
    // new
    // // ColorUIResource(0xDDE8F3),
    // getWhite(), getSecondary2() }));
    // // System.out.println(table.get("Button.gradient"));
}
项目:openjdk-jdk10    文件:ColorCustomizationTest.java   
void testInheritance() {
    Color defaultColor = label.getBackground();

    // more specific setting is in global defaults
    UIManager.put("Label[Enabled].background", new ColorUIResource(Color.RED));

    // less specific one is in overrides
    UIDefaults defs = new UIDefaults();
    defs.put("Label.background", new ColorUIResource(Color.GREEN));

    // global wins
    label.putClientProperty("Nimbus.Overrides", defs);
    check(Color.RED);

    // now override wins
    label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    check(Color.GREEN);

    // global is back
    label.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    check(Color.RED);

    // back to default color
    UIManager.put("Label[Enabled].background", null);
    label.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    label.putClientProperty("Nimbus.Overrides", null);
    check(defaultColor);
}
项目:openjdk-jdk10    文件:PropertiesMetalTheme.java   
@Override
protected ColorUIResource getPrimary3() {
    return primary3;
}
项目:jdk8u-jdk    文件:PropertiesMetalTheme.java   
@Override
protected ColorUIResource getSecondary2() {
    return secondary2;
}
项目:rapidminer    文件:Colors.java   
public ColorUIResource getCommonBackground() {
    return PANEL_BACKGROUND;
}
项目:rapidminer    文件:Colors.java   
public ColorUIResource[] getTabbedPaneColors() {
    return this.tabbedPaneColors;
}
项目:jdk8u-jdk    文件:ContrastMetalTheme.java   
@Override
public ColorUIResource getAcceleratorForeground() {
    return getBlack();
}
项目:rapidminer    文件:Colors.java   
public ColorUIResource getDesktopBackgroundColor() {
    return this.desktopBackgroundColor;
}
项目:rapidminer    文件:RapidLookAndFeel.java   
@Override
protected void initSystemColorDefaults(UIDefaults table) {
    Object[] systemColors = { "desktop",
            getDesktopColor(), /* Color of the desktop background */
            "activeCaption", getWindowTitleBackground(),
            /* Color for captions (title bars) when they are active. */
            "activeCaptionText", getWindowTitleForeground(),
            /* Text color for text in captions (title bars). */
            "activeCaptionBorder", getPrimaryControlShadow(),
            /* Border color for caption (title bar) window borders. */
            "inactiveCaption", getWindowTitleBackground(),
            /* Color for captions (title bars) when not active. */
            "inactiveCaptionText", getWindowTitleForeground(),
            /* Text color for text in inactive captions (title bars). */
            "inactiveCaptionBorder", getControlShadow(),
            /* Border color for inactive caption (title bar) window borders. */
            "window", Colors.WINDOW_BACKGROUND,  // getWindowBackground(), /* Default color for
            // the interior of windows */

            "windowBorder", getColors().getCommonBackground(), /* ??? */
            "windowText", getUserTextColor(), /* ??? */
            "menu", getMenuBackground(), /* Background color for menus */
            "menuText", getMenuForeground(), /* Text color for menus */
            "text", getTextBackground(), "textText", getUserTextColor(), "textHighlight", getTextHighlightColor(),
            "textHighlightText", Colors.TEXT_HIGHLIGHT_FOREGROUND, "textInactiveText", getInactiveSystemTextColor(),
            "control", getColors().getCommonBackground(), "controlText",
            getControlTextColor(), /*
                                     * Default color for text in controls
                                     */
            "controlHighlight", getControlHighlight(),
            /* Specular highlight (opposite of the shadow) */
            "controlLtHighlight", getControlHighlight(), /* Highlight color for controls */
            "controlShadow", getControlShadow(), /* Shadow color for controls */
            "controlDkShadow", getControlDarkShadow(), /* Dark shadow color for controls */
            "scrollbar", getColors().getCommonBackground(),
            /* Scrollbar background (usually the "track") */
            "info", new ColorUIResource(252, 252, 252), /* ToolTip Background */
            // "infoText", /* ToolTip Text */
    };

    for (int i = 0; i < systemColors.length; i += 2) {
        table.put(systemColors[i], systemColors[i + 1]);
    }
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getDesktopColor() {
    return new ColorUIResource(0, 0, 0);
}
项目:openjdk-jdk10    文件:ContrastMetalTheme.java   
@Override
protected ColorUIResource getPrimary1() {
    return primary1;
}
项目:openjdk-jdk10    文件:ContrastMetalTheme.java   
@Override
public ColorUIResource getAcceleratorForeground() {
    return getBlack();
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getControlHighlight() {
    return new ColorUIResource(255, 255, 255);
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getPrimaryControlDarkShadow() {
    return new ColorUIResource(70, 70, 70);
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getPrimaryControlHighlight() {
    return new ColorUIResource(255, 255, 255);
}
项目:openjdk-jdk10    文件:AquaMetalTheme.java   
@Override
protected ColorUIResource getPrimary3() {
    return primary3;
}
项目:openjdk-jdk10    文件:GreenMetalTheme.java   
@Override
protected ColorUIResource getPrimary3() {
    return primary3;
}
项目:xdman    文件:XDMTheme.java   
@Override
protected ColorUIResource getSecondary3() {
    return sc3;
}
项目:jdk8u-jdk    文件:ContrastMetalTheme.java   
@Override
public ColorUIResource getMenuSelectedForeground() {
    return getWhite();
}
项目:openjdk-jdk10    文件:PropertiesMetalTheme.java   
@Override
protected ColorUIResource getBlack() {
    return black;
}
项目:jdk8u-jdk    文件:KhakiMetalTheme.java   
@Override
protected ColorUIResource getPrimary1() {
    return primary1;
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getWindowTitleBackground() {
    return new ColorUIResource(220, 225, 230);
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getWindowTitleForeground() {
    return new ColorUIResource(255, 255, 255);
}
项目:rapidminer    文件:RapidLookAndFeel.java   
public static ColorUIResource getMenuBackground() {
    return new ColorUIResource(250, 250, 250);
}
项目:openjdk-jdk10    文件:KhakiMetalTheme.java   
@Override
protected ColorUIResource getPrimary1() {
    return primary1;
}