01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id: NCnameProperty.java 474225 2006-11-13 10:08:19Z jeremias $ */
19:
20: package org.apache.fop.fo.expr;
21:
22: import java.awt.Color;
23:
24: import org.apache.fop.apps.FOUserAgent;
25: import org.apache.fop.fo.properties.Property;
26: import org.apache.fop.util.ColorUtil;
27:
28: /**
29: * Class for handling NC Name objects
30: */
31: public class NCnameProperty extends Property {
32:
33: private final String ncName;
34:
35: /**
36: * Constructor
37: * @param ncName string representing the ncName
38: */
39: public NCnameProperty(String ncName) {
40: this .ncName = ncName;
41: }
42:
43: /**
44: * If a system color, return the corresponding value.
45: *
46: * @param foUserAgent
47: * Reference to FOP user agent - keeps track of cached ColorMaps for ICC colors
48: * @return Color object corresponding to the NCName
49: */
50: public Color getColor(FOUserAgent foUserAgent) {
51: try {
52: return ColorUtil.parseColorString(foUserAgent, ncName);
53: } catch (PropertyException e) {
54: //Not logging this error since for properties like "border" you would get an awful
55: //lot of error messages for things like "solid" not being valid colors.
56: //log.error("Can't create color value: " + e.getMessage());
57: return null;
58: }
59: }
60:
61: /**
62: * @return the name as a String (should be specified with quotes!)
63: */
64: public String getString() {
65: return this .ncName;
66: }
67:
68: /**
69: * @return the name as an Object.
70: */
71: public Object getObject() {
72: return this .ncName;
73: }
74:
75: /**
76: * @return ncName for this
77: */
78: public String getNCname() {
79: return this.ncName;
80: }
81:
82: }
|