net.returnvoid.analytics

## Class ColorCluster

- java.lang.Object
- - net.returnvoid.analytics.ColorCluster

- All Implemented Interfaces:
    Cluster

      public class ColorCluster
      extends java.lang.Object
      implements Cluster

  Author:
    Diana

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ColorCluster(RColor mean)` Builds a new cluster without any member but with a set mean.
    `ColorCluster(RColor mean, ColorDifferenceMeasure m)` Builds a new cluster without any member but with a set mean.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Cluster` | `addElement(java.lang.Object newMember)` Adds an element to the cluster.
    `ColorCluster` | `addElement(RColor newMember)` Adds an element to the cluster.
    `void` | `drawMean(processing.core.PApplet parent, float x, float y, float w, float h)` Draws the mean color (colored rectangle with given parameters).
    `void` | `drawMean(processing.core.PGraphics g, float x, float y, float w, float h)` Draws the mean color (colored rectangle with given parameters).
    `void` | `drawMembers(processing.core.PApplet parent, float x, float y, float w, float h)` Draws the members of the cluster (colored horizontal stripes within a rectangular area defined by the given parameters).
    `void` | `drawMembers(processing.core.PGraphics g, float x, float y, float w, float h)` Draws the members of the cluster (colored horizontal stripes within a rectangular area defined by the given parameters).
    `ColorDifferenceMeasure` | `getColorDifferenceMeasure()` Returns the current ColorDifferenceMeasure.
    `java.util.ArrayList<RColor>` | `getElements()` Returns all cluster members.
    `java.lang.Float` | `getLoss()` Caculates the loss / error of the cluster.
    `RColor` | `getMean()` Returns the current mean of the cluster.
    `RColor` | `getRepresentative()` Finds and returns the representative of this cluster.
    `Cluster` | `removeElement(java.lang.Object member)` Removes an element from the cluster (if the given element is a member).
    `ColorCluster` | `removeElement(RColor member)` Removes an element from the cluster (if the given element is a member).
    `ColorCluster` | `setColorDifferenceMeasure(ColorDifferenceMeasure m)` Sets a new ColorDifferenceMeasure.
    `int` | `size()` Returns the number of cluster members.
    `boolean` | `switchElement(java.lang.Object member, Cluster newCluster)` The given element member switches to another cluster under certain circumstances.
    `boolean` | `switchElement(RColor member, ColorCluster newCluster)` The given element member switches to another cluster under certain circumstances.
    `ColorCluster` | `updateMean()` Updates the mean value based on the current cluster members.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ColorCluster

          public ColorCluster(RColor mean)

      Builds a new cluster without any member but with a set mean. The ColorDifferenceMeasure will be RGBEuclidean. The ColorDifferenceMeasure will define the distance measure for finding the representative of the cluster and the color space for calculating the mean.
      Parameters:
        `mean` - The mean value for this cluster.

    - #### ColorCluster

          public ColorCluster(RColor mean,
                              ColorDifferenceMeasure m)

      Builds a new cluster without any member but with a set mean. The ColorDifferenceMeasure will define the distance measure for finding the representative of the cluster and the color space for calculating the mean.
      Parameters:
        `mean` - The mean value for this cluster.
        `m` - The ColorDifferenceMeasure.

  - ### Method Detail

    - #### getColorDifferenceMeasure

          public ColorDifferenceMeasure getColorDifferenceMeasure()

      Returns the current ColorDifferenceMeasure.
      Returns:
        The current ColorDifferenceMeasure.

    - #### setColorDifferenceMeasure

          public ColorCluster setColorDifferenceMeasure(ColorDifferenceMeasure m)

      Sets a new ColorDifferenceMeasure. All members and the mean will be converted to match the new ColorDifferenceMeasure.
      Parameters:
        `m` - The new ColorDifferenceMeasure.
      Returns:
        The current cluster.

    - #### size

          public int size()

      Returns the number of cluster members.
      Returns:
        The number of cluster members.

    - #### addElement

          public Cluster addElement(java.lang.Object newMember)

      Description copied from interface: `Cluster`
      Adds an element to the cluster.
      Specified by:
        `addElement` in interface `Cluster`
      Parameters:
        `newMember` - The new cluster member.
      Returns:
        The current cluster object.

    - #### addElement

          public ColorCluster addElement(RColor newMember)

      Adds an element to the cluster.
      Parameters:
        `newMember` - The new cluster member.
      Returns:
        The current cluster object.

    - #### removeElement

          public Cluster removeElement(java.lang.Object member)

      Description copied from interface: `Cluster`
      Removes an element from the cluster (if the given element is a member).
      Specified by:
        `removeElement` in interface `Cluster`
      Parameters:
        `member` - The element which should be removed.
      Returns:
        The current cluster object.

    - #### removeElement

          public ColorCluster removeElement(RColor member)

      Removes an element from the cluster (if the given element is a member).
      Parameters:
        `member` - The element which should be removed.
      Returns:
        The current cluster object.

    - #### switchElement

          public boolean switchElement(java.lang.Object member,
                                       Cluster newCluster)

      Description copied from interface: `Cluster`
      The given element member switches to another cluster under certain circumstances. Returns if the given member actually changed its cluster.
      Specified by:
        `switchElement` in interface `Cluster`
      Parameters:
        `member` - The element which might switch the cluster.
        `newCluster` - The cluster where the element might switch to.
      Returns:
        True, if element has changed its cluster. Otherwise false.

    - #### switchElement

          public boolean switchElement(RColor member,
                                       ColorCluster newCluster)

      The given element member switches to another cluster under certain circumstances. Returns if the given member actually changed its cluster.
      Parameters:
        `member` - The element which might switch the cluster.
        `newCluster` - The cluster where the element might switch to.
      Returns:
        True, if element has changed its cluster. Otherwise false.

    - #### updateMean

          public ColorCluster updateMean()

      Description copied from interface: `Cluster`
      Updates the mean value based on the current cluster members.
      Specified by:
        `updateMean` in interface `Cluster`
      Returns:
        The current cluster object.

    - #### getRepresentative

          public RColor getRepresentative()

      Finds and returns the representative of this cluster. The representative is the cluster member which is the most similar to the cluster mean.
      Returns:
        The representative (element of cluster members).

    - #### getMean

          public RColor getMean()

      Description copied from interface: `Cluster`
      Returns the current mean of the cluster.
      Specified by:
        `getMean` in interface `Cluster`
      Returns:
        The cluster's mean.

    - #### getElements

          public java.util.ArrayList<RColor> getElements()

      Description copied from interface: `Cluster`
      Returns all cluster members.
      Specified by:
        `getElements` in interface `Cluster`
      Returns:
        The cluster members.

    - #### getLoss

          public java.lang.Float getLoss()

      Description copied from interface: `Cluster`
      Caculates the loss / error of the cluster.
      Specified by:
        `getLoss` in interface `Cluster`
      Returns:
        The error / loss value.

    - #### drawMean

          public void drawMean(processing.core.PGraphics g,
                               float x,
                               float y,
                               float w,
                               float h)

      Draws the mean color (colored rectangle with given parameters).
      Parameters:
        `g` - A recorder.
        `x` - The x-position (top left corner) of the rectangle.
        `y` - The y-position (top left corner) of the rectangle.
        `w` - The width of the rectangle.
        `h` - The height of the rectangle.

    - #### drawMean

          public void drawMean(processing.core.PApplet parent,
                               float x,
                               float y,
                               float w,
                               float h)

      Draws the mean color (colored rectangle with given parameters).
      Parameters:
        `parent` - A recorder.
        `x` - The x-position (top left corner) of the rectangle.
        `y` - The y-position (top left corner) of the rectangle.
        `w` - The width of the rectangle.
        `h` - The height of the rectangle.

    - #### drawMembers

          public void drawMembers(processing.core.PApplet parent,
                                  float x,
                                  float y,
                                  float w,
                                  float h)

      Draws the members of the cluster (colored horizontal stripes within a rectangular area defined by the given parameters).
      Parameters:
        `parent` - A recorder.
        `x` - The x-position (top left corner) of the rectangle.
        `y` - The y-position (top left corner) of the rectangle.
        `w` - The width of the rectangle.
        `h` - The height of the rectangle.

    - #### drawMembers

          public void drawMembers(processing.core.PGraphics g,
                                  float x,
                                  float y,
                                  float w,
                                  float h)

      Draws the members of the cluster (colored horizontal stripes within a rectangular area defined by the given parameters).
      Parameters:
        `g` - A recorder.
        `x` - The x-position (top left corner) of the rectangle.
        `y` - The y-position (top left corner) of the rectangle.
        `w` - The width of the rectangle.
        `h` - The height of the rectangle.