Java 屏幕类使用示例
最编程
2024-07-09 21:20:05
...
实例1: onMouseMove
import tonegod.gui.core.Screen; //导入依赖的package包/类
@Override
public void onMouseMove(MouseMotionEvent evt) {
if (!Screen.isAndroid()) {
float x = evt.getX()-getX();
float y = scrollableArea.getAbsoluteHeight()-menuPadding.z-evt.getY();
if (currentMenuItemIndex != (int)Math.floor(y/menuItemHeight)) {
currentMenuItemIndex = (int)Math.floor(y/menuItemHeight);
if (currentMenuItemIndex > -1 && currentMenuItemIndex < menuItems.size()) {
setHighlight(currentMenuItemIndex);
this.hideAllSubmenus(false);
Menu subMenu = menuItems.get(currentMenuItemIndex).getSubMenu();
if (subMenu != null) {
subMenu.showMenu(this, getAbsoluteWidth()-this.menuOverhang, scrollableArea.getAbsoluteHeight()-(menuItemHeight+(currentMenuItemIndex*menuItemHeight))-(subMenu.getHeight()-menuItemHeight));
}
}
}
}
}
实例2: EmitterModule
import tonegod.gui.core.Screen; //导入依赖的package包/类
public EmitterModule(final SimpleApplication app) {
super(app.getAssetManager().loadTexture("org/hexgridapi/assets/Textures/"
+ "Icons/Buttons/hexIconBW.png").getImage(),
"Emitter Module", null, false);
this.app = app;
//@todo need to be cleanned
// app.getAssetManager().registerLocator("/home/roah/Documents/jmonkey/3.1/tonegodProjects/EmitterBuilder/assets", FileLocator.class);
screen = new Screen(app, "tonegod/gui/style/atlasdef/style_map.gui.xml");
screen.setUseTextureAtlas(true, "tonegod/gui/style/atlasdef/atlas.png");
// screen.setUseCustomCursors(true);
builder = new EmitterBuilder(app, screen);
chaseCam = new ChaseCamera(app.getCamera(), builder.getRootNode(), app.getInputManager());
app.enqueue(new Callable<Void>() {
@Override
public Void call() throws Exception {
if(app.getGuiNode().getControl(Screen.class) == null)
app.getGuiNode().addControl(screen);
return null;
}
});
}
实例3: initApp
import tonegod.gui.core.Screen; //导入依赖的package包/类
@Override
public void initApp() {
// initialise hexgrid
RTSCamera.KeyMapping keyMapping = RTSCamera.KeyMapping.col;
screen = new Screen(this);
getGuiNode().addControl(screen);
rtsCam = new RTSCamera(keyMapping);
MapData mapData = new MapData(assetManager, new String[]{"EARTH", "ICE", "NATURE", "VOLT"});
hexGridState = new HexGridAppState(mapData, rtsCam, "org/hexgridapi/assets/Textures/HexField/");
rootNode.attachChild(hexGridState.getGridNode());
MapParam param = new MapParam(SquareCoordinate.class, new Vector2Int(3, 4),
7, 1, false, false, 722093121, null);
hexGridState.setParam(param);
// EntityDataAppState entityDataAppState = new EntityDataAppState();
// stateManager.attachAll(rtsCam, hexGridState, entityDataAppState,
// new RenderSystem(), new HexPositionSystem(),
// new RenderDebugSystem(), new BattleSystemTest());
stateManager.attachAll(rtsCam, hexGridState,
new MultiverseCoreState(keyMapping, BattleSystemTest.class));
setDisplayFps(false);
setDisplayStatView(false);
}
实例4: StaminaGauge
import tonegod.gui.core.Screen; //导入依赖的package包/类
public StaminaGauge(Screen screen, String filePath, Vector2f position) {
gauge = new Indicator(screen, position, new Vector2f(300, 15),
new Vector4f(5, 50, 50, 5), filePath + "skill.png", Element.Orientation.HORIZONTAL) {
@Override
public void onChange(float currentValue, float currentPercentage) {
}
};
((Indicator)gauge).setIndicatorColor(ATBGauge.getColor("Blue"));
((Indicator)gauge).setAlphaMap(filePath + "skillAlpha.png");
((Indicator)gauge).setOverlayImage(filePath + "skillOverlay.png");
((Indicator)gauge).setBaseImage(filePath + "skill.png");
((Indicator)gauge).setMaxValue(100);
}
实例5: LayoutParser
import tonegod.gui.core.Screen; //导入依赖的package包/类
public LayoutParser(Screen screen) {
this.screen = screen;
controls.add(OSRViewPort.class);
controls.add(Indicator.class);
controls.add(Slider.class);
controls.add(Dial.class);
controls.add(CheckBox.class);
controls.add(RadioButton.class);
controls.add(Button.class);
controls.add(ChatBox.class);
controls.add(ChatBoxExt.class);
controls.add(Panel.class);
controls.add(ColorWheel.class);
controls.add(LoginBox.class);
controls.add(AlertBox.class);
controls.add(DialogBox.class);
controls.add(Window.class);
controls.add(TabControl.class);
controls.add(SelectBox.class);
controls.add(ComboBox.class);
controls.add(Menu.class);
controls.add(SelectList.class);
controls.add(ScrollArea.class);
controls.add(SlideTray.class);
controls.add(Spinner.class);
controls.add(Label.class);
controls.add(Password.class);
controls.add(TextField.class);
}
推荐阅读
-
Java】--集合框架:使用集合工具类
-
Java 8新特性探究(十三)JavaFX 8新特性以及开发2048游戏-JavaFX历史## 跟java在服务器端和web端成绩相比,桌面一直是java的软肋,于是Sun公司在2008年推出JavaFX,弥补桌面软件的缺陷,请看下图JavaFX一路走过来的改进 从上图看出,一开始推出时候,开发者需使用一种名为JavaFX Script的静态的、声明式的编程语言来开发JavaFX应用程序。因为JavaFX Script将会被编译为Java bytecode,程序员可以使用Java代码代替。 JavaFX 2.0之后的版本摒弃了JavaFX Script语言,而作为一个Java API来使用。因此使用JavaFX平台实现的应用程序将直接通过标准Java代码来实现。 JavaFX 2.0 包含非常丰富的 UI 控件、图形和多媒体特性用于简化可视化应用的开发,WebView可直接在应用中嵌入网页;另外 2.0 版本允许使用 FXML 进行 UI 定义,这是一个脚本化基于 XML 的标识语言。 从JDK 7u6开始,JavaFx就与JDK捆绑在一起了,JavaFX团队称,下一个版本将是8.0,目前所有的工作都已经围绕8.0库进行。这是因为JavaFX将捆绑在Java 8中,因此该团队决定跳过几个版本号,迎头赶上Java 8。 ##JavaFx8的新特性 ## ###全新现代主题:Modena 新的Modena主题来替换原来的Caspian主题。不过在Application的start方法中,可以通过setUserAgentStylesheet(STYLESHEET_CASPIAN)来继续使用Caspian主题。 参考http://fxexperience.com/2013/03/modena-theme-update/ ###JavaFX 3D 在JavaFX8中提供了3D图像处理API,包括Shape3D (Box, Cylinder, MeshView, Sphere子类),SubScene, Material, PickResult, LightBase (AmbientLight 和PointLight子类),SceneAntialiasing等。Camera类也得到了更新。从JavaDoc中可以找到更多信息。 ###富文本 强化了富文本的支持 ###TreeTableView ###日期控件DatePicker 增加日期控件 ###用于 CSS 结构的公共 API
-
如何在JSP页面中使用Java类:导入Java包的步骤
-
如何使用Java增加视频播放量和点赞数的代码示例
-
实战教程:Java StreamingOutput类的使用方法——实例1:process操作详解
-
使用Rational Rose进行Java反向工程:创建类图指南及问题排查详解
-
实操演示:Java BaseResponse类的第四个应用场景——onResponse方法示例
-
实操示例:在Java中运用ChannelMatcher类
-
实操示例:在Java中运用WebSocketClientProtocolHandler类
-
JAVA多线程ReentrantLock的lock, tryLock, tryLock(long timeout, TimeUnit unit) 及使用场景的简单示例