<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.chart.LineChart?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<BorderPane fx:id="mainPane" prefHeight="867.0" prefWidth="1508.0" stylesheets="@css.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cz.vutbr.feec.xjanou19.GUIController">
   <top>
      <MenuBar style="-fx-background-color: #353434;" BorderPane.alignment="CENTER">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" onAction="#closeApp" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Info">
               <items>
                  <MenuItem mnemonicParsing="false" onAction="#displayAboutBox" text="About" />
               </items></Menu>
        </menus>
      </MenuBar>
   </top>
   <center>
      <TabPane fx:id="tabPane" onMousePressed="#handleTabSelection" prefHeight="974.0" prefWidth="1065.0" styleClass="root" stylesheets="@css.css">
         <tabs>
            <Tab closable="false" text="Curve Graph in R">
               <content>
                  <AnchorPane fx:id="graphPane" maxHeight="1031.0" maxWidth="1508.0" minHeight="400.0" minWidth="600.0" onMouseDragReleased="#sliderAmoved" prefHeight="937.0" prefWidth="1070.0" styleClass="root" stylesheets="cz/vutbr/feec/xjanou19/css.css">
                     <children>
                        <AnchorPane layoutY="8.0" prefHeight="551.0" prefWidth="659.0">
                           <children>
                              <LineChart fx:id="lineGraph" layoutX="89.0" layoutY="34.0" legendVisible="false" prefHeight="720.0" prefWidth="907.0">
                                <xAxis>
                                	<NumberAxis autoRanging="false" lowerBound="-10" side="BOTTOM" tickUnit="1" upperBound="10" />
                                </xAxis>
                                <yAxis>
                                  <NumberAxis autoRanging="false" lowerBound="-10" side="LEFT" tickUnit="1" upperBound="10" />
                                </yAxis>
                                <cursor>
                                   <Cursor fx:constant="CROSSHAIR" />
                                </cursor>
                              </LineChart>
                              <Label fx:id="labelTableDescription" alignment="CENTER" layoutX="1.0" layoutY="-8.0" prefHeight="28.0" prefWidth="1071.0" style="-fx-border-color: white;" text="Graph of Elliptic Curve in Real Numbers">
                                 <font>
                                    <Font size="17.0" />
                                 </font>
                              </Label>
                           </children>
                        </AnchorPane>
                     </children>
                  </AnchorPane>
               </content>
            </Tab>
            <Tab closable="false" text="Point Addition">
               <content>
                  <AnchorPane prefHeight="200.0" prefWidth="200.0" styleClass="root">
                     <children>
                        <ListView fx:id="selectedPoint1" layoutX="99.0" layoutY="64.0" prefHeight="46.0" prefWidth="92.0" />
                        <ListView fx:id="selectedPoint2" layoutX="287.0" layoutY="64.0" prefHeight="46.0" prefWidth="92.0" />
                        <Label layoutX="232.0" layoutY="74.0" text="+">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Button fx:id="pointAdditionButton" layoutX="410.0" layoutY="73.0" mnemonicParsing="false" onAction="#handlePointAdditionAction" prefHeight="29.0" prefWidth="73.0" text="=" textAlignment="CENTER" />
                        <ListView fx:id="resultPoint" layoutX="502.0" layoutY="64.0" prefHeight="46.0" prefWidth="92.0" />
                        <Label layoutX="89.0" layoutY="142.0" prefHeight="26.0" prefWidth="483.0" text="1. Select 2 points from the table to perform point addition">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Label layoutX="93.0" layoutY="302.0" prefHeight="26.0" prefWidth="290.0" text="You are in this situation:">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <ImageView fx:id="situationImage" fitHeight="248.0" fitWidth="339.0" layoutX="314.0" layoutY="191.0" pickOnBounds="true" preserveRatio="true" />
                        <Label alignment="CENTER" prefHeight="28.0" prefWidth="1074.0" style="-fx-border-color: white;" text="Point addition">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
               </content>
            </Tab>
            <Tab closable="false" text="Point Multiplication">
               <content>
                  <AnchorPane prefHeight="200.0" prefWidth="200.0" styleClass="root">
                     <children>
                        <Label alignment="CENTER" prefHeight="28.0" prefWidth="1074.0" style="-fx-border-color: white;" text="Scalar point multiplication">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <ComboBox fx:id="multiplicationComboBox" layoutX="99.0" layoutY="64.0" onAction="#multiplicationComboBoxChange" prefHeight="25.0" prefWidth="80.0" />
                        <ListView fx:id="multipliedPoint" layoutX="287.0" layoutY="64.0" prefHeight="46.0" prefWidth="92.0" />
                        <Label layoutX="232.0" layoutY="74.0" prefHeight="26.0" prefWidth="25.0" text="  *">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <ListView fx:id="resultMultiplicationPoint" layoutX="502.0" layoutY="64.0" prefHeight="46.0" prefWidth="92.0" />
                        <Button fx:id="pointMultiplicationButton" layoutX="410.0" layoutY="73.0" mnemonicParsing="false" onAction="#handlePointMultiplicationAction" prefHeight="29.0" prefWidth="73.0" text="=" textAlignment="CENTER" />
                        <Label alignment="CENTER" layoutX="62.0" layoutY="142.0" prefHeight="26.0" prefWidth="391.0" text="1. Select a point from the Table of Points first">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Label alignment="CENTER" layoutX="62.0" layoutY="168.0" prefHeight="26.0" prefWidth="333.0" text="2. Choose value from the ComboBox ">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Label alignment="CENTER" layoutX="78.0" layoutY="194.0" prefHeight="26.0" prefWidth="524.0" text="3. The only values available are 1 to n, where n is order of the point">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Label alignment="CENTER" layoutX="78.0" layoutY="220.0" prefHeight="26.0" prefWidth="753.0" text="4. That is because the order of the point defines where the multiplication enters into another cycle">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                        <Label alignment="CENTER" layoutX="78.0" layoutY="246.0" prefHeight="26.0" prefWidth="622.0" text="5. In other words: (n+1)*P = P, where P is point on the curve and n the order of P">
                           <font>
                              <Font size="17.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
               </content>
            </Tab>
            <Tab closable="false" text="EC-DH Setup">
              <content>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" styleClass="root">
                     <children>
                        <VBox prefHeight="945.0" prefWidth="1073.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                           <children>
                              <AnchorPane prefHeight="284.0" prefWidth="1071.0">
                                 <VBox.margin>
                                    <Insets />
                                 </VBox.margin>
                                 <children>
                                    <HBox alignment="CENTER_RIGHT" layoutX="1.0" layoutY="7.0" prefHeight="257.0" prefWidth="1070.0">
                                       <children>
                                          <AnchorPane prefHeight="433.0" prefWidth="429.0">
                                             <children>
                                                <ListView fx:id="selectedRootPoint" layoutX="163.0" layoutY="171.0" prefHeight="46.0" prefWidth="92.0" />
                                                <Label alignment="CENTER" layoutX="13.0" layoutY="132.0" prefHeight="28.0" prefWidth="393.0" style="-fx-border-color: white;" text="Root Point - choose from Table of Points">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                </Label>
                                             </children>
                                          </AnchorPane>
                                          <VBox prefHeight="433.0" prefWidth="564.0" style="-fx-background-color: #3e4444;">
                                             <HBox.margin>
                                                <Insets bottom="50.0" left="50.0" right="50.0" top="50.0" />
                                             </HBox.margin>
                                             <children>
                                                <Label alignment="CENTER" prefHeight="26.0" prefWidth="564.0" style="-fx-border-color: white;" text="Public parameters">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                </Label>
                                                <Label fx:id="labelDhField" prefHeight="26.0" prefWidth="563.0" text="Field characteristics - p :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <opaqueInsets>
                                                      <Insets />
                                                   </opaqueInsets>
                                                   <VBox.margin>
                                                      <Insets left="23.0" />
                                                   </VBox.margin>
                                                </Label>
                                                <Label fx:id="labelDhA" prefHeight="26.0" prefWidth="564.0" text="Curve parameter - a :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <VBox.margin>
                                                      <Insets left="45.0" />
                                                   </VBox.margin>
                                                </Label>
                                                <Label fx:id="labelDhB" alignment="BOTTOM_LEFT" prefHeight="26.0" prefWidth="564.0" text="Curve parameter - b :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <VBox.margin>
                                                      <Insets left="44.0" />
                                                   </VBox.margin>
                                                </Label>
                                                <Label fx:id="labelDhGenerator" prefHeight="26.0" prefWidth="564.0" text="root Point, generator - G :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <VBox.margin>
                                                      <Insets left="10.0" />
                                                   </VBox.margin>
                                                </Label>
                                                <Label fx:id="labelDhN" prefHeight="26.0" prefWidth="565.0" text="order of root Point - n :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <VBox.margin>
                                                      <Insets left="29.0" />
                                                   </VBox.margin>
                                                </Label>
                                                <Label fx:id="labelDhCofactor" prefHeight="26.0" prefWidth="564.0" text="Cofactor - h :">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                   <VBox.margin>
                                                      <Insets left="106.0" />
                                                   </VBox.margin>
                                                </Label>
                                             </children>
                                          </VBox>
                                       </children>
                                    </HBox>
                                    <Label alignment="CENTER" prefHeight="28.0" prefWidth="1073.0" style="-fx-border-color: white;" text="Elliptic-Curve Diffie-Helman key agreement protocol">
                                       <font>
                                          <Font size="17.0" />
                                       </font>
                                    </Label>
                                 </children>
                              </AnchorPane>
                              <HBox prefHeight="653.0" prefWidth="1082.0">
                                 <children>
                                    <AnchorPane>
                                       <children>
                                          <Label alignment="CENTER" layoutX="803.0" layoutY="36.0" prefHeight="28.0" prefWidth="95.0" text="Bob">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                          <Label alignment="CENTER" layoutX="127.0" layoutY="36.0" prefHeight="28.0" prefWidth="95.0" text="Alice">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                          <ImageView fx:id="aliceImage" fitHeight="104.0" fitWidth="95.0" layoutX="128.0" layoutY="64.0" pickOnBounds="true" preserveRatio="true" />
                                          <Label alignment="CENTER" prefHeight="28.0" prefWidth="1073.0" style="-fx-border-color: white;" text="Key exchange">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                          <ImageView fx:id="bobImage" fitHeight="104.0" fitWidth="95.0" layoutX="807.0" layoutY="64.0" pickOnBounds="true" preserveRatio="true" />
                                          <VBox layoutX="24.0" layoutY="168.0" prefHeight="267.0" prefWidth="324.0">
                                             <children>
                                                <Label alignment="CENTER" prefHeight="26.0" prefWidth="324.0" text="Choose private value 1≤ α ≤ n -1">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                </Label>
                                                <AnchorPane>
                                                   <children>
                                                      <ComboBox fx:id="alfaComboBox" layoutX="109.0" layoutY="-1.0" onAction="#alfaComboBoxChange" prefHeight="31.0" prefWidth="71.0" />
                                                   </children>
                                                </AnchorPane>
                                                <AnchorPane>
                                                   <children>
                                                      <Label fx:id="labelATimesValue" prefHeight="92.0" prefWidth="84.0" text="A =">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="selectedRootPointAlice" layoutX="70.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                      <Label layoutX="183.0" layoutY="33.0" text="=">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedAPoint" layoutX="218.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                   </children>
                                                </AnchorPane>
                                                <AnchorPane>
                                                   <children>
                                                      <Label fx:id="labelPTimesValue1" prefHeight="92.0" prefWidth="84.0" text="K =">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedBPoint2" layoutX="70.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                      <Label layoutX="183.0" layoutY="33.0" text="=">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedPPoint" layoutX="218.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                   </children>
                                                </AnchorPane>
                                             </children>
                                          </VBox>
                                          <VBox layoutX="689.0" layoutY="168.0" prefHeight="267.0" prefWidth="324.0">
                                             <children>
                                                <Label alignment="CENTER" prefHeight="26.0" prefWidth="324.0" text="Choose private value 1≤ β ≤ n -1">
                                                   <font>
                                                      <Font size="17.0" />
                                                   </font>
                                                </Label>
                                                <AnchorPane>
                                                   <children>
                                                      <ComboBox fx:id="betaComboBox" layoutX="109.0" layoutY="-1.0" onAction="#betaComboBoxChange" prefHeight="31.0" prefWidth="71.0" />
                                                   </children>
                                                </AnchorPane>
                                                <AnchorPane>
                                                   <children>
                                                      <Label fx:id="labelBTimesValue" prefHeight="92.0" prefWidth="84.0" text="B =">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="selectedRootPointBob" layoutX="70.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                      <Label layoutX="183.0" layoutY="33.0" text="=">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedBPoint" layoutX="218.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                   </children>
                                                </AnchorPane>
                                                <AnchorPane>
                                                   <children>
                                                      <Label fx:id="labelPTimesValue2" prefHeight="92.0" prefWidth="84.0" text="K =">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedAPoint2" layoutX="70.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                      <Label layoutX="183.0" layoutY="33.0" text="=">
                                                         <font>
                                                            <Font size="17.0" />
                                                         </font>
                                                      </Label>
                                                      <ListView fx:id="calculatedPPoint1" layoutX="218.0" layoutY="23.0" prefHeight="46.0" prefWidth="92.0" />
                                                   </children>
                                                </AnchorPane>
                                             </children>
                                          </VBox>
                                          <ImageView fx:id="rightArrowImage" fitHeight="22.0" fitWidth="293.0" layoutX="369.0" layoutY="288.0" pickOnBounds="true" preserveRatio="true" />
                                          <Label alignment="CENTER" layoutX="455.0" layoutY="260.0" prefHeight="28.0" prefWidth="121.0" text="Send A to Bob">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                          <ImageView fx:id="leftArrowImage" fitHeight="22.0" fitWidth="293.0" layoutX="369.0" layoutY="318.0" pickOnBounds="true" preserveRatio="true" />
                                          <Label alignment="CENTER" layoutX="455.0" layoutY="334.0" prefHeight="28.0" prefWidth="121.0" text="Send B to Alice">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                          <Button fx:id="dhButton" layoutX="431.0" layoutY="374.0" mnemonicParsing="false" onAction="#handleDhButtonAction" prefHeight="29.0" prefWidth="170.0" text="Compute" textAlignment="CENTER" />
                                          <ListView fx:id="finalDisplayPoint" layoutX="470.0" layoutY="436.0" prefHeight="46.0" prefWidth="92.0" />
                                          <Label alignment="CENTER" layoutX="40.0" layoutY="446.0" prefHeight="26.0" prefWidth="391.0" text="The shared secret point K, established by EC-DH is:">
                                             <font>
                                                <Font size="17.0" />
                                             </font>
                                          </Label>
                                       </children>
                                    </AnchorPane>
                                 </children>
                              </HBox>
                           </children>
                        </VBox>
                     </children>
                  </AnchorPane>
              </content>
            </Tab>
         </tabs>
      </TabPane>
   </center>
   <right>
      <AnchorPane prefHeight="946.0" prefWidth="438.0" stylesheets="@css.css" BorderPane.alignment="CENTER">
         <children>
            <VBox prefHeight="392.0" prefWidth="435.0" spacing="10.0" style="-fx-border-color: white;" styleClass="root">
               <children>
                  <Label alignment="CENTER" prefHeight="30.0" prefWidth="436.0" text="Elltiptic Curve defined by: y^2 = x^3 + ax + b" textAlignment="JUSTIFY">
                     <font>
                        <Font size="20.0" />
                     </font>
                  </Label>
                  <Label fx:id="labelAValue" text="a=0">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin>
                  </Label>
                  <Slider fx:id="sliderA" majorTickUnit="1.0" max="10.0" min="-10.0" minorTickCount="0" onMouseClicked="#sliderAmoved" onMouseDragReleased="#sliderAmoved" prefHeight="72.0" prefWidth="227.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" />
                  <Label fx:id="labelBValue" text="b=0">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin>
                  </Label>
                  <Slider fx:id="sliderB" majorTickUnit="1.0" max="10.0" min="-10.0" minorTickCount="0" onMouseClicked="#sliderBmoved" onMouseDragReleased="#sliderBmoved" prefHeight="72.0" prefWidth="204.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" />
                  <Label fx:id="labelFieldValue" prefHeight="26.0" prefWidth="200.0" text="Finite Field Characteristics">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin>
                  </Label>
                  <ComboBox fx:id="fieldComboBox" onAction="#fieldComboBoxChange" prefHeight="25.0" prefWidth="80.0">
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin></ComboBox>
                  <Label fx:id="labelWarning" alignment="CENTER" prefHeight="17.0" prefWidth="454.0">
                     <font>
                        <Font size="17.0" />
                     </font>
                  </Label>
                  <Button fx:id="getButton" mnemonicParsing="false" onAction="#handleGetButtonAction" prefHeight="29.0" prefWidth="170.0" text="Get Curve Details" textAlignment="CENTER">
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin></Button>
                  <Label fx:id="labelOrderCurve" prefHeight="26.0" prefWidth="436.0" text="The order of the curve (The number of points) is:">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin>
                  </Label>
                  <Label fx:id="labelPossibleOrders" prefHeight="26.0" prefWidth="427.0" text="Possible orders of points are: ">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" />
                     </VBox.margin>
                  </Label>
                  <TextField fx:id="textFieldPossibleOrders">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" right="10.0" />
                     </VBox.margin>
                  </TextField>
                  <Label alignment="CENTER" prefHeight="26.0" prefWidth="427.0" style="-fx-border-color: white;" text="Table of Points">
                     <font>
                        <Font size="17.0" />
                     </font>
                     <VBox.margin>
                        <Insets left="10.0" right="10.0" />
                     </VBox.margin>
                  </Label>
                  <AnchorPane prefHeight="415.0" prefWidth="435.0">
                     <children>
                        <TableView fx:id="tableOfPoints" onMousePressed="#handlePointClicked" prefHeight="339.0" prefWidth="435.0" stylesheets="@css.css">
                          <columns>
                            <TableColumn fx:id="pointColumn" prefWidth="212.0" text="Point coordinates" />
                            <TableColumn fx:id="pointInfoColumn" prefWidth="221.0" text="Order of point" />
                          </columns>
                        </TableView>
                     </children>
                  </AnchorPane>
               </children>
            </VBox>
         </children>
         <BorderPane.margin>
            <Insets top="28.0" />
         </BorderPane.margin>
      </AnchorPane>
   </right>
</BorderPane>
