Class CompiereColor

  • All Implemented Interfaces:
    Serializable

    public class CompiereColor
    extends Object
    implements Serializable
    Adempiere Background Color
    Version:
    $Id: AdempiereColor.java,v 1.2 2006/07/30 00:52:24 jjanke Exp $
    Author:
    Jorg Janke
    See Also:
    Serialized Form
    • Field Detail

      • TYPE_VALUES

        public static final String[] TYPE_VALUES
        Type Values
      • TYPE_NAMES

        public static final String[] TYPE_NAMES
        Type Names
      • GRADIENT_SP_VALUES

        public static final int[] GRADIENT_SP_VALUES
        Gradient Starting Values
      • GRADIENT_SP_NAMES

        public static final String[] GRADIENT_SP_NAMES
        Gradient Starting Names
      • GRADIENT_SP

        public static final KeyNamePair[] GRADIENT_SP
        Gradient Starting Point
    • Constructor Detail

      • CompiereColor

        public CompiereColor()
        Create Gradient Background Color (Window System Color - White)
      • CompiereColor

        public CompiereColor​(String type)
        Create Default Background Colors of Type
        Parameters:
        type - Background type (see constants TYPE_*)
      • CompiereColor

        public CompiereColor​(Color bg)
        Create Flat Background Color
        Parameters:
        bg - background
      • CompiereColor

        public CompiereColor​(Color bg,
                             boolean flat)
        Create Background Color
        Parameters:
        bg - Color
        flat - if true create Flat color otherwise Gradient color with white lower color
      • CompiereColor

        public CompiereColor​(Color upperColor,
                             Color lowerColor,
                             int startPoint,
                             int repeatDistance)
        Set Background to Gradient colors
        Parameters:
        upperColor - upper Color
        lowerColor - lower Color
        startPoint - Starting point - e.g. SOUTH_WEST see SwingConstants, default NORTH_WEST
        repeatDistance - X/Y Distance to repeat gradient in points - 0 no repeats
      • CompiereColor

        public CompiereColor​(Color upperColor,
                             Color lowerColor)
        Set Background to Gradient colors. Starting in the north, repeat after 100 pt
        Parameters:
        upperColor - upper color
        lowerColor - lower color
      • CompiereColor

        public CompiereColor​(URL textureURL,
                             Color taint,
                             float compositeAlpha)
        Set Background to Texture
        Parameters:
        textureURL - URL to a *.gif or *.jpg graphic file
        taint - Color to taint the texture (use white for not tainting it)
        compositeAlpha - Value from 0(no) to 1(full) tainting
      • CompiereColor

        public CompiereColor​(String textureURL,
                             Color taint,
                             float compositeAlpha)
        Set Background to Texture
        Parameters:
        textureURL - URL to a *.gif or *.jpg graphic file
        taint - Color to taint the texture (use white for not tainting it)
        compositeAlpha - Tainting value from 0 (no - FullGraph) to 1 (full - NoGraph)
      • CompiereColor

        public CompiereColor​(Color lineColor,
                             Color backColor,
                             float lineWidth,
                             int lineDistance)
        Set Background to Lines
        Parameters:
        lineColor - line color
        backColor - background color
        lineWidth - Stroke width in point
        lineDistance - Distance between lines in points
      • CompiereColor

        public CompiereColor​(CompiereColor cc)
        Copy Color
        Parameters:
        cc - color
    • Method Detail

      • setBackground

        public static void setBackground​(JComponent c)
        Set Background of Component to default color
        Parameters:
        c - component
      • setBackground

        public static void setBackground​(JComponent c,
                                         CompiereColor cc)
        Set Background of Component
        Parameters:
        c - Component
        cc - Color
      • getBackground

        public static CompiereColor getBackground​(JComponent c)
        Get Background Color of component
        Parameters:
        c - JComponent
        Returns:
        Color
      • setBackground

        public static void setBackground​(Window win)
        Set Background of Window Content Pane to default color
        Parameters:
        win - window
      • setBackground

        public static void setBackground​(Window win,
                                         CompiereColor cc)
        Set Background of Window Content Pane
        Parameters:
        win - window
        cc - adempiere color
      • getDefaultBackground

        public static CompiereColor getDefaultBackground()
        Get Default Background
        Returns:
        Background
        See Also:
        CompierePanelUI#getDefaultBackground
      • parse

        public static CompiereColor parse​(String attributes)
        Parse attributes and return AdempiereColor
        Parameters:
        attributes - attributes
        Returns:
        AdempiereColor
      • getCompiereColor

        public static CompiereColor getCompiereColor​(MColor color)
        Get CompiereColor.
        Returns:
        CompiereColor
      • getType

        public String getType()
        Get BackgroundType (Flat, Gradient, Lines, Texture)
        Returns:
        Background Type (see TYPE_* constants)
      • isFlat

        public boolean isFlat()
        Flat Background Type (default)
        Returns:
        true if Flat background
      • isGradient

        public boolean isGradient()
        Gradient Background Type
        Returns:
        true if Gradient background
      • isLine

        public boolean isLine()
        Line Background Type
        Returns:
        true if Line background
      • isTexture

        public boolean isTexture()
        Texture Background Type
        Returns:
        true if Texture background
      • getFlatColor

        public Color getFlatColor()
        Get Flat Color
        Returns:
        Primary Color
      • setFlatColor

        public void setFlatColor​(Color color)
        Set Flat Color
        Parameters:
        color - flat color
      • getGradientUpperColor

        public Color getGradientUpperColor()
        Gradient Upper Color
        Returns:
        Color or null
      • setGradientUpperColor

        public void setGradientUpperColor​(Color color)
        Gradient Upper Color
        Parameters:
        color - upper color
      • getGradientLowerColor

        public Color getGradientLowerColor()
        Gradient Lower Color
        Returns:
        Color or null
      • setGradientLowerColor

        public void setGradientLowerColor​(Color color)
        Gradient Lower Color
        Parameters:
        color - lower color
      • getGradientStartPoint

        public int getGradientStartPoint()
        Gradient Starting Point
        Returns:
        starting point - e.g. NORTH - or 0
        See Also:
        SwingConstants
      • setGradientStartPoint

        public void setGradientStartPoint​(int startPoint)
        Gradient Starting Point
        Parameters:
        startPoint - starting point - e.g. NORTH
        See Also:
        SwingConstants
      • getGradientRepeatDistance

        public int getGradientRepeatDistance()
        Gradient Repeat Distance in point
        Returns:
        Repeat Distance - or 0
      • setGradientRepeatDistance

        public void setGradientRepeatDistance​(int repeatDistance)
        Gradient Repeat Distance. Zero stands for no repeats
        Parameters:
        repeatDistance - repeat gradient after point x+repeat / y+repeat (depending on direction)
      • setGradientRepeatDistance

        public void setGradientRepeatDistance​(String repeatDistanceString)
        Gradient Repeat Distance. Zero stands for no repeats
        Parameters:
        repeatDistanceString - repeat gradient after point x+repeat / y+repeat (depending on direction)
      • getTextureURL

        public URL getTextureURL()
        Texture Url
        Returns:
        URL (if not found, org.compiere.plaf.background.jpg is used)
      • getTextureImage

        public BufferedImage getTextureImage()
        Get Texture Image based on Texture URL
        Returns:
        Image
      • setTextureURL

        public void setTextureURL​(URL url)
        Texture Url
        Parameters:
        url - URL to graphic file (jpg)
      • setTextureURL

        public void setTextureURL​(String urlString)
        Texture Url
        Parameters:
        urlString - URL to graphic file (jpg)
      • getTextureTaintColor

        public Color getTextureTaintColor()
        Texture Taint Color
        Returns:
        Color or null
      • setTextureTaintColor

        public void setTextureTaintColor​(Color color)
        Texture Taint Color
        Parameters:
        color - taint color
      • getTextureCompositeAlpha

        public float getTextureCompositeAlpha()
        Texture Composite Alpha
        Returns:
        Composite Ampha or 0f
      • setTextureCompositeAlpha

        public void setTextureCompositeAlpha​(float alpha)
        Texture Composite Alpha
        Parameters:
        alpha - alpha value
      • setTextureCompositeAlpha

        public void setTextureCompositeAlpha​(String alphaString)
        Texture Composite Alpha
        Parameters:
        alphaString - String to be parsed
      • getLineColor

        public Color getLineColor()
        Line Color
        Returns:
        Color or null
      • setLineColor

        public void setLineColor​(Color color)
        Line Color
        Parameters:
        color - line color
      • getLineBackColor

        public Color getLineBackColor()
        Line Background Color
        Returns:
        Color or null
      • setLineBackColor

        public void setLineBackColor​(Color color)
        Line Background Color
        Parameters:
        color - background color
      • getLineWidth

        public float getLineWidth()
        Background Line Width
        Returns:
        width or 0f
      • setLineWidth

        public void setLineWidth​(float width)
        Background Line Width
        Parameters:
        width - line width
      • setLineWidth

        public void setLineWidth​(String widthString)
        Background Line Width
        Parameters:
        widthString - line width
      • getLineDistance

        public int getLineDistance()
        Background Line distance in pt
        Returns:
        distance or 0
      • setLineDistance

        public void setLineDistance​(int distance)
        Background Line distance in pt
        Parameters:
        distance - line distance
      • setLineDistance

        public void setLineDistance​(String distanceString)
        Background Line distance in pt
        Parameters:
        distanceString - line distance
      • setPrimaryColor

        protected void setPrimaryColor​(Color color)
        Set Prinary Color
        Parameters:
        color - primary color
      • setColor

        public void setColor​(CompiereColor cc)
        Set AdempiereColor from AdempiereColor
        Parameters:
        cc - AdempiereColor
      • paint

        public void paint​(Graphics g,
                          JComponent c)
        Fill with AdempiereColor Background
        Parameters:
        g - the Graphics context in which to paint
        c - the component being painted
      • paintRect

        public void paintRect​(Graphics g,
                              JComponent c,
                              int x,
                              int y,
                              int w,
                              int h)
        Fill with Adempiere Background
        Parameters:
        g - graphics
        c - component
        x - x pos
        y - y pos
        w - with
        h - height
      • toString

        public String toString()
        String representation
        Overrides:
        toString in class Object
        Returns:
        string representation