Search in sources :

Example 6 with RectFloat2D

use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.

the class SubOrtho method doLayout.

@Override
protected void doLayout(int dtMS) {
    int ww = window.getWidth();
    int wh = window.getHeight();
    pos(new RectFloat2D(boundsWin.x * ww, boundsWin.y * wh, boundsWin.w * ww, boundsWin.h * wh));
    super.doLayout(dtMS);
}
Also used : RectFloat2D(jcog.tree.rtree.rect.RectFloat2D)

Example 7 with RectFloat2D

use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.

the class ExeCharts method metaGoalControls.

public static Surface metaGoalControls(NAR n) {
    CheckBox auto = new CheckBox("Auto");
    auto.set(false);
    float[] want = n.emotion.want;
    Gridding g = grid(// Stream.of(auto),
    IntStream.range(0, want.length).mapToObj(w -> new FloatSlider(want[w], -1f, +1f) {

        @Override
        protected void paintWidget(GL2 gl, RectFloat2D bounds) {
            if (auto.on()) {
                value(want[w]);
            }
        }
    }.text(MetaGoal.values()[w].name()).type(BaseSlider.Knob).on((s, v) -> {
        if (!auto.on())
            want[w] = v;
    })).toArray(Surface[]::new));
    return g;
}
Also used : GL2(com.jogamp.opengl.GL2) IntStream(java.util.stream.IntStream) BaseSlider(spacegraph.space2d.widget.slider.BaseSlider) DurService(nars.control.DurService) Causable(nars.exe.Causable) Surface(spacegraph.space2d.Surface) TreeChart(spacegraph.space2d.widget.meter.TreeChart) StringUtils(org.apache.commons.lang3.StringUtils) Draw(spacegraph.video.Draw) Function(java.util.function.Function) AutoSurface(spacegraph.space2d.widget.meta.AutoSurface) Traffic(nars.control.Traffic) Gridding(spacegraph.space2d.container.Gridding) BitmapMatrixView(spacegraph.space2d.widget.meter.BitmapMatrixView) FloatSlider(spacegraph.space2d.widget.slider.FloatSlider) NAgent(nars.NAgent) FasterList(jcog.list.FasterList) FloatRange(jcog.math.FloatRange) nars.$(nars.$) LoopPanel(spacegraph.space2d.widget.meta.LoopPanel) Collectors(java.util.stream.Collectors) Util(jcog.Util) RectFloat2D(jcog.tree.rtree.rect.RectFloat2D) CheckBox(spacegraph.space2d.widget.button.CheckBox) List(java.util.List) Splitting(spacegraph.space2d.container.Splitting) NAR(nars.NAR) Cause(nars.control.Cause) MetaGoal(nars.control.MetaGoal) FloatFunction(org.eclipse.collections.api.block.function.primitive.FloatFunction) Label(spacegraph.space2d.widget.text.Label) Gridding(spacegraph.space2d.container.Gridding) CheckBox(spacegraph.space2d.widget.button.CheckBox) FloatSlider(spacegraph.space2d.widget.slider.FloatSlider) RectFloat2D(jcog.tree.rtree.rect.RectFloat2D) GL2(com.jogamp.opengl.GL2) Surface(spacegraph.space2d.Surface) AutoSurface(spacegraph.space2d.widget.meta.AutoSurface)

Example 8 with RectFloat2D

use of jcog.tree.rtree.rect.RectFloat2D in project narchy by automenta.

the class Label method doLayout.

@Override
protected void doLayout(float tx, float ty, float tw, float th) {
    innerBounds = new RectFloat2D(tx, ty, tx + tw, ty + th);
    int len = text().length();
    if (len == 0)
        return;
    float charAspect = 1.4f;
    this.textScaleX = 1f / len;
    this.textScaleY = 1 * charAspect;
    float visAspect = th / tw;
    if (textScaleY / textScaleX <= visAspect) {
        this.textScaleX = 1f / (charAspect * len);
        this.textScaleY = textScaleX * charAspect;
    } else {
        this.textScaleY = textScaleX / visAspect;
    }
    if (textScaleY > 1f) {
        // (charAspect * len);
        textScaleX = 1f / (len * textScaleY);
        textScaleY = 1f;
    }
    textY = 0.5f - textScaleY / 2f;
}
Also used : RectFloat2D(jcog.tree.rtree.rect.RectFloat2D)

Aggregations

RectFloat2D (jcog.tree.rtree.rect.RectFloat2D)8 GL2 (com.jogamp.opengl.GL2)2 Gridding (spacegraph.space2d.container.Gridding)2 AutoSurface (spacegraph.space2d.widget.meta.AutoSurface)2 List (java.util.List)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Util (jcog.Util)1 HaiQae (jcog.learn.ql.HaiQae)1 FasterList (jcog.list.FasterList)1 FloatRange (jcog.math.FloatRange)1 nars.$ (nars.$)1 NAR (nars.NAR)1 NAgent (nars.NAgent)1 Cause (nars.control.Cause)1 DurService (nars.control.DurService)1 MetaGoal (nars.control.MetaGoal)1 Traffic (nars.control.Traffic)1 Deriver (nars.derive.Deriver)1