目 录

一.需求分析 1
1.1 概述 1
1.2 课题分析 2
1.3 实现功能步骤 2
1.4 设计工作详解 2
1.5 运行环境 2
二.概要设计 4
2.1 系统流程图 4
2.2 功能模块图 5
2.3 排序算法操作演示程序初始化模块 5
2.4 按钮控制模块 6
2.5 排序算法模块 7
2.6 异常提示控制模块 7
三.详细设计 8
3.1 排序算法操作演示程序初始化模块 8
3.2按钮控制模块 8
3.2.1 基本控件数据初始化模块 9
3.2.2 显示数据模块 10
3.2.3待排序的数据保存到文件模块 11
3.2.4 程序自动随机生成数据模块 11
3.2.5 排序算法开始模块 12
3.2.6 排序算法演示单步控制模块 13
3.3提示显示模块 14
3.4 提示界面显示控制模块 15
3.5 界面显示配置模块 16
3.6 提示界面配置模块 20
3.7程序流程 21
3.8 系统界面 22
四.调试分析 24
4.1 调试过程中所遇到的问题及解决方法 24
4.2 经验与体会 24
五.用户使用说明 25
六.测试结果 25
七.参考文献 27
八.附录 27

一.需求分析
1.1 概述
Java是一种简单的,面向对象的,分布式的,解释型的,健壮安全的,结构中立的,可移植的,性能优异、多线程的动态语言。
Java平台由Java虚拟机(Java Virtual Machine)和Java 应用编程接口(Application Programming Interface、简称API)构成。Java 应用编程接口为Java应用提供了一个独立于操作系统的标准接口,可分为基本部分和扩展部分。在硬件或操作系统平台上安装一个Java平台之后,Java应用程序就可运行。现在Java平台已经嵌入了几乎所有的操作系统。这样Java程序可以只编译一次,就可以在各种系统中运行。Java应用编程接口已经从1.1x版发展到1.2版。目前常用的Java平台基于Java1.5,最近版本为Java1.7。
Java分为三个体系JavaSE(Java2 Platform Standard Edition,java平台标准版),JavaEE(Java 2 Platform,Enterprise Edition,java平台企业版),JavaME(Java 2 Platform Micro Edition,java平台微型版)。
本程序所使用的Java SE(Java Platform,Standard Edition)。Java SE 以前称为 J2SE。它允许开发和部署在桌面、服务器、嵌入式环境和实时环境中使用的 Java 应用程序。Java SE 包含了支持 Java Web 服务开发的类,并为 Java Platform,Enterprise Edition(Java EE)提供基础。
以下就给出这次课题设计的题目:排序算法操作演示程序。

功能需求:
该系统主要功能包括排序数据生成、排序过程演示及数据存储。其具体要求如下:
数据生成:可以采用手工录入排序数据和随机生成两种方式;
排序数据展示:能够采用动画的方式形象展示待排序数据;
排序过程演示:可以采用快排序、插入排序、起泡排序等排序算法对待排序数据进行排序,并用动画方式展示出来;
数据存储:可以对排序的数据进行保存操作。
要求动画演示过程可以进行暂停、继续等操作

技术要求:
1、课程设计必须使用面向对象中的封装性、继承性以及多态性(类、继承、抽象类、接口、多态),且类设计必须合理
2、可视化一律采用JavaFX(不允许使用Swing或AWT)
3、所有题目均要设计数据存储,且数据存储采用文件(文本文件或二进制文件)
1.2 课题分析
从这个题目来分析,要做的主要有四大点。
第一点就是要完成数据的输入以及数据的展示的运行。其中包括:

  1. 用户自定义数据也就是用户自己输入数据。
  2. 程序自己随机生成数据。
  3. 在界面上显示用户输入的数据或者是程序自己随机生成的数据。
    第二点就是要完成对排序数据的排序过程的动画演示。而且要实现的几种不同的算法,不同的算法的演示的过程会有相应的提示。在演示的过程中可以及时停止且在停下来之后的过程中可以继续演示(接着未演示完的过程)
    第三点我在本题目上增加了一个功能,单步功能。
    第四点是如何实现数据的保存在本地的文件。

1.3 实现功能步骤

  1. 程序开始时我设计时会有一个提示,告知用户是如何去演示本程序,以及告知用户一些基本的注意事项。
  2. 程序可判断用户是否输入了待排序的数据,未输入点击了开始排序则提示用户未输入待排序的数据。输入了待排序的数据则在显示待排序的数据区域显示待排序的数据。
  3. 程序可判断用户是否点击了随机按钮,点击后则显示在显示待排序数据区域内随机的待排序的数据。
  4. 在用户点击RUN按钮时,程序会自动演示数据排序的动画。而且在用户点击STOP按钮动画能及时停下。
  5. 在用户点击STEP按钮时,程序会一步一步演示数据排序的动画。

1.4 设计工作详解
通过分析,我认为数据可用数据矩形块的高度去表示数据的大小,然后再交换两个数据块的位置这样就可以实现一个动画的效果。

1.5 运行环境
系统软件:Window XP
所需文件:pro_main.java(主程序代码),LiftGroupMaster.java(控制台程序),OutButton.java,PersonControl.java,LiftMaster.java(单电梯主类),LiftCage.java,LiftState.java,LiftTage.java,InnerButton.java。
语言选择:Java SE(Java Platform,Standard Edition)
工具软件:MyEclipse 8.x

二.概要设计
2.1 系统流程图

图2.1 系统流程图
2.2 功能模块图

图2.2 功能模块图
2.3 排序算法操作演示程序初始化模块
在这一模块当中,初始化程序窗口的大小,并创建程序窗口。
包含方法:
public void start(Stage primaryStage){
}

public static void main(String[] args) {
launch(args);
}
2.4 按钮控制模块
这一模块是本程序的一个重要的模块,其中包括对一些数据的初始化,主要是对控制界面的大部分的按钮事件添加事件驱动,以及一些控件的初始化的数据的初始化。与人为控制的交互的事件驱动的控制事件的调用。以实现对排序算法的演示。
数据类型:
@FXML
private AnchorPane mainpane;
@FXML
private ComboBox sortlist;
@FXML
private Pane sortPane;
@FXML
private Button randomButton;
@FXML
private Button saveButton;
@FXML
private Button GetButton;
@FXML
private Button Intput_over_Button;
@FXML
private Button RunButton;
@FXML
private Button PauseButton;
@FXML
private Button StepButton;
@FXML
private TextField myTextField;
@FXML
private VBox explain;
//以上是对一些界面初始化的叙述。
//下面是对数据操作和动画的数组的描写。
static ArrayList dataArrayList = new ArrayList();
static SequentialTransition sTransition = new SequentialTransition();
ArrayList rectangle = new ArrayList();
ArrayList timeline = new ArrayList();
static int count = 0;
//初始化按钮的数据
public void initialize(URL location, ResourceBundle resources) {
this.initchoice();
}
//显示数据矩形方法
public void showData(ActionEvent event)
//保存待排序的数据方法
public void savedata(ActionEvent event)
//随机待排序数据的方法
public void randomdata(ActionEvent event)
//主界面按钮事件处理方法
public void start(ActionEvent event)
//单步按钮事件处理方法
public void Step(ActionEvent event)
//清空数据
public void clear()
//隐藏提示控件方法
public void Hideknow(ActionEvent event)
//暂停控件处理方法
public void Pause(ActionEvent event)
2.5 排序算法模块
这一模块有三个子模块分别为冒泡排序算法模块,快排算法模块和插入算法模块,三个模块主要是实现是对排序算法的动画的,对每一步的算法的动画添加及播放演示。
2.6 异常提示控制模块
这是对单个输入异常,比如用户输入的不是数字的话就会提示,还有用户输入没有安照指定的要求去输入的话同样也会有一些异常。
三.详细设计
3.1 排序算法操作演示程序初始化模块
该模块是嵌套在Main.class主程序文件中的,以实现对控制类的参数初始化以及对窗口大小的初始化。
核心代码:
public void start(Stage primaryStage) {
try {
Parent root = (Parent)FXMLLoader.load(this.getClass().getResource(“/application/Myscene.fxml”));
primaryStage.setResizable(false);
primaryStage.setTitle(“My Application”);
primaryStage.setScene(new Scene(root));
primaryStage.show();
} catch (Exception var3) {
var3.printStackTrace();
}

}

public static void main(String[] args) {
    launch(args);
}

3.2按钮控制模块
基本控件申明:
@FXML
private AnchorPane mainpane;
@FXML
private ComboBox sortlist;
@FXML
private Pane sortPane;
@FXML
private Button randomButton;
@FXML
private Button saveButton;
@FXML
private Button GetButton;
@FXML
private Button Intput_over_Button;
@FXML
private Button RunButton;
@FXML
private Button PauseButton;
@FXML
private Button StepButton;
@FXML
private TextField myTextField;
@FXML
private VBox explain;
基本数据申明:
static ArrayList dataArrayList = new ArrayList();
static SequentialTransition sTransition = new SequentialTransition();
ArrayList rectangle = new ArrayList();
ArrayList timeline = new ArrayList();
static int count = 0;
3.2.1 基本控件数据初始化模块
构造函数与initchoice()初始化了算法的选择

//构造函数
private void initchoice() {
this.sortlist.getItems().addAll(new String[]{“1.BubbleSort”, “2.QuickSort”, “3.InsertSort”});
this.sortlist.setValue(“1.BubbleSort”);
}

3.2.2 显示数据模块
public void showData(ActionEvent event) throws Exception {
System.out.println(“input over Button Clicked!”);
this.clear();
String getdata = this.myTextField.getText();
System.out.println(getdata);
if (getdata.equals(“”)) {
(new Tips()).start(new Stage());
} else {
getdata.replaceAll(“ “, “,”);
String[] var6;
int var5 = (var6 = getdata.split(“,”)).length;

        int i;
        for(i = 0; i < var5; ++i) {
            String retval = var6[i];
            dataArrayList.add(Integer.parseInt(retval));
        }

        ImageView image = new ImageView("file:2.jpg");
        image.setFitHeight(432.0D);
        image.setFitWidth(777.0D);
        this.sortPane.getChildren().add(image);
        this.sortPane.setVisible(true);

        for(i = 0; i < dataArrayList.size(); ++i) {
            new Rectangle();
            Rectangle rec = new Rectangle();
            rec.setLayoutX((double)((i + 1) * 10));
            rec.setLayoutY(0.0D);
            rec.setWidth(5.0D);
            rec.setFill(Color.BLUE);
            rec.setHeight((double)((Integer)dataArrayList.get(i) * 5));
            this.sortPane.getChildren().add(rec);
            this.rectangle.add(rec);
        }
    }

}

3.2.3待排序的数据保存到文件模块
//保存数据
public void savedata(ActionEvent event) throws IOException {
String getdata = this.myTextField.getText();
getdata.replaceAll(“ “, “,”);
String file = “Data.txt”;

    try {
        FileOutputStream inputFileOutputStream = new FileOutputStream(file, true);
        Iterator var6 = dataArrayList.iterator();

        while(var6.hasNext()) {
            Integer integer = (Integer)var6.next();
            String str = integer.toString();
            str = str + " ";
            byte[] b = str.getBytes();
            inputFileOutputStream.write(b);
        }

        inputFileOutputStream.close();
    } catch (FileNotFoundException var9) {
        var9.printStackTrace();
    }

}

3.2.4 程序自动随机生成数据模块
// 每次按钮按后随机生成50个数据
public void randomdata(ActionEvent event) {
System.out.println(“Random Button Clicked!”);
this.clear();
this.sortPane.setVisible(true);
int random = 50;
boolean var3 = false;

    while(random > 0) {
        int k = (int)(Math.random() * 100.0D);
        if (k > 0 && k < 85) {
            dataArrayList.add(k);
            --random;
        }
    }

    for(int i = 0; i < dataArrayList.size(); ++i) {
        new Rectangle();
        Rectangle rec = new Rectangle();
        rec.setLayoutX((double)((i + 1) * 10));
        rec.setLayoutY(0.0D);
        rec.setWidth(5.0D);
        rec.setFill(Color.BLUE);
        rec.setHeight((double)((Integer)dataArrayList.get(i) * 5));
        this.sortPane.getChildren().add(rec);
        this.rectangle.add(rec);
    }

}

3.2.5 排序算法开始模块
//点击开始按钮
public void start(ActionEvent event) {
System.out.println(“RUN Button Clicked!”);
String var2;
switch((var2 = (String)this.sortlist.getValue()).hashCode()) {
case -1163486649:
if (var2.equals(“1.BubbleSort”)) {
(new BubbleSort()).algorithm(dataArrayList, sTransition, this.rectangle);
return;
}
break;
case -1093194161:
if (var2.equals(“2.QuickSort”)) {
(new QuickSort()).algorithm(dataArrayList, sTransition, this.rectangle);
return;
}
break;
case -102493006:
if (var2.equals(“3.InsertSort”)) {
(new InsertSort()).algorithm(dataArrayList, sTransition, this.rectangle);
return;
}
}

    (new BubbleSort()).algorithm(dataArrayList, sTransition, this.rectangle);
}

3.2.6 排序算法演示单步控制模块
//点击单步的控制模块
public void Step(ActionEvent event) {
System.out.println(“Step Button Clicked! “);
String var2;
switch((var2 = (String)this.sortlist.getValue()).hashCode()) {
case -1163486649:
if (var2.equals(“1.BubbleSort”)) {
(new BubbleSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
++count;
return;
}
break;
case -1093194161:
if (var2.equals(“2.QuickSort”)) {
(new QuickSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
++count;
return;
}
break;
case -102493006:
if (var2.equals(“3.InsertSort”)) {
(new InsertSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
++count;
return;
}
}

    (new BubbleSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
    ++count;
}

3.3提示显示模块
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;

public class TipsController implements Initializable {
@FXML
private AnchorPane tip;
@FXML
private Button tips;

public TipsController() {
}

public void initialize(URL location, ResourceBundle resources) {
}

public void show() {
    ImageView image = new ImageView("file:12.jpg");
    image.setFitHeight(285.0D);
    image.setFitWidth(351.0D);
    this.tip.getChildren().add(image);
    this.tip.setVisible(true);
}

public void ok(ActionEvent event) {
    ((Node)event.getSource()).getScene().getWindow().hide();
}

3.4 提示界面显示控制模块
public void start(Stage primaryStage) throws Exception {
try {
AnchorPane tipAnchorPane = (AnchorPane)FXMLLoader.load(this.getClass().getResource(“/application/Tips.fxml”));
primaryStage.setResizable(false);
primaryStage.setTitle(“Tip”);
primaryStage.setScene(new Scene(tipAnchorPane));
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.show();
} catch (Exception var3) {
var3.printStackTrace();
}

}

3.5 界面显示配置模块

    <?xml version="1.0" encoding="UTF-8"?>
3.6 提示界面配置模块 3.7程序流程

3.8 系统界面

图 数据显示界面

提示输入数据
四.调试分析
4.1 调试过程中所遇到的问题及解决方法
1)在刚开始接到课程设计题目的时候,想了很久,一开始的时候不知该往哪里着手。上网查阅了一些资料,查看了一些人的源码,随后自己根据别人的思路有了自己的清晰的想法。然后通过自己写的类设计并逐步加以完善,才将程序慢慢设计出来。自己也增加了一个功能单步的功能。

2)在写排序算法打过程出现了一些问题。比如,交换两个矩形坐标位置只是交换了形参,实际的位置并没有交换,导致我的实现的过程中很迷,后来我只能通过去写静态的属性去传参数才解决这个问题,但是这样也会产生一个问题就是无法实际一步一部控制程序,所以只能事先运行完整个程序后存放在一个数组里面,然后演示通过调用数组里面的参数去演示。
4.2 经验与体会
通过本次的课程设计,让我完整体验了一把自己一个单独完成一个小项目的整体的过程与流程。虽然自己写的程序并不是很好,但是可以给今后的自己的增加经验,为将来自己一个很好的历史教训,而且我通过本次的课程设计再次明白写程序不应该盲目下手,得完整理解自己到底想做成什么样子的,不能盲人过河,这样对整体的设计与开发都是有利的。
五.用户使用说明
(1)这次程序的编译环境是MyEclipse 8.x工具,java版本是jdk1.8执行的主文件是Main. java,同时还有包含7个文件:BubbleSort.java,InsertSort.java,QuickSort.java,Tips.java,TipsController.java,Myscene.fxml,Tips.xml
(2)程序可以选择输入自己的待排序的数据和由程序随机生成待排序的数据
(3)用户可以选择排序的算法。有冒泡排序,快排排序和插入排序。
(4)当点击RUN按钮后,可以点击STOP,但是点击STEP并没有用,点击STOP按钮后再次点击RUN按钮后可以继续演示。
(5) 当点击STEP按钮后不能再点击RUN和STEP按钮
(6) 当用户点击Inputover但是输入框里面并没有数据输入会提示用户输入数据。
六.测试结果

运行程序。然后弹出一个窗口如下图。
在输入框中输入数字。

点击“Ramdom”按扭,会显示数据。

七.参考文献

  1. https://blog.csdn.net/mouday/article/details/100186537
    八.附录
    package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {
public Main() {
}

public void start(Stage primaryStage) {
    try {
        Parent root = (Parent)FXMLLoader.load(this.getClass().getResource("/application/Myscene.fxml"));
        primaryStage.setResizable(false);
        primaryStage.setTitle("My Application");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    } catch (Exception var3) {
        var3.printStackTrace();
    }

}

public static void main(String[] args) {
    launch(args);
}

}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package application;

import algorithm.BubbleSort;
import algorithm.InsertSort;
import algorithm.QuickSort;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.ResourceBundle;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class MyController implements Initializable {
@FXML
private AnchorPane mainpane;
@FXML
private ComboBox sortlist;
@FXML
private Pane sortPane;
@FXML
private Button randomButton;
@FXML
private Button saveButton;
@FXML
private Button GetButton;
@FXML
private Button Intput_over_Button;
@FXML
private Button RunButton;
@FXML
private Button PauseButton;
@FXML
private Button StepButton;
@FXML
private TextField myTextField;
@FXML
private VBox explain;
static ArrayList dataArrayList = new ArrayList();
static SequentialTransition sTransition = new SequentialTransition();
ArrayList rectangle = new ArrayList();
ArrayList timeline = new ArrayList();
static int count = 0;

public MyController() {
}

public void initialize(URL location, ResourceBundle resources) {
    this.initchoice();
}

private void initchoice() {
    this.sortlist.getItems().addAll(new String[]{"1.BubbleSort", "2.QuickSort", "3.InsertSort"});
    this.sortlist.setValue("1.BubbleSort");
}

public void showData(ActionEvent event) throws Exception {
    System.out.println("input over Button Clicked!");
    this.clear();
    String getdata = this.myTextField.getText();
    System.out.println(getdata);
    if (getdata.equals("")) {
        (new Tips()).start(new Stage());
    } else {
        getdata.replaceAll(" ", ",");
        String[] var6;
        int var5 = (var6 = getdata.split(",")).length;

        int i;
        for(i = 0; i < var5; ++i) {
            String retval = var6[i];
            dataArrayList.add(Integer.parseInt(retval));
        }

        ImageView image = new ImageView("file:2.jpg");
        image.setFitHeight(432.0D);
        image.setFitWidth(777.0D);
        this.sortPane.getChildren().add(image);
        this.sortPane.setVisible(true);

        for(i = 0; i < dataArrayList.size(); ++i) {
            new Rectangle();
            Rectangle rec = new Rectangle();
            rec.setLayoutX((double)((i + 1) * 10));
            rec.setLayoutY(0.0D);
            rec.setWidth(5.0D);
            rec.setFill(Color.BLUE);
            rec.setHeight((double)((Integer)dataArrayList.get(i) * 5));
            this.sortPane.getChildren().add(rec);
            this.rectangle.add(rec);
        }
    }

}

public void savedata(ActionEvent event) throws IOException {
    String getdata = this.myTextField.getText();
    getdata.replaceAll(" ", ",");
    String file = "Data.txt";

    try {
        FileOutputStream inputFileOutputStream = new FileOutputStream(file, true);
        Iterator var6 = dataArrayList.iterator();

        while(var6.hasNext()) {
            Integer integer = (Integer)var6.next();
            String str = integer.toString();
            str = str + " ";
            byte[] b = str.getBytes();
            inputFileOutputStream.write(b);
        }

        inputFileOutputStream.close();
    } catch (FileNotFoundException var9) {
        var9.printStackTrace();
    }

}

public void randomdata(ActionEvent event) {
    System.out.println("Random Button Clicked!");
    this.clear();
    this.sortPane.setVisible(true);
    int random = 50;
    boolean var3 = false;

    while(random > 0) {
        int k = (int)(Math.random() * 100.0D);
        if (k > 0 && k < 85) {
            dataArrayList.add(k);
            --random;
        }
    }

    for(int i = 0; i < dataArrayList.size(); ++i) {
        new Rectangle();
        Rectangle rec = new Rectangle();
        rec.setLayoutX((double)((i + 1) * 10));
        rec.setLayoutY(0.0D);
        rec.setWidth(5.0D);
        rec.setFill(Color.BLUE);
        rec.setHeight((double)((Integer)dataArrayList.get(i) * 5));
        this.sortPane.getChildren().add(rec);
        this.rectangle.add(rec);
    }

}

public void start(ActionEvent event) {
    System.out.println("RUN Button Clicked!");
    String var2;
    switch((var2 = (String)this.sortlist.getValue()).hashCode()) {
    case -1163486649:
        if (var2.equals("1.BubbleSort")) {
            (new BubbleSort()).algorithm(dataArrayList, sTransition, this.rectangle);
            return;
        }
        break;
    case -1093194161:
        if (var2.equals("2.QuickSort")) {
            (new QuickSort()).algorithm(dataArrayList, sTransition, this.rectangle);
            return;
        }
        break;
    case -102493006:
        if (var2.equals("3.InsertSort")) {
            (new InsertSort()).algorithm(dataArrayList, sTransition, this.rectangle);
            return;
        }
    }

    (new BubbleSort()).algorithm(dataArrayList, sTransition, this.rectangle);
}

public void Step(ActionEvent event) {
    System.out.println("Step Button Clicked!  ");
    String var2;
    switch((var2 = (String)this.sortlist.getValue()).hashCode()) {
    case -1163486649:
        if (var2.equals("1.BubbleSort")) {
            (new BubbleSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
            ++count;
            return;
        }
        break;
    case -1093194161:
        if (var2.equals("2.QuickSort")) {
            (new QuickSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
            ++count;
            return;
        }
        break;
    case -102493006:
        if (var2.equals("3.InsertSort")) {
            (new InsertSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
            ++count;
            return;
        }
    }

    (new BubbleSort()).algorithmstep(dataArrayList, this.rectangle, count, this.timeline);
    ++count;
}

public void clear() {
    dataArrayList.clear();
    this.rectangle.clear();
    sTransition.getChildren().clear();
    count = 0;
}

public void Hideknow(ActionEvent event) {
    this.sortPane.setMouseTransparent(true);
    this.explain.setVisible(false);
    this.GetButton.setVisible(false);
}

public void Pause(ActionEvent event) {
    sTransition.pause();
}

}

package application;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class Tips extends Application {
public Tips() {
}

public void start(Stage primaryStage) throws Exception {
    try {
        AnchorPane tipAnchorPane = (AnchorPane)FXMLLoader.load(this.getClass().getResource("/application/Tips.fxml"));
        primaryStage.setResizable(false);
        primaryStage.setTitle("Tip");
        primaryStage.setScene(new Scene(tipAnchorPane));
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.show();
    } catch (Exception var3) {
        var3.printStackTrace();
    }

}

}

// // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) //

package application;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;

public class TipsController implements Initializable {
@FXML
private AnchorPane tip;
@FXML
private Button tips;

public TipsController() {
}

public void initialize(URL location, ResourceBundle resources) {
}

public void show() {
    ImageView image = new ImageView("file:12.jpg");
    image.setFitHeight(285.0D);
    image.setFitWidth(351.0D);
    this.tip.getChildren().add(image);
    this.tip.setVisible(true);
}

public void ok(ActionEvent event) {
    ((Node)event.getSource()).getScene().getWindow().hide();
}

}
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package application;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;

public class TipsController implements Initializable {
@FXML
private AnchorPane tip;
@FXML
private Button tips;

public TipsController() {
}

public void initialize(URL location, ResourceBundle resources) {
}

public void show() {
    ImageView image = new ImageView("file:12.jpg");
    image.setFitHeight(285.0D);
    image.setFitWidth(351.0D);
    this.tip.getChildren().add(image);
    this.tip.setVisible(true);
}

public void ok(ActionEvent event) {
    ((Node)event.getSource()).getScene().getWindow().hide();
}

}

package algorithm;

import java.util.ArrayList;
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

public class QuickSort extends Sort {
public QuickSort() {
}

public void algorithm(ArrayList<Integer> list, SequentialTransition sTransition, ArrayList<Rectangle> rectangle) {
    ArrayList<Timeline> timeline = new ArrayList();
    int[] data = new int[list.size()];

    int i;
    for(i = 0; i < list.size(); ++i) {
        data[i] = 0;
    }

    for(i = 0; i < list.size(); ++i) {
        int min = i;

        for(int j = i + 1; j < list.size(); ++j) {
            if ((Integer)list.get(min) > (Integer)list.get(j)) {
                min = j;
            }
        }

        if (i != min) {
            Timeline start = new Timeline();
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min])}), new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i])}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min] + (i - min) * 10)}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i] - (i - min) * 10)})});
            timeline.add(start);
            data[min] += (i - min) * 10;
            data[i] -= (i - min) * 10;
            int temp = (Integer)list.get(i);
            list.set(i, (Integer)list.get(min));
            list.set(min, temp);
            Rectangle temp2 = (Rectangle)rectangle.get(i);
            rectangle.set(i, (Rectangle)rectangle.get(min));
            rectangle.set(min, temp2);
            int temp3 = data[min];
            data[min] = data[i];
            data[i] = temp3;
        }
    }

    for(i = 0; i < timeline.size(); ++i) {
        sTransition.getChildren().add((Animation)timeline.get(i));
    }

    sTransition.setCycleCount(0);
    sTransition.setInterpolator(Interpolator.EASE_IN);
    sTransition.play();
}

public void algorithmstep(ArrayList<Integer> list, ArrayList<Rectangle> rectangle, int count, ArrayList<Timeline> timeline) {
    int[] data = new int[list.size()];

    int i;
    for(i = 0; i < list.size(); ++i) {
        data[i] = 0;
    }

    for(i = 0; i < list.size(); ++i) {
        int min = i;

        for(int j = i + 1; j < list.size(); ++j) {
            if ((Integer)list.get(min) > (Integer)list.get(j)) {
                min = j;
            }
        }

        if (i != min) {
            Timeline start = new Timeline();
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min])}), new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i])}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min] + (i - min) * 10)}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i] - (i - min) * 10)})});
            timeline.add(start);
            data[min] += (i - min) * 10;
            data[i] -= (i - min) * 10;
            int temp = (Integer)list.get(i);
            list.set(i, (Integer)list.get(min));
            list.set(min, temp);
            Rectangle temp2 = (Rectangle)rectangle.get(i);
            rectangle.set(i, (Rectangle)rectangle.get(min));
            rectangle.set(min, temp2);
            int temp3 = data[min];
            data[min] = data[i];
            data[i] = temp3;
        }
    }

    ((Timeline)timeline.get(count)).play();
}

}

package algorithm;

import java.util.ArrayList;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

public class InsertSort extends Sort {
public InsertSort() {
}

public void algorithm(ArrayList<Integer> list, SequentialTransition sTransition, ArrayList<Rectangle> rectangle) {
    ArrayList<Timeline> timeline = new ArrayList();
    ArrayList<Integer> displacement = new ArrayList();

    int current;
    for(current = 0; current < list.size(); ++current) {
        displacement.add(0);
    }

    int j;
    for(j = 0; j < list.size() - 1; ++j) {
        Rectangle temp = (Rectangle)rectangle.get(j + 1);
        current = (Integer)list.get(j + 1);
        int preIndex = j;
        Timeline start = new Timeline();

        boolean is;
        for(is = false; preIndex >= 0 && current < (Integer)list.get(preIndex); is = true) {
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(preIndex)).translateXProperty(), (Number)displacement.get(preIndex))}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(preIndex)).translateXProperty(), (Integer)displacement.get(preIndex) + 10)})});
            displacement.set(preIndex, (Integer)displacement.get(preIndex) + 10);
            --preIndex;
        }

        timeline.add(start);
        if (is) {
            int t1 = j - preIndex;
            start = new Timeline();
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(j + 1)).translateXProperty(), (Number)displacement.get(j + 1))}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(j + 1)).translateXProperty(), (Integer)displacement.get(j + 1) - t1 * 10)})});
            displacement.set(j + 1, (Integer)displacement.get(j + 1) - t1 * 10);
            list.remove(j + 1);
            list.add(preIndex + 1, current);
            rectangle.remove(j + 1);
            rectangle.add(preIndex + 1, temp);
            timeline.add(start);
            int tem3 = (Integer)displacement.get(j + 1);
            displacement.remove(j + 1);
            displacement.add(preIndex + 1, tem3);
        }
    }

    for(j = 0; j < timeline.size(); ++j) {
        sTransition.getChildren().add((Animation)timeline.get(j));
    }

    sTransition.play();
}

public void algorithmstep(ArrayList<Integer> list, ArrayList<Rectangle> rectangle, int count, ArrayList<Timeline> timeline) {
    if (count == 0) {
        ArrayList<Integer> displacement = new ArrayList();

        int current;
        for(current = 0; current < list.size(); ++current) {
            displacement.add(0);
        }

        for(int j = 0; j < list.size() - 1; ++j) {
            Rectangle temp = (Rectangle)rectangle.get(j + 1);
            current = (Integer)list.get(j + 1);
            int preIndex = j;
            Timeline start = new Timeline();

            boolean is;
            for(is = false; preIndex >= 0 && current < (Integer)list.get(preIndex); is = true) {
                start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(preIndex)).translateXProperty(), (Number)displacement.get(preIndex))}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(preIndex)).translateXProperty(), (Integer)displacement.get(preIndex) + 10)})});
                displacement.set(preIndex, (Integer)displacement.get(preIndex) + 10);
                --preIndex;
            }

            timeline.add(start);
            if (is) {
                int t1 = j - preIndex;
                start = new Timeline();
                start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(j + 1)).translateXProperty(), (Number)displacement.get(j + 1))}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(j + 1)).translateXProperty(), (Integer)displacement.get(j + 1) - t1 * 5)})});
                displacement.set(j + 1, (Integer)displacement.get(j + 1) - t1 * 10);
                list.remove(j + 1);
                list.add(preIndex + 1, current);
                rectangle.remove(j + 1);
                rectangle.add(preIndex + 1, temp);
                timeline.add(start);
                int tem3 = (Integer)displacement.get(j + 1);
                displacement.remove(j + 1);
                displacement.add(preIndex + 1, tem3);
            }
        }
    }

    ((Timeline)timeline.get(count)).play();
}

}
package algorithm;

import java.util.ArrayList;
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

public class QuickSort extends Sort {
public QuickSort() {
}

public void algorithm(ArrayList<Integer> list, SequentialTransition sTransition, ArrayList<Rectangle> rectangle) {
    ArrayList<Timeline> timeline = new ArrayList();
    int[] data = new int[list.size()];

    int i;
    for(i = 0; i < list.size(); ++i) {
        data[i] = 0;
    }

    for(i = 0; i < list.size(); ++i) {
        int min = i;

        for(int j = i + 1; j < list.size(); ++j) {
            if ((Integer)list.get(min) > (Integer)list.get(j)) {
                min = j;
            }
        }

        if (i != min) {
            Timeline start = new Timeline();
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min])}), new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i])}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min] + (i - min) * 10)}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i] - (i - min) * 10)})});
            timeline.add(start);
            data[min] += (i - min) * 10;
            data[i] -= (i - min) * 10;
            int temp = (Integer)list.get(i);
            list.set(i, (Integer)list.get(min));
            list.set(min, temp);
            Rectangle temp2 = (Rectangle)rectangle.get(i);
            rectangle.set(i, (Rectangle)rectangle.get(min));
            rectangle.set(min, temp2);
            int temp3 = data[min];
            data[min] = data[i];
            data[i] = temp3;
        }
    }

    for(i = 0; i < timeline.size(); ++i) {
        sTransition.getChildren().add((Animation)timeline.get(i));
    }

    sTransition.setCycleCount(0);
    sTransition.setInterpolator(Interpolator.EASE_IN);
    sTransition.play();
}

public void algorithmstep(ArrayList<Integer> list, ArrayList<Rectangle> rectangle, int count, ArrayList<Timeline> timeline) {
    int[] data = new int[list.size()];

    int i;
    for(i = 0; i < list.size(); ++i) {
        data[i] = 0;
    }

    for(i = 0; i < list.size(); ++i) {
        int min = i;

        for(int j = i + 1; j < list.size(); ++j) {
            if ((Integer)list.get(min) > (Integer)list.get(j)) {
                min = j;
            }
        }

        if (i != min) {
            Timeline start = new Timeline();
            start.getKeyFrames().addAll(new KeyFrame[]{new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min])}), new KeyFrame(Duration.ZERO, new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i])}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(min)).translateXProperty(), data[min] + (i - min) * 10)}), new KeyFrame(Duration.seconds(0.1D), new KeyValue[]{new KeyValue(((Rectangle)rectangle.get(i)).translateXProperty(), data[i] - (i - min) * 10)})});
            timeline.add(start);
            data[min] += (i - min) * 10;
            data[i] -= (i - min) * 10;
            int temp = (Integer)list.get(i);
            list.set(i, (Integer)list.get(min));
            list.set(min, temp);
            Rectangle temp2 = (Rectangle)rectangle.get(i);
            rectangle.set(i, (Rectangle)rectangle.get(min));
            rectangle.set(min, temp2);
            int temp3 = data[min];
            data[min] = data[i];
            data[i] = temp3;
        }
    }

    ((Timeline)timeline.get(count)).play();
}

}