Search in sources :

Example 1 with Element

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

the class ConnectionController method initXianLanPanel.

/**
 * 初始化线缆面板
 */
public void initXianLanPanel(List<Wire> wires, boolean visible) {
    setContentVisible("xianlanColorsContent", String.valueOf(visible));
    if (!visible) {
        cableLabels = null;
        return;
    }
    Element xianlanColorsContent = findById("xianlanColorsContent");
    if (xianlanColorsContent == null || wires == null) {
        return;
    }
    // 线缆导线排序
    Comparator<Wire> comparator = new Comparator<Wire>() {

        @Override
        public int compare(Wire wire1, Wire wire2) {
            return wire1.getPO().getStitch1().compareTo(wire2.getPO().getStitch1());
        }
    };
    Collections.sort(wires, comparator);
    List<Element> eles = xianlanColorsContent.getElements();
    for (int i = 0; i < eles.size(); i++) {
        removeXianLanItem(i);
    }
    List<String> xianLanStrs = new ArrayList<String>();
    for (int i = 0; i < wires.size(); i++) {
        String xianLanStr = wires.get(i).getPO().getMark();
        xianLanStrs.add(xianLanStr);
        Element ele = createXianLanItem(xianLanStr, wires.get(i).getPO().getColor(), i);
        if (i != 0) {
            ele.stopEffect(EffectEventId.onActive);
        }
    }
    refreshxianlanColorsContent();
    currentCableIndex = 0;
    cableLabels = new String[xianLanStrs.size()];
    xianLanStrs.toArray(cableLabels);
}
Also used : Element(de.lessvoid.nifty.elements.Element) ArrayList(java.util.ArrayList) Wire(com.cas.circuit.vo.Wire) Comparator(java.util.Comparator)

Example 2 with Element

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

the class ConnectionController method setNumDialogueVisible.

public void setNumDialogueVisible(boolean visible) {
    Element numDialogue = nifty.findPopupByName("numDialoguePopup");
    if (numDialogue == null) {
        numDialogue = nifty.createPopupWithId("numDialoguePopup", "numDialoguePopup");
    }
    if (visible) {
        // SimpleApplication app = Dispatcher.getIns().getMainApp();
        // InputManager inputManager = app.getInputManager();
        // mouseVisible = inputManager.isCursorVisible();
        mouseVisible = nifty.isMouseVisible();
        TextField wireNumTextfield = numDialogue.findElementByName("wireNum").getNiftyControl(TextField.class);
        wireNumTextfield.setText("");
        nifty.showPopup(screen, "numDialoguePopup", null);
        // if (!inputManager.isCursorVisible()) {
        if (!nifty.isMouseVisible()) {
            nifty.setMouseVisible(true);
        }
    } else {
        nifty.closePopup("numDialoguePopup");
        if (!mouseVisible) {
            nifty.setMouseVisible(false);
        }
    }
}
Also used : Element(de.lessvoid.nifty.elements.Element) TextField(de.lessvoid.nifty.controls.TextField)

Example 3 with Element

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

the class ConnectionController method createXianLanItem.

private Element createXianLanItem(final String itemText, String colorParam, final int index) {
    Element parent = findById("xianlanColorsContent");
    Element ele = new CustomControlCreator(NiftyIdCreator.generate(), "wireAndPipeItem") {

        {
            set("label", itemText);
            setInteractOnClick("linkTransduscers(" + itemText + ")");
            if (index == 0) {
                ControlEffectAttributes ctrlEffectAttributes = new ControlEffectAttributes();
                ctrlEffectAttributes.setName("border");
                ctrlEffectAttributes.setAttribute("border", "0,0,0,1");
                ctrlEffectAttributes.setAttribute("color", "#333333");
                addEffectsOnShow(ctrlEffectAttributes);
            }
            ControlEffectOnHoverAttributes ctrlEffectAttributes = new ControlEffectOnHoverAttributes();
            ctrlEffectAttributes.setName("border");
            ctrlEffectAttributes.setAttribute("border", "2");
            ctrlEffectAttributes.setAttribute("color", "#009900");
            ctrlEffectAttributes.setAttribute("inset", "3");
            addEffectsOnHover(ctrlEffectAttributes);
            ControlEffectAttributes effect = new ControlEffectAttributes();
            effect.setName("border");
            effect.setAttribute("border", "2");
            effect.setAttribute("color", "#009900");
            effect.setAttribute("inset", "3");
            addEffectsOnActive(effect);
        }
    }.create(nifty, screen, parent);
    ImageRenderer imageRender = ele.findElementByName("#colorImage").getRenderer(ImageRenderer.class);
    InputStream resource = getClass().getClassLoader().getResourceAsStream("com/cas/circuit/ui/resorces/wire32.png");
    BufferedImage img = ImageUtil.getColorImage("0,0,1,1", colorParam, resource);
    Image image = load(img, true);
    Texture2D texture2D = new Texture2D(image);
    RenderImage createImage = new RenderImageJme(texture2D);
    imageRender.setImage(new NiftyImage(nifty.getRenderEngine(), createImage));
    return ele;
}
Also used : ImageRenderer(de.lessvoid.nifty.elements.render.ImageRenderer) Texture2D(com.jme3.texture.Texture2D) ControlEffectAttributes(de.lessvoid.nifty.controls.dynamic.attributes.ControlEffectAttributes) NiftyImage(de.lessvoid.nifty.render.NiftyImage) InputStream(java.io.InputStream) Element(de.lessvoid.nifty.elements.Element) ControlEffectOnHoverAttributes(de.lessvoid.nifty.controls.dynamic.attributes.ControlEffectOnHoverAttributes) RenderImage(de.lessvoid.nifty.spi.render.RenderImage) RenderImageJme(com.jme3.niftygui.RenderImageJme) Image(com.jme3.texture.Image) NiftyImage(de.lessvoid.nifty.render.NiftyImage) BufferedImage(java.awt.image.BufferedImage) RenderImage(de.lessvoid.nifty.spi.render.RenderImage) CustomControlCreator(de.lessvoid.nifty.controls.dynamic.CustomControlCreator) BufferedImage(java.awt.image.BufferedImage)

Example 4 with Element

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

the class ConnectionController method setContentVisible.

/**
 * 鼠标hover到气管或导线时,设置内容界面的显示或隐藏
 * @param ContentId
 * @param visbleStr
 */
public void setContentVisible(String ContentId, String visbleStr) {
    Element content = findById(ContentId);
    boolean visible = Boolean.parseBoolean(visbleStr);
    if (content == null || content.isVisible() == visible) {
        return;
    }
    content.setVisible(visible);
}
Also used : Element(de.lessvoid.nifty.elements.Element)

Example 5 with Element

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

the class ConnectionController method refreshxianlanColorsContent.

private void refreshxianlanColorsContent() {
    Element xianlanColorsContent = findById("xianlanColorsContent");
    int size = xianlanColorsContent.getElements().size();
    xianlanColorsContent.setConstraintWidth(SizeValue.px(size * 50));
    Element parent = xianlanColorsContent.getParent();
    parent.setConstraintWidth(SizeValue.px(size * 50));
    parent.getParent().layoutElements();
}
Also used : Element(de.lessvoid.nifty.elements.Element)

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