Search in sources :

Example 1 with StylingPolicy

use of de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy in project elki by elki-project.

the class OPTICSPlot method plotForClusterOrder.

/**
 * Static method to find an optics plot for a result, or to create a new one
 * using the given context.
 *
 * @param co Cluster order
 * @param context Context (for colors and reference clustering)
 *
 * @return New or existing optics plot
 */
public static OPTICSPlot plotForClusterOrder(ClusterOrder co, VisualizerContext context) {
    // Check for an existing plot
    // ArrayList<OPTICSPlot<D>> plots = ResultUtil.filterResults(co,
    // OPTICSPlot.class);
    // if (plots.size() > 0) {
    // return plots.get(0);
    // }
    final StylingPolicy policy = context.getStylingPolicy();
    OPTICSPlot opticsplot = new OPTICSPlot(co, policy);
    // co.addChildResult(opticsplot);
    return opticsplot;
}
Also used : StylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy)

Example 2 with StylingPolicy

use of de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy in project elki by elki-project.

the class OpenGL3DParallelCoordinates method processNewResult.

@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
    boolean nonefound = true;
    List<Relation<?>> rels = ResultUtil.getRelations(newResult);
    for (Relation<?> rel : rels) {
        if (!TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) {
            continue;
        }
        @SuppressWarnings("unchecked") Relation<? extends O> vrel = (Relation<? extends O>) rel;
        ScalesResult scales = ScalesResult.getScalesResult(vrel);
        ProjectionParallel proj = new SimpleParallel(null, scales.getScales());
        PropertiesBasedStyleLibrary stylelib = new PropertiesBasedStyleLibrary();
        StylingPolicy stylepol = getStylePolicy(hier, stylelib);
        new Instance<>(vrel, proj, settings, stylepol, stylelib).run();
        nonefound = false;
    }
    if (nonefound && hier.equals(newResult)) {
        LOG.warning("3DPC did not find a number vector field relation to visualize!");
    }
}
Also used : SimpleParallel(de.lmu.ifi.dbs.elki.visualization.projections.SimpleParallel) PropertiesBasedStyleLibrary(de.lmu.ifi.dbs.elki.visualization.style.PropertiesBasedStyleLibrary) ProjectionParallel(de.lmu.ifi.dbs.elki.visualization.projections.ProjectionParallel) Relation(de.lmu.ifi.dbs.elki.database.relation.Relation) ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult) StylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy) ClusterStylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy)

Example 3 with StylingPolicy

use of de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy 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);
}
Also used : Element(org.w3c.dom.Element) It(de.lmu.ifi.dbs.elki.utilities.datastructures.iterator.It) StyleLibrary(de.lmu.ifi.dbs.elki.visualization.style.StyleLibrary) StaticVisualizationInstance(de.lmu.ifi.dbs.elki.visualization.visualizers.StaticVisualizationInstance) EvaluationResult(de.lmu.ifi.dbs.elki.result.EvaluationResult) ClusterStylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy) StylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy) ClusterStylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy)

Aggregations

StylingPolicy (de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy)3 ClusterStylingPolicy (de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy)2 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)1 EvaluationResult (de.lmu.ifi.dbs.elki.result.EvaluationResult)1 ScalesResult (de.lmu.ifi.dbs.elki.result.ScalesResult)1 It (de.lmu.ifi.dbs.elki.utilities.datastructures.iterator.It)1 ProjectionParallel (de.lmu.ifi.dbs.elki.visualization.projections.ProjectionParallel)1 SimpleParallel (de.lmu.ifi.dbs.elki.visualization.projections.SimpleParallel)1 PropertiesBasedStyleLibrary (de.lmu.ifi.dbs.elki.visualization.style.PropertiesBasedStyleLibrary)1 StyleLibrary (de.lmu.ifi.dbs.elki.visualization.style.StyleLibrary)1 StaticVisualizationInstance (de.lmu.ifi.dbs.elki.visualization.visualizers.StaticVisualizationInstance)1 Element (org.w3c.dom.Element)1