Search in sources :

Example 6 with Visualization

use of de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization in project elki by elki-project.

the class OverviewPlot method embedOrThumbnail.

/**
 * Produce thumbnail for a visualizer.
 *
 * @param thumbsize Thumbnail size
 * @param it Plot item
 * @param task Task
 * @param parent Parent element to draw to
 */
private Visualization embedOrThumbnail(final int thumbsize, PlotItem it, VisualizationTask task, Element parent) {
    final Visualization vis;
    if (!single) {
        vis = task.getFactory().makeVisualizationOrThumbnail(context, task, plot, it.w, it.h, it.proj, thumbsize);
    } else {
        vis = task.getFactory().makeVisualization(context, task, plot, it.w, it.h, it.proj);
    }
    if (vis == null || vis.getLayer() == null) {
        LOG.warning("Visualization returned empty layer: " + vis);
        return vis;
    }
    if (task.has(RenderFlag.NO_EXPORT)) {
        vis.getLayer().setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
    }
    parent.appendChild(vis.getLayer());
    return vis;
}
Also used : Visualization(de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization)

Example 7 with Visualization

use of de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization in project elki by elki-project.

the class VisualizePairwiseGainMatrix method showVisualization.

/**
 * Show a single visualization.
 *
 * @param context Visualizer context
 * @param factory Visualizer factory
 * @param task Visualization task
 */
private void showVisualization(VisualizerContext context, SimilarityMatrixVisualizer factory, VisualizationTask task) {
    VisualizationPlot plot = new VisualizationPlot();
    Visualization vis = factory.makeVisualization(context, task, plot, 1.0, 1.0, null);
    plot.getRoot().appendChild(vis.getLayer());
    plot.getRoot().setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "20cm");
    plot.getRoot().setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "20cm");
    plot.getRoot().setAttribute(SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, "0 0 1 1");
    plot.updateStyleElement();
    (new SimpleSVGViewer()).setPlot(plot);
}
Also used : Visualization(de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization) VisualizationPlot(de.lmu.ifi.dbs.elki.visualization.gui.VisualizationPlot) SimpleSVGViewer(de.lmu.ifi.dbs.elki.visualization.gui.SimpleSVGViewer)

Example 8 with Visualization

use of de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization in project elki by elki-project.

the class VisualizationPlot method redraw.

/**
 * Redraw all pending updates.
 */
protected void redraw() {
    while (!updateQueue.isEmpty()) {
        Visualization vis = updateQueue.pop();
        vis.incrementalRedraw();
    }
}
Also used : Visualization(de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization)

Example 9 with Visualization

use of de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization in project elki by elki-project.

the class DetailView method destroy.

/**
 * Cleanup function. To remove listeners.
 */
public void destroy() {
    context.removeVisualizationListener(this);
    context.removeResultListener(this);
    for (Entry<VisualizationTask, Visualization> v : taskmap.entrySet()) {
        Visualization vis = v.getValue();
        if (vis != null) {
            vis.destroy();
        }
    }
    taskmap.clear();
}
Also used : Visualization(de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization) VisualizationTask(de.lmu.ifi.dbs.elki.visualization.VisualizationTask)

Example 10 with Visualization

use of de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization in project elki by elki-project.

the class OverviewPlot method reinitialize.

/**
 * Refresh the overview plot.
 */
private synchronized void reinitialize() {
    if (plot == null) {
        initializePlot();
    } else {
        final ActionEvent ev = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, OVERVIEW_REFRESHING);
        for (ActionListener actionListener : actionListeners) {
            actionListener.actionPerformed(ev);
        }
    }
    // Detach existing elements:
    for (Pair<Element, Visualization> pair : vistoelem.values()) {
        SVGUtil.removeFromParent(pair.first);
    }
    plotmap = arrangeVisualizations(ratio, 1.0);
    recalcViewbox();
    final int thumbsize = (int) Math.max(screenwidth / plotmap.getWidth(), screenheight / plotmap.getHeight());
    // TODO: cancel pending thumbnail requests!
    // Replace the layer map
    LayerMap oldlayers = vistoelem;
    vistoelem = new LayerMap();
    // Redo main layers
    SVGUtil.removeFromParent(plotlayer);
    SVGUtil.removeFromParent(hoverlayer);
    plotlayer = plot.svgElement(SVGConstants.SVG_G_TAG);
    hoverlayer = plot.svgElement(SVGConstants.SVG_G_TAG);
    hoverlayer.setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
    // Redo the layout
    for (Entry<PlotItem, double[]> e : plotmap.entrySet()) {
        final double basex = e.getValue()[0];
        final double basey = e.getValue()[1];
        for (Iterator<PlotItem> iter = e.getKey().itemIterator(); iter.hasNext(); ) {
            PlotItem it = iter.next();
            boolean hasDetails = false;
            // Container element for main plot item
            Element g = plot.svgElement(SVGConstants.SVG_G_TAG);
            SVGUtil.setAtt(g, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, "translate(" + (basex + it.x) + " " + (basey + it.y) + ")");
            plotlayer.appendChild(g);
            vistoelem.put(it, null, g, null);
            // Add the actual tasks:
            for (VisualizationTask task : it.tasks) {
                if (!visibleInOverview(task)) {
                    continue;
                }
                hasDetails |= !task.has(RenderFlag.NO_DETAIL);
                Pair<Element, Visualization> pair = oldlayers.remove(it, task);
                if (pair == null) {
                    pair = new Pair<>(plot.svgElement(SVGConstants.SVG_G_TAG), null);
                }
                if (pair.second == null) {
                    pair.second = embedOrThumbnail(thumbsize, it, task, pair.first);
                }
                g.appendChild(pair.first);
                vistoelem.put(it, task, pair);
            }
            // When needed, add a hover effect
            if (hasDetails && !single) {
                Element hover = plot.svgRect(basex + it.x, basey + it.y, it.w, it.h);
                SVGUtil.addCSSClass(hover, selcss.getName());
                // link hoverer.
                EventTarget targ = (EventTarget) hover;
                targ.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, hoverer, false);
                targ.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, hoverer, false);
                targ.addEventListener(SVGConstants.SVG_CLICK_EVENT_TYPE, hoverer, false);
                targ.addEventListener(SVGConstants.SVG_CLICK_EVENT_TYPE, new SelectPlotEvent(it), false);
                hoverlayer.appendChild(hover);
            }
        }
    }
    for (Pair<Element, Visualization> pair : oldlayers.values()) {
        if (pair.second != null) {
            pair.second.destroy();
        }
    }
    plot.getRoot().appendChild(plotlayer);
    plot.getRoot().appendChild(hoverlayer);
    plot.updateStyleElement();
    // Notify listeners.
    final ActionEvent ev = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, OVERVIEW_REFRESHED);
    for (ActionListener actionListener : actionListeners) {
        actionListener.actionPerformed(ev);
    }
}
Also used : Visualization(de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization) ActionEvent(java.awt.event.ActionEvent) Element(org.w3c.dom.Element) VisualizationTask(de.lmu.ifi.dbs.elki.visualization.VisualizationTask) ActionListener(java.awt.event.ActionListener) EventTarget(org.w3c.dom.events.EventTarget)

Aggregations

Visualization (de.lmu.ifi.dbs.elki.visualization.visualizers.Visualization)12 VisualizationTask (de.lmu.ifi.dbs.elki.visualization.VisualizationTask)7 Element (org.w3c.dom.Element)5 VisualizationPlot (de.lmu.ifi.dbs.elki.visualization.gui.VisualizationPlot)3 ArrayList (java.util.ArrayList)2 Logging (de.lmu.ifi.dbs.elki.logging.Logging)1 AbortException (de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException)1 SimpleSVGViewer (de.lmu.ifi.dbs.elki.visualization.gui.SimpleSVGViewer)1 PlotItem (de.lmu.ifi.dbs.elki.visualization.gui.overview.PlotItem)1 Projector (de.lmu.ifi.dbs.elki.visualization.projector.Projector)1 AbstractVisualization (de.lmu.ifi.dbs.elki.visualization.visualizers.AbstractVisualization)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 Entry (java.util.Map.Entry)1 Node (org.w3c.dom.Node)1 EventTarget (org.w3c.dom.events.EventTarget)1