Przeglądaj źródła

3.1.0-归档管理原图获取方式变更,没有轨迹也可以下载原图bug

xiaof 2 lat temu
rodzic
commit
7a6fc2ff67

+ 11 - 8
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/ImageTrajectoryUtil.java

@@ -46,15 +46,18 @@ public class ImageTrajectoryUtil {
             Graphics2D g = image.createGraphics();// 得到图形上下文
             g.setColor(Color.red); // 设置画笔颜色
             // 设置字体
-            g.setFont(new Font(FONT_FORMAT, Font.LAYOUT_LEFT_TO_RIGHT, FONT_SIZE));// 写入签名
-            for (int i = 0; i < jsonArray.size(); i++) {
-                JSONObject jsonObject = jsonArray.getJSONObject(i);
-                JSONArray contentJsonArray = (JSONArray) jsonObject.get("content");
-                StringJoiner stringJoiner = new StringJoiner(",");
-                for (int k = 0; k < contentJsonArray.size(); k++) {
-                    stringJoiner.add(contentJsonArray.get(k).toString());
+            g.setFont(new Font(FONT_FORMAT, Font.LAYOUT_LEFT_TO_RIGHT, FONT_SIZE));
+            // 写入签名
+            if(jsonArray != null && !jsonArray.isEmpty()) {
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    JSONObject jsonObject = jsonArray.getJSONObject(i);
+                    JSONArray contentJsonArray = (JSONArray) jsonObject.get("content");
+                    StringJoiner stringJoiner = new StringJoiner(",");
+                    for (int k = 0; k < contentJsonArray.size(); k++) {
+                        stringJoiner.add(contentJsonArray.get(k).toString());
+                    }
+                    g.drawString(stringJoiner.toString(), (Integer) jsonObject.get("left"), (Integer) jsonObject.get("top"));
                 }
-                g.drawString(stringJoiner.toString(), (Integer) jsonObject.get("left"), (Integer) jsonObject.get("top"));
             }
             g.dispose();