本文整理汇总了Java中de.lessvoid.nifty.screen.ScreenController类的典型用法代码示例。如果您正苦于以下问题:Java ScreenController类的具体用法?Java ScreenController怎么用?Java ScreenController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScreenController类属于de.lessvoid.nifty.screen包,在下文中一共展示了ScreenController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Override
public Screen apply(String screenName) {
ScreenDefinition screenDefinition = screenDefinitions.get(screenName);
ScreenGenerator interfaceConstructor
= null;
try {
interfaceConstructor = instanceResolutor.resolveScreenGenerator(screenDefinition.getInterfaceConstructor());
ScreenController controller
= instanceResolutor.resolveScreenControler(screenDefinition.getController());
Screen screen = new Screen(interfaceConstructor, controller, flow, screenName);
return screen;
} catch (InstanceResolutionException e) {
e.printStackTrace();
}
throw new RuntimeException();
}
示例2: shouldCreateRootFlow
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldCreateRootFlow() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenDefinition sc3 = new ScreenDefinition("screen3", "controllerClass", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addScreenDefinition(sc3);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2"));
assertEquals(tested.nextScreen(), "root:screen1");
tested.setNextScreenHint(ScreenFlowManager.NEXT);
assertEquals(tested.nextScreen(), "root:screen2");
tested.setNextScreenHint(ScreenFlowManager.PREV);
assertEquals(tested.nextScreen(), "root:screen1");
}
示例3: shouldNotMoveWithoutHints
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldNotMoveWithoutHints() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenDefinition sc3 = new ScreenDefinition("screen3", "controllerClass", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addScreenDefinition(sc3);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2", "screen3"));
assertEquals(tested.nextScreen(), "root:screen1");
tested.setNextScreenHint(ScreenFlowManager.NEXT);
assertEquals(tested.nextScreen(), "root:screen2");
//If next screen is invoked, without hints, we expect the same screen.
assertEquals(tested.nextScreen(), "root:screen2");
}
示例4: shouldNotMoveWithWrongHints
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldNotMoveWithWrongHints() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenDefinition sc3 = new ScreenDefinition("screen3", "controllerClass", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addScreenDefinition(sc3);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2", "screen3"));
assertEquals(tested.nextScreen(), "root:screen1");
tested.setNextScreenHint(ScreenFlowManager.PREV);
assertEquals(tested.nextScreen(), "root:screen1");
}
示例5: shouldSkipForwards
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldSkipForwards() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenDefinition sc3 = new ScreenDefinition("screen3", "controllerClass", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addScreenDefinition(sc3);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2", "screen3"));
assertEquals(tested.nextScreen(), "root:screen1");
tested.setNextScreenHint(ScreenFlowManager.NEXT);
assertEquals(tested.nextScreen(), "root:screen2");
tested.setNextScreenHint(ScreenFlowManager.SKIP);
assertEquals(tested.nextScreen(), "root:screen3");
}
示例6: shouldReturnChildren
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldReturnChildren() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2"));
tested.addFlowDefinition("child1", of("root:screen2"), newArrayList("screen1", "screen2"));
tested.setNextScreenHint(ScreenFlowManager.NEXT);
assertEquals(tested.nextScreen(), "root:screen2");
Collection<String> children = tested.getChildren();
assertFalse(children.isEmpty());
}
示例7: shouldSkipBackwards
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Test
public void shouldSkipBackwards() throws Exception {
ScreenDefinition sc1 = new ScreenDefinition("screen1", "controllerClass", "interfaceConstructor");
ScreenDefinition sc2 = new ScreenDefinition("screen2", "controllerClass2", "interfaceConstructor2");
ScreenDefinition sc3 = new ScreenDefinition("screen3", "controllerClass", "interfaceConstructor2");
ScreenGenerator interfaceConstructor = mock(ScreenGenerator.class);
ScreenGenerator interfaceConstructor2 = mock(ScreenGenerator.class);
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor")).thenReturn(interfaceConstructor);
when(instanceResolutor.resolveScreenControler("controllerClass")).thenReturn(mock(ScreenController.class));
when(instanceResolutor.resolveScreenGenerator("interfaceConstructor2")).thenReturn(interfaceConstructor2);
when(instanceResolutor.resolveScreenControler("controllerClass2")).thenReturn(mock(ScreenController.class));
tested.addScreenDefinition(sc1);
tested.addScreenDefinition(sc2);
tested.addScreenDefinition(sc3);
tested.addFlowDefinition("root", Optional.<String>absent(), newArrayList("screen1", "screen2", "screen3"));
assertEquals(tested.nextScreen(), "root:screen1");
tested.setNextScreenHint(ScreenFlowManager.NEXT);
assertEquals(tested.nextScreen(), "root:screen2");
tested.setNextScreenHint(ScreenFlowManager.SKIP);
assertEquals(tested.nextScreen(), "root:screen3");
tested.setNextScreenHint(ScreenFlowManager.PREV);
assertEquals(tested.nextScreen(), "root:screen2");
tested.setNextScreenHint(ScreenFlowManager.SKIP);
assertEquals(tested.nextScreen(), "root:screen1");
}
示例8: loadXml
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
public void loadXml(String filename, String startScreen, ScreenController... controllers) {
Log.info("[NIFTY] Loading '" + filename + "'");
nifty.fromXml(filename, Loader.getResourceAsStream("assets/gui/" + filename), startScreen, controllers);
}
示例9: createDesktop
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
ScreenBuilder createDesktop(final String title, final String message) {
final ScreenController controller = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(controller);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
width("400");
height("125");
control(new LabelBuilder("title", title) {
{
x("0");
y("0");
width("400");
height("30");
}
});
control(new TextFieldBuilder("message") {
{
x("0");
y("45");
width("100%");
height("30");
text(message);
}
});
}
});
}
});
}
};
}
示例10: createMobile
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
ScreenBuilder createMobile(final String title, final String message) {
final ScreenController controller = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(controller);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
width("90%");
height("300");
control(new LabelBuilder("title", title) {
{
x("0");
y("0");
width("100%");
height("60");
}
});
control(new TextFieldBuilder("message") {
{
x("0");
y("150");
width("100%");
height("60");
text(message);
}
});
}
});
}
});
}
};
}
示例11: createAndroid
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
private ScreenBuilder createAndroid(final String message) {
final ScreenController This = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(This);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
//x("100px");
//y("100px");
width("750px");
height("175px");
control(new LabelBuilder("title", message) {
{
x("0");
y("0");
width("600px");
height("60px");
}
});
control(new TextFieldBuilder("textField") {
{
maxLength(20);
x("10");
y("75");
width("450px");
height("60px");
}
});
control(new ButtonBuilder("enter", "Enter") {
{
x("500");
y("75");
height("60px");
width("200px");
interactOnClick("enter()");
}
});
}
});
}
});
}
};
}
示例12: createDesktop
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
private ScreenBuilder createDesktop(final String message) {
final ScreenController This = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(This);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
//x("100px");
// y("100px");
width("350px");
height("100px");
control(new LabelBuilder("title", message) {
{
x("0");
y("0");
width("350px");
height("40px");
}
});
control(new TextFieldBuilder("textField") {
{
maxLength(20);
x("10");
y("45");
width("200px");
height("25px");
}
});
control(new ButtonBuilder("enter", "Enter") {
{
x("225");
y("45");
height("25px");
interactOnClick("enter()");
}
});
}
});
}
});
}
};
}
示例13: bind
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
@Override
public void bind(Nifty nifty, Screen screen) {
this.nifty = nifty;
final ScreenController This = this;
Screen dialog = new ScreenBuilder(SCREEN_ID) {
{
controller(This);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
control(new ListBoxBuilder("moleculeList") {
{
childLayoutVertical();
set("horizontal", "false");
displayItems(10);
selectionModeSingle();
optionalVerticalScrollbar();
optionalHorizontalScrollbar();
width("85%");
height("85%");
x("8%");
y("10%");
}
});
}
});
}
}.build(nifty);
//Element e = dialog.findElementByName("foreground");
/*CreateListBoxControl clistBox = new CreateListBoxControl("listBoxDynamic");
clistBox.set("horizontal", "false");
clistBox.setWidth("85%");
clistBox.setHeight("85%");
//clistBox.setY("10%");
//clistBox.setX("8%");
clistBox.setChildLayout("vertical");
clistBox.set("displayItems", "10");
clistBox.set("vertical", "optional");
clistBox.set("horizontal", "optional");
listBox = clistBox.create(nifty, dialog, e);
File dir = Constants.getMoleculeLocation();
File[] fs = dir.listFiles();
if (fs == null) {
fs = new File[0];
}
for (File f : fs) {
String name = FileTools.getFileName(f);
listBox.addItem(name);
}*/
ListBox box = dialog.findNiftyControl("moleculeList", ListBox.class);
// add items; box.addItem
File dir = Constants.getMoleculeLocation();
String[] fs = FileTools.listSubFiles(dir);
for (String subF : fs) {
box.addItem(subF);
}
nifty.addScreen(SCREEN_ID, dialog);
nifty.gotoScreen(SCREEN_ID);
}
示例14: Generator2
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
public Generator2(Nifty nifty, ScreenController screenController) {
this.nifty = nifty;
this.screenController = screenController;
}
示例15: addController
import de.lessvoid.nifty.screen.ScreenController; //导入依赖的package包/类
public void addController(String name, ScreenController sc) {
controllers.put(name, sc);
}