/* * Copyright (c) 2006 Declarative Engineering LLC. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Declarative Engineering LLC * verson 1 which accompanies this distribution, and is available at * http://declarativeengineering.com/legal/DE_Developer_License_v1.txt */ package com.foundation.view.swt; import com.common.comparison.Comparator; import com.foundation.metadata.Attribute; import com.foundation.model.Model; import com.foundation.view.JefColor; /* * An external structure for specifying text style metadata. *

If the text represented by this info instance contains a mix of style settings then only the common styles will be set in this info object. The attributes for which there is a mix of data will be assigned a null value.

*/ public class StyleTextInfo extends Model { public static final Attribute FONT_NAME = registerAttribute(StyleTextInfo.class, "fontName"); public static final Attribute FONT_HEIGHT = registerAttribute(StyleTextInfo.class, "fontHeight"); public static final Attribute FOREGROUND_COLOR = registerAttribute(StyleTextInfo.class, "foregroundColor"); public static final Attribute BACKGROUND_COLOR = registerAttribute(StyleTextInfo.class, "backgroundColor"); public static final Attribute BOLD = registerAttribute(StyleTextInfo.class, "bold"); public static final Attribute ITALIC = registerAttribute(StyleTextInfo.class, "italic"); public static final Attribute UNDERLINE = registerAttribute(StyleTextInfo.class, "underline"); public static final Attribute STRIKEOUT = registerAttribute(StyleTextInfo.class, "strikeout"); public static final Attribute RISE = registerAttribute(StyleTextInfo.class, "rise"); public static final Attribute GLYPH_ASCENT = registerAttribute(StyleTextInfo.class, "glyphAscent"); public static final Attribute GLYPH_DESCENT = registerAttribute(StyleTextInfo.class, "glyphDescent"); public static final Attribute GLYPH_WIDTH = registerAttribute(StyleTextInfo.class, "glyphWidth"); /** * StyleTextInfo constructor. */ public StyleTextInfo() { super(); }//StyleTextInfo()// /** * Gets the font name for the related text. * @return The text's font name. */ public String getFontName() { return (String) getAttributeValue(FONT_NAME); }//getFontName()// /** * Sets the font name for the related text. * @param fontName The text's font name. */ public void setFontName(String fontName) { setAttributeValue(FONT_NAME, fontName); }//setFontName()// /** * Gets whether the font is bolded * @return The text's style flags. */ public Boolean getBold() { return (Boolean) getAttributeValue(BOLD); }//getBold()// /** * Sets whether the font is bolded. * @param bold The text's style flags. */ public void setBold(Boolean bold) { setAttributeValue(BOLD, bold); }//setBold()// /** * Gets whether the font is italicized. * @return The text's style flags. */ public Boolean getItalic() { return (Boolean) getAttributeValue(ITALIC); }//getItalic()// /** * Sets whether the font is italicized. * @param italic The text's style flags. */ public void setItalic(Boolean italic) { setAttributeValue(ITALIC, italic); }//setItalic()// /** * Gets the height of the related text's font. * @return The text's font height. */ public Integer getFontHeight() { return (Integer) getAttributeValue(FONT_HEIGHT); }//getFontHeight()// /** * Sets the height of the related text's font. * @param fontHeight The text's font height. */ public void setFontHeight(Integer fontHeight) { setAttributeValue(FONT_HEIGHT, fontHeight); }//setFontHeight()// /** * Gets the background color for the related text. * @return The text's background color. */ public JefColor getBackgroundColor() { return (JefColor) getAttributeValue(BACKGROUND_COLOR); }//getBackgroundColor()// /** * Sets the background color for the related text. * @param backgroundColor The text's background color. */ public void setBackgroundColor(JefColor backgroundColor) { setAttributeValue(BACKGROUND_COLOR, backgroundColor); }//setBackgroundColor()// /** * Gets the foreground color for the related text. * @return The text's foreground color. */ public JefColor getForegroundColor() { return (JefColor) getAttributeValue(FOREGROUND_COLOR); }//getForegroundColor()// /** * Sets the foreground color for the related text. * @param foregroundColor The text's foreground color. */ public void setForegroundColor(JefColor foregroundColor) { setAttributeValue(FOREGROUND_COLOR, foregroundColor); }//setForegroundColor()// /** * Gets whether the text is underlined. * @return Whether the text is underlined. */ public Boolean getUnderline() { return (Boolean) getAttributeValue(UNDERLINE); }//getUnderline()// /** * Sets whether the text is underlined. * @param underline Whether the text is underlined. */ public void setUnderline(Boolean underline) { setAttributeValue(UNDERLINE, underline); }//setUnderline()// /** * Gets whether the text is striked out. * @return Whether the text is striked out. */ public Boolean getStrikeout() { return (Boolean) getAttributeValue(STRIKEOUT); }//getStrikeout()// /** * Sets whether the text is striked out. * @param strikeout Whether the text is striked out. */ public void setStrikeout(Boolean strikeout) { setAttributeValue(STRIKEOUT, strikeout); }//setStrikeout()// /** * Gets the rise for the text. * @return The text rise. */ public Integer getRise() { return (Integer) getAttributeValue(RISE); }//getRise()// /** * Sets the rise for the text. * @param rise The text rise. */ public void setRise(Integer rise) { setAttributeValue(RISE, rise); }//setRise()// /** * Gets the glyph ascent for the text. * @return The glyph ascent for the text. The default is zero. */ public Integer getGlyphAscent() { return (Integer) getAttributeValue(GLYPH_ASCENT); }//getGlyphAscent()// /** * Sets the glyph ascent for the text. * @param glyphAscent The glyph ascent for the text. The default is zero. */ public void setGlyphAscent(Integer glyphAscent) { setAttributeValue(GLYPH_ASCENT, glyphAscent); }//setGlyphAscent()// /** * Gets the glyph descent for the text. * @return The glyph descent for the text. The default is zero. */ public Integer getGlyphDescent() { return (Integer) getAttributeValue(GLYPH_DESCENT); }//getGlyphDescent()// /** * Sets the glyph descent for the text. * @param glyphDescent The glyph descent for the text. The default is zero. */ public void setGlyphDescent(Integer glyphDescent) { setAttributeValue(GLYPH_DESCENT, glyphDescent); }//setGlyphDescent()// /** * Gets the glyph width for the text. * @return The glyph width for the text. The default is zero. */ public Integer getGlyphWidth() { return (Integer) getAttributeValue(GLYPH_WIDTH); }//getGlyphWidth()// /** * Sets the glyph width for the text. * @param glyphWidth The glyph width for the text. The default is zero. */ public void setGlyphWidth(Integer glyphWidth) { setAttributeValue(GLYPH_WIDTH, glyphWidth); }//setGlyphWidth()// /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return "Text Style"; }//toString()// /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object object) { return (object instanceof StyleTextInfo) && Comparator.equals(getFontName(), ((StyleTextInfo) object).getFontName()) && Comparator.equals(getFontHeight(), ((StyleTextInfo) object).getFontHeight()) && Comparator.equals(getBold(), ((StyleTextInfo) object).getBold()) && Comparator.equals(getItalic(), ((StyleTextInfo) object).getItalic()) && Comparator.equals(getBackgroundColor(), ((StyleTextInfo) object).getBackgroundColor()) && Comparator.equals(getForegroundColor(), ((StyleTextInfo) object).getForegroundColor()) && Comparator.equals(getGlyphAscent(), ((StyleTextInfo) object).getGlyphAscent()) && Comparator.equals(getGlyphDescent(), ((StyleTextInfo) object).getGlyphDescent()) && Comparator.equals(getGlyphWidth(), ((StyleTextInfo) object).getGlyphWidth()) && Comparator.equals(getRise(), ((StyleTextInfo) object).getRise()) && Comparator.equals(getUnderline(), ((StyleTextInfo) object).getUnderline()) && Comparator.equals(getStrikeout(), ((StyleTextInfo) object).getStrikeout()); }//equals()// /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return (getFontName() == null ? 0 : getFontName().hashCode()) ^ (getFontHeight() == null ? 0 : getFontHeight().hashCode()) ^ (getBold() == null ? 0 : getBold().hashCode()) ^ (getItalic() == null ? 0 : getItalic().hashCode()) ^ (getBackgroundColor() == null ? 0 : getBackgroundColor().hashCode()) ^ (getForegroundColor() == null ? 0 : getForegroundColor().hashCode()) ^ (getGlyphAscent() == null ? 0 : getGlyphAscent().hashCode()) ^ (getGlyphDescent() == null ? 0 : getGlyphDescent().hashCode()) ^ (getGlyphWidth() == null ? 0 : getGlyphWidth().hashCode()) ^ (getRise() == null ? 0 : getRise().hashCode()) ^ (getUnderline() == null ? 0 : getUnderline().hashCode()) ^ (getStrikeout() == null ? 0 : getStrikeout().hashCode()); }//hashCode()// }//StyleTextInfo//