1 package net.suberic.pooka.gui.filter; 2 import java.awt.*; 3 4 8 public class FontDisplayFilter implements DisplayFilter { 9 10 int fontStyle = -1; 11 12 java.util.HashMap derivedFontMap; 13 14 17 public FontDisplayFilter() { 18 } 19 20 23 public java.util.List performFilter(java.util.List tmp) { 24 return tmp; 25 } 26 27 30 public void initializeFilter(String propertyName) { 31 derivedFontMap = new java.util.HashMap (); 32 33 String fontString = net.suberic.pooka.Pooka.getProperty(propertyName + ".style", "bold"); 34 if (fontString.equalsIgnoreCase("bold")) 35 fontStyle = Font.BOLD; 36 else if (fontString.equalsIgnoreCase("italic")) 37 fontStyle = Font.ITALIC; 38 else if (fontString.equalsIgnoreCase("plain")) 39 fontStyle = Font.PLAIN; 40 } 41 42 45 public void apply(java.awt.Component target) { 46 Font currentFont = target.getFont(); 47 Font derivedFont = (Font) derivedFontMap.get(currentFont); 48 if (derivedFont != null) { 49 target.setFont(derivedFont); 50 } else { 51 derivedFont = currentFont.deriveFont(fontStyle); 52 derivedFontMap.put(currentFont, derivedFont); 53 target.setFont(derivedFont); 54 } 55 } 56 } 57 | Popular Tags |