├── Calculator_Kotlin_TornadoFx ├── Calculator_Kotlin_TornadoFx.iml ├── pom.xml ├── src │ └── main │ │ └── kotlin │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ └── com │ │ └── example │ │ └── demo │ │ ├── Controller │ │ ├── Functions.kt │ │ └── test.kt │ │ ├── app │ │ ├── 1.png │ │ ├── MyApp.kt │ │ └── Styles.kt │ │ └── view │ │ ├── 1.png │ │ ├── Integral.kt │ │ └── MainView.kt └── tornadofx-maven-project.iml └── README.md /Calculator_Kotlin_TornadoFx/Calculator_Kotlin_TornadoFx.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.example 8 | tornadofx-maven-project 9 | 1.0 10 | jar 11 | 12 | 13 | 1.4.32 14 | 1.7.20 15 | 16 | 17 | 18 | 19 | no.tornado 20 | tornadofx 21 | ${tornadofx.version} 22 | 23 | 24 | org.jetbrains.kotlin 25 | kotlin-stdlib 26 | ${kotlin.version} 27 | 28 | 29 | org.jetbrains.kotlin 30 | kotlin-test 31 | ${kotlin.version} 32 | test 33 | 34 | 35 | 36 | 37 | src/main/kotlin 38 | 39 | 40 | org.jetbrains.kotlin 41 | kotlin-maven-plugin 42 | ${kotlin.version} 43 | 44 | 45 | compile 46 | compile 47 | 48 | compile 49 | 50 | 51 | 1.8 52 | 53 | 54 | 55 | test-compile 56 | test-compile 57 | 58 | test-compile 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.example.demo.app.MyApp 3 | 4 | -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/Controller/Functions.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.Controller 2 | 3 | import com.example.demo.view.Integral 4 | import kotlin.math.PI 5 | import kotlin.math.cos 6 | import kotlin.math.pow 7 | import kotlin.math.sin 8 | 9 | class Functions { 10 | 11 | fun plus(numbers: List) : String 12 | { 13 | var result = "" ; var num1 : String ; var num2 : String 14 | val n1 : Int ; val n2 : Int 15 | var negative = false 16 | 17 | 18 | if ( numbers[0][0] == '-' && numbers[1][0] == '-'){ 19 | 20 | val x = listOf( numbers[0].substring(1) , numbers[1].substring(1) ) 21 | var result = plus(x) 22 | result = result.reversed() 23 | result += "-" 24 | result = result.reversed() 25 | 26 | return result 27 | } else if ( numbers[0][0] == '-' ){ 28 | 29 | val x = listOf( numbers[0].substring(1) , numbers[1] ) 30 | val negative = bigNumber(x) 31 | result = minus(x) 32 | if ( negative ){ 33 | result = result.reversed() 34 | result += "-" 35 | result = result.reversed() 36 | } 37 | 38 | return result 39 | } else if ( numbers[1][0] == '-' ){ 40 | 41 | val x = listOf( numbers[0] , numbers[1].substring(1) ) 42 | result = minus(x) 43 | 44 | return result 45 | } 46 | 47 | // make sure num2 is longer than num1 48 | if ( numbers[0].length > numbers[1].length ) { 49 | 50 | num2 = numbers[0] ; n2 = num2.length 51 | num1 = numbers[1] ; n1 = num1.length 52 | } else { 53 | 54 | num2 = numbers[1] ; n2 = num2.length 55 | num1 = numbers[0] ; n1 = num1.length 56 | } 57 | 58 | num2 = num2.reversed() 59 | num1 = num1.reversed() 60 | 61 | var carry = 0 62 | for ( i in 0 until n1 ) 63 | { 64 | val sum = (num2[i] - '0') + (num1[i] - '0') + carry 65 | result += ( sum % 10 ).toString() 66 | carry = sum/10 67 | } 68 | 69 | for ( i in n1 until n2 ) 70 | { 71 | val sum = ( num2[i] - '0' ) + carry 72 | result += ( sum % 10 ).toString() 73 | carry = sum / 10 74 | } 75 | 76 | if ( carry > 0){ 77 | 78 | result += carry.toString() 79 | } 80 | 81 | result = result.reversed() 82 | 83 | if ( negative ){ 84 | 85 | result = result.substring(1) 86 | } 87 | 88 | return result 89 | } 90 | 91 | fun minus(numbers: List) : String 92 | { 93 | var num1 : String ; var num2 : String 94 | var result = "" ; var sum : Int 95 | val negative : Boolean 96 | 97 | if ( numbers[0][0] == '-' && numbers[1][0] == '-'){ 98 | 99 | val x = listOf( numbers[0] , numbers[1].substring(1) ) 100 | val result = plus(x) 101 | 102 | return result 103 | } 104 | 105 | 106 | if ( bigNumber(numbers) ){ 107 | 108 | negative = false 109 | num1 = numbers[0] 110 | num2 = numbers[1] 111 | }else { 112 | 113 | negative = true 114 | num1 = numbers[1] 115 | num2 = numbers[0] 116 | } 117 | 118 | num1 = num1.reversed() 119 | num2 = num2.reversed() 120 | 121 | 122 | 123 | var carry = 0 124 | for ( i in num2.indices) 125 | { 126 | sum = ( num1[i] - '0' ) - ( num2[i] - '0' ) - carry 127 | 128 | if ( sum < 0 ) 129 | { 130 | sum += 10 131 | carry = 1 132 | }else{ 133 | 134 | carry = 0 135 | } 136 | 137 | result += sum.toString() 138 | } 139 | 140 | for ( i in num2.length until num1.length ) 141 | { 142 | sum = ( num1[i] - '0' ) - carry 143 | 144 | if ( sum < 0 ){ 145 | 146 | sum += 10 147 | carry = 1 148 | } else { 149 | 150 | carry = 0 151 | } 152 | 153 | result += sum.toString() 154 | } 155 | 156 | if ( negative ) 157 | { 158 | result += "-" 159 | } 160 | 161 | result = result.reversed() 162 | 163 | while ( result[0] == '0' && result.length > 1 ) 164 | { 165 | result = result.substring(1) 166 | } 167 | 168 | 169 | return result 170 | } 171 | 172 | private fun bigNumber(numbers: List) : Boolean 173 | { 174 | 175 | if ( numbers[0].length > numbers[1].length ){ 176 | return true 177 | } 178 | if ( numbers[1].length > numbers[0].length ){ 179 | return false 180 | } 181 | 182 | // if both have same length 183 | for ( i in numbers[0].indices){ 184 | 185 | if ( numbers[0][i] > numbers[1][i] ){ 186 | return true 187 | } else if ( numbers[0][i] < numbers[1][i] ){ 188 | return false 189 | } 190 | } 191 | 192 | return true 193 | } 194 | 195 | fun multi(numbers: List) : String 196 | { 197 | var result = "" 198 | var num1 = numbers[0] ; var num2 = numbers[1] 199 | 200 | if ( numbers[0][0] == '-' && numbers[0][0] == '-' ){ 201 | 202 | num1 = num1.substring(1) 203 | num2 = num2.substring(1) 204 | 205 | } else if ( numbers[0][0] == '-' ){ 206 | 207 | num1 = num1.substring(1) 208 | 209 | } else if ( numbers[1][0] == '-' ){ 210 | 211 | num2 = num2.substring(1) 212 | } 213 | 214 | num1 = num1.reversed() 215 | num2 = num2.reversed() 216 | 217 | val myArray = Array( (num1.length+num2.length) ){0} 218 | 219 | for ( i in num1.indices) 220 | { 221 | for ( j in num2.indices) 222 | { 223 | myArray[i+j] += ( num1[i] - '0' ) * ( num2[j] - '0' ) 224 | } 225 | } 226 | 227 | for ( i in myArray.indices) 228 | { 229 | val digit = myArray[i] % 10 230 | val carry = myArray[i] / 10 231 | 232 | if ( i+1 < myArray.size ) 233 | { 234 | myArray[i+1] = myArray[i+1] + carry 235 | } 236 | 237 | result = digit.toString() + result 238 | } 239 | 240 | while ( result.length > 1 && result[0] == '0' ) 241 | { 242 | result = result.substring(1) 243 | } 244 | 245 | return result 246 | } 247 | 248 | fun divide(numbers: List) : String 249 | { 250 | var x = mutableListOf() 251 | val y = mutableListOf( "0" , "1" ) 252 | var negative = false 253 | 254 | if ( numbers[0][0] == '-' && numbers[1][0] == '-' ) 255 | { 256 | x = mutableListOf( numbers[0].substring(1) , numbers[1].substring(1) ) 257 | negative = false 258 | 259 | } else if ( numbers[0][0] == '-' ) 260 | { 261 | x = mutableListOf( numbers[0].substring(1) , numbers[1] ) 262 | negative = true 263 | 264 | } else if ( numbers[1][0] == '-' ) 265 | { 266 | x = mutableListOf( numbers[0] , numbers[1].substring(1) ) 267 | negative = true 268 | } else { 269 | 270 | x = mutableListOf( numbers[0] , numbers[1] ) 271 | } 272 | 273 | while ( x[0] >= "0" ) 274 | { 275 | x[0] = minus(x) 276 | y[0] = plus(y) 277 | } 278 | 279 | if ( x[0] < "0" ) 280 | { 281 | val z = listOf( y[0] , "1" ) 282 | x[0] = plus(x) 283 | x[0] = x[0].substring(1) 284 | y[0] = minus(z) 285 | } 286 | 287 | if ( negative ) 288 | { 289 | y[0] = y[0].reversed() 290 | y[0] += "-" 291 | y[0] = y[0].reversed() 292 | 293 | if ( x[0] != "0" ) 294 | { 295 | x[0] = x[0].reversed() 296 | x[0] += "-" 297 | x[0] = x[0].reversed() 298 | } 299 | 300 | } 301 | 302 | while ( x[0].length > 1 && x[0][0] == '0' ){ 303 | 304 | x[0] = x[0].substring(1) 305 | } 306 | 307 | return "quotient = " + y[0] + "\nremaining = " + x[0] 308 | } 309 | 310 | fun calculate_integral(integral: Integral) 311 | { 312 | 313 | val x0 : Double = if ( integral.x0TF.text.isNullOrEmpty() ){ 314 | 0.0 315 | } else { 316 | integral.x0TF.text.toDouble() 317 | } 318 | 319 | val x1 : Double = if ( integral.x1TF.text.isNullOrEmpty() ){ 320 | 0.0 321 | } else { 322 | integral.x1TF.text.toDouble() 323 | } 324 | 325 | val x2 : Double = if ( integral.x2TF.text.isNullOrEmpty() ){ 326 | 0.0 327 | } else { 328 | integral.x2TF.text.toDouble() 329 | } 330 | 331 | val x3 : Double = if ( integral.x3TF.text.isNullOrEmpty() ){ 332 | 0.0 333 | } else { 334 | integral.x3TF.text.toDouble() 335 | } 336 | 337 | val x4 : Double = if ( integral.x4TF.text.isNullOrEmpty() ){ 338 | 0.0 339 | } else { 340 | integral.x4TF.text.toDouble() 341 | } 342 | 343 | val x5 : Double = if ( integral.x5TF.text.isNullOrEmpty() ){ 344 | 0.0 345 | } else { 346 | integral.x5TF.text.toDouble() 347 | } 348 | 349 | val x6 : Double = if ( integral.x6TF.text.isNullOrEmpty() ){ 350 | 0.0 351 | } else { 352 | integral.x6TF.text.toDouble() 353 | } 354 | 355 | val x7 : Double = if ( integral.x7TF.text.isNullOrEmpty() ){ 356 | 0.0 357 | } else { 358 | integral.x7TF.text.toDouble() 359 | } 360 | 361 | val x8 : Double = if ( integral.x8TF.text.isNullOrEmpty() ){ 362 | 0.0 363 | } else { 364 | integral.x8TF.text.toDouble() 365 | } 366 | 367 | val x9 : Double = if ( integral.x9TF.text.isNullOrEmpty() ){ 368 | 0.0 369 | } else { 370 | integral.x9TF.text.toDouble() 371 | } 372 | 373 | val x10 : Double = if ( integral.x10TF.text.isNullOrEmpty() ){ 374 | 0.0 375 | } else { 376 | integral.x10TF.text.toDouble() 377 | } 378 | 379 | 380 | val up : Double = integral.upperCase.text.toDouble() 381 | val low : Double = integral.lowerCase.text.toDouble() 382 | 383 | val result : Double 384 | 385 | val up_Sum : Double = ( x0*up ) + ( up.pow(2.0) * (x1/2) ) + ( up.pow(3.0) * (x2/3) ) + ( up.pow(4.0) * (x3/4) ) + 386 | ( up.pow(5.0) * (x4/5) ) + ( up.pow(6.0) * (x5/6) ) + ( up.pow(7.0) * (x6/7) ) + 387 | ( up.pow(8.0) * (x7/8) ) + ( up.pow(9.0) * (x8/9) ) + ( up.pow(10.0) * (x9/10) ) + ( up.pow(11.0) * (x10/11) ) 388 | 389 | val low_Sum : Double = ( x0*low ) + ( low.pow(2.0) * (x1/2) ) + ( low.pow(3.0) * (x2/3) ) + ( low.pow(4.0) * (x3/4) ) + 390 | ( low.pow(5.0) * (x4/5) ) + ( low.pow(6.0) * (x5/6) ) + ( low.pow(7.0) * (x6/7) ) + 391 | ( low.pow(8.0) * (x7/8) ) + ( low.pow(9.0) * (x8/9) ) + ( low.pow(10.0) * (x9/10) ) + ( low.pow(11.0) * (x10/11) ) 392 | 393 | result = ( up_Sum - low_Sum ) 394 | integral.resultTF.text = result.toString() 395 | } 396 | 397 | fun sinX(n : Double) : String 398 | { 399 | if ( n % 180.0 == 0.0 ){ 400 | return "0.0" 401 | } 402 | val rad = ( n / 180.0 ) * PI 403 | 404 | return sin( rad ).toString() 405 | } 406 | 407 | fun cosX(n : Double) : String 408 | { 409 | if ( n % 90.0 == 0.0 && n% 180.0 != 0.0){ 410 | return "0.0" 411 | } 412 | val rad = ( n / 180.0 ) * PI 413 | 414 | return cos( rad ).toString() 415 | } 416 | 417 | fun tanX(n : Double) : String 418 | { 419 | return ( sinX(n).toDouble() / cosX(n).toDouble() ).toString() 420 | } 421 | 422 | fun cotX(n : Double) : String 423 | { 424 | return ( cosX(n).toDouble() / sinX(n).toDouble() ).toString() 425 | } 426 | 427 | fun pow(numbers: List) : String 428 | { 429 | val x = numbers[0] 430 | var y = numbers[1] 431 | var z = x 432 | 433 | while ( minus( mutableListOf(y,"1") ) != "0" ){ 434 | 435 | z = multi( mutableListOf( z,x ) ) 436 | y = minus( mutableListOf( y,"1" ) ) 437 | } 438 | 439 | return z 440 | } 441 | 442 | fun fac(num : String) : String 443 | { 444 | var x = num 445 | var z = "1" 446 | 447 | while ( x != "0" ) 448 | { 449 | z = multi( mutableListOf( z , x ) ) 450 | x = minus( mutableListOf( x ,"1" ) ) 451 | } 452 | 453 | return z 454 | } 455 | 456 | fun abs(num : String) : String 457 | { 458 | var x = num 459 | while ( x[0] == '-' || x[0] == '+' ) 460 | { 461 | x = x.substring(1) 462 | } 463 | 464 | return x 465 | } 466 | 467 | 468 | 469 | } 470 | 471 | -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/Controller/test.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.Controller 2 | 3 | import tornadofx.* 4 | 5 | fun main() { 6 | 7 | val p = Functions() 8 | 9 | var x = "5" 10 | var z = "1" 11 | 12 | while ( x != "0" ) 13 | { 14 | z = p.multi( mutableListOf( z , x ) ) 15 | x = p.minus( mutableListOf( x ,"1" ) ) 16 | } 17 | 18 | println(z) 19 | 20 | } -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/app/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Amir-devs/BigNumber-Calculator/5d52adae7216950277dc725164d69b8b9c764cd2/Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/app/1.png -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/app/MyApp.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.app 2 | 3 | import com.example.demo.view.MainView 4 | import javafx.scene.image.Image 5 | import tornadofx.* 6 | 7 | open class MyApp: App(MainView::class, Styles::class){ 8 | } 9 | 10 | 11 | -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/app/Styles.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.app 2 | 3 | import javafx.scene.text.FontWeight 4 | import tornadofx.Stylesheet 5 | import tornadofx.box 6 | import tornadofx.cssclass 7 | import tornadofx.px 8 | 9 | class Styles : Stylesheet() { 10 | companion object { 11 | val heading by cssclass() 12 | } 13 | 14 | init { 15 | label and heading { 16 | padding = box(10.px) 17 | fontSize = 20.px 18 | fontWeight = FontWeight.BOLD 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/view/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Amir-devs/BigNumber-Calculator/5d52adae7216950277dc725164d69b8b9c764cd2/Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/view/1.png -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/view/Integral.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.view 2 | 3 | import com.example.demo.Controller.Functions 4 | import javafx.scene.image.Image 5 | import tornadofx.* 6 | import kotlin.math.PI 7 | import kotlin.math.sin 8 | 9 | class Integral : View("Integral") 10 | { 11 | init { 12 | setStageIcon(Image("https://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/WPint.svg/1200px-WPint.svg.png")) 13 | } 14 | 15 | private val integral = "\u222B" 16 | private var up = vbox() 17 | 18 | val x0TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 19 | private val x0 = hbox { 20 | spacing = 5.0 21 | add(x0TF) 22 | add( label { text = "X^0" }) 23 | } 24 | 25 | val x1TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 26 | private val x1 = hbox { 27 | spacing = 5.0 28 | add(x0) 29 | add( label { text = "+" }) 30 | add(x1TF) 31 | add( label { text = "X^1" }) 32 | } 33 | 34 | val x2TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 35 | private val x2 = hbox { 36 | spacing = 5.0 37 | add(x1) 38 | add( label { text = "+" }) 39 | add(x2TF) 40 | add( label { text = "X^2" }) 41 | } 42 | 43 | val x3TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 44 | private val x3 = hbox { 45 | spacing = 5.0 46 | add(x3TF) 47 | add( label { text = "X^3" }) 48 | } 49 | private val plus3Box = hbox { 50 | spacing = 5.0 51 | add(x2) 52 | add(label { text = "+" }) 53 | } 54 | 55 | val x4TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 56 | private val x4 = hbox { 57 | spacing = 5.0 58 | add(x3) 59 | add( label { text = "+" }) 60 | add(x4TF) 61 | add( label { text = "X^4" }) 62 | } 63 | 64 | val x5TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 65 | private val x5 = hbox { 66 | spacing = 5.0 67 | add(x4) 68 | add( label { text = "+" }) 69 | add(x5TF) 70 | add( label { text = "X^5" }) 71 | } 72 | 73 | private val plus6Box = hbox { 74 | spacing = 5.0 75 | add(x5) 76 | add(label { text = "+" }) 77 | } 78 | val x6TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 79 | private val x6 = hbox { 80 | spacing = 5.0 81 | add(x6TF) 82 | add( label { text = "X^6" }) 83 | } 84 | 85 | val x7TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 86 | private val x7 = hbox { 87 | spacing = 5.0 88 | add(x6) 89 | add( label { text = "+" }) 90 | add(x7TF) 91 | add( label { text = "X^7" }) 92 | } 93 | 94 | val x8TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 95 | private val x8 = hbox { 96 | spacing = 5.0 97 | add(x7) 98 | add( label { text = "+" }) 99 | add(x8TF) 100 | add( label { text = "X^8" }) 101 | } 102 | 103 | private val plus9Box = hbox { 104 | spacing = 5.0 105 | add(x8) 106 | add(label { text = "+" }) 107 | } 108 | val x9TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 109 | private val x9 = hbox { 110 | spacing = 5.0 111 | add(x9TF) 112 | add( label { text = "X^9" }) 113 | } 114 | 115 | val x10TF = textfield { style = "-fx-font-size: 10px ; -fx-background-radius: 50 ; -fx-font-size: 10px " ; setPrefSize(60.0,20.0) } 116 | private val x10 = hbox { 117 | spacing = 5.0 118 | add(x9) 119 | add( label { text = "+" }) 120 | add(x10TF) 121 | add( label { text = "X^10" }) 122 | } 123 | 124 | 125 | private val calculateBTN = button { 126 | text = "Calculate" 127 | style = "-fx-alignment: center ; -fx-background-radius: 50 ; -fx-font-weight: bold " 128 | action { 129 | val function = Functions() 130 | function.calculate_integral(this@Integral) 131 | } 132 | } 133 | 134 | val resultTF = textfield { 135 | style = "-fx-font-size: 20px ; -fx-background-radius: 50" 136 | } 137 | 138 | private val resultBox = vbox { 139 | spacing = 5.0 140 | add(resultTF) 141 | add(calculateBTN) 142 | } 143 | 144 | val upperCase = textfield { 145 | style = "-fx-font-size: 20px ; -fx-background-radius: 50" 146 | } 147 | val lowerCase = textfield { 148 | style = "-fx-font-size: 20px ; -fx-background-radius: 50" 149 | } 150 | 151 | 152 | private fun showDegree(number : Int) 153 | { 154 | when ( number ) 155 | { 156 | 0 -> { up.add(x0) ; up.add(resultBox) } 157 | 1 -> { up.add(x1) ; up.add(resultBox) } 158 | 2 -> { up.add(x2) ; up.add(resultBox) } 159 | 3 -> { up.add(plus3Box) ; up.add(x3) ; up.add(resultBox) } 160 | 4 -> { up.add(plus3Box) ; up.add(x4) ; up.add(resultBox) } 161 | 5 -> { up.add(plus3Box) ; up.add(x5) ; up.add(resultBox) } 162 | 6 -> { up.add(plus3Box) ; up.add(plus6Box) ; up.add(x6) ; up.add(resultBox) } 163 | 7 -> { up.add(plus3Box) ; up.add(plus6Box) ; up.add(x7) ; up.add(resultBox) } 164 | 8 -> { up.add(plus3Box) ; up.add(plus6Box) ; up.add(x8) ; up.add(resultBox) } 165 | 9 -> { up.add(plus3Box) ; up.add(plus6Box) ; up.add(plus9Box) ; up.add(x9) ; up.add(resultBox) } 166 | 10 -> { up.add(plus3Box) ; up.add(plus6Box) ; up.add(plus9Box) ; up.add(x10) ; up.add(resultBox) } 167 | } 168 | } 169 | 170 | override val root = anchorpane() { 171 | 172 | // style = "-fx-background-color: #3FEC9F" 173 | style = "-fx-background-color: #27C9FF" 174 | 175 | 176 | setMinSize(500.0 , 600.0) 177 | 178 | val upCase = vbox { 179 | style = "-fx-alignment: center" 180 | add( label { text = " Upper Case : " ; style = "-fx-font-weight: bold"} ) 181 | add( upperCase ) 182 | } 183 | 184 | val lowCase = vbox { 185 | style = "-fx-alignment: center" 186 | add(label { text = " Lower Case : " ; style = "-fx-font-weight: bold"} ) 187 | add( lowerCase ) 188 | } 189 | 190 | val case = vbox { 191 | spacing = 20.0 192 | add( upCase ) 193 | add( lowCase ) 194 | } 195 | 196 | val shape = hbox { 197 | 198 | add( label { text = integral ; style = "-fx-font-size : 110px"} ) 199 | add( case ) 200 | } 201 | 202 | val degreeTF = textfield { 203 | style = "-fx-font-size: 10px ; -fx-background-radius: 50" 204 | } 205 | 206 | val submit = button { 207 | text = "Submit" 208 | style = "-fx-alignment: center ; -fx-background-radius: 50 ; -fx-font-weight: bold " 209 | action { showDegree( degreeTF.text.toInt() ) } 210 | } 211 | 212 | val degree = hbox { 213 | spacing = 10.0 214 | add( label { text = " Enter degree :" ; style = "-fx-font-weight: bold" }) 215 | add( degreeTF ) 216 | add(submit) 217 | } 218 | 219 | up = vbox { 220 | spacing = 30.0 221 | paddingLeft = 80 222 | paddingTop = 30 223 | add( shape ) 224 | add( degree) 225 | } 226 | 227 | 228 | 229 | 230 | 231 | } 232 | 233 | 234 | } -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/src/main/kotlin/com/example/demo/view/MainView.kt: -------------------------------------------------------------------------------- 1 | package com.example.demo.view 2 | 3 | import com.example.demo.Controller.Functions 4 | import javafx.scene.image.Image 5 | import tornadofx.* 6 | import java.net.URL 7 | 8 | class MainView : View("Calculator") { 9 | 10 | init { 11 | setStageIcon(Image("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2BTrvmhmGWGCUPTVGKLdDqgtbRm7-AIrJoA&usqp=CAU")) 12 | } 13 | 14 | var textArea = textarea { setPrefSize( 600.0 , 100.0 ) ; style = "-fx-text-fill: black; -fx-background-color: black; -fx-font-size: 30px" } 15 | 16 | 17 | var operator = "" 18 | 19 | private fun calculte(operatorKeyboard : String) 20 | { 21 | operator = operatorKeyboard 22 | var textBar : String = textArea.text 23 | 24 | if ( textBar.contains("--") ) 25 | { 26 | textBar = textBar.replace("--","+") 27 | operator = "+" 28 | } 29 | if ( textBar.contains("-+" ) || textBar.contains("+-" ) ) 30 | { 31 | textBar = textBar.replace("-+","-") 32 | textBar = textBar.replace("+-","-") 33 | this.operator = "-" 34 | } 35 | 36 | if ( textBar[0] == '+' ) 37 | { 38 | textBar = textBar.substring(1) 39 | } 40 | 41 | val numbers = textBar.split(operator) 42 | 43 | val functions = Functions() 44 | when (operator) 45 | { 46 | "+" -> textArea.text = functions.plus(numbers) 47 | "-" -> textArea.text = functions.minus(numbers) 48 | "*" -> textArea.text = functions.multi(numbers) 49 | "/" -> { textArea.style = "-fx-font-size: 25px" ; textArea.text = functions.divide(numbers) } 50 | "^" -> textArea.text = functions.pow(numbers) 51 | } 52 | } 53 | 54 | 55 | override val root = anchorpane { 56 | setMinSize(500.0 , 300.0) 57 | style = "-fx-background-color: black" 58 | val functions = Functions() 59 | 60 | 61 | val column1 = vbox { 62 | val styleNumber = "-fx-background-color: #FBFBFB; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 63 | add(button { text = "1" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 64 | add(button { text = "4" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 65 | add(button { text = "7" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 66 | add(button { text = "0" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 67 | spacing = 2.0 68 | } 69 | 70 | val column2 = vbox { 71 | val styleNumber = "-fx-background-color: #FBFBFB; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 72 | add(button { text = "2" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 73 | add(button { text = "5" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 74 | add(button { text = "8" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 75 | spacing = 2.0 76 | } 77 | 78 | val column3 = vbox { 79 | val styleNumber = "-fx-background-color: #FBFBFB; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 80 | add(button { text = "3" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 81 | add(button { text = "6" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 82 | add(button { text = "9" ; setPrefSize(100.0 , 100.0) ; style = styleNumber ; action { textArea.text += text }}) 83 | spacing = 2.0 84 | } 85 | 86 | val hbox2_3 = hbox { 87 | add(column2) 88 | add(column3) 89 | spacing = 2.0 90 | } 91 | 92 | val column2_3 = vbox { 93 | add(hbox2_3) 94 | add(button { 95 | text = "=" ; setPrefSize(200.0 , 100.0) ; style = "-fx-background-color: #FF2E5E; -fx-background-radius: 50 ; -fx-font-size: 25px ;" ; 96 | action { calculte(operator) } 97 | }) 98 | spacing = 2.0 99 | } 100 | 101 | val column4 = vbox { 102 | val styleOperator = "-fx-background-color: #FBD712; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 103 | add(button { text = "+" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text} }) 104 | add(button { text = "-" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text}}) 105 | add(button { text = "*" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text}}) 106 | add(button { text = "/" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text}}) 107 | spacing = 2.0 108 | } 109 | 110 | val column5 = vbox { 111 | val styleOperator = "-fx-background-color: #FBD712; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 112 | add(button { text = "sin" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { 113 | action { textArea.text = functions.sinX( textArea.text.toDouble() ) } 114 | }}) 115 | add(button { text = "cos" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { 116 | action { textArea.text = functions.cosX( textArea.text.toDouble() ) } 117 | }}) 118 | add(button { text = "tan" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { 119 | action { action { textArea.text = functions.tanX( textArea.text.toDouble() ) } } 120 | }}) 121 | add(button { text = "cot" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { 122 | action { textArea.text = functions.cotX( textArea.text.toDouble() ) } 123 | }}) 124 | spacing = 2.0 125 | } 126 | 127 | val column5_5 = vbox { 128 | val styleOperator = "-fx-background-color: #FBD712; -fx-background-radius: 50 ; -fx-font-size: 20px ;" 129 | add(button { text = "^" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text} }) 130 | add(button { text = "!" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text = functions.fac(textArea.text) }}) 131 | add(button { text = "abs" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text = functions.abs(textArea.text) }}) 132 | add(button { text = "log" ; setPrefSize(100.0 , 100.0) ; style = styleOperator ; action { textArea.text += text ; operator = text }}) 133 | spacing = 2.0 134 | } 135 | 136 | val column6 = vbox { 137 | val integral = "\u222B" 138 | add(button { text = integral ; setPrefSize(100.0 , 200.0) ; 139 | style = "-fx-background-color: #FBD712; -fx-background-radius: 50 ; -fx-font-size: 30px ;" ; action { Integral().openWindow() }}) 140 | add(button { text = "Ac" ; setPrefSize(100.0 , 200.0) ; 141 | style = "-fx-background-color: #FF2E5E; -fx-background-radius: 50 ; -fx-font-size: 20px ;" ; action { textArea.text = "" }}) 142 | spacing = 4.0 143 | } 144 | 145 | val keyboard = hbox{ 146 | add(column1) 147 | add(column2_3) 148 | add(column4) 149 | add(column5) 150 | add(column5_5) 151 | add(column6) 152 | spacing = 2.0 153 | } 154 | 155 | val showBox = vbox { 156 | add(textArea) 157 | add(keyboard) 158 | spacing = 20.0 159 | paddingAll = 20.0 160 | } 161 | 162 | } 163 | } -------------------------------------------------------------------------------- /Calculator_Kotlin_TornadoFx/tornadofx-maven-project.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BigNumber-Calculator 2 | Big Number Calculator in Kotlin Tornadofx 3 | 4 | 5 | 6 | ![bandicam 2022-01-30 02-06-15-244](https://user-images.githubusercontent.com/89391453/151701633-ffa97cec-05a6-4587-8d07-cc91b1069733.gif) 7 | --------------------------------------------------------------------------------