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
19: * @version $Revision$
20: */package org.apache.harmony.awt.gl.linux;
21:
22: import java.awt.Font;
23: import java.awt.Graphics2D;
24: import java.awt.GraphicsEnvironment;
25: import java.io.IOException;
26:
27: import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
28: import org.apache.harmony.awt.gl.MultiRectArea;
29: import org.apache.harmony.awt.gl.opengl.OGLGraphics2D;
30: import org.apache.harmony.awt.gl.font.FontManager;
31: import org.apache.harmony.awt.gl.font.LinuxFont;
32: import org.apache.harmony.awt.gl.font.LinuxFontManager;
33: import org.apache.harmony.awt.wtk.NativeWindow;
34: import org.apache.harmony.awt.wtk.WindowFactory;
35: import org.apache.harmony.awt.wtk.linux.LinuxWindowFactory;
36:
37: /**
38: * Graphics2D factory for Linux
39: *
40: */
41: public class LinuxGraphics2DFactory extends CommonGraphics2DFactory {
42: static {
43: inst = new LinuxGraphics2DFactory();
44: }
45:
46: public Graphics2D getGraphics2D(NativeWindow nw, int tx, int ty,
47: MultiRectArea clip) {
48: String opengl = System.getProperty("java2d.opengl"); //$NON-NLS-1$
49: boolean useOpenGL = opengl != null && opengl.equals("true"); //$NON-NLS-1$
50: return useOpenGL ? (Graphics2D) new OGLGraphics2D(nw, tx, ty,
51: clip) : new XGraphics2D(nw, tx, ty, clip);
52: }
53:
54: public Graphics2D getGraphics2D(NativeWindow nw, int tx, int ty,
55: int width, int height) {
56: String opengl = System.getProperty("java2d.opengl"); //$NON-NLS-1$
57: boolean useOpenGL = opengl != null && opengl.equals("true"); //$NON-NLS-1$
58: return useOpenGL ? (Graphics2D) new OGLGraphics2D(nw, tx, ty,
59: width, height) : new XGraphics2D(nw, tx, ty, width,
60: height);
61: }
62:
63: public GraphicsEnvironment createGraphicsEnvironment(
64: WindowFactory wf) {
65: return new XGraphicsEnvironment((LinuxWindowFactory) wf);
66: }
67:
68: public FontManager getFontManager() {
69: return LinuxFontManager.inst;
70: }
71:
72: public Font embedFont(String fontFilePath) throws IOException {
73: return LinuxFont.embedFont(fontFilePath);
74: }
75:
76: }
|