View Javadoc
1   package nl.tudelft.simulation.dsol.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.djutils.logger.CategoryLogger;
12  
13  import nl.tudelft.simulation.dsol.logger.Cat;
14  
15  
16  /**
17   * HTMLGraphicsEnvironment.java. <br>
18   * <br>
19   * Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
20   * for project information <a href="https://www.simulation.tudelft.nl/" target="_blank">www.simulation.tudelft.nl</a>. The
21   * source code and binary code of this software is proprietary information of Delft University of Technology.
22   * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a>
23   */
24  public class HTMLGraphicsEnvironment extends GraphicsEnvironment
25  {
26      /** the (dummy) device to use in the graphics environment. */
27      HTMLDevice htmlDevice;
28  
29      /** the canvas to draw on. */
30      HTMLGraphics2D graphics2D;
31  
32      /** the (dummy) configuration to use. */
33      HTMLGraphicsConfiguration graphicsConfiguration;
34  
35      /**
36       * 
37       */
38      public HTMLGraphicsEnvironment()
39      {
40          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.<init>");
41          this.graphics2D = new HTMLGraphics2D();
42          this.graphicsConfiguration = new HTMLGraphicsConfiguration();
43          this.htmlDevice = new HTMLDevice(this.graphicsConfiguration);
44          this.graphicsConfiguration.setDevice(this.htmlDevice);
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public GraphicsDevice[] getScreenDevices() throws HeadlessException
50      {
51          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.getScreenDevices()");
52          return new GraphicsDevice[] {this.htmlDevice};
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public GraphicsDevice getDefaultScreenDevice() throws HeadlessException
58      {
59          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.getDefaultScreenDevice()");
60          return this.htmlDevice;
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public Graphics2D createGraphics(BufferedImage img)
66      {
67          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.createGraphics()");
68          return this.graphics2D;
69      }
70  
71      /** {@inheritDoc} */
72      @Override
73      public Font[] getAllFonts()
74      {
75          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.getAllFonts()");
76          return new Font[] {};
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public String[] getAvailableFontFamilyNames()
82      {
83          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.getAvailableFontFamilyNames()");
84          return new String[] {};
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      public String[] getAvailableFontFamilyNames(Locale l)
90      {
91          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsEnvironment.getAvailableFontFamilyNames()");
92          return new String[] {};
93      }
94  
95  }