1 | /*
|
---|
2 | * Copyright 2002,2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | package org.apache.tools.ant.types.optional.image;
|
---|
18 |
|
---|
19 | import java.awt.Color;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | *
|
---|
23 | * @see org.apache.tools.ant.taskdefs.optional.image.Image
|
---|
24 | */
|
---|
25 | public final class ColorMapper {
|
---|
26 | public static final String COLOR_BLACK = "black";
|
---|
27 | public static final String COLOR_BLUE = "blue";
|
---|
28 | public static final String COLOR_CYAN = "cyan";
|
---|
29 | public static final String COLOR_DARKGRAY = "darkgray";
|
---|
30 | public static final String COLOR_GRAY = "gray";
|
---|
31 | public static final String COLOR_LIGHTGRAY = "lightgray";
|
---|
32 | // Gotta atleast put in the proper spelling :-P
|
---|
33 | public static final String COLOR_DARKGREY = "darkgrey";
|
---|
34 | public static final String COLOR_GREY = "grey";
|
---|
35 | public static final String COLOR_LIGHTGREY = "lightgrey";
|
---|
36 | public static final String COLOR_GREEN = "green";
|
---|
37 | public static final String COLOR_MAGENTA = "magenta";
|
---|
38 | public static final String COLOR_ORANGE = "orange";
|
---|
39 | public static final String COLOR_PINK = "pink";
|
---|
40 | public static final String COLOR_RED = "red";
|
---|
41 | public static final String COLOR_WHITE = "white";
|
---|
42 | public static final String COLOR_YELLOW = "yellow";
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * @todo refactor to use an EnumeratedAttribute (maybe?)
|
---|
46 | */
|
---|
47 | public static final Color getColorByName(String color_name) {
|
---|
48 | color_name = color_name.toLowerCase();
|
---|
49 |
|
---|
50 | if (color_name.equals(COLOR_BLACK)) {
|
---|
51 | return Color.black;
|
---|
52 | } else if (color_name.equals(COLOR_BLUE)) {
|
---|
53 | return Color.blue;
|
---|
54 | } else if (color_name.equals(COLOR_CYAN)) {
|
---|
55 | return Color.cyan;
|
---|
56 | } else if (color_name.equals(COLOR_DARKGRAY) || color_name.equals(COLOR_DARKGREY)) {
|
---|
57 | return Color.darkGray;
|
---|
58 | } else if (color_name.equals(COLOR_GRAY) || color_name.equals(COLOR_GREY)) {
|
---|
59 | return Color.gray;
|
---|
60 | } else if (color_name.equals(COLOR_LIGHTGRAY) || color_name.equals(COLOR_LIGHTGREY)) {
|
---|
61 | return Color.lightGray;
|
---|
62 | } else if (color_name.equals(COLOR_GREEN)) {
|
---|
63 | return Color.green;
|
---|
64 | } else if (color_name.equals(COLOR_MAGENTA)) {
|
---|
65 | return Color.magenta;
|
---|
66 | } else if (color_name.equals(COLOR_ORANGE)) {
|
---|
67 | return Color.orange;
|
---|
68 | } else if (color_name.equals(COLOR_PINK)) {
|
---|
69 | return Color.pink;
|
---|
70 | } else if (color_name.equals(COLOR_RED)) {
|
---|
71 | return Color.red;
|
---|
72 | } else if (color_name.equals(COLOR_WHITE)) {
|
---|
73 | return Color.white;
|
---|
74 | } else if (color_name.equals(COLOR_YELLOW)) {
|
---|
75 | return Color.yellow;
|
---|
76 | }
|
---|
77 | return Color.black;
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|