我正在Google地图上绘制折线列表.我正在寻找一种解决方案,以适应地图的缩放,具体取决于绘制的折线.我已经计算了所有折线的中心点,所以我知道哪个点使地图居中.但我找不到任何解决方案来获得缩放级别.
这里是我使用的代码:
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(getZoomPoint(), 15));
private LatLng getZoomPoint() {
Double minLatitude = null;
Double minLongitude = null;
Double maxLatitude = null;
Double maxLongitude = null;
for (Feature feature : features) {
List<Coordinates> coordinates = ((LineString) feature.getGeometry()).getCoordinates();
for (Coordinates coordinate : coordinates) {
// --------------------------------------------------------- INITIALISATION
if (minLatitude == null) { // No matter on wich var we check
minLatitude = coordinate.getLatitude();
minLongitude = coordinate.getLongitude();
maxLatitude = coordinate.getLatitude();
maxLongitude = coordinate.getLongitude();
} else {
if (coordinate.getLatitude() < minLatitude) {
minLatitude = coordinate.getLatitude(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Swagger 2.0定义API.在我的模型中,我有一些具有可选属性的对象,所以我试图插入Swagger标签"required:false".
当我插入"required"标签时,我在编辑器中收到错误,我无法理解为什么..
我的Swagger定义是:
definitions:
Error:
type: object
properties:
code:
type: integer
message:
type: string
fields:
type: string
Run Code Online (Sandbox Code Playgroud)
这非常有效.现在我想指定'message'参数(例如)是可选的.所以我尝试以下方法:
definitions:
Error:
type: object
properties:
code:
type: integer
message:
type: string
required: false
fields:
type: string
Run Code Online (Sandbox Code Playgroud)
现在我在Swagger编辑器中出错:
Swagger Error
Expected type array but found type boolean
Run Code Online (Sandbox Code Playgroud)
错误详情如下:
Details
Object
code: "INVALID_TYPE"
message: "Expected type array but found type boolean"
path: Array [5]
0: "definitions"
1: "Error"
2: "properties"
3: "message"
4: "required"
level: 900
type: "Swagger Error"
description: "Expected type array …Run Code Online (Sandbox Code Playgroud) 我试图使用MOXy作为我的JAXB提供程序,以便将内容编组/解组成XML/JSON.
我用内容创建了"jaxb.properties"文件: javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactor
一切正常.
JAXBContext jaxbContext = JAXBContext.newInstance(ServerInformation.class); // The jaxb.properties must be in the same package as "ServerInformation.java"
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, false);
Run Code Online (Sandbox Code Playgroud)
我的问题是:有没有解决方案将此文件放在另一个包中?我正在使用Maven插件"wadl2java"来生成一些包和类,并且在每次Maven构建之后,所有包都被删除并重新创建.所以我每次都丢失这个文件...我想在我的ressource包中没有"jaxb.properties"的情况下将MOXy设置为我的JAXB提供程序.我在同一个项目中有一些其他软件包,我可以把这个文件放进去.
任何的想法 ?
谢谢.
我正在使用Java开发一个小游戏.我的应用程序有一个主JFrame,可以通过单击JButton创建另一个Window(游戏窗口).我已经单独测试了我的游戏窗口,一切都很好.
这是我的游戏窗口构造函数:
public GameWindow(final GameController controller)
{
super("Boulder Dash Game");
this.controller = controller;
this.controller.registerObserver(getCurrentFrame());
this.gamePanel = new GamePanel(controller);
this.frameWidth = controller.getColumns() * 16;
this.frameHeight = controller.getRows() * 16 + 76;
getContentPane().add(gamePanel, BorderLayout.CENTER);
setSize(frameWidth, frameHeight);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
controller.startGame();
}
Run Code Online (Sandbox Code Playgroud)
controller.startGame()方法启动游戏循环.当我直接从我的主要开始这个窗口时,游戏循环工作正常.
现在,我想从我的主框架启动这个GameWindow框架.这是我的主框架中的代码:
playButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final @Nullable ActionEvent e)
{
String selectedItem = (String) levelsComboBox.getSelectedItem();
assert selectedItem != null;
controller.lauchGame(selectedItem);
}
});
Run Code Online (Sandbox Code Playgroud)
controller.launchGame(String selectedItem)是一种用于加载游戏关卡并启动游戏窗口的方法.这是代码
public void lauchGame(final String levelQueried)
{
assert levelQueried != null;
Level level = LevelRepository.load(levelQueried); …Run Code Online (Sandbox Code Playgroud) java ×3
android ×1
google-maps ×1
jaxb ×1
json ×1
marshalling ×1
moxy ×1
swagger ×1
swagger-2.0 ×1
swing ×1