• JavaFx五子棋


    效果图:

    框架:SpringBoot+JavaFx

    GobangFxmlView.java

    1 import de.felixroske.jfxsupport.AbstractFxmlView;
    2 import de.felixroske.jfxsupport.FXMLView;
    3 
    4 @FXMLView(value = "/fxml/Gobang.fxml", title = "Gobang", bundle = "i18n.index", encoding = "utf-8")
    5 public class GobangFxmlView extends AbstractFxmlView {
    6 }

    Gobang.fxml

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 
     3 <?import javafx.geometry.*?>
     4 <?import javafx.scene.control.*?>
     5 <?import javafx.scene.shape.*?>
     6 <?import java.lang.*?>
     7 <?import javafx.scene.layout.*?>
     8 <?import javafx.scene.canvas.Canvas?>
     9 
    10 <BorderPane maxHeight="-Infinity" maxWidth="-Infinity"
    11             minHeight="-Infinity" minWidth="-Infinity"
    12             prefHeight="800.0" prefWidth="842.0"
    13             xmlns="http://javafx.com/javafx/8"
    14             xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.maxinhai.world.controller.GobangController">
    15    <center>
    16       <Pane fx:id="pane" prefHeight="800.0" prefWidth="800.0" BorderPane.alignment="CENTER">
    17          <children>
    18             <Canvas fx:id="canvas" height="800.0" width="800.0" />
    19          </children>
    20       </Pane>
    21    </center>
    22    <top>
    23       <HBox prefHeight="42.0" prefWidth="800.0" BorderPane.alignment="CENTER">
    24          <children>
    25             <Button mnemonicParsing="false" text="首页" onAction="#toIndex">
    26                <HBox.margin>
    27                   <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
    28                </HBox.margin>
    29             </Button>
    30             <Button mnemonicParsing="false" text="开始" onAction="#reset">
    31                <HBox.margin>
    32                   <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
    33                </HBox.margin>
    34             </Button>
    35             <Button mnemonicParsing="false" text="再来一局" onAction="#reset">
    36                <HBox.margin>
    37                   <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
    38                </HBox.margin>
    39             </Button>
    40             <Button mnemonicParsing="false" text="保存图片" onAction="#saveImage">
    41                <HBox.margin>
    42                   <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
    43                </HBox.margin>
    44             </Button>
    45          </children>
    46       </HBox>
    47    </top>
    48 </BorderPane>

    GobangController.java

       1 import com.maxinhai.world.component.MsgAlert;
       2 import de.felixroske.jfxsupport.FXMLController;
       3 import javafx.embed.swing.SwingFXUtils;
       4 import javafx.event.EventHandler;
       5 import javafx.fxml.FXML;
       6 import javafx.fxml.Initializable;
       7 import javafx.scene.SnapshotParameters;
       8 import javafx.scene.canvas.Canvas;
       9 import javafx.scene.canvas.GraphicsContext;
      10 import javafx.scene.image.Image;
      11 import javafx.scene.image.WritableImage;
      12 import javafx.scene.input.MouseEvent;
      13 import javafx.scene.layout.Pane;
      14 import javafx.scene.paint.Color;
      15 import org.slf4j.Logger;
      16 import org.slf4j.LoggerFactory;
      17 
      18 import javax.imageio.ImageIO;
      19 import java.io.File;
      20 import java.io.IOException;
      21 import java.math.BigDecimal;
      22 import java.net.URL;
      23 import java.util.*;
      24 import java.util.stream.Collectors;
      25 
      26 /**
      27  * 五子棋Game控制器
      28  */
      29 @SuppressWarnings("all")
      30 @FXMLController
      31 public class GobangController extends BaseController implements Initializable {
      32 
      33     private static final Logger logger = LoggerFactory.getLogger(GobangController.class);
      34 
      35     @FXML
      36     private Pane pane;
      37     @FXML
      38     private Canvas canvas;
      39 
      40     private GraphicsContext graphicsContext2D = null;
      41     private double align = 53.33;
      42     private String flag = "A";
      43     private boolean isFinish = false;
      44     private String result = "";
      45 
      46     private static List<Map<String, Double>> indexList = new ArrayList<>(14*14);
      47     private static List<Map<String, Double>> useIndexList = new ArrayList<>(10);
      48 
      49     @Override
      50     public void initialize(URL location, ResourceBundle resources) {
      51         draw();
      52 
      53         // 点击事件
      54         canvas.setOnMouseClicked(new EventHandler<MouseEvent>() {
      55             @Override
      56             public void handle(MouseEvent event) {
      57 
      58                 if(isFinish) {
      59                     pane.setDisable(true);
      60                     MsgAlert.alert(result);
      61                 } else {
      62                     double x = event.getX();
      63                     double y = event.getY();
      64                     logger.info("坐标: [{},{}]", x, y);
      65                     indexList.forEach(index -> {
      66                         double startX = index.get("startX").doubleValue();
      67                         double endX = index.get("endX").doubleValue();
      68                         double startY = index.get("startY").doubleValue();
      69                         double endY = index.get("endY").doubleValue();
      70                         // 判断是否在落子范围内
      71                         if(x > startX && x < endX && y > startY && y < endY) {
      72 
      73                             // 计算胜负
      74                             computeResult(startX, endX, startY, endY);
      75 
      76                             Map<String, Double> useIndex = new HashMap<>();
      77                             useIndex.put("startX", startX);
      78                             useIndex.put("endX", endX);
      79                             useIndex.put("startY", startY);
      80                             useIndex.put("endY", endY);
      81                             // 判断是否落子
      82                             if(isContains(useIndexList, useIndex)) {
      83                                 logger.info("已落子!");
      84                             } else {
      85                                 // 黑白子切换
      86                                 if("A".equals(flag)) {
      87                                     graphicsContext2D.setFill(Color.BLACK);
      88                                     graphicsContext2D.strokeOval(startX, startY, 40, 40);
      89                                     graphicsContext2D.fillOval(startX, startY, 40, 40);
      90                                     useIndex.put("author", 1.0);
      91                                     flag = "B";
      92                                 } else {
      93                                     graphicsContext2D.setFill(Color.WHITE);
      94                                     graphicsContext2D.strokeOval(startX, startY, 40, 40);
      95                                     graphicsContext2D.fillOval(startX, startY, 40, 40);
      96                                     useIndex.put("author", 2.0);
      97                                     flag = "A";
      98                                 }
      99                                 useIndexList.add(useIndex);
     100                             }
     101 
     102                             // 计算胜负
     103                             computeResult(startX, endX, startY, endY);
     104 
     105                         } else {
     106                             //logger.info("不在棋盘范围内!");
     107                         }
     108 
     109                     });
     110                 }
     111             }
     112         });
     113     }
     114 
     115     private void computeResult(double startX, double endX, double startY, double endY) {
     116         List<Map<String, Double>> aIndexList = useIndexList.stream().filter(index -> 1.0 == index.get("author").doubleValue()).collect(Collectors.toList());
     117         List<Map<String, Double>> bIndexList = useIndexList.stream().filter(index -> 2.0 == index.get("author").doubleValue()).collect(Collectors.toList());
     118         logger.info("A落子数据:{}", aIndexList);
     119         logger.info("B落子数据:{}", bIndexList);
     120         computeResultX(aIndexList, startX, endX, startY, endY);
     121         computeResultX(bIndexList, startX, endX, startY, endY);
     122         computeResultY(aIndexList, startX, endX, startY, endY);
     123         computeResultY(bIndexList, startX, endX, startY, endY);
     124         computeResultXY(aIndexList, startX, endX, startY, endY);
     125         computeResultXY(bIndexList, startX, endX, startY, endY);
     126     }
     127 
     128     /**
     129      * 计算成功结果(横向计算)
     130      * @param indexList
     131      * @param startX
     132      * @param endX
     133      * @param startY
     134      * @param endY
     135      */
     136     private void computeResultX(List<Map<String, Double>> indexList, double startX, double endX, double startY, double endY) {
     137         // 结果1
     138         List<Map<String, Double>> resultMap1 = new ArrayList<>(5);
     139         Map<String, Double> result1 = new HashMap<>();
     140         result1.put("startX", startX);
     141         result1.put("endX", endX);
     142         result1.put("startY", startY);
     143         result1.put("endY", endY);
     144         resultMap1.add(result1);
     145 
     146         Map<String, Double> result2 = new HashMap<>();
     147         result2.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     148         result2.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     149         result2.put("startY", startY);
     150         result2.put("endY", endY);
     151         resultMap1.add(result2);
     152 
     153         Map<String, Double> result3 = new HashMap<>();
     154         result3.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     155         result3.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     156         result3.put("startY", startY);
     157         result3.put("endY", endY);
     158         resultMap1.add(result3);
     159 
     160         Map<String, Double> result4 = new HashMap<>();
     161         result4.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     162         result4.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     163         result4.put("startY", startY);
     164         result4.put("endY", endY);
     165         resultMap1.add(result4);
     166 
     167         Map<String, Double> result5 = new HashMap<>();
     168         result5.put("startX", new BigDecimal(startX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     169         result5.put("endX", new BigDecimal(endX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     170         result5.put("startY", startY);
     171         result5.put("endY", endY);
     172         resultMap1.add(result5);
     173 
     174         // 结果2
     175         List<Map<String, Double>> resultMap2 = new ArrayList<>(5);
     176         Map<String, Double> result2_1 = new HashMap<>();
     177         result2_1.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     178         result2_1.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     179         result2_1.put("startY", startY);
     180         result2_1.put("endY", endY);
     181         resultMap2.add(result2_1);
     182 
     183         Map<String, Double> result2_2 = new HashMap<>();
     184         result2_2.put("startX", startX);
     185         result2_2.put("endX", endX);
     186         result2_2.put("startY", startY);
     187         result2_2.put("endY", endY);
     188         resultMap2.add(result2_2);
     189 
     190         Map<String, Double> result2_3 = new HashMap<>();
     191         result2_3.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     192         result2_3.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     193         result2_3.put("startY", startY);
     194         result2_3.put("endY", endY);
     195         resultMap2.add(result2_3);
     196 
     197         Map<String, Double> result2_4 = new HashMap<>();
     198         result2_4.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     199         result2_4.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     200         result2_4.put("startY", startY);
     201         result2_4.put("endY", endY);
     202         resultMap2.add(result2_4);
     203 
     204         Map<String, Double> result2_5 = new HashMap<>();
     205         result2_5.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     206         result2_5.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     207         result2_5.put("startY", startY);
     208         result2_5.put("endY", endY);
     209         resultMap2.add(result2_5);
     210 
     211         // 结果3
     212         List<Map<String, Double>> resultMap3 = new ArrayList<>(5);
     213         Map<String, Double> result3_1 = new HashMap<>();
     214         result3_1.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     215         result3_1.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     216         result3_1.put("startY", startY);
     217         result3_1.put("endY", endY);
     218         resultMap3.add(result3_1);
     219 
     220         Map<String, Double> result3_2 = new HashMap<>();
     221         result3_2.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     222         result3_2.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     223         result3_2.put("startY", startY);
     224         result3_2.put("endY", endY);
     225         resultMap3.add(result3_2);
     226 
     227         Map<String, Double> result3_3 = new HashMap<>();
     228         result3_3.put("startX", startX);
     229         result3_3.put("endX", endX);
     230         result3_3.put("startY", startY);
     231         result3_3.put("endY", endY);
     232         resultMap3.add(result3_3);
     233 
     234         Map<String, Double> result3_4 = new HashMap<>();
     235         result3_4.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     236         result3_4.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     237         result3_4.put("startY", startY);
     238         result3_4.put("endY", endY);
     239         resultMap3.add(result3_4);
     240 
     241         Map<String, Double> result3_5 = new HashMap<>();
     242         result3_5.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     243         result3_5.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     244         result3_5.put("startY", startY);
     245         result3_5.put("endY", endY);
     246         resultMap3.add(result3_5);
     247 
     248 
     249         // 结果4
     250         List<Map<String, Double>> resultMap4 = new ArrayList<>(5);
     251         Map<String, Double> result4_1 = new HashMap<>();
     252         result4_1.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     253         result4_1.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     254         result4_1.put("startY", startY);
     255         result4_1.put("endY", endY);
     256         resultMap4.add(result4_1);
     257 
     258         Map<String, Double> result4_2 = new HashMap<>();
     259         result4_2.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     260         result4_2.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     261         result4_2.put("startY", startY);
     262         result4_2.put("endY", endY);
     263         resultMap4.add(result4_2);
     264 
     265         Map<String, Double> result4_3 = new HashMap<>();
     266         result4_3.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     267         result4_3.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     268         result4_3.put("startY", startY);
     269         result4_3.put("endY", endY);
     270         resultMap4.add(result4_3);
     271 
     272         Map<String, Double> result4_4 = new HashMap<>();
     273         result4_4.put("startX", startX);
     274         result4_4.put("endX", endX);
     275         result4_4.put("startY", startY);
     276         result4_4.put("endY", endY);
     277         resultMap4.add(result4_4);
     278 
     279         Map<String, Double> result4_5 = new HashMap<>();
     280         result4_5.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     281         result4_5.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     282         result4_5.put("startY", startY);
     283         result4_5.put("endY", endY);
     284         resultMap4.add(result4_5);
     285 
     286         // 结果5
     287         List<Map<String, Double>> resultMap5 = new ArrayList<>(5);
     288         Map<String, Double> result5_1 = new HashMap<>();
     289         result5_1.put("startX", new BigDecimal(startX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     290         result5_1.put("endX", new BigDecimal(endX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     291         result5_1.put("startY", startY);
     292         result5_1.put("endY", endY);
     293         resultMap5.add(result5_1);
     294 
     295         Map<String, Double> result5_2 = new HashMap<>();
     296         result5_2.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     297         result5_2.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     298         result5_2.put("startY", startY);
     299         result5_2.put("endY", endY);
     300         resultMap5.add(result5_2);
     301 
     302         Map<String, Double> result5_3 = new HashMap<>();
     303         result5_3.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     304         result5_3.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     305         result5_3.put("startY", startY);
     306         result5_3.put("endY", endY);
     307         resultMap5.add(result5_3);
     308 
     309         Map<String, Double> result5_4 = new HashMap<>();
     310         result5_4.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     311         result5_4.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     312         result5_4.put("startY", startY);
     313         result5_4.put("endY", endY);
     314         resultMap5.add(result5_4);
     315 
     316         Map<String, Double> result5_5 = new HashMap<>();
     317         result5_5.put("startX", startX);
     318         result5_5.put("endX", endX);
     319         result5_5.put("startY", startY);
     320         result5_5.put("endY", endY);
     321         resultMap5.add(result5_5);
     322 
     323         int count = 0;
     324         for (int index = 0; index < resultMap1.size(); index++) {
     325             Map<String, Double> result = resultMap1.get(index);
     326             double startX1 = result.get("startX").doubleValue();
     327             double endX1 = result.get("endX").doubleValue();
     328             double startY1 = result.get("startY").doubleValue();
     329             double endY1 = result.get("endY").doubleValue();
     330             for (int i = 0; i < indexList.size(); i++) {
     331                 Map<String, Double> map = indexList.get(i);
     332                 double startX2 = map.get("startX").doubleValue();
     333                 double endX2 = map.get("endX").doubleValue();
     334                 double startY2 = map.get("startY").doubleValue();
     335                 double endY2 = map.get("endY").doubleValue();
     336                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     337                     count++;
     338                 }
     339             }
     340         }
     341         if(count == 5) {
     342             Double author = indexList.get(0).get("author");
     343             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     344             MsgAlert.alert("游戏结束," + name + "获胜!");
     345             result = "游戏结束," + name + "获胜!";
     346             isFinish = true;
     347             return;
     348         }
     349 
     350         int count_1 = 0;
     351         for (int index = 0; index < resultMap2.size(); index++) {
     352             Map<String, Double> result = resultMap2.get(index);
     353             double startX1 = result.get("startX").doubleValue();
     354             double endX1 = result.get("endX").doubleValue();
     355             double startY1 = result.get("startY").doubleValue();
     356             double endY1 = result.get("endY").doubleValue();
     357             for (int i = 0; i < indexList.size(); i++) {
     358                 Map<String, Double> map = indexList.get(i);
     359                 double startX2 = map.get("startX").doubleValue();
     360                 double endX2 = map.get("endX").doubleValue();
     361                 double startY2 = map.get("startY").doubleValue();
     362                 double endY2 = map.get("endY").doubleValue();
     363                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     364                     count_1++;
     365                 }
     366             }
     367         }
     368         if(count_1 == 5) {
     369             Double author = indexList.get(0).get("author");
     370             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     371             MsgAlert.alert("游戏结束," + name + "获胜!");
     372             result = "游戏结束," + name + "获胜!";
     373             isFinish = true;
     374             return;
     375         }
     376 
     377         int count_2 = 0;
     378         for (int index = 0; index < resultMap3.size(); index++) {
     379             Map<String, Double> result = resultMap3.get(index);
     380             double startX1 = result.get("startX").doubleValue();
     381             double endX1 = result.get("endX").doubleValue();
     382             double startY1 = result.get("startY").doubleValue();
     383             double endY1 = result.get("endY").doubleValue();
     384             for (int i = 0; i < indexList.size(); i++) {
     385                 Map<String, Double> map = indexList.get(i);
     386                 double startX2 = map.get("startX").doubleValue();
     387                 double endX2 = map.get("endX").doubleValue();
     388                 double startY2 = map.get("startY").doubleValue();
     389                 double endY2 = map.get("endY").doubleValue();
     390                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     391                     count_2++;
     392                 }
     393             }
     394         }
     395         if(count_2 == 5) {
     396             Double author = indexList.get(0).get("author");
     397             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     398             MsgAlert.alert("游戏结束," + name + "获胜!");
     399             result = "游戏结束," + name + "获胜!";
     400             isFinish = true;
     401             return;
     402         }
     403 
     404         int count_3 = 0;
     405         for (int index = 0; index < resultMap4.size(); index++) {
     406             Map<String, Double> result = resultMap4.get(index);
     407             double startX1 = result.get("startX").doubleValue();
     408             double endX1 = result.get("endX").doubleValue();
     409             double startY1 = result.get("startY").doubleValue();
     410             double endY1 = result.get("endY").doubleValue();
     411             for (int i = 0; i < indexList.size(); i++) {
     412                 Map<String, Double> map = indexList.get(i);
     413                 double startX2 = map.get("startX").doubleValue();
     414                 double endX2 = map.get("endX").doubleValue();
     415                 double startY2 = map.get("startY").doubleValue();
     416                 double endY2 = map.get("endY").doubleValue();
     417                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     418                     count_3++;
     419                 }
     420             }
     421         }
     422         if(count_3 == 5) {
     423             Double author = indexList.get(0).get("author");
     424             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     425             MsgAlert.alert("游戏结束," + name + "获胜!");
     426             result = "游戏结束," + name + "获胜!";
     427             isFinish = true;
     428             return;
     429         }
     430 
     431         int count_4 = 0;
     432         for (int index = 0; index < resultMap5.size(); index++) {
     433             Map<String, Double> result = resultMap5.get(index);
     434             double startX1 = result.get("startX").doubleValue();
     435             double endX1 = result.get("endX").doubleValue();
     436             double startY1 = result.get("startY").doubleValue();
     437             double endY1 = result.get("endY").doubleValue();
     438             for (int i = 0; i < indexList.size(); i++) {
     439                 Map<String, Double> map = indexList.get(i);
     440                 double startX2 = map.get("startX").doubleValue();
     441                 double endX2 = map.get("endX").doubleValue();
     442                 double startY2 = map.get("startY").doubleValue();
     443                 double endY2 = map.get("endY").doubleValue();
     444                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     445                     count_4++;
     446                 }
     447             }
     448         }
     449         if(count_4 == 5) {
     450             Double author = indexList.get(0).get("author");
     451             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     452             MsgAlert.alert("游戏结束," + name + "获胜!");
     453             result = "游戏结束," + name + "获胜!";
     454             isFinish = true;
     455             return;
     456         }
     457     }
     458 
     459     /**
     460      * 计算成功结果(纵向计算)
     461      * @param indexList
     462      * @param startX
     463      * @param endX
     464      * @param startY
     465      * @param endY
     466      */
     467     private void computeResultY(List<Map<String, Double>> indexList, double startX, double endX, double startY, double endY) {
     468         // 结果1
     469         List<Map<String, Double>> resultMap1 = new ArrayList<>(5);
     470         Map<String, Double> result1 = new HashMap<>();
     471         result1.put("startX", startX);
     472         result1.put("endX", endX);
     473         result1.put("startY", startY);
     474         result1.put("endY", endY);
     475         resultMap1.add(result1);
     476 
     477         Map<String, Double> result2 = new HashMap<>();
     478         result2.put("startX", startX);
     479         result2.put("endX", startX);
     480         result2.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     481         result2.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     482         resultMap1.add(result2);
     483 
     484         Map<String, Double> result3 = new HashMap<>();
     485         result3.put("startX", startX);
     486         result3.put("endX", endX);
     487         result3.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     488         result3.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     489         resultMap1.add(result3);
     490 
     491         Map<String, Double> result4 = new HashMap<>();
     492         result4.put("startX", startX);
     493         result4.put("endX", endX);
     494         result4.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     495         result4.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     496         resultMap1.add(result4);
     497 
     498         Map<String, Double> result5 = new HashMap<>();
     499         result5.put("startX", startX);
     500         result5.put("endX", endX);
     501         result5.put("startY", new BigDecimal(startY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     502         result5.put("endY", new BigDecimal(endY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     503         resultMap1.add(result5);
     504 
     505         // 结果2
     506         List<Map<String, Double>> resultMap2 = new ArrayList<>(5);
     507         Map<String, Double> result2_1 = new HashMap<>();
     508         result2_1.put("startX", startX);
     509         result2_1.put("endX", endX);
     510         result2_1.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     511         result2_1.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     512         resultMap2.add(result2_1);
     513 
     514         Map<String, Double> result2_2 = new HashMap<>();
     515         result2_2.put("startX", startX);
     516         result2_2.put("endX", endX);
     517         result2_2.put("startY", startY);
     518         result2_2.put("endY", endY);
     519         resultMap2.add(result2_2);
     520 
     521         Map<String, Double> result2_3 = new HashMap<>();
     522         result2_3.put("startX", startX);
     523         result2_3.put("endX", endX);
     524         result2_3.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     525         result2_3.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     526         resultMap2.add(result2_3);
     527 
     528         Map<String, Double> result2_4 = new HashMap<>();
     529         result2_4.put("startX", startX);
     530         result2_4.put("endX", endX);
     531         result2_4.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     532         result2_4.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     533         resultMap2.add(result2_4);
     534 
     535         Map<String, Double> result2_5 = new HashMap<>();
     536         result2_5.put("startX", startX);
     537         result2_5.put("endX", endX);
     538         result2_5.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     539         result2_5.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     540         resultMap2.add(result2_5);
     541 
     542         // 结果3
     543         List<Map<String, Double>> resultMap3 = new ArrayList<>(5);
     544         Map<String, Double> result3_1 = new HashMap<>();
     545         result3_1.put("startX", startX);
     546         result3_1.put("endX", endX);
     547         result3_1.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     548         result3_1.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     549         resultMap3.add(result3_1);
     550 
     551         Map<String, Double> result3_2 = new HashMap<>();
     552         result3_2.put("startX", startX);
     553         result3_2.put("endX", endX);
     554         result3_2.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     555         result3_2.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     556         resultMap3.add(result3_2);
     557 
     558         Map<String, Double> result3_3 = new HashMap<>();
     559         result3_3.put("startX", startX);
     560         result3_3.put("endX", endX);
     561         result3_3.put("startY", startY);
     562         result3_3.put("endY", endY);
     563         resultMap3.add(result3_3);
     564 
     565         Map<String, Double> result3_4 = new HashMap<>();
     566         result3_4.put("startX", startX);
     567         result3_4.put("endX", endX);
     568         result3_4.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     569         result3_4.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     570         resultMap3.add(result3_4);
     571 
     572         Map<String, Double> result3_5 = new HashMap<>();
     573         result3_5.put("startX", startX);
     574         result3_5.put("endX", endX);
     575         result3_5.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     576         result3_5.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     577         resultMap3.add(result3_5);
     578 
     579 
     580         // 结果4
     581         List<Map<String, Double>> resultMap4 = new ArrayList<>(5);
     582         Map<String, Double> result4_1 = new HashMap<>();
     583         result4_1.put("startX", startX);
     584         result4_1.put("endX", endX);
     585         result4_1.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     586         result4_1.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     587         resultMap4.add(result4_1);
     588 
     589         Map<String, Double> result4_2 = new HashMap<>();
     590         result4_2.put("startX", startX);
     591         result4_2.put("endX", endX);
     592         result4_2.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     593         result4_2.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     594         resultMap4.add(result4_2);
     595 
     596         Map<String, Double> result4_3 = new HashMap<>();
     597         result4_3.put("startX", startX);
     598         result4_3.put("endX", endX);
     599         result4_3.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     600         result4_3.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     601         resultMap4.add(result4_3);
     602 
     603         Map<String, Double> result4_4 = new HashMap<>();
     604         result4_4.put("startX", startX);
     605         result4_4.put("endX", endX);
     606         result4_4.put("startY", startY);
     607         result4_4.put("endY", endY);
     608         resultMap4.add(result4_4);
     609 
     610         Map<String, Double> result4_5 = new HashMap<>();
     611         result4_5.put("startX", startX);
     612         result4_5.put("endX", endX);
     613         result4_5.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     614         result4_5.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     615         resultMap4.add(result4_5);
     616 
     617         // 结果4
     618         List<Map<String, Double>> resultMap5 = new ArrayList<>(5);
     619         Map<String, Double> result5_1 = new HashMap<>();
     620         result5_1.put("startX", startX);
     621         result5_1.put("endX", endX);
     622         result5_1.put("startY", new BigDecimal(startY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     623         result5_1.put("endY", new BigDecimal(endY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     624         resultMap5.add(result5_1);
     625 
     626         Map<String, Double> result5_2 = new HashMap<>();
     627         result5_2.put("startX", startX);
     628         result5_2.put("endX", endX);
     629         result5_2.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     630         result5_2.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     631         resultMap5.add(result5_2);
     632 
     633         Map<String, Double> result5_3 = new HashMap<>();
     634         result5_3.put("startX", startX);
     635         result5_3.put("endX", endX);
     636         result5_3.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     637         result5_3.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     638         resultMap5.add(result5_3);
     639 
     640         Map<String, Double> result5_4 = new HashMap<>();
     641         result5_4.put("startX", startX);
     642         result5_4.put("endX", endX);
     643         result5_4.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     644         result5_4.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     645         resultMap5.add(result5_4);
     646 
     647         Map<String, Double> result5_5 = new HashMap<>();
     648         result5_5.put("startX", startX);
     649         result5_5.put("endX", endX);
     650         result5_5.put("startY", startY);
     651         result5_5.put("endY", endY);
     652         resultMap5.add(result5_5);
     653 
     654         int count = 0;
     655         for (int index = 0; index < resultMap1.size(); index++) {
     656             Map<String, Double> result = resultMap1.get(index);
     657             double startX1 = result.get("startX").doubleValue();
     658             double endX1 = result.get("endX").doubleValue();
     659             double startY1 = result.get("startY").doubleValue();
     660             double endY1 = result.get("endY").doubleValue();
     661             for (int i = 0; i < indexList.size(); i++) {
     662                 Map<String, Double> map = indexList.get(i);
     663                 double startX2 = map.get("startX").doubleValue();
     664                 double endX2 = map.get("endX").doubleValue();
     665                 double startY2 = map.get("startY").doubleValue();
     666                 double endY2 = map.get("endY").doubleValue();
     667                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     668                     count++;
     669                 }
     670             }
     671         }
     672         if(count == 5) {
     673             Double author = indexList.get(0).get("author");
     674             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     675             MsgAlert.alert("游戏结束," + name + "获胜!");
     676             result = "游戏结束," + name + "获胜!";
     677             isFinish = true;
     678             return;
     679         }
     680 
     681         int count_1 = 0;
     682         for (int index = 0; index < resultMap2.size(); index++) {
     683             Map<String, Double> result = resultMap2.get(index);
     684             double startX1 = result.get("startX").doubleValue();
     685             double endX1 = result.get("endX").doubleValue();
     686             double startY1 = result.get("startY").doubleValue();
     687             double endY1 = result.get("endY").doubleValue();
     688             for (int i = 0; i < indexList.size(); i++) {
     689                 Map<String, Double> map = indexList.get(i);
     690                 double startX2 = map.get("startX").doubleValue();
     691                 double endX2 = map.get("endX").doubleValue();
     692                 double startY2 = map.get("startY").doubleValue();
     693                 double endY2 = map.get("endY").doubleValue();
     694                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     695                     count_1++;
     696                 }
     697             }
     698         }
     699         if(count_1 == 5) {
     700             Double author = indexList.get(0).get("author");
     701             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     702             MsgAlert.alert("游戏结束," + name + "获胜!");
     703             result = "游戏结束," + name + "获胜!";
     704             isFinish = true;
     705             return;
     706         }
     707 
     708         int count_2 = 0;
     709         for (int index = 0; index < resultMap3.size(); index++) {
     710             Map<String, Double> result = resultMap3.get(index);
     711             double startX1 = result.get("startX").doubleValue();
     712             double endX1 = result.get("endX").doubleValue();
     713             double startY1 = result.get("startY").doubleValue();
     714             double endY1 = result.get("endY").doubleValue();
     715             for (int i = 0; i < indexList.size(); i++) {
     716                 Map<String, Double> map = indexList.get(i);
     717                 double startX2 = map.get("startX").doubleValue();
     718                 double endX2 = map.get("endX").doubleValue();
     719                 double startY2 = map.get("startY").doubleValue();
     720                 double endY2 = map.get("endY").doubleValue();
     721                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     722                     count_2++;
     723                 }
     724             }
     725         }
     726         if(count_2 == 5) {
     727             Double author = indexList.get(0).get("author");
     728             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     729             MsgAlert.alert("游戏结束," + name + "获胜!");
     730             result = "游戏结束," + name + "获胜!";
     731             isFinish = true;
     732             return;
     733         }
     734 
     735         int count_3 = 0;
     736         for (int index = 0; index < resultMap4.size(); index++) {
     737             Map<String, Double> result = resultMap4.get(index);
     738             double startX1 = result.get("startX").doubleValue();
     739             double endX1 = result.get("endX").doubleValue();
     740             double startY1 = result.get("startY").doubleValue();
     741             double endY1 = result.get("endY").doubleValue();
     742             for (int i = 0; i < indexList.size(); i++) {
     743                 Map<String, Double> map = indexList.get(i);
     744                 double startX2 = map.get("startX").doubleValue();
     745                 double endX2 = map.get("endX").doubleValue();
     746                 double startY2 = map.get("startY").doubleValue();
     747                 double endY2 = map.get("endY").doubleValue();
     748                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     749                     count_3++;
     750                 }
     751             }
     752         }
     753         if(count_3 == 5) {
     754             Double author = indexList.get(0).get("author");
     755             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     756             MsgAlert.alert("游戏结束," + name + "获胜!");
     757             result = "游戏结束," + name + "获胜!";
     758             isFinish = true;
     759             return;
     760         }
     761 
     762         int count_4 = 0;
     763         for (int index = 0; index < resultMap5.size(); index++) {
     764             Map<String, Double> result = resultMap5.get(index);
     765             double startX1 = result.get("startX").doubleValue();
     766             double endX1 = result.get("endX").doubleValue();
     767             double startY1 = result.get("startY").doubleValue();
     768             double endY1 = result.get("endY").doubleValue();
     769             for (int i = 0; i < indexList.size(); i++) {
     770                 Map<String, Double> map = indexList.get(i);
     771                 double startX2 = map.get("startX").doubleValue();
     772                 double endX2 = map.get("endX").doubleValue();
     773                 double startY2 = map.get("startY").doubleValue();
     774                 double endY2 = map.get("endY").doubleValue();
     775                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     776                     count_4++;
     777                 }
     778             }
     779         }
     780         if(count_4 == 5) {
     781             Double author = indexList.get(0).get("author");
     782             String name = author.doubleValue()==1.0 ? "A方" : "B方";
     783             MsgAlert.alert("游戏结束," + name + "获胜!");
     784             result = "游戏结束," + name + "获胜!";
     785             isFinish = true;
     786             return;
     787         }
     788     }
     789 
     790     /**
     791      * 计算成功结果(斜线计算)
     792      * @param indexList
     793      * @param startX
     794      * @param endX
     795      * @param startY
     796      * @param endY
     797      */
     798     private void computeResultXY(List<Map<String, Double>> indexList, double startX, double endX, double startY, double endY) {
     799         // 结果1
     800         List<Map<String, Double>> resultMap1 = new ArrayList<>(5);
     801         Map<String, Double> result1 = new HashMap<>();
     802         result1.put("startX", startX);
     803         result1.put("endX", endX);
     804         result1.put("startY", startY);
     805         result1.put("endY", endY);
     806         resultMap1.add(result1);
     807 
     808         Map<String, Double> result2 = new HashMap<>();
     809         result2.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     810         result2.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     811         result2.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     812         result2.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     813         resultMap1.add(result2);
     814 
     815         Map<String, Double> result3 = new HashMap<>();
     816         result3.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     817         result3.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     818         result3.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     819         result3.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     820         resultMap1.add(result3);
     821 
     822         Map<String, Double> result4 = new HashMap<>();
     823         result4.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     824         result4.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     825         result4.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     826         result4.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     827         resultMap1.add(result4);
     828 
     829         Map<String, Double> result5 = new HashMap<>();
     830         result5.put("startX", new BigDecimal(startX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     831         result5.put("endX", new BigDecimal(endX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     832         result5.put("startY", new BigDecimal(startY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     833         result5.put("endY", new BigDecimal(endY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     834         resultMap1.add(result5);
     835 
     836         // 结果2
     837         List<Map<String, Double>> resultMap2 = new ArrayList<>(5);
     838         Map<String, Double> result2_1 = new HashMap<>();
     839         result2_1.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     840         result2_1.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     841         result2_1.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     842         result2_1.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     843         resultMap2.add(result2_1);
     844 
     845         Map<String, Double> result2_2 = new HashMap<>();
     846         result2_2.put("startX", startX);
     847         result2_2.put("endX", endX);
     848         result2_2.put("startY", startY);
     849         result2_2.put("endY", endY);
     850         resultMap2.add(result2_2);
     851 
     852         Map<String, Double> result2_3 = new HashMap<>();
     853         result2_3.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     854         result2_3.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     855         result2_3.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     856         result2_3.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     857         resultMap2.add(result2_3);
     858 
     859         Map<String, Double> result2_4 = new HashMap<>();
     860         result2_4.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     861         result2_4.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     862         result2_4.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     863         result2_4.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     864         resultMap2.add(result2_4);
     865 
     866         Map<String, Double> result2_5 = new HashMap<>();
     867         result2_5.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     868         result2_5.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     869         result2_5.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     870         result2_5.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     871         resultMap2.add(result2_5);
     872 
     873         // 结果3
     874         List<Map<String, Double>> resultMap3 = new ArrayList<>(5);
     875         Map<String, Double> result3_1 = new HashMap<>();
     876         result3_1.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     877         result3_1.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     878         result3_1.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     879         result3_1.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     880         resultMap3.add(result3_1);
     881 
     882         Map<String, Double> result3_2 = new HashMap<>();
     883         result3_2.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     884         result3_2.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     885         result3_2.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     886         result3_2.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     887         resultMap3.add(result3_2);
     888 
     889         Map<String, Double> result3_3 = new HashMap<>();
     890         result3_3.put("startX", startX);
     891         result3_3.put("endX", endX);
     892         result3_3.put("startY", startY);
     893         result3_3.put("endY", endY);
     894         resultMap3.add(result3_3);
     895 
     896         Map<String, Double> result3_4 = new HashMap<>();
     897         result3_4.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     898         result3_4.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     899         result3_4.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     900         result3_4.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     901         resultMap3.add(result3_4);
     902 
     903         Map<String, Double> result3_5 = new HashMap<>();
     904         result3_5.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     905         result3_5.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     906         result3_5.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     907         result3_5.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     908         resultMap3.add(result3_5);
     909 
     910 
     911         // 结果4
     912         List<Map<String, Double>> resultMap4 = new ArrayList<>(5);
     913         Map<String, Double> result4_1 = new HashMap<>();
     914         result4_1.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     915         result4_1.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     916         result4_1.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     917         result4_1.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     918         resultMap4.add(result4_1);
     919 
     920         Map<String, Double> result4_2 = new HashMap<>();
     921         result4_2.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     922         result4_2.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     923         result4_2.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     924         result4_2.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     925         resultMap4.add(result4_2);
     926 
     927         Map<String, Double> result4_3 = new HashMap<>();
     928         result4_3.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     929         result4_3.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     930         result4_3.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     931         result4_3.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     932         resultMap4.add(result4_3);
     933 
     934         Map<String, Double> result4_4 = new HashMap<>();
     935         result4_4.put("startX", startX);
     936         result4_4.put("endX", endX);
     937         result4_4.put("startY", startY);
     938         result4_4.put("endY", endY);
     939         resultMap4.add(result4_4);
     940 
     941         Map<String, Double> result4_5 = new HashMap<>();
     942         result4_5.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     943         result4_5.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     944         result4_5.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     945         result4_5.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     946         resultMap4.add(result4_5);
     947 
     948         // 结果4
     949         List<Map<String, Double>> resultMap5 = new ArrayList<>(5);
     950         Map<String, Double> result5_1 = new HashMap<>();
     951         result5_1.put("startX", new BigDecimal(startX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     952         result5_1.put("endX", new BigDecimal(endX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     953         result5_1.put("startY", new BigDecimal(startY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     954         result5_1.put("endY", new BigDecimal(endY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     955         resultMap5.add(result5_1);
     956 
     957         Map<String, Double> result5_2 = new HashMap<>();
     958         result5_2.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     959         result5_2.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     960         result5_2.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     961         result5_2.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     962         resultMap5.add(result5_2);
     963 
     964         Map<String, Double> result5_3 = new HashMap<>();
     965         result5_3.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     966         result5_3.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     967         result5_3.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     968         result5_3.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     969         resultMap5.add(result5_3);
     970 
     971         Map<String, Double> result5_4 = new HashMap<>();
     972         result5_4.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     973         result5_4.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     974         result5_4.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     975         result5_4.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     976         resultMap5.add(result5_4);
     977 
     978         Map<String, Double> result5_5 = new HashMap<>();
     979         result5_5.put("startX", startX);
     980         result5_5.put("endX", endX);
     981         result5_5.put("startY", startY);
     982         result5_5.put("endY", endY);
     983         resultMap5.add(result5_5);
     984 
     985         int count = 0;
     986         for (int index = 0; index < resultMap1.size(); index++) {
     987             Map<String, Double> result = resultMap1.get(index);
     988             double startX1 = result.get("startX").doubleValue();
     989             double endX1 = result.get("endX").doubleValue();
     990             double startY1 = result.get("startY").doubleValue();
     991             double endY1 = result.get("endY").doubleValue();
     992             for (int i = 0; i < indexList.size(); i++) {
     993                 Map<String, Double> map = indexList.get(i);
     994                 double startX2 = map.get("startX").doubleValue();
     995                 double endX2 = map.get("endX").doubleValue();
     996                 double startY2 = map.get("startY").doubleValue();
     997                 double endY2 = map.get("endY").doubleValue();
     998                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
     999                     count++;
    1000                 }
    1001             }
    1002         }
    1003         if(count == 5) {
    1004             Double author = indexList.get(0).get("author");
    1005             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1006             MsgAlert.alert("游戏结束," + name + "获胜!");
    1007             result = "游戏结束," + name + "获胜!";
    1008             isFinish = true;
    1009             return;
    1010         }
    1011 
    1012         int count_1 = 0;
    1013         for (int index = 0; index < resultMap2.size(); index++) {
    1014             Map<String, Double> result = resultMap2.get(index);
    1015             double startX1 = result.get("startX").doubleValue();
    1016             double endX1 = result.get("endX").doubleValue();
    1017             double startY1 = result.get("startY").doubleValue();
    1018             double endY1 = result.get("endY").doubleValue();
    1019             for (int i = 0; i < indexList.size(); i++) {
    1020                 Map<String, Double> map = indexList.get(i);
    1021                 double startX2 = map.get("startX").doubleValue();
    1022                 double endX2 = map.get("endX").doubleValue();
    1023                 double startY2 = map.get("startY").doubleValue();
    1024                 double endY2 = map.get("endY").doubleValue();
    1025                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1026                     count_1++;
    1027                 }
    1028             }
    1029         }
    1030         if(count_1 == 5) {
    1031             Double author = indexList.get(0).get("author");
    1032             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1033             MsgAlert.alert("游戏结束," + name + "获胜!");
    1034             result = "游戏结束," + name + "获胜!";
    1035             isFinish = true;
    1036             return;
    1037         }
    1038 
    1039         int count_2 = 0;
    1040         for (int index = 0; index < resultMap3.size(); index++) {
    1041             Map<String, Double> result = resultMap3.get(index);
    1042             double startX1 = result.get("startX").doubleValue();
    1043             double endX1 = result.get("endX").doubleValue();
    1044             double startY1 = result.get("startY").doubleValue();
    1045             double endY1 = result.get("endY").doubleValue();
    1046             for (int i = 0; i < indexList.size(); i++) {
    1047                 Map<String, Double> map = indexList.get(i);
    1048                 double startX2 = map.get("startX").doubleValue();
    1049                 double endX2 = map.get("endX").doubleValue();
    1050                 double startY2 = map.get("startY").doubleValue();
    1051                 double endY2 = map.get("endY").doubleValue();
    1052                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1053                     count_2++;
    1054                 }
    1055             }
    1056         }
    1057         if(count_2 == 5) {
    1058             Double author = indexList.get(0).get("author");
    1059             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1060             MsgAlert.alert("游戏结束," + name + "获胜!");
    1061             result = "游戏结束," + name + "获胜!";
    1062             isFinish = true;
    1063             return;
    1064         }
    1065 
    1066         int count_3 = 0;
    1067         for (int index = 0; index < resultMap4.size(); index++) {
    1068             Map<String, Double> result = resultMap4.get(index);
    1069             double startX1 = result.get("startX").doubleValue();
    1070             double endX1 = result.get("endX").doubleValue();
    1071             double startY1 = result.get("startY").doubleValue();
    1072             double endY1 = result.get("endY").doubleValue();
    1073             for (int i = 0; i < indexList.size(); i++) {
    1074                 Map<String, Double> map = indexList.get(i);
    1075                 double startX2 = map.get("startX").doubleValue();
    1076                 double endX2 = map.get("endX").doubleValue();
    1077                 double startY2 = map.get("startY").doubleValue();
    1078                 double endY2 = map.get("endY").doubleValue();
    1079                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1080                     count_3++;
    1081                 }
    1082             }
    1083         }
    1084         if(count_3 == 5) {
    1085             Double author = indexList.get(0).get("author");
    1086             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1087             MsgAlert.alert("游戏结束," + name + "获胜!");
    1088             result = "游戏结束," + name + "获胜!";
    1089             isFinish = true;
    1090             return;
    1091         }
    1092 
    1093         int count_4 = 0;
    1094         for (int index = 0; index < resultMap5.size(); index++) {
    1095             Map<String, Double> result = resultMap5.get(index);
    1096             double startX1 = result.get("startX").doubleValue();
    1097             double endX1 = result.get("endX").doubleValue();
    1098             double startY1 = result.get("startY").doubleValue();
    1099             double endY1 = result.get("endY").doubleValue();
    1100             for (int i = 0; i < indexList.size(); i++) {
    1101                 Map<String, Double> map = indexList.get(i);
    1102                 double startX2 = map.get("startX").doubleValue();
    1103                 double endX2 = map.get("endX").doubleValue();
    1104                 double startY2 = map.get("startY").doubleValue();
    1105                 double endY2 = map.get("endY").doubleValue();
    1106                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1107                     count_4++;
    1108                 }
    1109             }
    1110         }
    1111         if(count_4 == 5) {
    1112             Double author = indexList.get(0).get("author");
    1113             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1114             MsgAlert.alert("游戏结束," + name + "获胜!");
    1115             result = "游戏结束," + name + "获胜!";
    1116             isFinish = true;
    1117             return;
    1118         }
    1119 
    1120         // 结果6
    1121         List<Map<String, Double>> resultMap6 = new ArrayList<>(5);
    1122         Map<String, Double> result6_1 = new HashMap<>();
    1123         result6_1.put("startX", startX);
    1124         result6_1.put("endX", endX);
    1125         result6_1.put("startY", startY);
    1126         result6_1.put("endY", endY);
    1127         resultMap6.add(result6_1);
    1128 
    1129         Map<String, Double> result6_2 = new HashMap<>();
    1130         result6_2.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1131         result6_2.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1132         result6_2.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1133         result6_2.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1134         resultMap6.add(result6_2);
    1135 
    1136         Map<String, Double> result6_3 = new HashMap<>();
    1137         result6_3.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1138         result6_3.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1139         result6_3.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1140         result6_3.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1141         resultMap6.add(result6_3);
    1142 
    1143         Map<String, Double> result6_4 = new HashMap<>();
    1144         result6_4.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1145         result6_4.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1146         result6_4.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1147         result6_4.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1148         resultMap6.add(result6_4);
    1149 
    1150         Map<String, Double> result6_5 = new HashMap<>();
    1151         result6_5.put("startX", new BigDecimal(startX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1152         result6_5.put("endX", new BigDecimal(endX+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1153         result6_5.put("startY", new BigDecimal(startY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1154         result6_5.put("endY", new BigDecimal(endY-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1155         resultMap6.add(result6_5);
    1156 
    1157         // 结果7
    1158         List<Map<String, Double>> resultMap7 = new ArrayList<>(5);
    1159         Map<String, Double> result7_1 = new HashMap<>();
    1160         result7_1.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1161         result7_1.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1162         result7_1.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1163         result7_1.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1164         resultMap7.add(result7_1);
    1165 
    1166         Map<String, Double> result7_2 = new HashMap<>();
    1167         result7_2.put("startX", startX);
    1168         result7_2.put("endX", endX);
    1169         result7_2.put("startY", startY);
    1170         result7_2.put("endY", endY);
    1171         resultMap7.add(result7_2);
    1172 
    1173         Map<String, Double> result7_3 = new HashMap<>();
    1174         result7_3.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1175         result7_3.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1176         result7_3.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1177         result7_3.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1178         resultMap7.add(result7_3);
    1179 
    1180         Map<String, Double> result7_4 = new HashMap<>();
    1181         result7_4.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1182         result7_4.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1183         result7_4.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1184         result7_4.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1185         resultMap7.add(result7_4);
    1186 
    1187         Map<String, Double> result7_5 = new HashMap<>();
    1188         result7_5.put("startX", new BigDecimal(startX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1189         result7_5.put("endX", new BigDecimal(endX+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1190         result7_5.put("startY", new BigDecimal(startY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1191         result7_5.put("endY", new BigDecimal(endY-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1192         resultMap7.add(result7_5);
    1193 
    1194         // 结果8
    1195         List<Map<String, Double>> resultMap8 = new ArrayList<>(5);
    1196         Map<String, Double> result8_1 = new HashMap<>();
    1197         result8_1.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1198         result8_1.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1199         result8_1.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1200         result8_1.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1201         resultMap8.add(result8_1);
    1202 
    1203         Map<String, Double> result8_2 = new HashMap<>();
    1204         result8_2.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1205         result8_2.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1206         result8_2.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1207         result8_2.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1208         resultMap8.add(result8_2);
    1209 
    1210         Map<String, Double> result8_3 = new HashMap<>();
    1211         result8_3.put("startX", startX);
    1212         result8_3.put("endX", endX);
    1213         result8_3.put("startY", startY);
    1214         result8_3.put("endY", endY);
    1215         resultMap8.add(result8_3);
    1216 
    1217         Map<String, Double> result8_4 = new HashMap<>();
    1218         result8_4.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1219         result8_4.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1220         result8_4.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1221         result8_4.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1222         resultMap8.add(result8_4);
    1223 
    1224         Map<String, Double> result8_5 = new HashMap<>();
    1225         result8_5.put("startX", new BigDecimal(startX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1226         result8_5.put("endX", new BigDecimal(endX+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1227         result8_5.put("startY", new BigDecimal(startY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1228         result8_5.put("endY", new BigDecimal(endY-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1229         resultMap8.add(result8_5);
    1230 
    1231 
    1232         // 结果9
    1233         List<Map<String, Double>> resultMap9 = new ArrayList<>(5);
    1234         Map<String, Double> result9_1 = new HashMap<>();
    1235         result9_1.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1236         result9_1.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1237         result9_1.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1238         result9_1.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1239         resultMap9.add(result9_1);
    1240 
    1241         Map<String, Double> result9_2 = new HashMap<>();
    1242         result9_2.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1243         result9_2.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1244         result9_2.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1245         result9_2.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1246         resultMap9.add(result9_2);
    1247 
    1248         Map<String, Double> result9_3 = new HashMap<>();
    1249         result9_3.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1250         result9_3.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1251         result9_3.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1252         result9_3.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1253         resultMap9.add(result9_3);
    1254 
    1255         Map<String, Double> result9_4 = new HashMap<>();
    1256         result9_4.put("startX", startX);
    1257         result9_4.put("endX", endX);
    1258         result9_4.put("startY", startY);
    1259         result9_4.put("endY", endY);
    1260         resultMap9.add(result9_4);
    1261 
    1262         Map<String, Double> result9_5 = new HashMap<>();
    1263         result9_5.put("startX", new BigDecimal(startX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1264         result9_5.put("endX", new BigDecimal(endX+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1265         result9_5.put("startY", new BigDecimal(startY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1266         result9_5.put("endY", new BigDecimal(endY-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1267         resultMap9.add(result9_5);
    1268 
    1269         // 结果4
    1270         List<Map<String, Double>> resultMap10 = new ArrayList<>(5);
    1271         Map<String, Double> result10_1 = new HashMap<>();
    1272         result10_1.put("startX", new BigDecimal(startX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1273         result10_1.put("endX", new BigDecimal(endX-(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1274         result10_1.put("startY", new BigDecimal(startY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1275         result10_1.put("endY", new BigDecimal(endY+(53.33*4)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1276         resultMap10.add(result10_1);
    1277 
    1278         Map<String, Double> result10_2 = new HashMap<>();
    1279         result10_2.put("startX", new BigDecimal(startX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1280         result10_2.put("endX", new BigDecimal(endX-(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1281         result10_2.put("startY", new BigDecimal(startY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1282         result10_2.put("endY", new BigDecimal(endY+(53.33*3)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1283         resultMap10.add(result10_2);
    1284 
    1285         Map<String, Double> result10_3 = new HashMap<>();
    1286         result10_3.put("startX", new BigDecimal(startX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1287         result10_3.put("endX", new BigDecimal(endX-(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1288         result10_3.put("startY", new BigDecimal(startY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1289         result10_3.put("endY", new BigDecimal(endY+(53.33*2)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1290         resultMap10.add(result10_3);
    1291 
    1292         Map<String, Double> result10_4 = new HashMap<>();
    1293         result10_4.put("startX", new BigDecimal(startX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1294         result10_4.put("endX", new BigDecimal(endX-(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1295         result10_4.put("startY", new BigDecimal(startY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1296         result10_4.put("endY", new BigDecimal(endY+(53.33*1)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1297         resultMap10.add(result10_4);
    1298 
    1299         Map<String, Double> result10_5 = new HashMap<>();
    1300         result10_5.put("startX", startX);
    1301         result10_5.put("endX", endX);
    1302         result10_5.put("startY", startY);
    1303         result10_5.put("endY", endY);
    1304         resultMap10.add(result10_5);
    1305 
    1306         int count_6 = 0;
    1307         for (int index = 0; index < resultMap6.size(); index++) {
    1308             Map<String, Double> result = resultMap6.get(index);
    1309             double startX1 = result.get("startX").doubleValue();
    1310             double endX1 = result.get("endX").doubleValue();
    1311             double startY1 = result.get("startY").doubleValue();
    1312             double endY1 = result.get("endY").doubleValue();
    1313             for (int i = 0; i < indexList.size(); i++) {
    1314                 Map<String, Double> map = indexList.get(i);
    1315                 double startX2 = map.get("startX").doubleValue();
    1316                 double endX2 = map.get("endX").doubleValue();
    1317                 double startY2 = map.get("startY").doubleValue();
    1318                 double endY2 = map.get("endY").doubleValue();
    1319                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1320                     count_6++;
    1321                 }
    1322             }
    1323         }
    1324         if(count_6 == 5) {
    1325             Double author = indexList.get(0).get("author");
    1326             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1327             MsgAlert.alert("游戏结束," + name + "获胜!");
    1328             result = "游戏结束," + name + "获胜!";
    1329             isFinish = true;
    1330             return;
    1331         }
    1332 
    1333         int count_7 = 0;
    1334         for (int index = 0; index < resultMap6.size(); index++) {
    1335             Map<String, Double> result = resultMap6.get(index);
    1336             double startX1 = result.get("startX").doubleValue();
    1337             double endX1 = result.get("endX").doubleValue();
    1338             double startY1 = result.get("startY").doubleValue();
    1339             double endY1 = result.get("endY").doubleValue();
    1340             for (int i = 0; i < indexList.size(); i++) {
    1341                 Map<String, Double> map = indexList.get(i);
    1342                 double startX2 = map.get("startX").doubleValue();
    1343                 double endX2 = map.get("endX").doubleValue();
    1344                 double startY2 = map.get("startY").doubleValue();
    1345                 double endY2 = map.get("endY").doubleValue();
    1346                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1347                     count_7++;
    1348                 }
    1349             }
    1350         }
    1351         if(count_7 == 5) {
    1352             Double author = indexList.get(0).get("author");
    1353             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1354             MsgAlert.alert("游戏结束," + name + "获胜!");
    1355             result = "游戏结束," + name + "获胜!";
    1356             isFinish = true;
    1357             return;
    1358         }
    1359 
    1360         int count_8 = 0;
    1361         for (int index = 0; index < resultMap8.size(); index++) {
    1362             Map<String, Double> result = resultMap8.get(index);
    1363             double startX1 = result.get("startX").doubleValue();
    1364             double endX1 = result.get("endX").doubleValue();
    1365             double startY1 = result.get("startY").doubleValue();
    1366             double endY1 = result.get("endY").doubleValue();
    1367             for (int i = 0; i < indexList.size(); i++) {
    1368                 Map<String, Double> map = indexList.get(i);
    1369                 double startX2 = map.get("startX").doubleValue();
    1370                 double endX2 = map.get("endX").doubleValue();
    1371                 double startY2 = map.get("startY").doubleValue();
    1372                 double endY2 = map.get("endY").doubleValue();
    1373                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1374                     count_8++;
    1375                 }
    1376             }
    1377         }
    1378         if(count_8 == 5) {
    1379             Double author = indexList.get(0).get("author");
    1380             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1381             MsgAlert.alert("游戏结束," + name + "获胜!");
    1382             result = "游戏结束," + name + "获胜!";
    1383             isFinish = true;
    1384             return;
    1385         }
    1386 
    1387         int count_9 = 0;
    1388         for (int index = 0; index < resultMap9.size(); index++) {
    1389             Map<String, Double> result = resultMap9.get(index);
    1390             double startX1 = result.get("startX").doubleValue();
    1391             double endX1 = result.get("endX").doubleValue();
    1392             double startY1 = result.get("startY").doubleValue();
    1393             double endY1 = result.get("endY").doubleValue();
    1394             for (int i = 0; i < indexList.size(); i++) {
    1395                 Map<String, Double> map = indexList.get(i);
    1396                 double startX2 = map.get("startX").doubleValue();
    1397                 double endX2 = map.get("endX").doubleValue();
    1398                 double startY2 = map.get("startY").doubleValue();
    1399                 double endY2 = map.get("endY").doubleValue();
    1400                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1401                     count_9++;
    1402                 }
    1403             }
    1404         }
    1405         if(count_9 == 5) {
    1406             Double author = indexList.get(0).get("author");
    1407             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1408             MsgAlert.alert("游戏结束," + name + "获胜!");
    1409             result = "游戏结束," + name + "获胜!";
    1410             isFinish = true;
    1411             return;
    1412         }
    1413 
    1414         int count_10 = 0;
    1415         for (int index = 0; index < resultMap10.size(); index++) {
    1416             Map<String, Double> result = resultMap10.get(index);
    1417             double startX1 = result.get("startX").doubleValue();
    1418             double endX1 = result.get("endX").doubleValue();
    1419             double startY1 = result.get("startY").doubleValue();
    1420             double endY1 = result.get("endY").doubleValue();
    1421             for (int i = 0; i < indexList.size(); i++) {
    1422                 Map<String, Double> map = indexList.get(i);
    1423                 double startX2 = map.get("startX").doubleValue();
    1424                 double endX2 = map.get("endX").doubleValue();
    1425                 double startY2 = map.get("startY").doubleValue();
    1426                 double endY2 = map.get("endY").doubleValue();
    1427                 if(startX1==startX2 && endX1==endX2 && startY1==startY2 && endY1==endY2) {
    1428                     count_10++;
    1429                 }
    1430             }
    1431         }
    1432         if(count_10 == 5) {
    1433             Double author = indexList.get(0).get("author");
    1434             String name = author.doubleValue()==1.0 ? "A方" : "B方";
    1435             MsgAlert.alert("游戏结束," + name + "获胜!");
    1436             result = "游戏结束," + name + "获胜!";
    1437             isFinish = true;
    1438             return;
    1439         }
    1440     }
    1441 
    1442     /**
    1443      * 重写匹配元素方法
    1444      * @param indexList
    1445      * @param index
    1446      * @return
    1447      */
    1448     private boolean isContains(List<Map<String,Double>> indexList, Map<String, Double> index) {
    1449         double startX1 = index.get("startX").doubleValue();
    1450         double endX1 = index.get("endX").doubleValue();
    1451         double startY1 = index.get("startY").doubleValue();
    1452         double endY1 = index.get("endY").doubleValue();
    1453         for (int i = 0; i < indexList.size(); i++) {
    1454             Map<String, Double> map = indexList.get(i);
    1455             double startX = map.get("startX").doubleValue();
    1456             double endX = map.get("endX").doubleValue();
    1457             double startY = map.get("startY").doubleValue();
    1458             double endY = map.get("endY").doubleValue();
    1459             if(startX1==startX && endX==endX1 && startY1==startY && endY==endY1) {
    1460                 return true;
    1461             }
    1462         }
    1463         return false;
    1464     }
    1465 
    1466     /**
    1467      * 绘制棋盘
    1468      */
    1469     private void draw() {
    1470         if(Objects.isNull(graphicsContext2D)) {
    1471             graphicsContext2D = canvas.getGraphicsContext2D();
    1472         }
    1473         graphicsContext2D.setFill(Color.BURLYWOOD);
    1474         graphicsContext2D.fillRect(0,0,800,800);
    1475 
    1476         // 绘制纵横线
    1477         //double align = 53.33;
    1478         for(int w=1; w<(800/align); w++) {
    1479             graphicsContext2D.strokeLine(0, align * w, 800, align * w);
    1480         }
    1481         for(int h=1; h<(800/align); h++) {
    1482             graphicsContext2D.strokeLine(align * h, 0, align * h, 800);
    1483         }
    1484 
    1485         // 绘制棋子
    1486         for(int w1=1; w1<(800/align-1); w1++) {
    1487             for(int h1=1; h1<(800/align-1); h1++) {
    1488                 Map<String, Double> index = new HashMap<>();
    1489                 index.put("startX", new BigDecimal((align * w1) - 20).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1490                 index.put("endX", new BigDecimal((align * w1) + 20).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1491                 index.put("startY", new BigDecimal((align * h1) - 20).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1492                 index.put("endY", new BigDecimal((align * h1) + 20).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    1493                 indexList.add(index);
    1494             }
    1495         }
    1496 
    1497         // 绘制四条外边
    1498         graphicsContext2D.setLineWidth(3.0);
    1499         graphicsContext2D.strokeLine(0, 0, 800, 0);
    1500         graphicsContext2D.strokeLine(0, 800, 800, 800);
    1501         graphicsContext2D.strokeLine(0, 0, 0, 800);
    1502         graphicsContext2D.strokeLine(800, 0, 800, 800);
    1503     }
    1504 
    1505     /**
    1506      * 重置
    1507      */
    1508     @FXML
    1509     private void reset() {
    1510         pane.setDisable(false);
    1511         isFinish = false;
    1512         flag = "A";
    1513         result = "";
    1514         indexList.removeAll(indexList);
    1515         useIndexList.removeAll(useIndexList);
    1516         graphicsContext2D.clearRect(0, 0, 800, 800);
    1517         draw();
    1518     }
    1519 
    1520     @FXML
    1521     private void saveImage() {
    1522         if(Objects.nonNull(canvas) && Objects.nonNull(graphicsContext2D)) {
    1523             UUID uuid = UUID.randomUUID();
    1524             Image image = new Image("file:C:\Users\Public\world\images\"+uuid+".jpg");
    1525             graphicsContext2D.drawImage(image, 0, 0, 800.00, 800.00);
    1526 
    1527             File file = new File("C:\Users\Public\world\images\" + uuid + ".jpg");
    1528             WritableImage snapshot = canvas.snapshot(new SnapshotParameters(), null);
    1529             try {
    1530                 ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), "jpg", file);
    1531                 MsgAlert.alert("保存图片成功!");
    1532             } catch (IOException e) {
    1533                 e.printStackTrace();
    1534                 MsgAlert.alert("保存图片失败!"+e.getMessage());
    1535             }
    1536         }
    1537     }
    1538 
    1539 }
  • 相关阅读:
    数组
    分支.顺序结构
    博客作业-查找
    DS博客作业-图
    DS 数据结构-树
    数据结构-栈,队列
    博客作业05-指针
    C语言博客作业04-数组
    C语言博客作业03——函数
    c语言博客作业02-循环结构
  • 原文地址:https://www.cnblogs.com/mxh-java/p/15174561.html
Copyright © 2020-2023  润新知