Search in sources :

Example 11 with LinearScale

use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.

the class Parallel3DRenderer method drawParallelPlot.

protected void drawParallelPlot(GLAutoDrawable drawable, GL2 gl) {
    // Sort axes by sq. distance from camera, front-to-back:
    sortAxes();
    // Sort edges by the maximum (foreground) index.
    IntIntPair[] edgesort = sortEdges(dindex);
    if (textures != null) {
        gl.glShadeModel(GL2.GL_FLAT);
        // Render spider web:
        // outside glBegin!
        gl.glLineWidth(shared.settings.linewidth);
        gl.glBegin(GL.GL_LINES);
        gl.glColor4f(0f, 0f, 0f, 1f);
        for (Layout.Edge edge : shared.layout.edges) {
            Node n1 = shared.layout.getNode(edge.dim1), n2 = shared.layout.getNode(edge.dim2);
            gl.glVertex3d(n1.getX(), n1.getY(), 0f);
            gl.glVertex3d(n2.getX(), n2.getY(), 0f);
        }
        gl.glEnd();
        // Draw axes and 3DPC:
        for (int i = 0; i < shared.dim; i++) {
            final int d = axes[i].second;
            final Node node1 = shared.layout.getNode(d);
            // Draw edge textures
            for (IntIntPair pair : edgesort) {
                // Not yet available?
                if (pair.second >= completedTextures) {
                    continue;
                }
                // Other axis must have a smaller index.
                if (pair.first >= i) {
                    continue;
                }
                Layout.Edge edge = shared.layout.edges.get(pair.second);
                // Must involve the current axis.
                if (edge.dim1 != d && edge.dim2 != d) {
                    continue;
                }
                int od = axes[pair.first].second;
                gl.glEnable(GL.GL_TEXTURE_2D);
                gl.glColor4f(1f, 1f, 1f, 1f);
                final Node node2 = shared.layout.getNode(od);
                gl.glBindTexture(GL.GL_TEXTURE_2D, textures[pair.second]);
                gl.glBegin(GL2.GL_QUADS);
                gl.glTexCoord2d((edge.dim1 == d) ? 0f : 1f, 0f);
                gl.glVertex3d(node1.getX(), node1.getY(), 0f);
                gl.glTexCoord2d((edge.dim1 == d) ? 0f : 1f, 1f);
                gl.glVertex3d(node1.getX(), node1.getY(), 1f);
                gl.glTexCoord2d((edge.dim1 != d) ? 0f : 1f, 1f);
                gl.glVertex3d(node2.getX(), node2.getY(), 1f);
                gl.glTexCoord2d((edge.dim1 != d) ? 0f : 1f, 0f);
                gl.glVertex3d(node2.getX(), node2.getY(), 0f);
                gl.glEnd();
                gl.glDisable(GL.GL_TEXTURE_2D);
            }
            // Draw axis
            // outside glBegin!
            gl.glLineWidth(shared.settings.linewidth);
            gl.glBegin(GL.GL_LINES);
            gl.glColor4f(0f, 0f, 0f, 1f);
            gl.glVertex3d(node1.getX(), node1.getY(), 0f);
            gl.glVertex3d(node1.getX(), node1.getY(), 1f);
            gl.glEnd();
            // Draw ticks.
            LinearScale scale = shared.proj.getAxisScale(d);
            gl.glPointSize(shared.settings.linewidth * 2f);
            gl.glBegin(GL.GL_POINTS);
            for (double tick = scale.getMin(); tick <= scale.getMax() + scale.getRes() / 10; tick += scale.getRes()) {
                gl.glVertex3d(node1.getX(), node1.getY(), scale.getScaled(tick));
            }
            gl.glEnd();
        }
    }
    // Render labels
    renderLabels(gl, edgesort);
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale) Layout(de.lmu.ifi.dbs.elki.visualization.parallel3d.layout.Layout) Node(de.lmu.ifi.dbs.elki.visualization.parallel3d.layout.Layout.Node) IntIntPair(de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair)

Example 12 with LinearScale

use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.

the class AbstractObjDynamicHistogram method materialize.

/**
 * Materialize the histogram from the cache.
 */
@SuppressWarnings("unchecked")
void materialize() {
    // already materialized?
    if (cachefill <= 0) {
        return;
    }
    // Compute minimum and maximum
    double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
    for (int i = 0; i < cachefill; i++) {
        min = MathUtil.min(min, cacheposs[i]);
        max = MathUtil.max(max, cacheposs[i]);
    }
    // use the LinearScale magic to round to "likely suitable" step sizes.
    // TODO: extract into a reusable function?
    LinearScale scale = new LinearScale(min, max);
    min = scale.getMin();
    max = scale.getMax();
    this.base = min;
    this.max = max;
    this.binsize = (max - min) / this.destsize;
    // initialize array
    this.data = new Object[this.destsize << 1];
    for (int i = 0; i < this.destsize; i++) {
        this.data[i] = makeObject();
    }
    size = destsize;
    // re-insert data we have
    final int end = cachefill;
    // So reinsert works!
    cachefill = -1;
    for (int i = 0; i < end; i++) {
        putData(cacheposs[i], (T) cachevals[i]);
    }
    // delete cache, signal that we're initialized
    cacheposs = null;
    cachevals = null;
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale)

Example 13 with LinearScale

use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.

the class FloatDynamicHistogram method materialize.

/**
 * Materialize the histogram from the cache.
 */
void materialize() {
    // already materialized?
    if (cachefill < 0) {
        return;
    }
    // Compute minimum and maximum
    double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
    for (int i = 0; i < cachefill; i++) {
        min = Math.min(min, cachec[i]);
        max = Math.max(max, cachec[i]);
    }
    // use the LinearScale magic to round to "likely suiteable" step sizes.
    // TODO: extract into a reusable function?
    LinearScale scale = new LinearScale(min, max);
    min = scale.getMin();
    max = scale.getMax();
    this.base = min;
    this.max = max;
    this.binsize = (max - min) / this.destsize;
    // initialize array
    this.data = new float[this.destsize << 1];
    size = destsize;
    // re-insert data we have
    final int end = cachefill;
    // So reinsert works!
    cachefill = -1;
    for (int i = 0; i < end; i++) {
        increment(cachec[i], cachev[i]);
    }
    // delete cache, signal that we're initialized
    cachec = null;
    cachev = null;
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale)

Example 14 with LinearScale

use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.

the class ShortDynamicHistogram method materialize.

/**
 * Materialize the histogram from the cache.
 */
void materialize() {
    // already materialized?
    if (cachefill < 0) {
        return;
    }
    // Compute minimum and maximum
    double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
    for (int i = 0; i < cachefill; i++) {
        min = Math.min(min, cachec[i]);
        max = Math.max(max, cachec[i]);
    }
    // use the LinearScale magic to round to "likely suiteable" step sizes.
    // TODO: extract into a reusable function?
    LinearScale scale = new LinearScale(min, max);
    min = scale.getMin();
    max = scale.getMax();
    this.base = min;
    this.max = max;
    this.binsize = (max - min) / this.destsize;
    // initialize array
    this.data = new short[this.destsize << 1];
    size = destsize;
    // re-insert data we have
    final int end = cachefill;
    // So reinsert works!
    cachefill = -1;
    for (int i = 0; i < end; i++) {
        increment(cachec[i], cachev[i]);
    }
    // delete cache, signal that we're initialized
    cachec = null;
    cachev = null;
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale)

Aggregations

LinearScale (de.lmu.ifi.dbs.elki.math.scales.LinearScale)14 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)3 DoubleMinMax (de.lmu.ifi.dbs.elki.math.DoubleMinMax)3 CSSNamingConflict (de.lmu.ifi.dbs.elki.visualization.css.CSSClassManager.CSSNamingConflict)3 StyleLibrary (de.lmu.ifi.dbs.elki.visualization.style.StyleLibrary)3 SVGPath (de.lmu.ifi.dbs.elki.visualization.svg.SVGPath)3 StaticVisualizationInstance (de.lmu.ifi.dbs.elki.visualization.visualizers.StaticVisualizationInstance)3 Element (org.w3c.dom.Element)3 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)2 ScalesResult (de.lmu.ifi.dbs.elki.result.ScalesResult)2 VectorFieldTypeInformation (de.lmu.ifi.dbs.elki.data.type.VectorFieldTypeInformation)1 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)1 PRCurve (de.lmu.ifi.dbs.elki.evaluation.outlier.OutlierPrecisionRecallCurve.PRCurve)1 ROCResult (de.lmu.ifi.dbs.elki.evaluation.outlier.OutlierROCCurve.ROCResult)1 XYCurve (de.lmu.ifi.dbs.elki.math.geometry.XYCurve)1 XYPlot (de.lmu.ifi.dbs.elki.math.geometry.XYPlot)1 HistogramResult (de.lmu.ifi.dbs.elki.result.HistogramResult)1 ListSizeConstraint (de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ListSizeConstraint)1 IntIntPair (de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair)1 ColorLibrary (de.lmu.ifi.dbs.elki.visualization.colors.ColorLibrary)1