View Javadoc
1   package nl.tudelft.simulation.dsol.web.animation;
2   
3   import java.awt.GraphicsConfiguration;
4   import java.awt.GraphicsDevice;
5   import java.awt.Rectangle;
6   import java.awt.geom.AffineTransform;
7   import java.awt.image.ColorModel;
8   
9   import org.djutils.logger.CategoryLogger;
10  
11  import nl.tudelft.simulation.dsol.logger.Cat;
12  
13  /**
14   * The <code>HTMLGraphicsConfiguration</code> class describes the characteristics of the HTML canvas in the browser, as a
15   * graphics destination to write to. Note that there can be several <code>GraphicsConfiguration</code> objects associated with a
16   * single graphics device, representing different drawing modes or capabilities.
17   * <p>
18   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
20   * </p>
21   * @author <a href="https://github.com/averbraeck" target="_blank">Alexander Verbraeck</a>
22   */
23  public class HtmlGraphicsConfiguration extends GraphicsConfiguration
24  {
25      /** the {@link HtmlDevice} associated with this <code>HTMLGraphicsConfiguration</code>. */
26      HtmlDevice htmlDevice;
27  
28      /** the identity AffineTransform. */
29      AffineTransform identityTransform = new AffineTransform();
30  
31      /** the bounds, TODO: which should be filled in some way by the window size in the browser. */
32      Rectangle bounds = new Rectangle(0, 0, 1920, 1080);
33  
34      /**
35       * Create a graphics configuration for the HTML device.
36       */
37      public HtmlGraphicsConfiguration()
38      {
39          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.<init>");
40      }
41  
42      /** {@inheritDoc} */
43      @Override
44      public GraphicsDevice getDevice()
45      {
46          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getDevice()");
47          return this.htmlDevice;
48      }
49  
50      /**
51       * Set the {@link HtmlDevice} associated with this <code>HTMLGraphicsConfiguration</code>.
52       * @param htmlDevice HTMLDevice; a &lt;code&gt;GraphicsDevice&lt;/code&gt; object that is associated with this
53       *            <code>HTMLGraphicsConfiguration</code>.
54       */
55      public void setDevice(final HtmlDevice htmlDevice)
56      {
57          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.setDevice()");
58          this.htmlDevice = htmlDevice;
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public ColorModel getColorModel()
64      {
65          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getColorModel()");
66          return ColorModel.getRGBdefault();
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public ColorModel getColorModel(int transparency)
72      {
73          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getColorModel()");
74          return ColorModel.getRGBdefault();
75      }
76  
77      /** {@inheritDoc} */
78      @Override
79      public AffineTransform getDefaultTransform()
80      {
81          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getDefaultTransform()");
82          return this.identityTransform;
83      }
84  
85      /** {@inheritDoc} */
86      @Override
87      public AffineTransform getNormalizingTransform()
88      {
89          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getNormalizingTransform()");
90          return this.identityTransform;
91      }
92  
93      /** {@inheritDoc} */
94      @Override
95      public Rectangle getBounds()
96      {
97          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getBounds()");
98          return this.bounds;
99      }
100 
101 }