001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.css.engine.value;
020:
021: import org.w3c.dom.DOMException;
022: import org.w3c.dom.css.CSSPrimitiveValue;
023:
024: /**
025: * This class represents CSS rect values.
026: *
027: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
028: * @version $Id: RectValue.java 478160 2006-11-22 13:35:06Z dvholten $
029: */
030: public class RectValue extends AbstractValue {
031:
032: /**
033: * The top value.
034: */
035: protected Value top;
036:
037: /**
038: * The right value.
039: */
040: protected Value right;
041:
042: /**
043: * The bottom value.
044: */
045: protected Value bottom;
046:
047: /**
048: * The left value.
049: */
050: protected Value left;
051:
052: /**
053: * Creates a new Rect value.
054: */
055: public RectValue(Value t, Value r, Value b, Value l) {
056: top = t;
057: right = r;
058: bottom = b;
059: left = l;
060: }
061:
062: /**
063: * The type of the value.
064: */
065: public short getPrimitiveType() {
066: return CSSPrimitiveValue.CSS_RECT;
067: }
068:
069: /**
070: * A string representation of the current value.
071: */
072: public String getCssText() {
073: return "rect(" + top.getCssText() + ", " + right.getCssText()
074: + ", " + bottom.getCssText() + ", " + left.getCssText()
075: + ')';
076: }
077:
078: /**
079: * Implements {@link Value#getTop()}.
080: */
081: public Value getTop() throws DOMException {
082: return top;
083: }
084:
085: /**
086: * Implements {@link Value#getRight()}.
087: */
088: public Value getRight() throws DOMException {
089: return right;
090: }
091:
092: /**
093: * Implements {@link Value#getBottom()}.
094: */
095: public Value getBottom() throws DOMException {
096: return bottom;
097: }
098:
099: /**
100: * Implements {@link Value#getLeft()}.
101: */
102: public Value getLeft() throws DOMException {
103: return left;
104: }
105:
106: /**
107: * Returns a printable representation of this value.
108: */
109: public String toString() {
110: return getCssText();
111: }
112: }
|