/** * Get a String representation of the Color attribute. * * @return A String representation of the color attribute. */ @Override public String toString() { return String.format( "%s [red: %f, green: %f, blue: %f, alpha: %f]", getName(), components.getRed(), components.getGreen(), components.getBlue(), components.getAlpha()); }
/** * Create a copy of this ColorStyleAttribute. * * @return A copy of this ColorStyleAttribute. */ @Override public StyleAttribute clone() { return new ColorStyleAttribute( getName(), getDescription(), components.getRed(), components.getGreen(), components.getBlue(), components.getAlpha()); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj instanceof ColorStyleAttribute) { ColorStyleAttribute attribute = (ColorStyleAttribute) obj; return equal(attribute.getName(), getName()) && equal(attribute.getDescription(), getDescription()) && attribute.getRed() == components.getRed() && attribute.getGreen() == components.getGreen() && attribute.getBlue() == components.getBlue() && attribute.getAlpha() == components.getAlpha(); } return false; }
/** * Convert the color components to an array of RGBA float values. * * @return An array of four elements containing the red, green, blue and alpha values * respectively. */ public float[] toArray() { return new float[] { components.getRed(), components.getGreen(), components.getBlue(), components.getAlpha() }; }
/** * Get the red portion of the color value. Values should be between 0.0 and 1.0. * * @return The red portion of the color value. */ @Override @XmlAttribute(name = "red") public float getRed() { return components.getRed(); }