aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/lowagie/text/markup
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lowagie/text/markup')
-rw-r--r--src/main/java/com/lowagie/text/markup/MarkupParser.java736
-rw-r--r--src/main/java/com/lowagie/text/markup/MarkupTags.java266
-rw-r--r--src/main/java/com/lowagie/text/markup/WebColors.java246
3 files changed, 0 insertions, 1248 deletions
diff --git a/src/main/java/com/lowagie/text/markup/MarkupParser.java b/src/main/java/com/lowagie/text/markup/MarkupParser.java
deleted file mode 100644
index d2446d3..0000000
--- a/src/main/java/com/lowagie/text/markup/MarkupParser.java
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- * $Id: MarkupParser.java,v 1.56 2005/07/07 10:04:49 blowagie Exp $
- * $Name: $
- *
- * Copyright 2001, 2002 by Bruno Lowagie.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * (the "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the License.
- *
- * The Original Code is 'iText, a free JAVA-PDF library'.
- *
- * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
- * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
- * All Rights Reserved.
- * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
- * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
- *
- * Contributor(s): all the names of the contributors are added in the source code
- * where applicable.
- *
- * Alternatively, the contents of this file may be used under the terms of the
- * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
- * provisions of LGPL are applicable instead of those above. If you wish to
- * allow use of your version of this file only under the terms of the LGPL
- * License and not to allow others to use your version of this file under
- * the MPL, indicate your decision by deleting the provisions above and
- * replace them with the notice and other provisions required by the LGPL.
- * If you do not delete the provisions above, a recipient may use your version
- * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the MPL as stated above or under the terms of the GNU
- * Library General Public License as published by the Free Software Foundation;
- * either version 2 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
- * details.
- *
- * If you didn't download this code from the following link, you should check if
- * you aren't using an obsolete version:
- * http://www.lowagie.com/iText/
- */
-
-package com.lowagie.text.markup;
-
-import java.awt.Color;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import com.lowagie.text.Element;
-import com.lowagie.text.ExceptionConverter;
-import com.lowagie.text.Font;
-import com.lowagie.text.FontFactory;
-import com.lowagie.text.ListItem;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.Rectangle;
-import com.lowagie.text.SimpleCell;
-import com.lowagie.text.SimpleTable;
-
-/**
- * This class is a HashMap that contains selectors (String) and styles (a
- * Properties object). Given a tag and its attributes (id/class), this class can
- * return an iText object with the according style.
- *
- * @author blowagie
- */
-public class MarkupParser extends HashMap {
- /**
- * HashMap with styles for each known combination of tag/id/class. The key
- * is a String-combination, the value a Properties object.
- */
- protected HashMap stylecache = new HashMap();
-
- /**
- * HashMap with fonts for each known combination of tag/id/class. The key is
- * the same String-combination used for the stylecache.
- */
- protected HashMap fontcache = new HashMap();
-
- // processing CSS
-
- /**
- * Creates new MarkupParser
- *
- * @param file
- * the path to a CSS file.
- */
- public MarkupParser(String file) {
- super();
- try {
- FileReader reader = new FileReader(file);
- BufferedReader br = new BufferedReader(reader);
- StringBuffer buf = new StringBuffer();
- String line;
- while ((line = br.readLine()) != null) {
- buf.append(line.trim());
- }
- String string = buf.toString();
- string = removeComment(string, "/*", "*/");
- StringTokenizer tokenizer = new StringTokenizer(string, "}");
- String tmp;
- int pos;
- String selector;
- String attributes;
- while (tokenizer.hasMoreTokens()) {
- tmp = tokenizer.nextToken();
- pos = tmp.indexOf("{");
- if (pos > 0) {
- selector = tmp.substring(0, pos).trim();
- attributes = tmp.substring(pos + 1).trim();
- if (attributes.endsWith("}"))
- attributes = attributes.substring(0, attributes
- .length() - 1);
- put(selector, parseAttributes(attributes));
- }
- }
- } catch (Exception e) {
- throw new ExceptionConverter(e);
- }
- }
-
- /**
- * Removes the comments sections of a String.
- *
- * @param string
- * the original String
- * @param startComment
- * the String that marks the start of a Comment section
- * @param endComment
- * the String that marks the end of a Comment section.
- * @return the String stripped of its comment section
- */
- public static String removeComment(String string, String startComment,
- String endComment) {
- StringBuffer result = new StringBuffer();
- int pos = 0;
- int end = endComment.length();
- int start = string.indexOf(startComment, pos);
- while (start > -1) {
- result.append(string.substring(pos, start));
- pos = string.indexOf(endComment, start) + end;
- start = string.indexOf(startComment, pos);
- }
- result.append(string.substring(pos));
- return result.toString();
- }
-
- /**
- * This method parses a String with attributes and returns a Properties
- * object.
- *
- * @param string
- * a String of this form: 'key1="value1"; key2="value2";...
- * keyN="valueN" '
- * @return a Properties object
- */
- public static Properties parseAttributes(String string) {
- Properties result = new Properties();
- if (string == null)
- return result;
- StringTokenizer keyValuePairs = new StringTokenizer(string, ";");
- StringTokenizer keyValuePair;
- String key;
- String value;
- while (keyValuePairs.hasMoreTokens()) {
- keyValuePair = new StringTokenizer(keyValuePairs.nextToken(), ":");
- if (keyValuePair.hasMoreTokens())
- key = keyValuePair.nextToken().trim();
- else
- continue;
- if (keyValuePair.hasMoreTokens())
- value = keyValuePair.nextToken().trim();
- else
- continue;
- if (value.startsWith("\""))
- value = value.substring(1);
- if (value.endsWith("\""))
- value = value.substring(0, value.length() - 1);
- result.setProperty(key, value);
- }
- return result;
- }
-
- // reading attributevalues
-
- /**
- * Parses a length.
- *
- * @param string
- * a length in the form of an optional + or -, followed by a
- * number and a unit.
- * @return a float
- */
-
- public static float parseLength(String string) {
- int pos = 0;
- int length = string.length();
- boolean ok = true;
- while (ok && pos < length) {
- switch (string.charAt(pos)) {
- case '+':
- case '-':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '.':
- pos++;
- break;
- default:
- ok = false;
- }
- }
- if (pos == 0)
- return 0f;
- if (pos == length)
- return Float.valueOf(string + "f").floatValue();
- float f = Float.valueOf(string.substring(0, pos) + "f").floatValue();
- string = string.substring(pos);
- // inches
- if (string.startsWith("in")) {
- return f * 72f;
- }
- // centimeters
- if (string.startsWith("cm")) {
- return (f / 2.54f) * 72f;
- }
- // millimeters
- if (string.startsWith("mm")) {
- return (f / 25.4f) * 72f;
- }
- // picas
- if (string.startsWith("pc")) {
- return f * 12f;
- }
- // default: we assume the length was measured in points
- return f;
- }
-
- /**
- * Converts a <CODE>Color</CODE> into a HTML representation of this <CODE>
- * Color</CODE>.
- *
- * @param color
- * the <CODE>Color</CODE> that has to be converted.
- * @return the HTML representation of this <COLOR>Color </COLOR>
- */
-
- public static Color decodeColor(String color) {
- int red = 0;
- int green = 0;
- int blue = 0;
- try {
- red = Integer.parseInt(color.substring(1, 3), 16);
- green = Integer.parseInt(color.substring(3, 5), 16);
- blue = Integer.parseInt(color.substring(5), 16);
- } catch (Exception sioobe) {
- // empty on purpose
- }
- return new Color(red, green, blue);
- }
-
- // helper methods
-
- /**
- * Generates a key for an tag/id/class combination and adds the style
- * attributes to the stylecache.
- *
- * @param attributes
- * a Properties object with the tagname and the attributes of the
- * tag.
- * @return a key
- */
- private String getKey(Properties attributes) {
- String tag = attributes.getProperty(MarkupTags.ITEXT_TAG);
- String id = attributes.getProperty(MarkupTags.HTML_ATTR_CSS_ID);
- String cl = attributes.getProperty(MarkupTags.HTML_ATTR_CSS_CLASS);
- if (id == null) {
- id = "";
- } else {
- id = "#" + id;
- }
- if (cl == null) {
- cl = "";
- } else {
- cl = "." + cl;
- }
- String key = tag + id + cl;
- if (!stylecache.containsKey(key) && key.length() > 0) {
- Properties props = new Properties();
- Properties tagprops = (Properties) get(tag);
- Properties idprops = (Properties) get(id);
- Properties clprops = (Properties) get(cl);
- Properties tagidprops = (Properties) get(tag + id);
- Properties tagclprops = (Properties) get(tag + cl);
- if (tagprops != null)
- props.putAll(tagprops);
- if (idprops != null)
- props.putAll(idprops);
- if (clprops != null)
- props.putAll(clprops);
- if (tagidprops != null)
- props.putAll(tagidprops);
- if (tagclprops != null)
- props.putAll(tagclprops);
- stylecache.put(key, props);
- }
- return key;
- }
-
- // getting the objects based on the tag and its attributes
-
- /**
- * Returns pagebreak information.
- *
- * @param attributes
- * @return true if a page break is needed before the tag
- */
- public boolean getPageBreakBefore(Properties attributes) {
- String key = getKey(attributes);
- Properties styleattributes = (Properties) stylecache.get(key);
- if (styleattributes != null
- && MarkupTags.CSS_VALUE_ALWAYS.equals(styleattributes
- .getProperty(MarkupTags.CSS_KEY_PAGE_BREAK_BEFORE))) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns pagebreak information.
- *
- * @param attributes
- * @return true if a page break is needed after the tag
- */
- public boolean getPageBreakAfter(Properties attributes) {
- String key = getKey(attributes);
- Properties styleattributes = (Properties) stylecache.get(key);
- if (styleattributes != null
- && MarkupTags.CSS_VALUE_ALWAYS.equals(styleattributes
- .getProperty(MarkupTags.CSS_KEY_PAGE_BREAK_AFTER))) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns an object based on a tag and its attributes.
- *
- * @param attributes
- * a Properties object with the tagname and the attributes of the
- * tag.
- * @return an iText object
- */
- public Element getObject(Properties attributes) {
- String key = getKey(attributes);
- Properties styleattributes = (Properties) stylecache.get(key);
- if (styleattributes != null
- && MarkupTags.CSS_VALUE_HIDDEN.equals(styleattributes
- .get(MarkupTags.CSS_KEY_VISIBILITY))) {
- return null;
- }
- String display = styleattributes
- .getProperty(MarkupTags.CSS_KEY_DISPLAY);
- Element element = null;
- if (MarkupTags.CSS_VALUE_INLINE.equals(display)) {
- element = retrievePhrase(getFont(attributes), styleattributes);
- } else if (MarkupTags.CSS_VALUE_BLOCK.equals(display)) {
- element = retrieveParagraph(getFont(attributes), styleattributes);
- } else if (MarkupTags.CSS_VALUE_LISTITEM.equals(display)) {
- element = retrieveListItem(getFont(attributes), styleattributes);
- } else if (MarkupTags.CSS_VALUE_TABLECELL.equals(display)) {
- element = retrieveTableCell(attributes, styleattributes);
- } else if (MarkupTags.CSS_VALUE_TABLEROW.equals(display)) {
- element = retrieveTableRow(attributes, styleattributes);
- } else if (MarkupTags.CSS_VALUE_TABLE.equals(display)) {
- element = retrieveTable(attributes, styleattributes);
- }
- return element;
- }
-
- /**
- * Returns a font based on the ID and CLASS attributes of a tag.
- *
- * @param attributes
- * a Properties object with the tagname and the attributes of the
- * tag.
- * @return an iText Font;
- */
- public Font getFont(Properties attributes) {
- String key = getKey(attributes);
- Font f = (Font) fontcache.get(key);
- if (f != null) {
- return f;
- } else {
- Properties styleattributes = (Properties) stylecache.get(key);
- f = retrieveFont(styleattributes);
- fontcache.put(key, f);
- }
- return f;
- }
-
- /**
- * Returns a rectangle based on the width and height attributes of a tag,
- * can be overridden by the ID and CLASS attributes.
- *
- * @param attrs
- * the attributes that came with the tag
- * @return an iText Rectangle object
- */
- public Rectangle getRectangle(Properties attrs) {
- String width = null;
- String height = null;
- String key = getKey(attrs);
- Properties styleattributes = (Properties) stylecache.get(key);
- if (styleattributes != null) {
- width = styleattributes.getProperty(MarkupTags.HTML_ATTR_WIDTH);
- height = styleattributes.getProperty(MarkupTags.HTML_ATTR_HEIGHT);
- }
- if (width == null)
- width = attrs.getProperty(MarkupTags.HTML_ATTR_WIDTH);
- if (height == null)
- height = attrs.getProperty(MarkupTags.HTML_ATTR_HEIGHT);
- if (width == null || height == null)
- return null;
- return new Rectangle(parseLength(width), parseLength(height));
- }
-
- // retrieving objects based on the styleAttributes
-
- /**
- * Retrieves a Phrase based on some style attributes.
- *
- * @param font
- * @param styleattributes
- * a Properties object containing keys and values
- * @return an iText Phrase object
- */
- public Element retrievePhrase(Font font, Properties styleattributes) {
- Phrase p = new Phrase("", font);
- if (styleattributes == null)
- return p;
- String leading = styleattributes
- .getProperty(MarkupTags.CSS_KEY_LINEHEIGHT);
- if (leading != null) {
- if (leading.endsWith("%")) {
- p.setLeading(p.font().size() * (parseLength(leading) / 100f));
- } else {
- p.setLeading(parseLength(leading));
- }
- }
- return p;
- }
-
- /**
- * Retrieves a Paragraph based on some style attributes.
- *
- * @param font
- * @param styleattributes
- * a Properties object containing keys and values
- * @return an iText Paragraph object
- */
- public Element retrieveParagraph(Font font, Properties styleattributes) {
- Paragraph p = new Paragraph((Phrase) retrievePhrase(font,
- styleattributes));
- if (styleattributes == null)
- return p;
- String margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGIN);
- float f;
- if (margin != null) {
- f = parseLength(margin);
- p.setIndentationLeft(f);
- p.setIndentationRight(f);
- p.setSpacingBefore(f);
- p.setSpacingAfter(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINLEFT);
- if (margin != null) {
- f = parseLength(margin);
- p.setIndentationLeft(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINRIGHT);
- if (margin != null) {
- f = parseLength(margin);
- p.setIndentationRight(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINTOP);
- if (margin != null) {
- f = parseLength(margin);
- p.setSpacingBefore(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINBOTTOM);
- if (margin != null) {
- f = parseLength(margin);
- p.setSpacingAfter(f);
- }
- String align = styleattributes
- .getProperty(MarkupTags.CSS_KEY_TEXTALIGN);
- if (MarkupTags.CSS_VALUE_TEXTALIGNLEFT.equals(align)) {
- p.setAlignment(Element.ALIGN_LEFT);
- } else if (MarkupTags.CSS_VALUE_TEXTALIGNRIGHT.equals(align)) {
- p.setAlignment(Element.ALIGN_RIGHT);
- } else if (MarkupTags.CSS_VALUE_TEXTALIGNCENTER.equals(align)) {
- p.setAlignment(Element.ALIGN_CENTER);
- } else if (MarkupTags.CSS_VALUE_TEXTALIGNJUSTIFY.equals(align)) {
- p.setAlignment(Element.ALIGN_JUSTIFIED);
- }
- return p;
- }
-
- /**
- * Gets a table based on the styleattributes.
- *
- * @param attributes
- * @param styleattributes
- * @return an iText Table
- */
- private Element retrieveTable(Properties attributes,
- Properties styleattributes) {
- SimpleTable table = new SimpleTable();
- applyBordersColors(table, attributes, styleattributes);
- return table;
- }
-
- /**
- * Returns a Cell based on the styleattributes.
- *
- * @param attributes
- * @param styleattributes
- * @return an iText Cell
- */
- private Element retrieveTableRow(Properties attributes,
- Properties styleattributes) {
- SimpleCell row = new SimpleCell(SimpleCell.ROW);
- applyBordersColors(row, attributes, styleattributes);
- String width = null;
- if (attributes != null)
- width = attributes.getProperty(MarkupTags.HTML_ATTR_WIDTH);
- if (width == null)
- width = styleattributes.getProperty(MarkupTags.HTML_ATTR_WIDTH);
- if (width != null) {
- if (width.endsWith("%")) {
- row.setWidthpercentage(parseLength(width));
- } else {
- row.setWidth(parseLength(width));
- }
- }
- String margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGIN);
- float f;
- if (margin != null) {
- f = parseLength(margin);
- row.setSpacing(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINLEFT);
- if (margin != null) {
- f = parseLength(margin);
- row.setSpacing_left(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINRIGHT);
- if (margin != null) {
- f = parseLength(margin);
- row.setSpacing_right(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINTOP);
- if (margin != null) {
- f = parseLength(margin);
- row.setSpacing_top(f);
- }
- margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINBOTTOM);
- if (margin != null) {
- f = parseLength(margin);
- row.setSpacing_bottom(f);
- }
- String padding = styleattributes.getProperty(MarkupTags.CSS_KEY_PADDING);
- if (padding != null) {
- f = parseLength(padding);
- row.setPadding(f);
- }
- padding = styleattributes.getProperty(MarkupTags.CSS_KEY_PADDINGLEFT);
- if (padding != null) {
- f = parseLength(padding);
- row.setSpacing_left(f);
- }
- padding = styleattributes.getProperty(MarkupTags.CSS_KEY_PADDINGRIGHT);
- if (padding != null) {
- f = parseLength(padding);
- row.setSpacing_right(f);
- }
- padding = styleattributes.getProperty(MarkupTags.CSS_KEY_PADDINGTOP);
- if (padding != null) {
- f = parseLength(padding);
- row.setSpacing_top(f);
- }
- padding = styleattributes.getProperty(MarkupTags.CSS_KEY_PADDINGBOTTOM);
- if (padding != null) {
- f = parseLength(padding);
- row.setSpacing_bottom(f);
- }
- return row;
- }
-
- /**
- * Returns a Cell based on the styleattributes.
- *
- * @param attributes
- * @param styleattributes
- * @return an iText Cell
- */
- private Element retrieveTableCell(Properties attributes,
- Properties styleattributes) {
- SimpleCell cell = (SimpleCell) retrieveTableRow(attributes,
- styleattributes);
- cell.setCellgroup(false);
- return cell;
- }
-
- /**
- * Returns a ListItem based on the styleattributes.
- *
- * @param font
- * @param styleattributes
- * @return an iText ListItem
- */
- private Element retrieveListItem(Font font, Properties styleattributes) {
- ListItem li = new ListItem();
- return li;
- }
-
- /**
- * Applies colors to a Rectangle object.
- * @param rect
- * @param attributes
- * @param styleattributes
- */
- private void applyBordersColors(Rectangle rect, Properties attributes, Properties styleattributes) {
- String s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERWIDTH);
- float f;
- if (s != null) {
- f = parseLength(s);
- rect.setBorderWidth(f);
- }
- s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERWIDTHLEFT);
- if (s != null) {
- f = parseLength(s);
- rect.setBorderWidthLeft(f);
- }
- s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERWIDTHRIGHT);
- if (s != null) {
- f = parseLength(s);
- rect.setBorderWidthRight(f);
- }
- s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERWIDTHTOP);
- if (s != null) {
- f = parseLength(s);
- rect.setBorderWidthTop(f);
- }
- s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERWIDTHBOTTOM);
- if (s != null) {
- f = parseLength(s);
- rect.setBorderWidthBottom(f);
- }
- s = styleattributes.getProperty(MarkupTags.CSS_KEY_BORDERCOLOR);
- if (s != null) {
- rect.setBorderColor(decodeColor(s));
- }
- }
-
- /**
- * Retrieves a font from the FontFactory based on some style attributes.
- * Looks for the font-family, font-size, font-weight, font-style and color.
- * Takes the default encoding and embedded value.
- *
- * @param styleAttributes
- * a Properties object containing keys and values
- * @return an iText Font object
- */
-
- public Font retrieveFont(Properties styleAttributes) {
- String fontname = null;
- String encoding = FontFactory.defaultEncoding;
- boolean embedded = FontFactory.defaultEmbedding;
- float size = Font.UNDEFINED;
- int style = Font.NORMAL;
- Color color = null;
- String value = (String) styleAttributes
- .get(MarkupTags.CSS_KEY_FONTFAMILY);
- if (value != null) {
- if (value.indexOf(",") == -1) {
- fontname = value.trim();
- } else {
- String tmp;
- while (value.indexOf(",") != -1) {
- tmp = value.substring(0, value.indexOf(",")).trim();
- if (FontFactory.isRegistered(tmp)) {
- fontname = tmp;
- break;
- } else {
- value = value.substring(value.indexOf(",") + 1);
- }
- }
- }
- }
- if ((value = (String) styleAttributes.get(MarkupTags.CSS_KEY_FONTSIZE)) != null) {
- size = MarkupParser.parseLength(value);
- }
- if ((value = (String) styleAttributes
- .get(MarkupTags.CSS_KEY_FONTWEIGHT)) != null) {
- style |= Font.getStyleValue(value);
- }
- if ((value = (String) styleAttributes.get(MarkupTags.CSS_KEY_FONTSTYLE)) != null) {
- style |= Font.getStyleValue(value);
- }
- if ((value = (String) styleAttributes.get(MarkupTags.CSS_KEY_COLOR)) != null) {
- color = MarkupParser.decodeColor(value);
- }
- return FontFactory.getFont(fontname, encoding, embedded, size, style,
- color);
- }
-} \ No newline at end of file
diff --git a/src/main/java/com/lowagie/text/markup/MarkupTags.java b/src/main/java/com/lowagie/text/markup/MarkupTags.java
deleted file mode 100644
index e712124..0000000
--- a/src/main/java/com/lowagie/text/markup/MarkupTags.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * $Id: MarkupTags.java,v 1.51 2005/06/17 13:39:13 blowagie Exp $
- * $Name: $
- *
- * Copyright 2001, 2002 by Bruno Lowagie.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * (the "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the License.
- *
- * The Original Code is 'iText, a free JAVA-PDF library'.
- *
- * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
- * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
- * All Rights Reserved.
- * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
- * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
- *
- * Contributor(s): all the names of the contributors are added in the source code
- * where applicable.
- *
- * Alternatively, the contents of this file may be used under the terms of the
- * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
- * provisions of LGPL are applicable instead of those above. If you wish to
- * allow use of your version of this file only under the terms of the LGPL
- * License and not to allow others to use your version of this file under
- * the MPL, indicate your decision by deleting the provisions above and
- * replace them with the notice and other provisions required by the LGPL.
- * If you do not delete the provisions above, a recipient may use your version
- * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the MPL as stated above or under the terms of the GNU
- * Library General Public License as published by the Free Software Foundation;
- * either version 2 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
- * details.
- *
- * If you didn't download this code from the following link, you should check if
- * you aren't using an obsolete version:
- * http://www.lowagie.com/iText/
- */
-
-package com.lowagie.text.markup;
-
-/**
- * A class that contains all the possible tagnames and their attributes.
- */
-
-public class MarkupTags {
-
- // iText specific
-
- /** the key for any tag */
- public static final String ITEXT_TAG = "tag";
-
- // HTML tags
-
- /** the markup for the body part of a file */
- public static final String HTML_TAG_BODY = "body";
-
- /** The DIV tag. */
- public static final String HTML_TAG_DIV = "div";
-
- /** This is a possible HTML-tag. */
- public static final String HTML_TAG_LINK = "link";
-
- /** The SPAN tag. */
- public static final String HTML_TAG_SPAN = "span";
-
- // HTML attributes
-
- /** the height attribute. */
- public static final String HTML_ATTR_HEIGHT = "height";
-
- /** the hyperlink reference attribute. */
- public static final String HTML_ATTR_HREF = "href";
-
- /** This is a possible HTML attribute for the LINK tag. */
- public static final String HTML_ATTR_REL = "rel";
-
- /** This is used for inline css style information */
- public static final String HTML_ATTR_STYLE = "style";
-
- /** This is a possible HTML attribute for the LINK tag. */
- public static final String HTML_ATTR_TYPE = "type";
-
- /** This is a possible HTML attribute. */
- public static final String HTML_ATTR_STYLESHEET = "stylesheet";
-
- /** the width attribute. */
- public static final String HTML_ATTR_WIDTH = "width";
-
- /** attribute for specifying externally defined CSS class */
- public static final String HTML_ATTR_CSS_CLASS = "class";
-
- /** The ID attribute. */
- public static final String HTML_ATTR_CSS_ID = "id";
-
- // HTML values
-
- /** This is a possible value for the language attribute (SCRIPT tag). */
- public static final String HTML_VALUE_JAVASCRIPT = "text/javascript";
-
- /** This is a possible HTML attribute for the LINK tag. */
- public static final String HTML_VALUE_CSS = "text/css";
-
- // CSS keys
-
- /** the CSS tag for background color */
- public static final String CSS_KEY_BGCOLOR = "background-color";
-
- /** the CSS tag for text color */
- public static final String CSS_KEY_COLOR = "color";
-
- /** CSS key that indicate the way something has to be displayed */
- public static final String CSS_KEY_DISPLAY = "display";
-
- /** the CSS tag for the font family */
- public static final String CSS_KEY_FONTFAMILY = "font-family";
-
- /** the CSS tag for the font size */
- public static final String CSS_KEY_FONTSIZE = "font-size";
-
- /** the CSS tag for the font style */
- public static final String CSS_KEY_FONTSTYLE = "font-style";
-
- /** the CSS tag for the font weight */
- public static final String CSS_KEY_FONTWEIGHT = "font-weight";
-
- /** the CSS tag for text decorations */
- public static final String CSS_KEY_LINEHEIGHT = "line-height";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_MARGIN = "margin";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_MARGINLEFT = "margin-left";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_MARGINRIGHT = "margin-right";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_MARGINTOP = "margin-top";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_MARGINBOTTOM = "margin-bottom";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_PADDING = "padding";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_PADDINGLEFT = "padding-left";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_PADDINGRIGHT = "padding-right";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_PADDINGTOP = "padding-top";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_PADDINGBOTTOM = "padding-bottom";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERCOLOR = "border-color";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERWIDTH = "border-width";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERWIDTHLEFT = "border-left-width";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERWIDTHRIGHT = "border-right-width";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERWIDTHTOP = "border-top-width";
-
- /** the CSS tag for the margin of an object */
- public static final String CSS_KEY_BORDERWIDTHBOTTOM = "border-bottom-width";
-
- /** the CSS tag for adding a page break when the document is printed */
- public static final String CSS_KEY_PAGE_BREAK_AFTER = "page-break-after";
-
- /** the CSS tag for adding a page break when the document is printed */
- public static final String CSS_KEY_PAGE_BREAK_BEFORE = "page-break-before";
-
- /** the CSS tag for the horizontal alignment of an object */
- public static final String CSS_KEY_TEXTALIGN = "text-align";
-
- /** the CSS tag for text decorations */
- public static final String CSS_KEY_TEXTDECORATION = "text-decoration";
-
- /** the CSS tag for text decorations */
- public static final String CSS_KEY_VERTICALALIGN = "vertical-align";
-
- /** the CSS tag for the visibility of objects */
- public static final String CSS_KEY_VISIBILITY = "visibility";
-
- // CSS values
-
- /** value for the CSS tag for adding a page break when the document is printed */
- public static final String CSS_VALUE_ALWAYS = "always";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_BLOCK = "block";
-
- /** a CSS value for text font weight */
- public static final String CSS_VALUE_BOLD = "bold";
-
- /** the value if you want to hide objects. */
- public static final String CSS_VALUE_HIDDEN = "hidden";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_INLINE = "inline";
-
- /** a CSS value for text font style */
- public static final String CSS_VALUE_ITALIC = "italic";
-
- /** a CSS value for text decoration */
- public static final String CSS_VALUE_LINETHROUGH = "line-through";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_LISTITEM = "list-item";
-
- /** a CSS value */
- public static final String CSS_VALUE_NONE = "none";
-
- /** a CSS value */
- public static final String CSS_VALUE_NORMAL = "normal";
-
- /** a CSS value for text font style */
- public static final String CSS_VALUE_OBLIQUE = "oblique";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_TABLE = "table";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_TABLEROW = "table-row";
-
- /** A possible value for the DISPLAY key */
- public static final String CSS_VALUE_TABLECELL = "table-cell";
-
- /** the CSS value for a horizontal alignment of an object */
- public static final String CSS_VALUE_TEXTALIGNLEFT = "left";
-
- /** the CSS value for a horizontal alignment of an object */
- public static final String CSS_VALUE_TEXTALIGNRIGHT = "right";
-
- /** the CSS value for a horizontal alignment of an object */
- public static final String CSS_VALUE_TEXTALIGNCENTER = "center";
-
- /** the CSS value for a horizontal alignment of an object */
- public static final String CSS_VALUE_TEXTALIGNJUSTIFY = "justify";
-
- /** a CSS value for text decoration */
- public static final String CSS_VALUE_UNDERLINE = "underline";
-
-} \ No newline at end of file
diff --git a/src/main/java/com/lowagie/text/markup/WebColors.java b/src/main/java/com/lowagie/text/markup/WebColors.java
deleted file mode 100644
index c4119b2..0000000
--- a/src/main/java/com/lowagie/text/markup/WebColors.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * $Id: WebColors.java,v 1.3 2005/08/24 11:37:28 blowagie Exp $
- * $Name: $
- *
- * Copyright 2001, 2002 by Bruno Lowagie.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * (the "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the License.
- *
- * The Original Code is 'iText, a free JAVA-PDF library'.
- *
- * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
- * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
- * All Rights Reserved.
- * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
- * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
- *
- * Contributor(s): all the names of the contributors are added in the source code
- * where applicable.
- *
- * Alternatively, the contents of this file may be used under the terms of the
- * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
- * provisions of LGPL are applicable instead of those above. If you wish to
- * allow use of your version of this file only under the terms of the LGPL
- * License and not to allow others to use your version of this file under
- * the MPL, indicate your decision by deleting the provisions above and
- * replace them with the notice and other provisions required by the LGPL.
- * If you do not delete the provisions above, a recipient may use your version
- * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the MPL as stated above or under the terms of the GNU
- * Library General Public License as published by the Free Software Foundation;
- * either version 2 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
- * details.
- *
- * If you didn't download this code from the following link, you should check if
- * you aren't using an obsolete version:
- * http://www.lowagie.com/iText/
- */
-
-package com.lowagie.text.markup;
-
-import java.awt.Color;
-import java.util.HashMap;
-
-/**
- * This class is a HashMap that contains the names of colors as a key and the
- * corresponding Color as value. (Source: Wikipedia
- * http://en.wikipedia.org/wiki/Web_colors )
- *
- * @author blowagie
- */
-public class WebColors extends HashMap {
-
- /** HashMap containing all the names and corresponding color values. */
- public static final WebColors NAMES = new WebColors();
- static {
- NAMES.put("aliceblue", new int[] { 0xf0, 0xf8, 0xff, 0x00 });
- NAMES.put("antiquewhite", new int[] { 0xfa, 0xeb, 0xd7, 0x00 });
- NAMES.put("aqua", new int[] { 0x00, 0xff, 0xff, 0x00 });
- NAMES.put("aquamarine", new int[] { 0x7f, 0xff, 0xd4, 0x00 });
- NAMES.put("azure", new int[] { 0xf0, 0xff, 0xff, 0x00 });
- NAMES.put("beige", new int[] { 0xf5, 0xf5, 0xdc, 0x00 });
- NAMES.put("bisque", new int[] { 0xff, 0xe4, 0xc4, 0x00 });
- NAMES.put("black", new int[] { 0x00, 0x00, 0x00, 0x00 });
- NAMES.put("blanchedalmond", new int[] { 0xff, 0xeb, 0xcd, 0x00 });
- NAMES.put("blue", new int[] { 0x00, 0x00, 0xff, 0x00 });
- NAMES.put("blueviolet", new int[] { 0x8a, 0x2b, 0xe2, 0x00 });
- NAMES.put("brown", new int[] { 0xa5, 0x2a, 0x2a, 0x00 });
- NAMES.put("burlywood", new int[] { 0xde, 0xb8, 0x87, 0x00 });
- NAMES.put("cadetblue", new int[] { 0x5f, 0x9e, 0xa0, 0x00 });
- NAMES.put("chartreuse", new int[] { 0x7f, 0xff, 0x00, 0x00 });
- NAMES.put("chocolate", new int[] { 0xd2, 0x69, 0x1e, 0x00 });
- NAMES.put("coral", new int[] { 0xff, 0x7f, 0x50, 0x00 });
- NAMES.put("cornflowerblue", new int[] { 0x64, 0x95, 0xed, 0x00 });
- NAMES.put("cornsilk", new int[] { 0xff, 0xf8, 0xdc, 0x00 });
- NAMES.put("crimson", new int[] { 0xdc, 0x14, 0x3c, 0x00 });
- NAMES.put("cyan", new int[] { 0x00, 0xff, 0xff, 0x00 });
- NAMES.put("darkblue", new int[] { 0x00, 0x00, 0x8b, 0x00 });
- NAMES.put("darkcyan", new int[] { 0x00, 0x8b, 0x8b, 0x00 });
- NAMES.put("darkgoldenrod", new int[] { 0xb8, 0x86, 0x0b, 0x00 });
- NAMES.put("darkgray", new int[] { 0xa9, 0xa9, 0xa9, 0x00 });
- NAMES.put("darkgreen", new int[] { 0x00, 0x64, 0x00, 0x00 });
- NAMES.put("darkkhaki", new int[] { 0xbd, 0xb7, 0x6b, 0x00 });
- NAMES.put("darkmagenta", new int[] { 0x8b, 0x00, 0x8b, 0x00 });
- NAMES.put("darkolivegreen", new int[] { 0x55, 0x6b, 0x2f, 0x00 });
- NAMES.put("darkorange", new int[] { 0xff, 0x8c, 0x00, 0x00 });
- NAMES.put("darkorchid", new int[] { 0x99, 0x32, 0xcc, 0x00 });
- NAMES.put("darkred", new int[] { 0x8b, 0x00, 0x00, 0x00 });
- NAMES.put("darksalmon", new int[] { 0xe9, 0x96, 0x7a, 0x00 });
- NAMES.put("darkseagreen", new int[] { 0x8f, 0xbc, 0x8f, 0x00 });
- NAMES.put("darkslateblue", new int[] { 0x48, 0x3d, 0x8b, 0x00 });
- NAMES.put("darkslategray", new int[] { 0x2f, 0x4f, 0x4f, 0x00 });
- NAMES.put("darkturquoise", new int[] { 0x00, 0xce, 0xd1, 0x00 });
- NAMES.put("darkviolet", new int[] { 0x94, 0x00, 0xd3, 0x00 });
- NAMES.put("deeppink", new int[] { 0xff, 0x14, 0x93, 0x00 });
- NAMES.put("deepskyblue", new int[] { 0x00, 0xbf, 0xff, 0x00 });
- NAMES.put("dimgray", new int[] { 0x69, 0x69, 0x69, 0x00 });
- NAMES.put("dodgerblue", new int[] { 0x1e, 0x90, 0xff, 0x00 });
- NAMES.put("firebrick", new int[] { 0xb2, 0x22, 0x22, 0x00 });
- NAMES.put("floralwhite", new int[] { 0xff, 0xfa, 0xf0, 0x00 });
- NAMES.put("forestgreen", new int[] { 0x22, 0x8b, 0x22, 0x00 });
- NAMES.put("fuchsia", new int[] { 0xff, 0x00, 0xff, 0x00 });
- NAMES.put("gainsboro", new int[] { 0xdc, 0xdc, 0xdc, 0x00 });
- NAMES.put("ghostwhite", new int[] { 0xf8, 0xf8, 0xff, 0x00 });
- NAMES.put("gold", new int[] { 0xff, 0xd7, 0x00, 0x00 });
- NAMES.put("goldenrod", new int[] { 0xda, 0xa5, 0x20, 0x00 });
- NAMES.put("gray", new int[] { 0x80, 0x80, 0x80, 0x00 });
- NAMES.put("green", new int[] { 0x00, 0x80, 0x00, 0x00 });
- NAMES.put("greenyellow", new int[] { 0xad, 0xff, 0x2f, 0x00 });
- NAMES.put("honeydew", new int[] { 0xf0, 0xff, 0xf0, 0x00 });
- NAMES.put("hotpink", new int[] { 0xff, 0x69, 0xb4, 0x00 });
- NAMES.put("indianred", new int[] { 0xcd, 0x5c, 0x5c, 0x00 });
- NAMES.put("indigo", new int[] { 0x4b, 0x00, 0x82, 0x00 });
- NAMES.put("ivory", new int[] { 0xff, 0xff, 0xf0, 0x00 });
- NAMES.put("khaki", new int[] { 0xf0, 0xe6, 0x8c, 0x00 });
- NAMES.put("lavender", new int[] { 0xe6, 0xe6, 0xfa, 0x00 });
- NAMES.put("lavenderblush", new int[] { 0xff, 0xf0, 0xf5, 0x00 });
- NAMES.put("lawngreen", new int[] { 0x7c, 0xfc, 0x00, 0x00 });
- NAMES.put("lemonchiffon", new int[] { 0xff, 0xfa, 0xcd, 0x00 });
- NAMES.put("lightblue", new int[] { 0xad, 0xd8, 0xe6, 0x00 });
- NAMES.put("lightcoral", new int[] { 0xf0, 0x80, 0x80, 0x00 });
- NAMES.put("lightcyan", new int[] { 0xe0, 0xff, 0xff, 0x00 });
- NAMES.put("lightgoldenrodyellow", new int[] { 0xfa, 0xfa, 0xd2, 0x00 });
- NAMES.put("lightgreen", new int[] { 0x90, 0xee, 0x90, 0x00 });
- NAMES.put("lightgrey", new int[] { 0xd3, 0xd3, 0xd3, 0x00 });
- NAMES.put("lightpink", new int[] { 0xff, 0xb6, 0xc1, 0x00 });
- NAMES.put("lightsalmon", new int[] { 0xff, 0xa0, 0x7a, 0x00 });
- NAMES.put("lightseagreen", new int[] { 0x20, 0xb2, 0xaa, 0x00 });
- NAMES.put("lightskyblue", new int[] { 0x87, 0xce, 0xfa, 0x00 });
- NAMES.put("lightslategray", new int[] { 0x77, 0x88, 0x99, 0x00 });
- NAMES.put("lightsteelblue", new int[] { 0xb0, 0xc4, 0xde, 0x00 });
- NAMES.put("lightyellow", new int[] { 0xff, 0xff, 0xe0, 0x00 });
- NAMES.put("lime", new int[] { 0x00, 0xff, 0x00, 0x00 });
- NAMES.put("limegreen", new int[] { 0x32, 0xcd, 0x32, 0x00 });
- NAMES.put("linen", new int[] { 0xfa, 0xf0, 0xe6, 0x00 });
- NAMES.put("magenta", new int[] { 0xff, 0x00, 0xff, 0x00 });
- NAMES.put("maroon", new int[] { 0x80, 0x00, 0x00, 0x00 });
- NAMES.put("mediumaquamarine", new int[] { 0x66, 0xcd, 0xaa, 0x00 });
- NAMES.put("mediumblue", new int[] { 0x00, 0x00, 0xcd, 0x00 });
- NAMES.put("mediumorchid", new int[] { 0xba, 0x55, 0xd3, 0x00 });
- NAMES.put("mediumpurple", new int[] { 0x93, 0x70, 0xdb, 0x00 });
- NAMES.put("mediumseagreen", new int[] { 0x3c, 0xb3, 0x71, 0x00 });
- NAMES.put("mediumslateblue", new int[] { 0x7b, 0x68, 0xee, 0x00 });
- NAMES.put("mediumspringgreen", new int[] { 0x00, 0xfa, 0x9a, 0x00 });
- NAMES.put("mediumturquoise", new int[] { 0x48, 0xd1, 0xcc, 0x00 });
- NAMES.put("mediumvioletred", new int[] { 0xc7, 0x15, 0x85, 0x00 });
- NAMES.put("midnightblue", new int[] { 0x19, 0x19, 0x70, 0x00 });
- NAMES.put("mintcream", new int[] { 0xf5, 0xff, 0xfa, 0x00 });
- NAMES.put("mistyrose", new int[] { 0xff, 0xe4, 0xe1, 0x00 });
- NAMES.put("moccasin", new int[] { 0xff, 0xe4, 0xb5, 0x00 });
- NAMES.put("navajowhite", new int[] { 0xff, 0xde, 0xad, 0x00 });
- NAMES.put("navy", new int[] { 0x00, 0x00, 0x80, 0x00 });
- NAMES.put("oldlace", new int[] { 0xfd, 0xf5, 0xe6, 0x00 });
- NAMES.put("olive", new int[] { 0x80, 0x80, 0x00, 0x00 });
- NAMES.put("olivedrab", new int[] { 0x6b, 0x8e, 0x23, 0x00 });
- NAMES.put("orange", new int[] { 0xff, 0xa5, 0x00, 0x00 });
- NAMES.put("orangered", new int[] { 0xff, 0x45, 0x00, 0x00 });
- NAMES.put("orchid", new int[] { 0xda, 0x70, 0xd6, 0x00 });
- NAMES.put("palegoldenrod", new int[] { 0xee, 0xe8, 0xaa, 0x00 });
- NAMES.put("palegreen", new int[] { 0x98, 0xfb, 0x98, 0x00 });
- NAMES.put("paleturquoise", new int[] { 0xaf, 0xee, 0xee, 0x00 });
- NAMES.put("palevioletred", new int[] { 0xdb, 0x70, 0x93, 0x00 });
- NAMES.put("papayawhip", new int[] { 0xff, 0xef, 0xd5, 0x00 });
- NAMES.put("peachpuff", new int[] { 0xff, 0xda, 0xb9, 0x00 });
- NAMES.put("peru", new int[] { 0xcd, 0x85, 0x3f, 0x00 });
- NAMES.put("pink", new int[] { 0xff, 0xc0, 0xcb, 0x00 });
- NAMES.put("plum", new int[] { 0xdd, 0xa0, 0xdd, 0x00 });
- NAMES.put("powderblue", new int[] { 0xb0, 0xe0, 0xe6, 0x00 });
- NAMES.put("purple", new int[] { 0x80, 0x00, 0x80, 0x00 });
- NAMES.put("red", new int[] { 0xff, 0x00, 0x00, 0x00 });
- NAMES.put("rosybrown", new int[] { 0xbc, 0x8f, 0x8f, 0x00 });
- NAMES.put("royalblue", new int[] { 0x41, 0x69, 0xe1, 0x00 });
- NAMES.put("saddlebrown", new int[] { 0x8b, 0x45, 0x13, 0x00 });
- NAMES.put("salmon", new int[] { 0xfa, 0x80, 0x72, 0x00 });
- NAMES.put("sandybrown", new int[] { 0xf4, 0xa4, 0x60, 0x00 });
- NAMES.put("seagreen", new int[] { 0x2e, 0x8b, 0x57, 0x00 });
- NAMES.put("seashell", new int[] { 0xff, 0xf5, 0xee, 0x00 });
- NAMES.put("sienna", new int[] { 0xa0, 0x52, 0x2d, 0x00 });
- NAMES.put("silver", new int[] { 0xc0, 0xc0, 0xc0, 0x00 });
- NAMES.put("skyblue", new int[] { 0x87, 0xce, 0xeb, 0x00 });
- NAMES.put("slateblue", new int[] { 0x6a, 0x5a, 0xcd, 0x00 });
- NAMES.put("slategray", new int[] { 0x70, 0x80, 0x90, 0x00 });
- NAMES.put("snow", new int[] { 0xff, 0xfa, 0xfa, 0x00 });
- NAMES.put("springgreen", new int[] { 0x00, 0xff, 0x7f, 0x00 });
- NAMES.put("steelblue", new int[] { 0x46, 0x82, 0xb4, 0x00 });
- NAMES.put("tan", new int[] { 0xd2, 0xb4, 0x8c, 0x00 });
- NAMES.put("transparent", new int[] { 0x00, 0x00, 0x00, 0xff });
- NAMES.put("teal", new int[] { 0x00, 0x80, 0x80, 0x00 });
- NAMES.put("thistle", new int[] { 0xd8, 0xbf, 0xd8, 0x00 });
- NAMES.put("tomato", new int[] { 0xff, 0x63, 0x47, 0x00 });
- NAMES.put("turquoise", new int[] { 0x40, 0xe0, 0xd0, 0x00 });
- NAMES.put("violet", new int[] { 0xee, 0x82, 0xee, 0x00 });
- NAMES.put("wheat", new int[] { 0xf5, 0xde, 0xb3, 0x00 });
- NAMES.put("white", new int[] { 0xff, 0xff, 0xff, 0x00 });
- NAMES.put("whitesmoke", new int[] { 0xf5, 0xf5, 0xf5, 0x00 });
- NAMES.put("yellow", new int[] { 0xff, 0xff, 0x00, 0x00 });
- NAMES.put("yellowgreen", new int[] { 0x9, 0xacd, 0x32, 0x00 });
- }
-
- /**
- * Gives you a Color based on a name.
- *
- * @param name
- * a name such as black, violet, cornflowerblue
- * @return the corresponding Color object
- * @throws IllegalArgumentException
- * if the String isn't a know representation of a color.
- */
- public static Color getRGBColor(String name)
- throws IllegalArgumentException {
- int[] c = { 0, 0, 0, 0 };
- if (name.startsWith("#")) {
- if (name.length() == 4) {
- c[0] = Integer.parseInt(name.substring(1, 2), 16) * 16;
- c[1] = Integer.parseInt(name.substring(2, 3), 16) * 16;
- c[2] = Integer.parseInt(name.substring(3), 16) * 16;
- return new Color(c[0], c[1], c[2], c[3]);
- }
- if (name.length() == 7) {
- c[0] = Integer.parseInt(name.substring(1, 3), 16);
- c[1] = Integer.parseInt(name.substring(3, 5), 16);
- c[2] = Integer.parseInt(name.substring(5), 16);
- return new Color(c[0], c[1], c[2], c[3]);
- }
- throw new IllegalArgumentException(
- "Unknown color format. Must be #RGB or #RRGGBB");
- }
- name = name.toLowerCase();
- if (!NAMES.containsKey(name))
- throw new IllegalArgumentException("Color '" + name
- + "' not found.");
- c = (int[]) NAMES.get(name);
- return new Color(c[0], c[1], c[2], c[3]);
- }
-} \ No newline at end of file