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.windows;
21:
22: import java.awt.*;
23:
24: import java.io.IOException;
25:
26: import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
27: import org.apache.harmony.awt.gl.MultiRectArea;
28: import org.apache.harmony.awt.gl.opengl.OGLGraphics2D;
29: import org.apache.harmony.awt.gl.font.FontManager;
30: import org.apache.harmony.awt.gl.font.WinFontManager;
31: import org.apache.harmony.awt.gl.font.WindowsFont;
32: import org.apache.harmony.awt.wtk.NativeWindow;
33: import org.apache.harmony.awt.wtk.WindowFactory;
34:
35: /**
36: * Graphics2D factory for Windows
37: *
38: */
39: public class WinGraphics2DFactory extends CommonGraphics2DFactory {
40: static {
41: inst = new WinGraphics2DFactory();
42: }
43:
44: @SuppressWarnings("deprecation")
45: @Deprecated
46: public Graphics2D getGraphics2D(NativeWindow nw, int tx, int ty,
47: MultiRectArea clip) {
48: Insets ins = nw.getInsets();
49: if (WinGraphicsDevice.useOpenGL) {
50: return new OGLGraphics2D(nw, tx - ins.left, ty - ins.top,
51: clip);
52: }
53: if (WinGraphicsDevice.useGDI) {
54: return new WinGDIGraphics2D(nw, tx - ins.left,
55: ty - ins.top, clip);
56: }
57: return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top,
58: clip);
59: }
60:
61: public Graphics2D getGraphics2D(NativeWindow nw, int tx, int ty,
62: int width, int height) {
63: Insets ins = nw.getInsets();
64: if (WinGraphicsDevice.useOpenGL) {
65: return new OGLGraphics2D(nw, tx - ins.left, ty - ins.top,
66: width, height);
67: }
68: if (WinGraphicsDevice.useGDI) {
69: return new WinGDIGraphics2D(nw, tx - ins.left,
70: ty - ins.top, width, height);
71: }
72: return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top,
73: width, height);
74: }
75:
76: public GraphicsEnvironment createGraphicsEnvironment(
77: WindowFactory wf) {
78: return new WinGraphicsEnvironment(wf);
79: }
80:
81: public FontManager getFontManager() {
82: return WinFontManager.inst;
83: }
84:
85: @Override
86: public Font embedFont(String fontFilePath) throws IOException {
87: return WindowsFont.embedFont(fontFilePath);
88: }
89:
90: }
|