Package snap.swing

Class AWTEnv


public class AWTEnv extends GFXEnv
A GFXEnv implementation using AWT.
  • Constructor Details

    • AWTEnv

      public AWTEnv()
      Creates a new AWTEnv.
  • Method Details

    • getResource

      public URL getResource(Class<?> aClass, String aPath)
      Returns resource for class and path.
      Specified by:
      getResource in class GFXEnv
    • getClassRoot

      public String getClassRoot()
      Returns the root URL classes in Snap Jar as string.
      Specified by:
      getClassRoot in class GFXEnv
    • getFontNames

      public String[] getFontNames()
      Returns a list of all system fontnames (excludes any that don't start with capital A-Z).
      Specified by:
      getFontNames in class GFXEnv
    • getFamilyNames

      public String[] getFamilyNames()
      Returns a list of all system family names.
      Specified by:
      getFamilyNames in class GFXEnv
    • getFontNames

      public String[] getFontNames(String aFamilyName)
      Returns a list of all font names for a given family name.
      Specified by:
      getFontNames in class GFXEnv
    • getFontFile

      public FontFile getFontFile(String aName)
      Returns a font file for given name.
      Specified by:
      getFontFile in class GFXEnv
    • getImageForSource

      public Image getImageForSource(Object aSource)
      Creates image from source.
      Specified by:
      getImageForSource in class GFXEnv
    • getImageForSizeAndScale

      public Image getImageForSizeAndScale(double aWidth, double aHeight, boolean hasAlpha, double aScale)
      Creates image for width, height and alpha and dpi scale (0 = screen dpi, 1 = 72 dpi, 2 = 144 dpi).
      Specified by:
      getImageForSizeAndScale in class GFXEnv
    • getSound

      public SoundClip getSound(Object aSource)
      Returns a sound for given source.
      Specified by:
      getSound in class GFXEnv
    • createSound

      public SoundClip createSound()
      Creates a sound for given source.
      Specified by:
      createSound in class GFXEnv
    • openFile

      public void openFile(Object aSource)
      Tries to open the given file source with the platform reader.
      Specified by:
      openFile in class GFXEnv
    • openURL

      public void openURL(Object aSource)
      Tries to open the given URL with the platform reader.
      Specified by:
      openURL in class GFXEnv
    • openTextFile

      public void openTextFile(Object aSource)
      Tries to open the given file source with the platform text file reader.
      Overrides:
      openTextFile in class GFXEnv
    • getScreenResolution

      public double getScreenResolution()
      Returns the screen resolution.
      Specified by:
      getScreenResolution in class GFXEnv
    • getScreenScale

      public double getScreenScale()
      Returns the screen scale. Usually 1, but could be 2 for HiDPI/Retina displays.
      Specified by:
      getScreenScale in class GFXEnv
    • beep

      public void beep()
      Plays a beep.
      Specified by:
      beep in class GFXEnv
    • getPrefs

      public Prefs getPrefs(String aName)
      Override to return AWTPrefs for name.
      Overrides:
      getPrefs in class GFXEnv
    • getMethod

      public Method getMethod(Class<?> aClass, String aName, Class<?>... theClasses) throws NoSuchMethodException
      This is really just here to help with TeaVM.
      Specified by:
      getMethod in class GFXEnv
      Throws:
      NoSuchMethodException
    • createSiteForURL

      public WebSite createSiteForURL(WebURL aSiteURL)
      Creates a site for a URL.
      Overrides:
      createSiteForURL in class GFXEnv
    • exit

      public void exit(int aValue)
      This is really just here to help with TeaVM.
      Specified by:
      exit in class GFXEnv
    • getHostname

      public String getHostname()
      This is really just here to help with TeaVM.
      Overrides:
      getHostname in class GFXEnv
    • get

      public static AWTEnv get()
      Returns a shared instance.
    • set

      public static void set()
      Sets AWTEnv to be the default env.