Class FreeColImageBorder

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.border.Border

    public class FreeColImageBorder
    extends javax.swing.border.AbstractBorder
    A border created from a set of images.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FreeColImageBorder​(java.lang.String baseKey)  
      private FreeColImageBorder​(java.lang.String baseKey, boolean noScaling)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void ensureInitialized()  
      java.awt.Insets getBorderInsets​(java.awt.Component c)
      Gets the insets of this border around the given component.
      java.awt.Insets getBorderInsets​(java.awt.Component c, java.awt.Insets insets)
      Gets the insets of this border around the given component.
      private static int getHeight​(java.awt.Image im)
      Get the height of an image.
      private java.awt.image.BufferedImage getImage​(java.lang.String key)  
      private static int getWidth​(java.awt.Image im)
      Get the width of an image.
      private void loadImages()  
      private void loadImages​(java.awt.image.BufferedImage topLeftCornerImage, java.awt.image.BufferedImage topImage, java.awt.image.BufferedImage topRightCornerImage, java.awt.image.BufferedImage rightImage, java.awt.image.BufferedImage bottomRightCornerImage, java.awt.image.BufferedImage bottomImage, java.awt.image.BufferedImage bottomLeftCornerImage, java.awt.image.BufferedImage leftImage)
      Loads the images for the border.
      void paintBorder​(java.awt.Component c, java.awt.Graphics g, int x, int y, int width, int height)
      Paints the border on the given component.
      private static void reloadAllImages()  
      static void setScaleFactor​(float scaleFactor)  
      • Methods inherited from class javax.swing.border.AbstractBorder

        getBaseline, getBaselineResizeBehavior, getInteriorRectangle, getInteriorRectangle, isBorderOpaque
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • panelWithoutShadowBorder

        public static final FreeColImageBorder panelWithoutShadowBorder
      • scaleFactor

        private static float scaleFactor
      • baseKey

        private final java.lang.String baseKey
        The key used for getting the image resources.
      • noScaling

        private final boolean noScaling
        If true, no scaling to the border is applied.
      • initialized

        private boolean initialized
      • topLeftCornerImage

        private java.awt.image.BufferedImage topLeftCornerImage
        NW-corner
      • topImage

        private java.awt.image.BufferedImage topImage
        N-border
      • topRightCornerImage

        private java.awt.image.BufferedImage topRightCornerImage
        NE-corner
      • rightImage

        private java.awt.image.BufferedImage rightImage
        E-border
      • bottomRightCornerImage

        private java.awt.image.BufferedImage bottomRightCornerImage
        SE-corner
      • bottomImage

        private java.awt.image.BufferedImage bottomImage
        S-border
      • bottomLeftCornerImage

        private java.awt.image.BufferedImage bottomLeftCornerImage
        SW-corner
      • leftImage

        private java.awt.image.BufferedImage leftImage
        W-border
    • Constructor Detail

      • FreeColImageBorder

        private FreeColImageBorder​(java.lang.String baseKey)
      • FreeColImageBorder

        private FreeColImageBorder​(java.lang.String baseKey,
                                   boolean noScaling)
    • Method Detail

      • ensureInitialized

        private void ensureInitialized()
      • loadImages

        private void loadImages()
      • loadImages

        private void loadImages​(java.awt.image.BufferedImage topLeftCornerImage,
                                java.awt.image.BufferedImage topImage,
                                java.awt.image.BufferedImage topRightCornerImage,
                                java.awt.image.BufferedImage rightImage,
                                java.awt.image.BufferedImage bottomRightCornerImage,
                                java.awt.image.BufferedImage bottomImage,
                                java.awt.image.BufferedImage bottomLeftCornerImage,
                                java.awt.image.BufferedImage leftImage)
        Loads the images for the border.
        Parameters:
        topLeftCornerImage - NW-corner
        topImage - N-border
        topRightCornerImage - NE-corner
        rightImage - E-border
        bottomRightCornerImage - SE-corner
        bottomImage - S-border
        bottomLeftCornerImage - SW-corner
        leftImage - W-border
      • setScaleFactor

        public static void setScaleFactor​(float scaleFactor)
      • reloadAllImages

        private static void reloadAllImages()
      • getImage

        private java.awt.image.BufferedImage getImage​(java.lang.String key)
      • getBorderInsets

        public java.awt.Insets getBorderInsets​(java.awt.Component c)
        Gets the insets of this border around the given component.
        Specified by:
        getBorderInsets in interface javax.swing.border.Border
        Overrides:
        getBorderInsets in class javax.swing.border.AbstractBorder
        Parameters:
        c - The Component having the border.
        Returns:
        The Insets.
      • getBorderInsets

        public java.awt.Insets getBorderInsets​(java.awt.Component c,
                                               java.awt.Insets insets)
        Gets the insets of this border around the given component.
        Overrides:
        getBorderInsets in class javax.swing.border.AbstractBorder
        Parameters:
        c - The Component having the border.
        insets - An instance of Insets to be updated.
        Returns:
        The given instance of Insets if not null, or a new instance otherwise.
      • paintBorder

        public void paintBorder​(java.awt.Component c,
                                java.awt.Graphics g,
                                int x,
                                int y,
                                int width,
                                int height)
        Paints the border on the given component.
        Specified by:
        paintBorder in interface javax.swing.border.Border
        Overrides:
        paintBorder in class javax.swing.border.AbstractBorder
        Parameters:
        c - The Component to draw the border on.
        g - The Graphics used for painting the border.
        x - The x-component of the offset.
        y - The y-component of the offset.
        width - The width of the border.
        height - The height of the border.
      • getHeight

        private static int getHeight​(java.awt.Image im)
        Get the height of an image. If image is null, return 0.
        Parameters:
        im - The image.
        Returns:
        The height of the image.
      • getWidth

        private static int getWidth​(java.awt.Image im)
        Get the width of an image. If image is null, return 0.
        Parameters:
        im - The image.
        Returns:
        The width of the image.