001 /*
002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: RelativeScriptlevelLayoutContext.java,v 8afef6dd0d58 2007/09/14 08:29:58 maxberger $ */
018
019 package net.sourceforge.jeuclid.context;
020
021 import net.sourceforge.jeuclid.LayoutContext;
022
023 /**
024 * @version $Revision: 8afef6dd0d58 $
025 */
026 public class RelativeScriptlevelLayoutContext implements LayoutContext {
027
028 private final LayoutContext parentLayoutContext;
029
030 private final int sizeOffset;
031
032 /**
033 * Default Constructor.
034 *
035 * @param parent
036 * LayoutContext of parent.
037 * @param offset
038 * offset to parent. In most cases this will be 1.
039 *
040 */
041 public RelativeScriptlevelLayoutContext(final LayoutContext parent,
042 final int offset) {
043 this.parentLayoutContext = parent;
044 this.sizeOffset = offset;
045 }
046
047 /** {@inheritDoc} */
048 public Object getParameter(final Parameter which) {
049 if (Parameter.SCRIPTLEVEL.equals(which)) {
050 return ((Integer) this.parentLayoutContext
051 .getParameter(Parameter.SCRIPTLEVEL))
052 + this.sizeOffset;
053 }
054 return this.parentLayoutContext.getParameter(which);
055 }
056 }