src/demo/share/jfc/Metalworks/PropertiesMetalTheme.java
author ysuenaga
Wed, 13 Nov 2019 10:27:06 +0900
changeset 59045 846fee5ea75e
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233785: Incorrect JDK version is reported in hs_err log Reviewed-by: dholmes, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
10292
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    32
/*
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    33
 * This source code is provided to illustrate the usage of a given feature
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    34
 * or technique and has been deliberately simplified. Additional steps
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    35
 * required for a production-quality application, such as security checks,
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    36
 * input validation and proper error handling, might not be present in
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    37
 * this sample code.
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    38
 */
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    39
ed7db6a12c2a 7067811: Update demo/sample code to state it should not be used for production
nloodin
parents: 8961
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    42
import java.io.IOException;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    43
import java.io.InputStream;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    44
import java.util.Properties;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    45
import java.util.StringTokenizer;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    46
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    47
import javax.swing.plaf.ColorUIResource;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    48
import javax.swing.plaf.metal.DefaultMetalTheme;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    49
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * This class allows you to load a theme from a file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * It uses the standard Java Properties file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * To create a theme you provide a text file which contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * tags corresponding to colors of the theme along with a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * for that color.  For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * name=My Ugly Theme
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * primary1=255,0,0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * primary2=0,255,0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * primary3=0,0,255
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * This class only loads colors from the properties file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * but it could easily be extended to load fonts -  or even icons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @author Steve Wilson
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    67
 * @author Alexander Kouznetsov
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public class PropertiesMetalTheme extends DefaultMetalTheme {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private String name = "Custom Theme";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private ColorUIResource primary1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private ColorUIResource primary2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private ColorUIResource primary3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private ColorUIResource secondary1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private ColorUIResource secondary2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private ColorUIResource secondary3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private ColorUIResource black;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private ColorUIResource white;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    82
     * pass an inputstream pointing to a properties file.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    83
     * Colors will be initialized to be the same as the DefaultMetalTheme,
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    84
     * and then any colors provided in the properties file will override that.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    85
     */
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    86
    public PropertiesMetalTheme(InputStream stream) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        initColors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        loadProperties(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    92
     * Initialize all colors to be the same as the DefaultMetalTheme.
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
    93
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private void initColors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        primary1 = super.getPrimary1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        primary2 = super.getPrimary2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        primary3 = super.getPrimary3();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        secondary1 = super.getSecondary1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        secondary2 = super.getSecondary2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        secondary3 = super.getSecondary3();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        black = super.getBlack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        white = super.getWhite();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   108
     * Load the theme name and colors from the properties file
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   109
     * Items not defined in the properties file are ignored
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   110
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private void loadProperties(InputStream stream) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        Properties prop = new Properties();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            prop.load(stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            System.out.println(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        Object tempName = prop.get("name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (tempName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            name = tempName.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        Object colorString = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        colorString = prop.get("primary1");
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   127
        if (colorString != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            primary1 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        colorString = prop.get("primary2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            primary2 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        colorString = prop.get("primary3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            primary3 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        colorString = prop.get("secondary1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            secondary1 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        colorString = prop.get("secondary2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            secondary2 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        colorString = prop.get("secondary3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            secondary3 = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        colorString = prop.get("black");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            black = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        colorString = prop.get("white");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if (colorString != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            white = parseColor(colorString.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   168
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   169
    public String getName() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   170
        return name;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   171
    }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   172
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   173
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   174
    protected ColorUIResource getPrimary1() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   175
        return primary1;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   176
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   178
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   179
    protected ColorUIResource getPrimary2() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   180
        return primary2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   181
    }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   182
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   183
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   184
    protected ColorUIResource getPrimary3() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   185
        return primary3;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   186
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   188
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   189
    protected ColorUIResource getSecondary1() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   190
        return secondary1;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   191
    }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   192
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   193
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   194
    protected ColorUIResource getSecondary2() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   195
        return secondary2;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   196
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   198
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   199
    protected ColorUIResource getSecondary3() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   200
        return secondary3;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   201
    }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   202
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   203
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   204
    protected ColorUIResource getBlack() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   205
        return black;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   206
    }
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   207
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   208
    @Override
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   209
    protected ColorUIResource getWhite() {
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   210
        return white;
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   211
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
8961
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   214
     * parse a comma delimited list of 3 strings into a Color
6e8562ef340d 7027696: /jfc/Metalworks demo needs to be improved
mrkam
parents: 5506
diff changeset
   215
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    private ColorUIResource parseColor(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        int red = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        int green = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        int blue = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            StringTokenizer st = new StringTokenizer(s, ",");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            red = Integer.parseInt(st.nextToken());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            green = Integer.parseInt(st.nextToken());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            blue = Integer.parseInt(st.nextToken());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            System.out.println(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            System.out.println("Couldn't parse color :" + s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return new ColorUIResource(red, green, blue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}