• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java View类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.gluonhq.charm.glisten.mvc.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



View类属于com.gluonhq.charm.glisten.mvc包,在下文中一共展示了View类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: updateDrawer

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
private void updateDrawer(View view) {
    OTNView.registry.getView(view)
            .ifPresent(otnView -> {
                drawer.setSelectedItem(otnView.getMenuItem());
                otnView.selectMenuItem();
            });
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:8,代码来源:OTNDrawerPresenter.java


示例2: getView

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
/**
 * Gets a view from a viewPackage for the corresponding orientation and size
 * Loads the view and creates the view only if needed.
 *
 * @param viewType    The viewType which contains the view. The viewType has to return the class that is a VIEW _and_ a FXMLView
 * @param size        The size for the new view
 * @param orientation The orientation for the new view
 * @return The unique identifier of the new view
 */
@Nullable
private String getView(@NotNull IViewPackage viewType, OrientationHandler.Size size, OrientationHandler.Orientation orientation) {
    final Class<? extends IView> viewClass = viewType.getView(size, orientation);

    if (viewClass != null) {
        final String name = ViewNameGenerator.generateViewName(viewType.getID(), size, orientation);

        //disable intellij code inspection for optionals/suppliers etc
        //noinspection Since15
        gluon.addViewFactory(name, new Supplier<View>() {
            @Override
            public View get() {
                if (!addedViews.containsKey(name)) {
                    try {
                        Constructor<? extends IView> con = null;
                        for (Constructor c : viewClass.getConstructors()) {
                            if (c.getParameterTypes().length == 1 && c.getParameterTypes()[0].equals(String.class)) {
                                con = c;
                            }
                        }
                        Parent parent;
                        if (con == null) {
                            parent = viewClass.newInstance().getView();
                        } else {
                            parent = con.newInstance(name).getView();
                        }
                        if (!(parent instanceof View)) {
                            throw new YouDidShitException("You supplied an FXMLView but it also has to be a View or else Gluon can't handle it!");
                        }
                        View view = (View) parent;
                        if (con == null) {
                            view.setName(name);
                        }
                        addedViews.put(name, view);
                        return view;
                    } catch (InstantiationException | InvocationTargetException | IllegalAccessException | YouDidShitException e) {
                        Log.ex(ViewHandler.class.getSimpleName(), "could not instantiate the specified view class", e);
                    }
                }
                return addedViews.get(name);
            }
        });
        return name;
    } else {
        return null;
    }
}
 
开发者ID:Ciruman,项目名称:QuarkFX,代码行数:57,代码来源:ViewHandler.java


示例3: init

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
@Override
public final void init() {
    nativePlatform = NativePlatformFactory.getPlatform();
    Log.overrideDefaultLogger(nativePlatform.getLogger());

    final OrientationHandler orientationHandler = new OrientationHandler();
    final ViewHandler viewHandler = new ViewHandler(this);

    /*
     * Loading Screen
     */
    addViewFactory(HOME_VIEW, new Supplier<View>() {

                @Override
                public View get() {
                    View v = new View(HOME_VIEW);
                    final ImageView imageView = new ImageView(new Image(QuarkFXApplication.class.getResourceAsStream("/logo.jpg")));
                    imageView.setPreserveRatio(true);
                    imageView.setFitWidth(150);
                    v.setCenter(imageView);
                    v.setBottom(new Label("Loading ..."));
                    v.setOnShown(new EventHandler<LifecycleEvent>() {
                                   @Override
                                   public void handle(LifecycleEvent event) {
                                       QuarkFXApplication.this.getAppBar().setVisible(false);
                                       //TODO is this good?
                                       OrientationEventDispatcher.register(orientationHandler, QuarkFXApplication.this.getGlassPane());
                                       viewHandler.startUp(orientationHandler);
                                       QuarkFXApplication.this.triggerStartup();
                                       Log.d("### initial switch ###");

                                       final Timer timer = new Timer();
                                       timer.schedule(new TimerTask() {
                                           @Override
                                           public void run() {
                                               Platform.runLater(new Runnable() {
                                                   @Override
                                                   public void run() {
                                                       viewHandler.switchToHome(ViewStackPolicy.SKIP);
                                                   }
                                               });

                                               //explicitly end timer: when you don't there could be a running thread on application stop that blocks other threads
                                               timer.cancel();
                                               timer.purge();
                                           }
                                       }, 1500);

                                   }
                               }
                    );
                    return v;
                }
            }

    );
    initApp(viewHandler);
}
 
开发者ID:Ciruman,项目名称:QuarkFX,代码行数:59,代码来源:QuarkFXApplication.java


示例4: init

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
@Override
public void init() {
	try {
		MQTTConnector connection = new MQTTConnector("localhost", null, null, null);
		GamePresenter.setConnection(connection);
	} catch (MqttException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		System.out.println("pb de connexion");
		
	}
	
	//addViewFactory(PRIMARY_VIEW, () -> (View) new PrimaryView().getView());
	//this.addLayerFactory(PRIMARY_VIEW, (VBox) new GameView().); 
	Supplier<View> v1 = new Supplier<View>() {

		@Override
		public View get() {
			// TODO Auto-generated method stub
			return (View) new GameView().getView();
		}
	};
	Supplier<View> v2 = new Supplier<View>() {

		@Override
		public View get() {
			// TODO Auto-generated method stub
			return (View) new SecondaryView().getView();
		}
	};
	addViewFactory(PRIMARY_VIEW, v1);
	System.out.println("pb de connexion 1");
	
	addViewFactory(SECONDARY_VIEW, v2);
	System.out.println("pb de connexion 2");
	
	final NavigationDrawer drawer = new NavigationDrawer();

	NavigationDrawer.Header header = new NavigationDrawer.Header("MarrakAir",
			"Smart city Participative project",
			new Avatar(21, new Image(GluonApplication.class.getResourceAsStream("/icon.png"))));
	drawer.setHeader(header);
	System.out.println("pb de connexion 3");
	

	final Item primaryItem = new Item("Game", MaterialDesignIcon.HOME.graphic());
	final Item secondaryItem = new Item("Configuration", MaterialDesignIcon.DASHBOARD.graphic());
	drawer.getItems().addAll(primaryItem, secondaryItem);
	System.out.println("pb de connexion 4");
	
	ChangeListener<? super Node> nd1 = new ChangeListener<Node>() {

		@Override
		public void changed(ObservableValue<? extends Node> obs, Node oldItem, Node newItem) {
			hideLayer(MENU_LAYER);
			switchView(newItem.equals(primaryItem) ? PRIMARY_VIEW : SECONDARY_VIEW);

		}
	};
	drawer.selectedItemProperty().addListener(nd1);
	Supplier<Layer> v3 = new Supplier<Layer>() {

		@Override
		public Layer get() {
			// TODO Auto-generated method stub
			return  new SidePopupView(drawer);
		}
	};
	System.out.println("pb de connexion 5");
	
	addLayerFactory(MENU_LAYER, v3);
	System.out.println("pb de connexion 6");
	

}
 
开发者ID:gnoubi,项目名称:MarrakAir,代码行数:76,代码来源:GluonApplication.java


示例5: init

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
@Override
public void init() {
	try {
		MQTTConnector connection = new MQTTConnector("localhost", null, null, null);
		GamePresenter.setConnection(connection);
		System.out.println("connected !");
		
	} catch (MqttException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		System.out.println("pb de connexion");
		
	}
	
	Supplier<View> v1 = new Supplier<View>() {

		@Override
		public View get() {
			// TODO Auto-generated method stub
			return (View) new GameView().getView();
		}
	};
	Supplier<View> v2 = new Supplier<View>() {

		@Override
		public View get() {
			// TODO Auto-generated method stub
			return (View) new SecondaryView().getView();
		}
	};
	
	addViewFactory(PRIMARY_VIEW, v1);
	addViewFactory(SECONDARY_VIEW, v2);
	final NavigationDrawer drawer = new NavigationDrawer();

	NavigationDrawer.Header header = new NavigationDrawer.Header("MarrakAir",
			"Smart city Participative project",
			new Avatar(21, new Image(GluonApplication.class.getResourceAsStream("/icon.png"))));
	drawer.setHeader(header);
			final Item primaryItem = new Item("Game", MaterialDesignIcon.HOME.graphic());
	final Item secondaryItem = new Item("Configuration", MaterialDesignIcon.DASHBOARD.graphic());
	drawer.getItems().addAll(primaryItem, secondaryItem);
	
	ChangeListener<? super Node> nd1 = new ChangeListener<Node>() {

		@Override
		public void changed(ObservableValue<? extends Node> obs, Node oldItem, Node newItem) {
			hideLayer(MENU_LAYER);
			switchView(newItem.equals(primaryItem) ? PRIMARY_VIEW : SECONDARY_VIEW);

		}
	};
	drawer.selectedItemProperty().addListener(nd1);
	Supplier<Layer> v3 = new Supplier<Layer>() {

		@Override
		public Layer get() {
			// TODO Auto-generated method stub
			return  new SidePopupView(drawer);
		}
	};
	System.out.println("pb de connexion 5");
	
	addLayerFactory(MENU_LAYER, v3);
	System.out.println("pb de connexion 6");
	

}
 
开发者ID:gnoubi,项目名称:MarrakAir,代码行数:69,代码来源:GluonApplication.java


示例6: init

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
@Override
public void init() {
    addViewFactory(HOME_VIEW, () -> {
        HomeView homeView = new HomeView();
        homePresenter = (HomePresenter) homeView.getPresenter();
        return (View) homeView.getView();
    });
    addViewFactory(GAUGES_VIEW, () -> (View) new GaugesView().getView());
    addViewFactory(SETTINGS_VIEW, () -> (View) new SettingsView().getView());
    addViewFactory(CONTROL_VIEW, () -> {
        ControlView controlView = new ControlView();
        controlPresenter = (ControlPresenter) controlView.getPresenter();
        return (View) controlView.getView();
    });
    
    NavigationDrawer navigationDrawer = new NavigationDrawer();
    NavigationDrawer.Header header = new NavigationDrawer.Header("TRIP",
            "Test Robotics IoT Platform",
            new Avatar(21, new Image(getClass().getResourceAsStream("views/[email protected]"))));
    navigationDrawer.setHeader(header);

    navigationDrawer.selectedItemProperty().addListener(listener);
    
    navigationDrawer.getItems().setAll(
        new NavigationDrawer.Item(HOME_VIEW, MaterialDesignIcon.HOME.graphic()),
        new NavigationDrawer.Item(GAUGES_VIEW, MaterialDesignIcon.NETWORK_CHECK.graphic()),
        new NavigationDrawer.Item(CONTROL_VIEW, MaterialDesignIcon.DIRECTIONS.graphic()),
        new NavigationDrawer.Item(SETTINGS_VIEW, MaterialDesignIcon.SETTINGS.graphic()));
    
    addLayerFactory(MENU_LAYER, () -> new SidePopupView(navigationDrawer));
    viewProperty().addListener((obs, ov, nv) -> {
        for (Node node : navigationDrawer.getItems()) {
            NavigationDrawer.Item item = (NavigationDrawer.Item) node;
            if (item.getTitle().equals(nv.getName())) {
                navigationDrawer.selectedItemProperty().removeListener(listener);
                navigationDrawer.setSelectedItem(node);
                item.setSelected(true);
                navigationDrawer.selectedItemProperty().addListener(listener);
            } else {
                item.setSelected(false);
            }
        }
    });
    
}
 
开发者ID:TRIPJavaFXClientBraintrust,项目名称:TRIPfx,代码行数:46,代码来源:TRIPMobile.java


示例7: init

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
@Override
public void init() {

    View view = new DoodleTrace(DOODLE_TRACE_VIEW);
    addViewFactory(DOODLE_TRACE_VIEW, () -> view);
}
 
开发者ID:gluonhq,项目名称:gluon-samples,代码行数:7,代码来源:GluonApplication.java


示例8: addViewFactory

import com.gluonhq.charm.glisten.mvc.View; //导入依赖的package包/类
void addViewFactory(String name, Supplier<View> supplier); 
开发者ID:Ciruman,项目名称:QuarkFX,代码行数:2,代码来源:IGluon.java



注:本文中的com.gluonhq.charm.glisten.mvc.View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TomcatBaseTest类代码示例发布时间:2022-05-22
下一篇:
Java FlakyTest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap