// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.objects.graphical; import xaal.util.XaalConstants; /** * @author vkaravir * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Font { private boolean bold = false; private boolean italic = false; private String family; private int size; /** * */ public Font() { super(); family = XaalConstants.DEFAULT_PROPERTY_FONTFAMILY; size = XaalConstants.DEFAULT_PROPERTY_FONTSIZE; } /** * @return Returns the bold. */ public boolean isBold() { return bold; } /** * @param bold The bold to set. */ public void setBold(boolean bold) { this.bold = bold; } /** * @return Returns the family. */ public String getFamily() { return family; } /** * @param family The family to set. */ public void setFamily(String family) { if (family == null || (!family.equalsIgnoreCase("Serif") && !family.equalsIgnoreCase("SansSerif") && !family.equalsIgnoreCase("Monospaced"))) { // TODO Common error handling - invalid font family return; } else this.family = family.toLowerCase(); } /** * @return Returns the italic. */ public boolean isItalic() { return italic; } /** * @param italic The italic to set. */ public void setItalic(boolean italic) { this.italic = italic; } /** * @return Returns the size. */ public int getSize() { return size; } /** * @param size The size to set. */ public void setSize(int size) { if (size <= 0) { // TODO Common error handling - negative font size return; } this.size = size; } public java.awt.Font getAwtFont() { int style = java.awt.Font.PLAIN; if (isItalic() && isBold()) { style = java.awt.Font.BOLD & java.awt.Font.ITALIC; } else if (isItalic()) { style = java.awt.Font.ITALIC; } else if (isBold()) { style = java.awt.Font.BOLD; } java.awt.Font f = new java.awt.Font(getFamily(), style, getSize()); return f; } }