Holger's Java API

## com.antelmann.image
Class ColorPath

    java.lang.Object
      com.antelmann.image.ColorPath

All Implemented Interfaces:
  XMLSerializable, Forgeable<ColorPath>, Serializable

    public class ColorPath

extends Object
implements Serializable, XMLSerializable, Forgeable<ColorPath>

provides a path for deriving gradual colors based on a number.

Since:
  15.05.2009, 18:28:55
Author:
  Holger Antelmann
See Also:
  `ColorPathBarRenderer`, Serialized Form

Constructor Summary
`ColorPath()`
`ColorPath(boolean onlyFullColors)`
`ColorPath(Map<? extends Number,? extends Color> map)`
`ColorPath(Map<? extends Number,? extends Color> map, boolean onlyFullColors)`

Method Summary
`void` `add(Color c, float n)`
`void` `clear()`
`static Color` `deriveColor(Color color1, Color color2, float weight)` derives a color as a mixture of the given two colors.
`void` `exportXML(OutputStream out)` exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with `importXML(InputSource)`.
`Color` `getColor(float n)`
`Color` `getColor(Number n)`
`Map<Float,Color>` `getColorMap()` returns an unmodifiable view of the embedded data
`void` `importXML(InputStream source)` The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.
`boolean` `isOnlyFullColors()` if true, the colors on the path are used as thresholds rather than serving as a basis to merge two colors into a new one
`static Color` `makeTransparent(Color color, float transparency)` makes a given color transparent based on a percentage
`boolean` `remove(Color c)` removes every occurrence of the given color from the path
`Color` `remove(float n)`
`void` `setAllFrom(ColorPath cp)` copies the properties of the given object and applies them to this instance, so that its behavior in regards to the given object can be matched to the extend that the implementing class supports that behavior.
`void` `setColorMap(Map<? extends Number,Color> map)`
`void` `setOnlyFullColors(boolean onlyFullColors)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ColorPath

    public ColorPath(boolean onlyFullColors)

### ColorPath

    public ColorPath()

### ColorPath

    public ColorPath(Map<? extends Number,? extends Color> map)

### ColorPath

    public ColorPath(Map<? extends Number,? extends Color> map,
                     boolean onlyFullColors)

Method Detail

### isOnlyFullColors

    public boolean isOnlyFullColors()

  if true, the colors on the path are used as thresholds rather than serving as a basis to merge two colors into a new one

### setOnlyFullColors

    public void setOnlyFullColors(boolean onlyFullColors)

### getColorMap

    public Map<Float,Color> getColorMap()

  returns an unmodifiable view of the embedded data

### setColorMap

    public void setColorMap(Map<? extends Number,Color> map)

### clear

    public void clear()

### add

    public void add(Color c,
                    float n)

### remove

    public Color remove(float n)

### remove

    public boolean remove(Color c)

  removes every occurrence of the given color from the path

### getColor

    public Color getColor(Number n)

### getColor

    public Color getColor(float n)

### exportXML

    public void exportXML(OutputStream out)
                   throws IOException

  Description copied from interface: `XMLSerializable`
  exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with `importXML(InputSource)`. The given stream is neither flushed nor closed, so that other data may be effectively written to the InputSource after the method returned.

  Specified by:
    `exportXML` in interface `XMLSerializable`
  Throws:
    `IOException`
  See Also:
    `XMLSerializable.importXML(InputStream)`

### importXML

    public void importXML(InputStream source)
                   throws SAXException,
                          IOException,
                          ClassCastException

  Description copied from interface: `XMLSerializable`
  The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.

  Specified by:
    `importXML` in interface `XMLSerializable`
  Throws:
    `SAXException`
    `IOException`
    `ClassCastException`
  See Also:
    `XMLSerializable.exportXML(OutputStream)`

### setAllFrom

    public void setAllFrom(ColorPath cp)
                    throws NullPointerException,
                           IllegalArgumentException

  Description copied from interface: `Forgeable`
  copies the properties of the given object and applies them to this instance, so that its behavior in regards to the given object can be matched to the extend that the implementing class supports that behavior.

  Specified by:
    `setAllFrom` in interface `Forgeable<ColorPath>`
  Parameters:
    `cp` - the object whose behavior is to be copied to this instance
  Throws:
    `NullPointerException` - if the given object parameter is null
    `IllegalArgumentException` - if the given object contains properties that for some reason cannot be copied to this instance

### deriveColor

    public static Color deriveColor(Color color1,
                                    Color color2,
                                    float weight)

  derives a color as a mixture of the given two colors.

  Parameters:
    `color1` - the base color
    `color2` - the alternative color
    `weight` - the percentage (between 0 and 1) to which amount the returned color is to be nearer to the alternative color. If weight is 0, color1 is returned; if weight is 1, color2 is returned; if if weight is .5, the 'middle' of the two colors is returned, and so on.
  Returns:
    a new color that is derived from the given colors

### makeTransparent

    public static Color makeTransparent(Color color,
                                        float transparency)

  makes a given color transparent based on a percentage

  Parameters:
    `color` - the color that is to be used as a base for deriving a transparent color
    `transparency` - a number between 0 and 1 where 0 is fully transparent and 1 is fully opaque
  Returns:
    a new color that is transparent according to the given transparency factor

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads