01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexey A. Petrenko, Oleg V. Khaschansky
19: * @version $Revision$
20: */package org.apache.harmony.awt.gl;
21:
22: import java.awt.Font;
23: import java.awt.Graphics2D;
24: import java.awt.GraphicsEnvironment;
25: import java.awt.image.BufferedImage;
26: import java.util.ArrayList;
27: import java.util.Locale;
28:
29: import org.apache.harmony.awt.gl.font.FontManager;
30: import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
31: import org.apache.harmony.awt.gl.image.BufferedImageGraphics2D;
32:
33: /**
34: * Common GraphicsEnvironment implementation
35: *
36: */
37: public abstract class CommonGraphicsEnvironment extends
38: GraphicsEnvironment {
39:
40: @Override
41: public Graphics2D createGraphics(BufferedImage bufferedImage) {
42: return new BufferedImageGraphics2D(bufferedImage);
43: }
44:
45: @Override
46: public String[] getAvailableFontFamilyNames(Locale locale) {
47: Font[] fonts = getAllFonts();
48: ArrayList<String> familyNames = new ArrayList<String>();
49:
50: for (Font element : fonts) {
51: String name = element.getFamily(locale);
52: if (!familyNames.contains(name)) {
53: familyNames.add(name);
54: }
55: }
56:
57: return familyNames.toArray(new String[familyNames.size()]);
58: }
59:
60: @Override
61: public Font[] getAllFonts() {
62: return FontManager.getInstance().getAllFonts();
63: }
64:
65: @Override
66: public String[] getAvailableFontFamilyNames() {
67: return FontManager.getInstance().getAllFamilies();
68: }
69: }
|