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);
}
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);
}
}
}
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;
}
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);
}
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();
}
Aggregations