package experimentalcode.remigius.Visualizers;

import java.util.Iterator;

import org.w3c.dom.Element;

import de.lmu.ifi.dbs.elki.data.DoubleVector;
import de.lmu.ifi.dbs.elki.data.FeatureVector;
import de.lmu.ifi.dbs.elki.database.Database;
import de.lmu.ifi.dbs.elki.result.CollectionResult;
import de.lmu.ifi.dbs.elki.visualization.svg.SVGPlot;
import experimentalcode.remigius.ShapeLibrary;
import experimentalcode.remigius.VisualizationManager;
import experimentalcode.remigius.visualization.PlanarVisualization;

// TODO Fix CSS, IDs and replace Dots.  

public class ReferencePointsVisualizer<O extends DoubleVector, V extends FeatureVector<V,N>,N extends Number> extends PlanarVisualizer<O> {

	private CollectionResult<V> colResult;

	public ReferencePointsVisualizer(){

	}
	
	public void setup(Database<O> database, CollectionResult<V> colResult, VisualizationManager<O> visManager){
		init(database, visManager);
		this.colResult = colResult;
		setupCSS();
	}

	private void setupCSS(){

//			CSSClass bubble = visManager.createCSSClass(CommonSVGShapes.CSS_BUBBLE_PREFIX);
//			bubble.setStatement(SVGConstants.CSS_STROKE_WIDTH_PROPERTY, "0.001");
//
//			visManager.registerCSSClass(bubble);
	}

	@Override
	protected PlanarVisualization visualize(SVGPlot svgp, Element layer) {

		Iterator<V> iter = colResult.iterator();
		
		while (iter.hasNext()){
			V v = iter.next();
			layer.appendChild(
					ShapeLibrary.createRef(svgp.getDocument(), v.getValue(dimx).doubleValue(), v.getValue(dimy).doubleValue(), (int)Math.random(), dimx, dimy, toString())
			);
		}
		return new PlanarVisualization(dimx, dimy, layer);
	}
	
	public String getName(){
		return "ReferencePoints";
	}
}

@@ -69,16 +69,59 @@
 rator;%0A%0A
+import org.apache.batik.util.SVGConstants;%0A
 import o
@@ -140,16 +140,16 @@
 lement;%0A
-
 %0Aimport 
@@ -332,16 +332,71 @@
 Result;%0A
+import de.lmu.ifi.dbs.elki.visualization.css.CSSClass;%0A
 import d
@@ -616,50 +616,8 @@
 n;%0A%0A
-// TODO Fix CSS, IDs and replace Dots.  %0A%0A
 publ
@@ -973,16 +973,40 @@
 sManager
+, Integer.MAX_VALUE-2000
 );%0A%09%09thi
@@ -1075,18 +1075,16 @@
 CSS()%7B%0A%0A
-//
 %09%09%09CSSCl
@@ -1087,22 +1087,24 @@
 SSClass 
-bubble
+refpoint
  = visMa
@@ -1128,55 +1128,43 @@
 ass(
-CommonSVGShapes.CSS_BUBBLE_PREFIX
+ShapeLibrary.REFPOINT
 );%0A
-//
 %09%09%09
-bubble
+refpoint
 .set
@@ -1194,46 +1194,32 @@
 CSS_
-STROKE_WIDTH_PROPERTY, %220.001%22);%0A//%0A//
+FILL_PROPERTY, %22red%22);%0A%0A
 %09%09%09v
@@ -1249,14 +1249,16 @@
 ass(
-bubble
+refpoint
 );%0A%09
@@ -1576,26 +1576,9 @@
 (), 
-(int)Math.random()
+0
 , di

Fix ReferencePointsVisualizer