23 package com.realtime.crossfire.jxclient.skin.io;
32 import java.awt.Color;
33 import java.io.IOException;
34 import java.io.LineNumberReader;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
56 public static int parseStat(@NotNull
final String name)
throws IOException {
59 }
catch (
final IllegalArgumentException ignored) {
63 throw new IOException(
"invalid stat name: "+name);
76 }
catch (
final IllegalArgumentException ignored) {
80 throw new IOException(
"invalid orientation: "+name);
90 public static Color
parseColor(@NotNull
final String name)
throws IOException {
95 throw new IOException(
"unknown color name "+name);
105 final int pos = name.lastIndexOf(
'/');
113 }
catch (
final IOException ignored) {
116 if (alpha < 0 || alpha > 255) {
120 final String colorName = name.substring(0, pos);
129 return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
139 if (name.equals(
"BLACK")) {
142 if (name.equals(
"BLUE")) {
145 if (name.equals(
"DARK_GRAY")) {
146 return Color.DARK_GRAY;
148 if (name.equals(
"GRAY")) {
151 if (name.equals(
"LIGHT_GRAY")) {
152 return Color.LIGHT_GRAY;
154 if (name.equals(
"RED")) {
157 if (name.equals(
"WHITE")) {
160 if (name.length() == 7 && name.charAt(0) ==
'#' && name.charAt(1) !=
'-') {
162 return new Color(Integer.parseInt(name.substring(1), 16));
163 }
catch (
final NumberFormatException ignored) {
180 public static String
parseText(@NotNull
final Args args, @NotNull
final LineNumberReader lnr)
throws IOException {
181 final StringBuilder text =
new StringBuilder();
182 if (args.hasMore()) {
183 text.append(args.get());
184 while (args.hasMore()) {
186 text.append(args.get());
189 if (text.toString().equals(
"<<EOF")) {
192 final String line = lnr.readLine();
194 throw new IOException(
"EOF");
196 if (line.equals(
"EOF")) {
199 if (line.startsWith(
"#")) {
206 if (text.length() > 0) {
207 text.setLength(text.length()-1);
211 return text.toString().replaceFirst(
"_$",
" ");
224 return optionManager.getCheckBoxOption(name);
226 throw new IOException(ex.getMessage(), ex);