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. <br>
17   * <br>
18   * Copyright (c) 2003-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
19   * for project information <a href="https://www.simulation.tudelft.nl/" target="_blank">www.simulation.tudelft.nl</a>. The
20   * source code and binary code of this software is proprietary information of Delft University of Technology.
21   * @author <a href="https://www.tudelft.nl/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 }