/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (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.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id: IFState.java 1069439 2011-02-10 15:58:57Z jeremias $ */

package org.apache.fop.render.intermediate;

import java.awt.Color;

import org.apache.xmlgraphics.java2d.color.ColorUtil;

a state class for intermediate format data
/** a state class for intermediate format data */
public final class IFState { private IFState parent; private String fontFamily; private int fontSize; private String fontStyle; private int fontWeight; private String fontVariant; private boolean fontChanged = true; private Color textColor; private IFState() { //nop } private IFState(IFState parent) { this.parent = parent; this.fontFamily = parent.fontFamily; this.fontSize = parent.fontSize; this.fontStyle = parent.fontStyle; this.fontWeight = parent.fontWeight; this.fontVariant = parent.fontVariant; this.textColor = parent.textColor; }
Returns:create state
/** @return create state */
public static IFState create() { return new IFState(); }
Returns:push state
/** @return push state */
public IFState push() { return new IFState(this); }
Returns:pop state
/** @return pop state */
public IFState pop() { return this.parent; }
Returns:true if font changed
/** @return true if font changed */
public boolean isFontChanged() { return this.fontChanged; }
reset font changed
/** reset font changed */
public void resetFontChanged() { this.fontChanged = false; }
Returns the font family.
Returns:the font family
/** * Returns the font family. * @return the font family */
public String getFontFamily() { return fontFamily; }
Sets the font family.
Params:
  • family – the new font family
/** * Sets the font family. * @param family the new font family */
public void setFontFamily(String family) { if (!family.equals(this.fontFamily)) { this.fontChanged = true; } this.fontFamily = family; }
Returns the font size.
Returns:the font size (in mpt)
/** * Returns the font size. * @return the font size (in mpt) */
public int getFontSize() { return fontSize; }
Sets the font size.
Params:
  • size – the new font size (in mpt)
/** * Sets the font size. * @param size the new font size (in mpt) */
public void setFontSize(int size) { if (size != this.fontSize) { this.fontChanged = true; } this.fontSize = size; }
Returns the font style.
Returns:the font style
/** * Returns the font style. * @return the font style */
public String getFontStyle() { return fontStyle; }
Set the font style
Params:
  • style – the new font style
/** * Set the font style * @param style the new font style */
public void setFontStyle(String style) { if (!style.equals(this.fontStyle)) { this.fontChanged = true; } this.fontStyle = style; }
Returns the font weight.
Returns:the font weight
/** * Returns the font weight. * @return the font weight */
public int getFontWeight() { return fontWeight; }
Sets the font weight
Params:
  • weight – the new font weight
/** * Sets the font weight * @param weight the new font weight */
public void setFontWeight(int weight) { if (weight != this.fontWeight) { this.fontChanged = true; } this.fontWeight = weight; }
Returns the font variant.
Returns:the font variant
/** * Returns the font variant. * @return the font variant */
public String getFontVariant() { return fontVariant; }
Sets the font variant.
Params:
  • variant – the new font variant
/** * Sets the font variant. * @param variant the new font variant */
public void setFontVariant(String variant) { if (!variant.equals(this.fontVariant)) { this.fontChanged = true; } this.fontVariant = variant; }
Returns the text color.
Returns:the text color
/** * Returns the text color. * @return the text color */
public Color getTextColor() { return textColor; }
Sets the text color.
Params:
  • color – the new text color
/** * Sets the text color. * @param color the new text color */
public void setTextColor(Color color) { if (!ColorUtil.isSameColor(color, this.textColor)) { this.fontChanged = true; } this.textColor = color; } }