Tag: 方向

Mapbox Android:如何获取从当前位置到您选择的目的地的路线?

好吧所以我对Mapbox相当新,我之前使用过GMaps但是我发现Mapbox更能胜任我需要的东西,问题是我已经碰到了一点墙。 我已经使用了他们网站上提供的示例组合,例如 https://www.mapbox.com/android-sdk/examples/geocoding和https://www.mapbox.com/android-sdk/examples/directions 我试图允许用户搜索目的地,然后将其转换为将用于在地图中绘制的坐标。 然后,我想绘制从当前位置到目的地的路线,这是我的问题所在。 mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { map = mapboxMap; // Set the origin waypoint to the devices location Position origin = Position.fromCoordinates(mapboxMap.getMyLocation().getLongitude(), mapboxMap.getMyLocation().getLatitude()); // Set the destination waypoint to the location point long clicked by the user final Position destination = updateMap(feature.getLongitude(), feature.getLatitude()); mapboxMap.addMarker(new MarkerOptions() .position(new LatLng(origin.getLatitude(), […]

使用keyPressed检测键盘方向键

G’day全部, 在这里了解到Java控制台不支持键盘输入后,我切换到了Swing和AWT。 我现在的问题是如何检测键盘方向键(非数字小键盘)的使用时间。 按下向下,向上,向左,向右键时,我的代码(下面)不会打印“小方块”字符。 例如,这个小方框字符与CTRL和ALT键使用的字符没有什么不同。 有谁知道键盘方向键的实际身份是什么,以便我可以在我的应用程序中为它们编码? import java.awt.*; import java.awt.event.*; import javax.swing.*; public class KeyChecker extends JFrame { JLabel keyLabel = new JLabel(“Hit any key”); public KeyChecker() { super(“Hit a Key”); setSize(300, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.CENTER)); KeyMonitor monitor = new KeyMonitor(this); setFocusable(true); addKeyListener(monitor); add(keyLabel); setVisible(true); } public static void main(String[] arguments) { new KeyChecker(); } […]

切换到横向布局时,应用程序崩溃

我在应用程序中设置横向模式时遇到问题。 我有一个/ res文件夹,其中包含布局文件夹和layout-land文件夹 layout —–main.xml layout-land —–main.xml 我的/layout-land/main.xml包含与/layout/main.xml不同的UI元素。 当用户切换到横向模式时,如何正确映射每个布局,反之亦然? 当用户切换到横向模式时,我基本上显示全屏ImageView。 ImageView将从互联网上下载图像并显示它。 切换回肖像,应该回到我的肖像模式,它具有不同的UI组件集。 当我切换到横向模式时,我遇到了崩溃: 因为我无法获得身份certificate: chartImageViewLandscape = (ImageView) this.findViewById(R.id.chartImageViewLandscape); chartImageViewLandscape位于/layout-land/main.xml中 我怎样才能得到这个参考?

文本区域右侧的Java显示文本

我在ComponentOrientation.RIGHT_TO_LEFT的问题是’/’或’!’等字符 要么 ‘。’ 显示在左侧。 我只需要从右到左绘制文本,但使用标准,西方,英文从左到右的符号表示文本字符。 这可能无需手动渲染文本吗?

java printerjob景观白色空间

我目前在打印机工作时遇到问题,它适用于人像图像,但对于风景图像,它会切割部分图像并填充白色空间。 这是我的代码 编辑 PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); BufferedImage bufferedImage = ImageIO.read(new File(“house.jpg”)); boolean isLandscape = bufferedImage.getWidth() > bufferedImage.getHeight(); PrinterJob printerJob = PrinterJob.getPrinterJob(); printerJob.setPrintService(printService); printerJob.setCopies(copies); PageFormat pageFormat = printerJob.defaultPage(); pageFormat.setOrientation(isLandscape ? PageFormat.LANDSCAPE : PageFormat.PORTRAIT); Paper paper = new Paper(); paper.setSize(pageFormat.getWidth(), pageFormat.getHeight()); paper.setImageableArea(0.0, 0.0, paper.getWidth(), paper.getHeight()); pageFormat.setPaper(paper); printerJob.setPrintable(new Printable(){ @Override public int print(Graphics graphics, PageFormat pageFormat, int […]

使用键盘在java中以角度移动圆圈

所以我有一个应用程序可以成功地向左,向右,向上或向下移动一个球(椭圆),具体取决于按下键盘的哪个按钮。 但是,我无法让球以一定角度移动。 我试图这样说,如果用户握住2个方向键,球将对角线。 例如,如果他们单击左键和向上键,我希望球在NorthWest方向上移动。 如果你们中的任何人看到导致问题的原因,我真的很感激帮助! 发动机 class KeyClickListener implements KeyListener { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN ) { component.moveCircle(1); } else if (e.getKeyCode() == KeyEvent.VK_UP) { component.moveCircle(2); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { component.moveCircle(3); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { component.moveCircle(5); } //this is my attempt at telling whether […]

基于键盘输入让我的精灵面向某个方向 – Java Game

所以我通过跟随一堆不同的教程将java基本游戏放在一起 – 问题是我无法弄清楚如何让我的精灵向不同的方向移动。 这是我的主要代码 package com.game.src.main; import java.awt.Canvas; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import java.io.DataOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import javax.swing.JFrame; public class Game extends Canvas implements Runnable { private static final long serialVersionUID = 1L; public static final int WIDTH = 850; public static final int HEIGHT […]

在Java中检测并操作键盘方向键

G’day全部, 我有一个控制台项目,用户按下键盘方向键(非数字键盘)来移动头像。 我编码很难检查这些键的按键。 在Pascal中,使用“readkey”和代码很容易,例如,#80用于向下按键。 但是,我很难理解如何在Java中实现相同的function,尽管我认为我理解使用System.in和BufferedInputStream。 任何人都可以帮我吗? 非常感谢您的想法或提示。