diff options
author | Karen Lease <klease@apache.org> | 2000-11-10 22:28:38 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2000-11-10 22:28:38 +0000 |
commit | fa87b4edc1f730f01a78fcf15499dcd98b6fe164 (patch) | |
tree | c0fdf94a05b107bb4e7301aca4c4b421ffb8b7be /src/org | |
parent | 1819a8cd168a69c708a1f15e46e5dce6787e6e76 (diff) | |
download | xmlgraphics-fop-fa87b4edc1f730f01a78fcf15499dcd98b6fe164.tar.gz xmlgraphics-fop-fa87b4edc1f730f01a78fcf15499dcd98b6fe164.zip |
Move rgb() into new fo.expr package
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193772 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/apache/fop/datatypes/ColorType.java | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/org/apache/fop/datatypes/ColorType.java b/src/org/apache/fop/datatypes/ColorType.java index df2ef07ec..14cfd0faa 100644 --- a/src/org/apache/fop/datatypes/ColorType.java +++ b/src/org/apache/fop/datatypes/ColorType.java @@ -70,6 +70,12 @@ public class ColorType { /** the alpha component */ protected float alpha = 0; + public ColorType (float red, float green, float blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + /** * set the colour given a particular String specifying either a * colour name or #RGB or #RRGGBB @@ -99,45 +105,8 @@ public class ColorType { this.blue = 0; MessageHandler.errorln("ERROR: unknown colour format. Must be #RGB or #RRGGBB"); } - } else if (value.startsWith("rgb(")) { - int poss = value.indexOf("("); - int pose = value.indexOf(")"); - if(poss != -1 && pose != -1) { - value = value.substring(poss + 1, pose); - StringTokenizer st = new StringTokenizer(value, ","); - try { - if(st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if(str.endsWith("%")) { - this.red = Integer.parseInt(str.substring(0, str.length() - 1)) * 2.55f; - } else { - this.red = Integer.parseInt(str)/255f; - } - } - if(st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if(str.endsWith("%")) { - this.green = Integer.parseInt(str.substring(0, str.length() - 1)) * 2.55f; - } else { - this.green = Integer.parseInt(str)/255f; - } - } - if(st.hasMoreTokens()) { - String str = st.nextToken().trim(); - if(str.endsWith("%")) { - this.blue = Integer.parseInt(str.substring(0, str.length() - 1)) * 2.55f; - } else { - this.blue = Integer.parseInt(str)/255f; - } - } - } catch (Exception e) { - this.red = 0; - this.green = 0; - this.blue = 0; - MessageHandler.errorln("ERROR: unknown colour format. Must be #RGB or #RRGGBB"); - } - } - } else if (value.startsWith("url(")) { + } + else if (value.startsWith("url(")) { // refers to a gradient } else { if (value.toLowerCase().equals("transparent")) { |