Class ColorAttribute

All Implemented Interfaces:
Comparable<Object>, Attribute, CollectionAttribute, ColorSetAndGetSupport, DeepCopy, GraphicAttributeConstants, Displayable

public class ColorAttribute
extends HashMapAttribute
implements GraphicAttributeConstants, ColorSetAndGetSupport
Contains the color graphic attribute. (The value of opacity has no effect when applied to the outline of a node since that would lead to problems with overlapping filling and outline.)
Version:
$Revision: 1.6 $
  • Constructor Details

    • ColorAttribute

      public ColorAttribute​(String id, Color c)
      Constructs a new ColorAttribute.
      Parameters:
      id - the id of the attribute.
      c - the color-value of the attribute.
    • ColorAttribute

      public ColorAttribute​(String id, ColorAttribute c)
      Constructs a new ColorAttribute.
      Parameters:
      id - the id of the attribute.
      c - the color-value of the attribute.
    • ColorAttribute

      public ColorAttribute​(String id)
      Constructs a new ColorAttribute.
      Parameters:
      id - the id of the attribute.
    • ColorAttribute

      public ColorAttribute​(String id, int r, int g, int b, int t)
      Constructs a new ColorAttribute and initialises with the given values.
      Parameters:
      id - the id of the attribute.
      r - the red-value of the attribute.
      g - the green-value of the attribute.
      b - the blue-value of the attribute.
      t - the opacity-value of the attribute.
  • Method Details

    • setBlue

      public void setBlue​(int b)
      Sets the 'blue'-value.
      Parameters:
      b - the 'blue'-value to be set.
    • getBlue

      public int getBlue()
      Returns the 'blue'-value of the encapsulated color.
      Returns:
      the 'blue'-value of the encapsulated color.
    • setCollection

      public void setCollection​(Map<String,​Attribute> attrs)
      Sets the collection of attributes contained within this CollectionAttribute. The color values are set, additional values are simply added (that means that if there exists already a subattribute with the same id, an exception will be thrown).
      Specified by:
      setCollection in interface CollectionAttribute
      Overrides:
      setCollection in class HashMapAttribute
      Parameters:
      attrs - the map that contains all attributes.
      Throws:
      IllegalArgumentException - DOCUMENT ME!
    • setColor

      public void setColor​(Color c)
      Comfort function to set a java.awt.Color.
      Specified by:
      setColor in interface ColorSetAndGetSupport
      Parameters:
      c - the java.awt.Color value.
    • getColor

      public Color getColor()
      Comfort function to get a java.awt.Color.
      Specified by:
      getColor in interface ColorSetAndGetSupport
      Returns:
      the built java.awt.Color object.
    • setGreen

      public void setGreen​(int g)
      Sets the 'green'-value.
      Parameters:
      g - the 'green'-value to be set.
    • getGreen

      public int getGreen()
      Returns the 'green'-value of the encapsulated color.
      Returns:
      the 'green'-value of the encapsulated color.
    • setOpacity

      public void setOpacity​(int t)
      Sets the 'opacity'-value.
      Parameters:
      t - the 'opacity'-value to be set.
    • getOpacity

      public int getOpacity()
      Returns the 'opacity'-value of the encapsulated color.
      Returns:
      the 'opacity'-value of the encapsulated color.
    • setRed

      public void setRed​(int r)
      Sets the 'red'-value.
      Parameters:
      r - the 'red'-value to be set.
    • getRed

      public int getRed()
      Returns the 'red'-value of the encapsulated color.
      Returns:
      the 'red'-value of the encapsulated color.
    • copy

      public Object copy()
      Returns a deep copy of this object.
      Specified by:
      copy in interface DeepCopy
      Overrides:
      copy in class HashMapAttribute
      Returns:
      A deep copy of this object.