Search in sources :

Example 6 with Element

use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method bindLocal.

@Override
protected void bindLocal(Properties parameter, Attributes controlDefinitionAttributes) {
    super.bindLocal(parameter, controlDefinitionAttributes);
    if (Util.notEmpty(parameter.getProperty("noMult"))) {
        noMult = Boolean.valueOf(parameter.getProperty("noMult"));
    }
    if (Util.notEmpty(parameter.getProperty("noPipe"))) {
        noPipe = Boolean.valueOf(parameter.getProperty("noPipe"));
    }
    if (Util.notEmpty(parameter.getProperty("noWire"))) {
        noWire = Boolean.valueOf(parameter.getProperty("noWire"));
    }
    if (Util.notEmpty(parameter.getProperty("noCable"))) {
        noCable = Boolean.valueOf(parameter.getProperty("noCable"));
    }
    if (noMult) {
        Element multimeterPanel = findById("multimeterPanel");
        multimeterPanel.markForRemoval();
    }
    if (noPipe) {
        Element pipePanel = findById("pipePanel");
        pipePanel.markForRemoval();
    } else {
        Element pipeColorsContent = findById("pipeColorsContent");
        updateImageMode("currentPipe#colorImage", pipeImageModes[0]);
        for (int i = 0; i < pipeLabels.length; i++) {
            creatWireAndPipeItem(i, pipeImageModes, pipeLabels, "changePipeColor", pipeColorsContent);
        }
    }
    if (noWire) {
        Element wirePanel = findById("wirePanel");
        wirePanel.markForRemoval();
    } else {
        Element wireColorsContent = findById("wireColorsContent");
        updateImageMode("currentWire#colorImage", wireImageModes[0]);
        for (int j = 0; j < wireLabels.length; j++) {
            creatWireAndPipeItem(j, wireImageModes, wireLabels, "changeWireColor", wireColorsContent);
        }
    }
    if (noCable) {
        Element xianlanPanel = findById("xianlanPanel");
        xianlanPanel.markForRemoval();
    }
    addCleanningControlOnEnd(new ICleanableControl() {

        @Override
        public void onClean() {
            if (timer != null) {
                timer.cancel();
            }
        }

        @Override
        public String getName() {
            if (timer != null) {
                return timer.toString();
            }
            return "null Timer";
        }
    });
}
Also used : ICleanableControl(com.cas.robot.common.ICleanableControl) Element(de.lessvoid.nifty.elements.Element)

Example 7 with Element

use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method selectCable.

/**
 */
public void selectCable() {
    setContentVisible("pipeColorsContent", "false");
    setContentVisible("wireColorsContent", "false");
    if (cableLabels == null) {
        if (!connectionHandler.checkChange()) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
            return;
        }
        connectionHandler.setCurrLinker(ConnectionUtil.CONNECT_CABLE, null);
        return;
    }
    if (connectionHandler.getCurrLinker() instanceof Cable) {
        currentCableIndex = currentCableIndex + 1 > cableLabels.length - 1 ? 0 : currentCableIndex + 1;
        List<Element> colorEles = findById("xianlanColorsContent").getElements();
        Cable cable = (Cable) connectionHandler.getCurrLinker();
        for (int i = 0; i < colorEles.size(); i++) {
            Element colorEle = colorEles.get(i);
            if (i == currentCableIndex) {
                colorEle.startEffect(EffectEventId.onActive);
                cable.setNowConnectingWire(cableLabels[currentCableIndex]);
            } else {
                colorEle.stopEffect(EffectEventId.onActive);
            }
        }
    }
}
Also used : Cable(com.cas.circuit.vo.Cable) Element(de.lessvoid.nifty.elements.Element)

Example 8 with Element

use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method setViewAreaVisible.

public void setViewAreaVisible(boolean visible) {
    Element border = findById("border");
    border.setVisible(visible);
}
Also used : Element(de.lessvoid.nifty.elements.Element)

Example 9 with Element

use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method selectPipe.

/**
 */
private void selectPipe() {
    if (!connectionHandler.checkChange()) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
        return;
    }
    setContentVisible("pipeColorsContent", "true");
    setContentVisible("wireColorsContent", "false");
    if (connectionHandler.getCurrLinker() instanceof Pipe) {
        // 当前是气管
        currentPipeIndex = currentPipeIndex + 1 > pipeColors.length - 1 ? 0 : currentPipeIndex + 1;
    }
    List<Element> pipeEles = findById("pipeColorsContent").getElements();
    for (int i = 0; i < pipeEles.size(); i++) {
        Element pipeEle = pipeEles.get(i);
        if (i == currentPipeIndex) {
            pipeEle.startEffect(EffectEventId.onHover);
        } else {
            pipeEle.stopEffect(EffectEventId.onHover);
        }
    }
    changePipeColor(String.valueOf(currentPipeIndex));
    // 2秒后隐藏
    selectHideTimer("pipeColorsContent");
}
Also used : Element(de.lessvoid.nifty.elements.Element) Pipe(com.cas.gas.vo.Pipe)

Example 10 with Element

use of de.lessvoid.nifty.elements.Element in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionController method removeXianLanItem.

private void removeXianLanItem(int index) {
    final Element parent = findById("xianlanColorsContent");
    Element item = parent.getElements().get(index);
    item.markForRemoval(new EndNotify() {

        @Override
        public void perform() {
            refreshxianlanColorsContent();
            currentCableIndex = currentCableIndex == parent.getElements().size() ? 0 : currentCableIndex;
        }
    });
}
Also used : Element(de.lessvoid.nifty.elements.Element) EndNotify(de.lessvoid.nifty.EndNotify)

Aggregations

Element (de.lessvoid.nifty.elements.Element)14 TextField (de.lessvoid.nifty.controls.TextField)3 Wire (com.cas.circuit.vo.Wire)2 Cable (com.cas.circuit.vo.Cable)1 Pipe (com.cas.gas.vo.Pipe)1 ICleanableControl (com.cas.robot.common.ICleanableControl)1 SoftTextDialogInput (com.jme3.input.SoftTextDialogInput)1 SoftTextDialogInputListener (com.jme3.input.controls.SoftTextDialogInputListener)1 RenderImageJme (com.jme3.niftygui.RenderImageJme)1 Image (com.jme3.texture.Image)1 Texture2D (com.jme3.texture.Texture2D)1 EndNotify (de.lessvoid.nifty.EndNotify)1 CustomControlCreator (de.lessvoid.nifty.controls.dynamic.CustomControlCreator)1 ControlEffectAttributes (de.lessvoid.nifty.controls.dynamic.attributes.ControlEffectAttributes)1 ControlEffectOnHoverAttributes (de.lessvoid.nifty.controls.dynamic.attributes.ControlEffectOnHoverAttributes)1 ImageRenderer (de.lessvoid.nifty.elements.render.ImageRenderer)1 NiftyImage (de.lessvoid.nifty.render.NiftyImage)1 RenderImage (de.lessvoid.nifty.spi.render.RenderImage)1 BufferedImage (java.awt.image.BufferedImage)1 InputStream (java.io.InputStream)1