package experimentalcode.heidi;

import de.lmu.ifi.dbs.elki.data.Clustering;
import de.lmu.ifi.dbs.elki.data.NumberVector;
import de.lmu.ifi.dbs.elki.data.model.Model;
import de.lmu.ifi.dbs.elki.visualization.VisualizationProjection;
import de.lmu.ifi.dbs.elki.visualization.svg.SVGPlot;
import de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization;
import de.lmu.ifi.dbs.elki.visualization.visualizers.Visualizer;
import de.lmu.ifi.dbs.elki.visualization.visualizers.VisualizerContext;
import de.lmu.ifi.dbs.elki.visualization.visualizers.thumbs.ProjectedThumbnail;
import de.lmu.ifi.dbs.elki.visualization.visualizers.thumbs.ThumbnailVisualization;
import de.lmu.ifi.dbs.elki.visualization.visualizers.vis2d.Projection2DVisualizer;

/**
 * Factory for visualizers to generate an SVG-Element containing a marker for the mean 
 * in a KMeans-Clustering
 * 
 * @author Heidi Kolb
 * 
 * @param <NV> Type of the NumberVector being visualized.
 */
public class KmeansVisualizerFactory<NV extends NumberVector<NV, ?>> extends Projection2DVisualizer<NV> {

  /**
   * A short name characterizing this Visualizer.
   */
  private static final String NAME = "KMeans";

  /**
   * Clustering to visualize.
   */
  protected Clustering<Model> clustering = null;
  
  /**
   * Constructor
   */
  public KmeansVisualizerFactory() {
    super(NAME);
  }

  @Override
  public Visualization visualize(SVGPlot svgp, VisualizationProjection proj, double width, double height) {
    return new KmeansVisualizer<NV>(context, clustering, svgp, proj, width, height);
  }

  /**
   * Initializes this Visualizer.
   * 
   * @param context Visualization context
   * @param clustering Clustering to visualize
   */
  @SuppressWarnings("unchecked")
  public void init(VisualizerContext<? extends NV> context, Clustering<?> clustering) {
    super.init(context);
    super.setLevel(Visualizer.LEVEL_BACKGROUND + 1);
    this.clustering = (Clustering<Model>) clustering;
  }
  @Override
  public Visualization makeThumbnail(SVGPlot svgp, VisualizationProjection proj, double width, double height, int tresolution) {
    return new ProjectedThumbnail<NV>(this, context, svgp, proj, width, height, tresolution, ThumbnailVisualization.ON_DATA | ThumbnailVisualization.ON_SELECTION);
  }
}

@@ -158,16 +158,20 @@
 a.model.
+Mean
 Model;%0D%0A
@@ -1263,20 +1263,28 @@
 tering%3CM
-odel
+eanModel%3CNV%3E
 %3E cluste
@@ -1762,42 +1762,8 @@
 */%0D%0A
-  @SuppressWarnings(%22unchecked%22)%0D%0A
   pu
@@ -1829,17 +1829,29 @@
 stering%3C
-?
+MeanModel%3CNV%3E
 %3E cluste
@@ -1935,24 +1935,24 @@
 OUND + 1);%0D%0A
+
     this.clu
@@ -1964,28 +1964,8 @@
 ng =
- (Clustering%3CModel%3E)
  clu

Improve Kmeans visualizer and ugly generics handling.