use of de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy in project elki by elki-project.
the class VisualizerContext method makeStyleResult.
/**
* Generate a new style result for the given style library.
*
* @param stylelib Style library
*/
protected void makeStyleResult(StyleLibrary stylelib) {
final Database db = ResultUtil.findDatabase(hier);
stylelibrary = stylelib;
List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db);
if (!clusterings.isEmpty()) {
stylepolicy = new ClusterStylingPolicy(clusterings.get(0), stylelib);
} else {
Clustering<Model> c = generateDefaultClustering();
stylepolicy = new ClusterStylingPolicy(c, stylelib);
}
}
use of de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy in project elki by elki-project.
the class EvaluationVisualization method makeVisualization.
@Override
public Visualization makeVisualization(VisualizerContext context, VisualizationTask task, VisualizationPlot plot, double width, double height, Projection proj) {
// TODO: make a utility class to wrap SVGPlot + parent layer + ypos.
// TODO: use CSSClass and StyleLibrary
// Skip space before first header
double ypos = -.5;
Element parent = plot.svgElement(SVGConstants.SVG_G_TAG);
Object o = task.getResult();
EvaluationResult sr = null;
if (o instanceof EvaluationResult) {
sr = (EvaluationResult) o;
} else if (o instanceof Class && EvaluationResult.class.isAssignableFrom((Class<?>) o)) {
// Use cluster evaluation of current style instead.
StylingPolicy spol = context.getStylingPolicy();
if (spol instanceof ClusterStylingPolicy) {
ClusterStylingPolicy cpol = (ClusterStylingPolicy) spol;
// will be a subtype, actually!
@SuppressWarnings("unchecked") Class<EvaluationResult> c = (Class<EvaluationResult>) o;
for (It<EvaluationResult> it = VisualizationTree.findNewResults(context, cpol.getClustering()).filter(c); it.valid(); it.advance()) {
// may end up displaying the wrong evaluation.
if (context.getHierarchy().iterAncestors(it.get()).find(cpol.getClustering())) {
sr = it.get();
break;
}
}
}
}
if (sr == null) {
// Failed.
return new StaticVisualizationInstance(context, task, plot, width, height, parent);
}
for (String header : sr.getHeaderLines()) {
ypos = addHeader(plot, parent, ypos, header);
}
for (EvaluationResult.MeasurementGroup g : sr) {
ypos = addHeader(plot, parent, ypos, g.getName());
for (EvaluationResult.Measurement m : g) {
ypos = addBarChart(plot, parent, ypos, m.getName(), m.getVal(), m.getMin(), m.getMax(), m.getExp(), m.lowerIsBetter());
}
}
// scale vis
double cols = 10;
final StyleLibrary style = context.getStyleLibrary();
final double margin = style.getSize(StyleLibrary.MARGIN);
final String transform = SVGUtil.makeMarginTransform(width, height, cols, ypos, margin / StyleLibrary.SCALE);
SVGUtil.setAtt(parent, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform);
return new StaticVisualizationInstance(context, task, plot, width, height, parent);
}
use of de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy in project elki by elki-project.
the class OpenGL3DParallelCoordinates method getStylePolicy.
/**
* Hack: Get/Create the style result.
*
* @return Style result
*/
public StylingPolicy getStylePolicy(ResultHierarchy hier, StyleLibrary stylelib) {
Database db = ResultUtil.findDatabase(hier);
AutomaticEvaluation.ensureClusteringResult(db, db);
List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db);
if (clusterings.size() > 0) {
return new ClusterStylingPolicy(clusterings.get(0), stylelib);
} else {
throw new AbortException("No clustering result generated?!?");
}
}
Aggregations