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  /**
15   * The <code>HTMLGraphicsConfiguration</code> class describes the characteristics of the HTML canvas in the browser, as a
16   * graphics destination to write to. Note that there can be several <code>GraphicsConfiguration</code> objects associated with a
17   * single graphics device, representing different drawing modes or capabilities. <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 HTMLGraphicsConfiguration extends GraphicsConfiguration
25  {
26      /** the {@link HTMLDevice} associated with this <code>HTMLGraphicsConfiguration</code>. */
27      HTMLDevice htmlDevice;
28  
29      /** the identity AffineTransform. */
30      AffineTransform identityTransform = new AffineTransform();
31  
32      /** the bounds, TODO: which should be filled in some way by the window size in the browser. */
33      Rectangle bounds = new Rectangle(0, 0, 1920, 1080);
34  
35      /**
36       * Create a graphics configuration for the HTML device.
37       */
38      public HTMLGraphicsConfiguration()
39      {
40          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.<init>");
41      }
42  
43      /** {@inheritDoc} */
44      @Override
45      public GraphicsDevice getDevice()
46      {
47          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getDevice()");
48          return this.htmlDevice;
49      }
50  
51      /**
52       * Set the {@link HTMLDevice} associated with this <code>HTMLGraphicsConfiguration</code>.
53       * @param htmlDevice HTMLDevice; a &lt;code&gt;GraphicsDevice&lt;/code&gt; object that is associated with this
54       *            <code>HTMLGraphicsConfiguration</code>.
55       */
56      public void setDevice(final HTMLDevice htmlDevice)
57      {
58          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.setDevice()");
59          this.htmlDevice = htmlDevice;
60      }
61  
62      /** {@inheritDoc} */
63      @Override
64      public ColorModel getColorModel()
65      {
66          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getColorModel()");
67          return ColorModel.getRGBdefault();
68      }
69  
70      /** {@inheritDoc} */
71      @Override
72      public ColorModel getColorModel(int transparency)
73      {
74          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getColorModel()");
75          return ColorModel.getRGBdefault();
76      }
77  
78      /** {@inheritDoc} */
79      @Override
80      public AffineTransform getDefaultTransform()
81      {
82          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getDefaultTransform()");
83          return this.identityTransform;
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public AffineTransform getNormalizingTransform()
89      {
90          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getNormalizingTransform()");
91          return this.identityTransform;
92      }
93  
94      /** {@inheritDoc} */
95      @Override
96      public Rectangle getBounds()
97      {
98          CategoryLogger.filter(Cat.WEB).trace("HTMLGraphicsConfiguration.getBounds()");
99          return this.bounds;
100     }
101 
102 }