1 package org.opentrafficsim.web.animation;
2
3 import java.awt.Font;
4 import java.awt.Graphics2D;
5 import java.awt.GraphicsDevice;
6 import java.awt.GraphicsEnvironment;
7 import java.awt.HeadlessException;
8 import java.awt.image.BufferedImage;
9 import java.util.Locale;
10
11 import org.opentrafficsim.base.logger.Logger;
12
13
14
15
16
17
18
19
20
21 public class HtmlGraphicsEnvironment extends GraphicsEnvironment
22 {
23
24 private HtmlDevice htmlDevice;
25
26
27 private HtmlGraphics2d graphics2D;
28
29
30 private HtmlGraphicsConfiguration graphicsConfiguration;
31
32
33
34
35 public HtmlGraphicsEnvironment()
36 {
37 Logger.ots().trace("HTMLGraphicsEnvironment.<init>");
38 this.graphics2D = new HtmlGraphics2d();
39 this.graphicsConfiguration = new HtmlGraphicsConfiguration();
40 this.htmlDevice = new HtmlDevice(this.graphicsConfiguration);
41 this.graphicsConfiguration.setDevice(this.htmlDevice);
42 }
43
44 @Override
45 public GraphicsDevice[] getScreenDevices() throws HeadlessException
46 {
47 Logger.ots().trace("HTMLGraphicsEnvironment.getScreenDevices()");
48 return new GraphicsDevice[] {this.htmlDevice};
49 }
50
51 @Override
52 public GraphicsDevice getDefaultScreenDevice() throws HeadlessException
53 {
54 Logger.ots().trace("HTMLGraphicsEnvironment.getDefaultScreenDevice()");
55 return this.htmlDevice;
56 }
57
58 @Override
59 public Graphics2D createGraphics(final BufferedImage img)
60 {
61 Logger.ots().trace("HTMLGraphicsEnvironment.createGraphics()");
62 return this.graphics2D;
63 }
64
65 @Override
66 public Font[] getAllFonts()
67 {
68 Logger.ots().trace("HTMLGraphicsEnvironment.getAllFonts()");
69 return new Font[] {};
70 }
71
72 @Override
73 public String[] getAvailableFontFamilyNames()
74 {
75 Logger.ots().trace("HTMLGraphicsEnvironment.getAvailableFontFamilyNames()");
76 return new String[] {};
77 }
78
79 @Override
80 public String[] getAvailableFontFamilyNames(final Locale l)
81 {
82 Logger.ots().trace("HTMLGraphicsEnvironment.getAvailableFontFamilyNames()");
83 return new String[] {};
84 }
85
86 }