【软件工程】把Jackson图转换为流程图例题+画状态描述图

       如果对Jackson图概念有什么疑问,可以看一下我另外一篇博客(*/ω\*) 

       https://blog.csdn.net/d52370/article/details/102844494 【软件工程】Jackson图概念+优点缺点+改进的Jackson图+实例

       如果我下面画的图您觉得有不对的地方请提出来呀,提前感谢。


一、把如下统计空格程序的Jackson图改画为等价的程序流程图和盒图

 

1.转换为流程图

2.转换为盒图

二、用Jackson图描述下述的一列火车的构成

        一列火车最多有两个火车头。只有一个火车头时则位于列车最前面,若还有第二个火车头时,则第二个火车头位于列车的最后面。火车头既可以是内燃机车也可以是电气机车。车厢分为硬座车厢、硬卧车厢和软卧车厢等3种。硬座车厢在所有车厢的前面部分,软卧车厢在所有车厢的后面部分。此外,在硬卧车厢和软卧车厢之间还有一节餐车。

三、画出状态转换图

     假定图形用户界面(GUI)可以处于以下3种状态之一:

     Initializing(初始化)、Working(工作)、Shuting Down(关闭)。当Turn PC on(打开PC)电源的时候,GUI的状态转移到Initializing状态并Bootup(自启动)。当Initializing状态中活动完成后,GUI将转移到Working状态。当你对PC选择Shut Down(关闭机器)时,GUI将转移到Shuting Down状态,最后PC自己切断电源,整个过程结束。请画出GUI的状态转换图(包括触发事件、动作和无触发事件)。

 

  • 25
    点赞
  • 123
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
以下是使用Java将GeoJSON转换片的详细代码: ```java import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.util.List; import javax.imageio.ImageIO; import org.geojson.Feature; import org.geojson.FeatureCollection; import org.geojson.GeoJsonObject; import org.geojson.LngLatAlt; import org.geojson.Point; import org.geojson.Polygon; import org.geojson.jackson.JsonParser; import org.geojson.jackson.ObjectMapper; public class GeoJsonToImage { public static void main(String[] args) throws Exception { // 读取GeoJSON文件 FileInputStream fis = new FileInputStream(new File("input.geojson")); ObjectMapper mapper = new ObjectMapper(); JsonParser parser = new JsonParser(mapper); FeatureCollection featureCollection = parser.parseFeatureCollection(fis); // 计算GeoJSON数据的范围 double minX = Double.POSITIVE_INFINITY; double minY = Double.POSITIVE_INFINITY; double maxX = Double.NEGATIVE_INFINITY; double maxY = Double.NEGATIVE_INFINITY; for (Feature feature : featureCollection.getFeatures()) { GeoJsonObject geometry = feature.getGeometry(); if (geometry instanceof Point) { LngLatAlt coordinates = ((Point) geometry).getCoordinates(); minX = Math.min(minX, coordinates.getLongitude()); minY = Math.min(minY, coordinates.getLatitude()); maxX = Math.max(maxX, coordinates.getLongitude()); maxY = Math.max(maxY, coordinates.getLatitude()); } else if (geometry instanceof Polygon) { List<List<LngLatAlt>> coordinates = ((Polygon) geometry).getCoordinates(); for (List<LngLatAlt> ring : coordinates) { for (LngLatAlt point : ring) { minX = Math.min(minX, point.getLongitude()); minY = Math.min(minY, point.getLatitude()); maxX = Math.max(maxX, point.getLongitude()); maxY = Math.max(maxY, point.getLatitude()); } } } } // 计算片的大小和比例 int width = 800; int height = (int) (800 * (maxY - minY) / (maxX - minX)); double xRatio = width / (maxX - minX); double yRatio = height / (maxY - minY); // 创建片 BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); g2d.setBackground(Color.WHITE); g2d.clearRect(0, 0, width, height); // 绘制GeoJSON数据 for (Feature feature : featureCollection.getFeatures()) { GeoJsonObject geometry = feature.getGeometry(); if (geometry instanceof Point) { LngLatAlt coordinates = ((Point) geometry).getCoordinates(); int x = (int) ((coordinates.getLongitude() - minX) * xRatio); int y = (int) ((maxY - coordinates.getLatitude()) * yRatio); g2d.setColor(Color.RED); g2d.fillRect(x - 5, y - 5, 10, 10); } else if (geometry instanceof Polygon) { List<List<LngLatAlt>> coordinates = ((Polygon) geometry).getCoordinates(); for (List<LngLatAlt> ring : coordinates) { int[] xPoints = new int[ring.size()]; int[] yPoints = new int[ring.size()]; for (int i = 0; i < ring.size(); i++) { LngLatAlt point = ring.get(i); int x = (int) ((point.getLongitude() - minX) * xRatio); int y = (int) ((maxY - point.getLatitude()) * yRatio); xPoints[i] = x; yPoints[i] = y; } g2d.setColor(Color.GREEN); g2d.fillPolygon(xPoints, yPoints, ring.size()); } } } // 保存片 ImageIO.write(image, "png", new File("output.png")); // 关闭流 fis.close(); } } ``` 这个程序使用 `org.geojson` 包解析 GeoJSON 数据,绘制点和多边形,并保存为 PNG 片。你可以替换 `org.geojson` 包为其它 GeoJSON 解析库,以适应你的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值