Class AWTStyleDatabase

java.lang.Object
io.sf.carte.doc.style.css.om.AbstractStyleDatabase
io.sf.carte.doc.style.css.awt.AWTStyleDatabase
All Implemented Interfaces:
StyleDatabase, Serializable

public class AWTStyleDatabase extends AbstractStyleDatabase
CSS style database for use with AWT objects.

See Also:
  • Constructor Details

    • AWTStyleDatabase

      public AWTStyleDatabase()
      Constructs a default style database with no graphics configuration.
    • AWTStyleDatabase

      public AWTStyleDatabase(GraphicsConfiguration gConf)
      Constructs a style database for the given graphics configuration.
      Parameters:
      gConf - the graphics configuration.
  • Method Details

    • getDefaultGenericFontFamily

      public String getDefaultGenericFontFamily(String genericFamily)
      Gets the name of the default font used when a generic font family (serif, sans-serif, monospace, cursive, fantasy) is specified.

      This class attempts to map the generic name to a "logical font" name.

      As, in Java, logical font names are internally mapped to physical fonts by the Java runtime environment, the name of the corresponding "logical font" is returned, and no further mapping is attempted.

      Parameters:
      genericFamily - the name of the logical font.
      Returns:
      the name of the associated logical font, or null if none.
    • isFontFamilyAvailable

      protected boolean isFontFamilyAvailable(String fontFamily)
      Specified by:
      isFontFamilyAvailable in class AbstractStyleDatabase
    • isFontFaceName

      public boolean isFontFaceName(String requestedFamily)
      Description copied from interface: StyleDatabase
      Is requestedFamily an available font family loaded by a font face rule?
      Parameters:
      requestedFamily - the font family name in lower case.
      Returns:
      true if is an available font family, false otherwise.
    • loadFontFace

      protected boolean loadFontFace(String familyName, AbstractStyleDatabase.FontFormat format, InputStream is, CSSFontFaceRule rule) throws IOException
      Overrides:
      loadFontFace in class AbstractStyleDatabase
      Throws:
      IOException
    • getFont

      public Font getFont(String lcFamilyName)
      Get a font that was loaded by a @font-face rule.
      Parameters:
      lcFamilyName - the family name in lowercase.
      Returns:
      the font, or null if no font with that family name (in lowercase) has been loaded from a @font-face rule.
    • getGraphicsConfiguration

      protected GraphicsConfiguration getGraphicsConfiguration()
      Gets the GraphicsConfiguration for this style database.
      Returns:
      the GraphicsConfiguration object previously set, the default one if none was set, or null if the graphics environment is headless.
    • setGraphicsConfiguration

      public void setGraphicsConfiguration(GraphicsConfiguration configuration)
    • deviceResolutionFactor

      protected float deviceResolutionFactor()
      This method is used to normalize sizes to a 595pt width.
      Returns:
      the factor by which screensize-dependent quantities can be multiplied to be normalized.
    • getFontSizeFromIdentifier

      public float getFontSizeFromIdentifier(String familyName, String fontSizeIdentifier) throws DOMException
      Description copied from interface: StyleDatabase
      Gets the font size from the given size identifier (small, medium, etc.), expressed in typographic points.
      Parameters:
      familyName - the font family name. Could be null.
      fontSizeIdentifier - the font size identifier.
      Returns:
      the font size.
      Throws:
      DOMException - if the identifier is unknown.
    • getWidthSize

      public float getWidthSize(String widthIdentifier, float fontSize) throws DOMException
      Description copied from interface: StyleDatabase
      Gets the size corresponding to the given identifier (thin, thick, medium), in typographic points.
      Parameters:
      widthIdentifier - the CSS width identifier.
      fontSize - the font size used by the box, in typographic points.
      Returns:
      the size.
      Throws:
      DOMException - if the identifier is unknown.
    • getNaturalUnit

      public short getNaturalUnit()
      Description copied from interface: StyleDatabase
      Gets the identifier of the device's natural unit.
      Returns:
      the unit identifier as in CSSUnit.
    • getDeviceHeight

      public float getDeviceHeight()
      Description copied from interface: StyleDatabase
      Gets the height of the device, expressed in its natural unit.
      Returns:
      the height of the rendering device.
    • getDeviceWidth

      public float getDeviceWidth()
      Description copied from interface: StyleDatabase
      Gets the width of the device, expressed in its natural unit.
      Returns:
      the width of the rendering device.
    • setDefaultWidth

      public void setDefaultWidth(float defaultWidth)
    • setDefaultHeight

      public void setDefaultHeight(float defaultHeight)
    • getColorDepth

      public int getColorDepth()
      Description copied from interface: StyleDatabase
      Gives the number of bits allocated to colors (excluding the alpha channel) in the output device.

      If the device is not a color device, the value is zero.

      From W3C's Screen interface.

      Returns:
      the number of bits allocated to colors, or zero if the output device does not support colors.