MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getFont

Method getFont

src/main/java/gate/util/OptionsMap.java:150–172  ·  view source on GitHub ↗

If the object stored under key is a Font then returns its value otherwise returns null. @param key key associated to the value to retrieve @return the associated font

(Object key)

Source from the content-addressed store, hash-verified

148 * @return the associated font
149 */
150 public Font getFont(Object key) {
151 try {
152 String stringValue = (String) get(key);
153 if (stringValue == null) { return null; }
154 StringTokenizer strTok = new StringTokenizer(stringValue, "#", false);
155 String family = strTok.nextToken();
156 int size = Integer.parseInt(strTok.nextToken());
157 boolean italic = Boolean.valueOf(strTok.nextToken());
158 boolean bold = Boolean.valueOf(strTok.nextToken());
159 HashMap<TextAttribute, Serializable> fontAttrs =
160 new HashMap<TextAttribute, Serializable>();
161 fontAttrs.put(TextAttribute.FAMILY, family);
162 fontAttrs.put(TextAttribute.SIZE, (float) size);
163 if(bold) fontAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
164 else fontAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
165 if(italic) fontAttrs.put(
166 TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
167 else fontAttrs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
168 return new Font(fontAttrs);
169 } catch (Exception e) {
170 return null;
171 }
172 }
173
174 /**
175 * If the object stored under key is a set then returns its value

Callers 15

applyUserPreferencesMethod · 0.95
JFontChooserMethod · 0.80
initGuiComponentsMethod · 0.80
actionPerformedMethod · 0.80
mainMethod · 0.80
updateStyleMethod · 0.80
calcDimensionsMethod · 0.80
paintIconMethod · 0.80
arangeAllComponentsMethod · 0.80
initLocalDataMethod · 0.80
mainMethod · 0.80
setTargetMethod · 0.80

Calls 2

getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected