Search in sources :

Example 1 with TreeMLData

use of automenta.vivisect.TreeMLData in project opennars by opennars.

the class LineChart method drawOverlay.

protected void drawOverlay(TimelineVis l, float screenyLo, float screenyHi) {
    // draw overlay
    l.g.pushMatrix();
    l.g.resetMatrix();
    if (xorOverlay) {
        Graphics2D g2 = l.g2;
        g2.setXORMode(Color.white);
    }
    int dsy = (int) Math.abs(screenyLo - screenyHi);
    float ytspace = dsy * 0.75f / data.size() / 2;
    l.g.textSize(11f);
    l.g.fill(210);
    // TODO number precision formatting
    l.g.text("" + ((double) min), 0, screenyLo - dsy / 10f);
    l.g.text("" + ((double) max), 0, screenyHi + dsy / 10f);
    l.g.textSize(15f);
    float dsyt = screenyHi + 0.15f * dsy;
    for (TreeMLData chart : data) {
        l.g.fill(chart.getColor() | 0x77777777);
        dsyt += ytspace;
        l.g.text(chart.label, 0, dsyt);
        dsyt += ytspace;
    }
    if (xorOverlay) {
        Graphics2D g2 = l.g2;
        g2.setPaintMode();
    }
    l.g.popMatrix();
}
Also used : TreeMLData(automenta.vivisect.TreeMLData) Graphics2D(java.awt.Graphics2D)

Example 2 with TreeMLData

use of automenta.vivisect.TreeMLData in project opennars by opennars.

the class LineChart method drawData.

protected void drawData(TimelineVis l, float timeScale1, float yScale1, float y) {
    int ccolor = 0;
    float w = lineThickness * 2.75f;
    for (TreeMLData chart : data) {
        ccolor = chart.getColor();
        float lx = 0;
        float ly = 0;
        l.g.fill(255f);
        boolean firstPoint = false;
        l.g.stroke(ccolor);
        l.g.strokeWeight(lineThickness);
        int cs = l.cycleStart;
        for (int t = cs; t < l.cycleEnd; t++) {
            l.g.stroke = true;
            float x = (t - cs) * timeScale1;
            float v = (float) chart.getData(t);
            if (Float.isNaN(v)) {
                continue;
            }
            float p = (float) ((max == min) ? 0 : (double) ((v - min) / (max - min)));
            float px = width * x;
            float h = p * yScale1;
            float py = y + yScale1 - h;
            if (firstPoint) {
                boolean hadCustom = false;
                if (this.customColor.containsKey(t)) {
                    hadCustom = true;
                    l.g.stroke(this.customColor.get(t));
                }
                if (showVerticalLines) {
                    l.g.line(px, py, px, py + h);
                }
                if (t != l.cycleStart) {
                    l.g.line(lx, ly, px, py);
                }
                if (hadCustom) {
                    l.g.stroke(ccolor);
                }
            }
            lx = px;
            ly = py;
            firstPoint = true;
            if (showPoints) {
                l.g.stroke = false;
                // TODO create separate size and opacity get/set parameter for the points
                l.g.fill(ccolor, 128f * (p * 0.5f + 0.5f));
                l.g.rect(px - w / 2f, py - w / 2f, w, w);
            }
        }
    }
}
Also used : TreeMLData(automenta.vivisect.TreeMLData)

Example 3 with TreeMLData

use of automenta.vivisect.TreeMLData in project opennars by opennars.

the class SpectrumChart method drawData.

@Override
protected void drawData(TimelineVis l, float timeScale, float yScale, float y) {
    TreeMLData chart = data.get(0);
    if (!updated) {
        update();
        updated = true;
    }
    // int ccolor = chart.getColor();
    l.g.noStroke();
    long prevWindow = -1;
    float yh = yScale / windowSize;
    for (long t = l.cycleStart - (windowSize); t < l.cycleEnd; t++) {
        if (t < 0)
            continue;
        float x = t * timeScale;
        long w = cycleToWindow(t);
        if ((w != prevWindow) && (w < windows.size())) {
            float t2 = t + windowSize;
            float x2 = t2 * timeScale;
            // draw window block
            Window win = windows.get((int) w);
            float magMax = Floats.max(win.magnitude);
            float yy = yScale;
            for (int f = 0; f < windowSize; f++) {
                float m = win.magnitude[f] / magMax;
                m = (0.25f + 0.75f * m);
                float phase = (win.phase[f] + (float) Math.PI * 2f) / ((float) Math.PI * 2f);
                l.g.fill((0.2f + 0.3f * phase) * 255f, 0.75f * 255f, m * 255f);
                yy -= yh;
                l.g.rect(x, y + yy, x2 - x, yh);
            }
            prevWindow = w;
        }
    }
}
Also used : TreeMLData(automenta.vivisect.TreeMLData)

Example 4 with TreeMLData

use of automenta.vivisect.TreeMLData in project opennars by opennars.

the class BarChart method drawData.

@Override
protected void drawData(TimelineVis l, float timeScale, float yScale1, float y) {
    if (data.size() != 1)
        throw new RuntimeException("BarChart only supports one data set");
    TreeMLData chart = data.get(0);
    int ccolor = chart.getColor();
    l.g.noStroke();
    for (int t = l.cycleStart; t < l.cycleEnd; t++) {
        float x = (t - l.cycleStart) * timeScale;
        float v = (float) chart.getData(t);
        if (Float.isNaN(v)) {
            continue;
        }
        float p = (max == min) ? 0 : (float) ((v - min) / (max - min));
        float px = width * x;
        float h = p * yScale1;
        float py = y + yScale1 - h;
        l.g.fill(ccolor, 255f * (0.5f + 0.5f * p));
        l.g.rect(px, py, width * timeScale * barWidth, h);
    }
}
Also used : TreeMLData(automenta.vivisect.TreeMLData)

Example 5 with TreeMLData

use of automenta.vivisect.TreeMLData in project opennars by opennars.

the class LineChart method updateRange.

protected void updateRange(TimelineVis l) {
    min = Float.POSITIVE_INFINITY;
    max = Float.NEGATIVE_INFINITY;
    for (TreeMLData chart : data) {
        double[] mm = chart.getMinMax(l.cycleStart, l.cycleEnd);
        min = (float) Math.min(min, mm[0]);
        max = (float) Math.max(max, mm[1]);
    }
}
Also used : TreeMLData(automenta.vivisect.TreeMLData)

Aggregations

TreeMLData (automenta.vivisect.TreeMLData)9 NWindow (automenta.vivisect.swing.NWindow)1 PCanvas (automenta.vivisect.swing.PCanvas)1 LineChart (automenta.vivisect.timeline.LineChart)1 TimelineVis (automenta.vivisect.timeline.TimelineVis)1 Graphics2D (java.awt.Graphics2D)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 DerivationContext (nars.control.DerivationContext)1 Sentence (nars.entity.Sentence)1 Task (nars.entity.Task)1 NARSwing (nars.gui.NARSwing)1 Narsese (nars.io.Narsese)1 AnswerHandler (nars.io.events.AnswerHandler)1 TaskImmediateProcess (nars.io.events.Events.TaskImmediateProcess)1 ChangedTextInput (nars.lab.ioutils.ChangedTextInput)1 Term (nars.language.Term)1 NAR (nars.main.NAR)1 Complex (org.apache.commons.math3.complex.Complex)1