├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── Versioning.md ├── pom.xml ├── src └── main │ ├── kotlin │ ├── GBEE.kt │ ├── app │ │ ├── Application.kt │ │ ├── ApplicationImpl.kt │ │ ├── components │ │ │ ├── menuBar │ │ │ │ ├── View │ │ │ │ │ ├── MenuView.kt │ │ │ │ │ └── subItem │ │ │ │ │ │ ├── grid │ │ │ │ │ │ └── MenuBarViewGrid.kt │ │ │ │ │ │ └── list │ │ │ │ │ │ └── MenuBarViewList.kt │ │ │ │ └── options │ │ │ │ │ ├── MenuOptions.kt │ │ │ │ │ └── subItem │ │ │ │ │ └── options │ │ │ │ │ └── MenuBarOptions.kt │ │ │ └── panel │ │ │ │ ├── ContentPaneParentImpl.kt │ │ │ │ └── grid │ │ │ │ ├── CacheGrid.kt │ │ │ │ ├── CacheState.kt │ │ │ │ ├── TableGridImpl.kt │ │ │ │ └── TableGridScrollPaneImpl.kt │ │ └── configuration │ │ │ ├── Configuration.kt │ │ │ ├── ConfigurationImpl.kt │ │ │ └── properties │ │ │ ├── PropertiesEnum.kt │ │ │ ├── PropertiesImpl.kt │ │ │ └── Propierties.kt │ ├── assets │ │ ├── Component.kt │ │ ├── Renderable.kt │ │ ├── button │ │ │ ├── ButtonAbstractExt.kt │ │ │ └── group │ │ │ │ └── ButtonGroupExt.kt │ │ ├── chooser │ │ │ ├── color │ │ │ │ ├── ColorChooser.kt │ │ │ │ └── ColorChooserImpl.kt │ │ │ └── file │ │ │ │ ├── FileChooser.kt │ │ │ │ └── FileChooserImpl.kt │ │ ├── dialog │ │ │ ├── EnumDialog.kt │ │ │ ├── confirm │ │ │ │ ├── Confirm.kt │ │ │ │ └── ConfirmImpl.kt │ │ │ ├── input │ │ │ │ ├── Input.kt │ │ │ │ └── InputImpl.kt │ │ │ └── message │ │ │ │ ├── Message.kt │ │ │ │ └── MessageImpl.kt │ │ ├── display │ │ │ ├── Display.kt │ │ │ └── DisplayImpl.kt │ │ ├── frame │ │ │ ├── Frame.kt │ │ │ └── component │ │ │ │ └── ComponentListenerScreen.kt │ │ ├── menu │ │ │ └── MenuImplExt.kt │ │ ├── menuBarExt │ │ │ └── JMenuBarImpl.kt │ │ ├── panel │ │ │ ├── Panel.kt │ │ │ ├── PanelImpl.kt │ │ │ ├── grid │ │ │ │ └── PanelGridLayoutImpl.kt │ │ │ ├── multipleImages │ │ │ │ ├── PanelCartridge.kt │ │ │ │ ├── PanelCover.kt │ │ │ │ ├── PanelSnapshot.kt │ │ │ │ └── base │ │ │ │ │ └── PanelMultipleImages.kt │ │ │ ├── split │ │ │ │ ├── Split.kt │ │ │ │ └── SplitImpl.kt │ │ │ └── tab │ │ │ │ ├── TabPane.kt │ │ │ │ └── TabPaneListener.kt │ │ ├── progressBar │ │ │ ├── ProgressBar.kt │ │ │ └── ProgressBarImpl.kt │ │ ├── scroll │ │ │ └── ScrollPane.kt │ │ ├── slider │ │ │ ├── Slider.kt │ │ │ └── SliderImpl.kt │ │ ├── statusBar │ │ │ ├── StatusBar.kt │ │ │ └── StatusBarImpl.kt │ │ ├── table │ │ │ ├── TableImpl.kt │ │ │ ├── comparator │ │ │ │ └── TableHeaderComparator.kt │ │ │ ├── daemon │ │ │ │ └── TableDaemon.kt │ │ │ ├── listener │ │ │ │ ├── BaseInputTableList.kt │ │ │ │ ├── adapter │ │ │ │ │ ├── TableColumnHeaderAdapter.kt │ │ │ │ │ └── TableRowAdapter.kt │ │ │ │ ├── renderer │ │ │ │ │ └── TableCellRendererComponent.kt │ │ │ │ └── rowKey │ │ │ │ │ └── TableRowKeyListener.kt │ │ │ └── model │ │ │ │ └── TableModelImpl.kt │ │ └── textArea │ │ │ ├── TextArea.kt │ │ │ └── TextAreaImpl.kt │ └── utils │ │ ├── completable │ │ └── CompletableCancelable.kt │ │ ├── event │ │ └── ActionEventRunBlockingLaunchSwing.kt │ │ ├── fps │ │ └── Fps.kt │ │ ├── image │ │ ├── BufferedImageMemoryFromComponent.kt │ │ └── ImageIconExt.kt │ │ ├── listGames │ │ └── ListGames.kt │ │ ├── map │ │ └── MergeMaps.kt │ │ ├── monitor │ │ └── PerformanceMonitor.kt │ │ ├── swing │ │ ├── Swing.kt │ │ └── SwingDelay.kt │ │ ├── system │ │ └── System.kt │ │ ├── thread │ │ ├── CustomExecutor.kt │ │ ├── DynamicSemaphore.kt │ │ └── ThreadMain.kt │ │ ├── tween │ │ └── Tween.kt │ │ └── zip │ │ └── Zipable.kt │ └── resources │ ├── app │ └── readme.md │ ├── cartridge │ └── readme.md │ ├── cover │ └── readme.md │ ├── gameList │ ├── list │ └── listGame.json │ ├── rom │ └── readme.md │ ├── snapshot │ └── readme.md │ └── version │ ├── GBEE_v.0.0.1.gif │ ├── GBEE_v.0.0.2.gif │ ├── GBEE_v.0.1.0.gif │ ├── GBEE_v.0.1.1.gif │ ├── GBEE_v.0.2.0.gif │ ├── GBEE_v.0.2.1-1.gif │ ├── GBEE_v.0.2.1-2.gif │ ├── GBEE_v.0.2.1.gif │ ├── GBEE_v.0.2.2-1.gif │ ├── GBEE_v.0.2.2-2.png │ ├── GBEE_v.0.2.2-3.png │ ├── GBEE_v.0.2.2-4.png │ ├── GBEE_v.0.2.2-5.png │ ├── GBEE_v.0.2.2-6.png │ ├── GBEE_v.0.2.2.gif │ ├── GBEE_v.0.2.3-1.png │ ├── GBEE_v.0.2.3-2.png │ ├── GBEE_v.0.2.3-3.png │ └── GBEE_v.0.2.3.gif └── start-async-checkbutton-application.iml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: vicboma1 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | /src/main/resources/cartridge 3 | /lib 4 | /.idea 5 | /src/main/resources/snapshot 6 | /src/main/resources/rom 7 | /src/main/resources/list/ 8 | /src/main/resources/cover 9 | /src/main/resources/cartridge/ 10 | /src/main/resources/app 11 | src/main/resources/font/ 12 | target/ 13 | /src/main/resources/list/listGame.json 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [GameBoy Emulator](https://github.com/vicboma1/emulators/tree/master/gameboyclassic) Environment - GBEE [v.0.2.3](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/Versioning.md#version-023----wip) 2 | 3 | Front-End developed with **Kotlin Experimental** for my [GameBoy Emulator](https://github.com/vicboma1/emulators/tree/master/gameboyclassic) 4 | 5 | #### Now, with coroutines Average Timing with 2546 covers 6 | #### Async + CompletableFuture-Deferred - [ 50 - 79 ] ms 7 | 8 | ### 9 | 10 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.3.gif) 11 | 12 | #### version 0.2.3 - news 13 | ``` 14 | MenuBar Options 15 | MenuItemView { Delay load Async - Permits } / Dynamic configuration with sliderBar 16 | Custom Sempahore 17 | Add MenuItemsView Grid by Rom Name 18 | Processing with Coroutine + async 19 | ``` 20 | 21 | # Grid Async 22 | 23 | ## Rom Name 24 | 25 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.2-2.png) 26 | 27 | ## x4 Cover 28 | 29 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.2-3.png) 30 | 31 | ## x3 Cover 32 | 33 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.2-4.png) 34 | 35 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.3-1.png) 36 | 37 | ## x2 Cover 38 | 39 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.2-5.png) 40 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.3-2.png) 41 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.3-3.png) 42 | 43 | ## x1 Cover 44 | 45 | ![](https://github.com/vicboma1/GameBoyEmulatorEnvironment/blob/master/src/main/resources/version/GBEE_v.0.2.2-6.png) 46 | 47 | 48 | # Resources 49 | 50 | Folders 51 | ``` 52 | app 53 | |______ main.png 54 | 55 | cartridge 56 | |______ _bg.png 57 | |______ addamsf.png 58 | |______ {romName}.png 59 | 60 | cover 61 | |______ _bg.png 62 | |______ _gbNotFound.png 63 | |______ addamsf.png 64 | |______ {romName}.png 65 | 66 | font 67 | |______ _fontGrid.png 68 | 69 | list 70 | |______ listGame.json 71 | 72 | rom 73 | |______ ace_stri.gb 74 | |______ addamsf.gb 75 | |______ addamsf2.gb 76 | |______ *.gb 77 | 78 | snapshot 79 | |______ _bg.png 80 | |______ addamsf.png 81 | |______ {romName}.png 82 | ``` 83 | 84 | where : 85 | 86 | ``` 87 | "main.png" is the icon 88 | "{romName}.png" is the Game image 89 | "_bg.png" is the pattern that contains the others images inside it. 90 | "_gbNotFound.png" is the pattern that represents the image not found. 91 | "*.gb" is the specific name that contains the game inside the rom 92 | "listGame.json" is a Array> than contains the column and rows 93 | "_fontGrid.png " is the font that represent the game cover 94 | ``` 95 | 96 | ## Tooling 97 | 98 | [Download Asynk Resource](https://github.com/kotlin-es/kotlin-asynk-resources) 99 | 100 | ![](https://github.com/kotlin-es/kotlin-asynk-resources/blob/master/src/main/resource/Asynk-Resources.gif) 101 | 102 | ### 103 | # Game List 104 | ### 105 | 106 | This is a list of 1049 games released for the Game Boy handheld video game system, excluding any cancelled and unlicensed games campatible with GameBoy Emulator Environment - GBEE 107 | 108 | ```kotlin 109 | " --- CADA --- "         "BURAI FIGHTER DE"           "ELITE SOCCER   "           "HATRIS         " 110 | "ACE STRIKER " "BURAI FIGHTER DX" "EMPIRE STRIKES " "HEAD ON " 111 | "ADDAMS FAMILY " "BURGER TIME " "ESPARKS " "HEIANKYO ALIEN " 112 | "ADDAMS FAMILY 2 " "BURNING PAPER " "F-1 HEROGB " "HEIANKYO ALIEN " 113 | "ADVENTURE ISLAND" "BZONE SBREAKOUT " "F-1HERO GB92 " "HERCULES EIKOU " 114 | "ADVENTUREISLAND2" "CADILLAC2 " "F1 BOY " "HIGH STAKES " 115 | "AEROSTAR " "CAESARS PALACE " "F1 SPIRIT " "HIRYU GAIDEN " 116 | "AFTER BURST " "CAESARS PALACE " "F1 SUPER DRIVING" "HOME ALONE " 117 | "ALADDIN " "CAPCOM QUIZ " "F15 STRIKE EAGLE" "HOME ALONE2 " 118 | "ALFRED CHICKEN " "CAPTAIN TUBASA J" "F1RACE " "HONG KONG " 119 | "ALIEN " "CARD GAME " "FACEBALL 2000 " "HOOK " 120 | "ALIEN OLYMPICS " "CASINO FUNPAK " "FAMILYJOCKEY " "HOOK " 121 | "ALIEN V PREDATOR" "CASTELIAN " "FASTEST LAP " "HOSHINOKA-BI " 122 | "ALLEY WAY " "CASTLEVANIA ADVE" "FELIX THE CAT " "HUDSON HAWK " 123 | "ALLSTARCHALLENGE" "CASTLEVANIA ADVE" "FERRARI " "HUDSON HAWK " 124 | "ALSTARCHALLENGE2" "CASTLEVANIA2 BEL" "FIFA SOCCER " "HUGO " 125 | "ALSTARCHALLENGE2" "CAVE NOIRE " "FIFA SOCCER 96 " "HYPER BLACKBASS " 126 | "ALTERED SPACE " "CENTIPEDE " "FIGHBIRD GB " "HYPER DUNK " 127 | "ALTERED SPACE " "CHACHAMARUPANIC " "FIGHTING SOCCER " "HYPERLODERUNNER " 128 | "AMAZING-TATER " "CHASE HQ " "FINAL REVERSE " "IKARI NO YOUSAI " 129 | "AMIDA " "CHASE HQ " "FIRE FIGHTER " "IN YOUR FACE " 130 | "ANIMANIACS " "CHIBIMARUKO " "FISH DUDE " "INDIANA JONES " 131 | "ANOTHER BIBLE " "CHIKI RACE GB " "FLAPPY SPECIAL " "INDIANA JONES 3 " 132 | "ARETHA " "CHOPLIFTER 2 " "FLINTSTONES " "IREM FIGHTER " 133 | "ARETHA3 " "CHOPLIFTER 2 " "FLIPULL " "ISHIDO JPN VER. " 134 | "ASMIK2 " "CHOPLIFTER III " "FLYING WARRIORS " "ISHIDO USA VER. " 135 | "ASTERIX " "CLEMENS BASEBALL" "FOOTBALL INT'L " "ITCHY & SCRATCHY" 136 | "ASTEROIDS " "CLIFFHANGER " "FOREMAN FOR REAL" "J CONNOR TENNIS " 137 | "ASTEROIDS/MISCMD" "CONTRA " "FORTIFIED ZONE " "J.CUP SOCCER " 138 | "ASTRO RABBY " "CONTRA SPIRITS " "FORTIFIED ZONE2 " "JAMES POND " 139 | "ATOMIC PUNK " "COOL SPOT " "FRANK THOMAS BB " "JANKENMAN " 140 | "AVENGING SPIRIT " "COOL WORLD " "FUNNY FIELD " "JANSHIRO " 141 | "AYAKASI NO SIRO " "COSMO TANK " "FUNPAK 4IN1 " "JANTAKUBOY " 142 | "B.C.KID2 " "CRASH DUMMIES " "FUNPAK 4IN1 - V2" "JEEP JAMBOREE " 143 | "BALLOON KID " "CRYSTAL QUEST " "FUSHIGINA BULOBI" "JELLY BOY " 144 | "BANISHING RACER " "CUTTHROAT ISLAND" "G&W GALLERY " "JEOPARDY " 145 | "BARBIE GAME GIRL" "CYBER FORMULA " "GALAGA&GALAXIAN " "JINSEI " 146 | "BASE BALL KIDS " "CYRAID " "GAME&WATCH " "JOE AND MAC " 147 | "BASEBALL " "DAEDALIAN OPUS " "GAMERA DAIKAIJUU" "JOE AND MAC " 148 | "BASES LOADED GB " "DAFFY DUCK " "GANBARE GOEMON " "JOE AND MAC " 149 | "BATMAN " "DAFFY DUCK " "GARFIELD " "JORDAN ONEONONE " 150 | "BATMAN ANIMATED " "DAISENRYAKU HIRO" "GARGOYLE'S " "JORDAN VS BIRD " 151 | "BATMAN FOREVER " "DARK WING DUCK " "GAUNTLET II " "JUDGE DREDD " 152 | "BATMAN ROJ " "DARKMAN " "GB 3TAMA " "JUNGLE BOOK " 153 | "BATTLE BULL " "DARUMAN BUSTERS " "GB BASKETBALL " "JUNGLE STRIKE " 154 | "BATTLE CRUSHER " "DAYS OF THUNDER " "GB BEACHVOLLEY " "JUNGLE WARS " 155 | "BATTLE OFKINGDOM" "DEADHEATSCRAMBLE" "GB DBZ GOKOU " "JURASSIC PARK " 156 | "BATTLE PINGPONG " "DEADHEATSCRAMBLE" "GB DRUAGA 1 " "JURASSIC PARK II" 157 | "BATTLE SHIP " "DEFENDER/JOUST " "GB GARMS 1 " "KAERUNOTAMENI " 158 | "BATTLE SHIP " "DENNIS " "GB GENJIN " "KAGUYAHIME " 159 | "BATTLE SHIP " "DESERT STRIKE " "GB GENJIN LAND " "KATTOBI ROAD " 160 | "BATTLE SHIP " "DEXTERITY " "GB GODZILLA " "KESAMARU " 161 | "BATTLECITY " "DICK TRACY " "GB IRON LEAGUER1" "KID ICARUS " 162 | "BATTLETOADS " "DIG DUG " "GB JIDAIGEKI " "KID NIKI " 163 | "BATTLEUNIT ZEOTH" "DLAIR LEGEND UK0" "GB KINNIKUMAN DM" "KILLER TOMATOES " 164 | "BEACH,VOLLEYBALL" "DLAIR THE LEGEND" "GB KUREYON SHIN " "KILLERINSTINCT95" 165 | "BEACH_VOLLEY " "DMG FOOTBALL " "GB KUREYON SHIN4" "KINGDOM CRUSADE " 166 | "BEETHOVEN " "DMG-ASE " "GB LACROANHERO 1" "KINGOFTHEZOO " 167 | "BEETLEJUICE " "DMG-ASJ " "GB MASKRIDER SD " "KINTARO ACG " 168 | "BEST OF THE BEST" "DMG-KMJ " "GB MUSASHIROAD 1" "KIRBY BLOCKBALL " 169 | "BIKKURI NEKKETU " "DMG-SJJ " "GB MUSASHIROAD 1" "KIRBY DREAM LAND" 170 | "BILL AND TED " "DMG-UQJ " "GB NEW SD GUNDAM" "KIRBY'S PINBALL " 171 | "BIONIC BATTLER " "DODGE BALL " "GB OTOKOJYUKU 1 " "KIRBY'S PINBALL " 172 | "BIONIC-COMMANDO " "DODGE BOY " "GB OTOKOJYUKU 1 " "KIRBY2 " 173 | "BIONIC-COMMANDO " "DODGEDANPEI " "GB OTOKOJYUKU 1 " "KITCHIN PANIC " 174 | "BISHOJYOSENSI SE" "DONKEY KONG " "GB POWER MOVIE " "KITERETU ZYURAKI" 175 | "BLADES OF STEEL " "DONKEYKONGLAND 2" "GB SAILORMOON R " "KLAX " 176 | "BLASTER MASTER B" "DONKEYKONGLAND 3" "GB SAILORMOON R " "KNIGHT QUEST " 177 | "BLODIA " "DONKEYKONGLAND95" "GB SLAM DUNK " "KOI WA KAKEHIKI " 178 | "BLUES BROTHERS " "DORAEMON " "GB SLAM DUNK 2 " "KONAMI GOLF " 179 | "BO JACKSON " "DORAEMON " "GB SUPERBIKKURI1" "KONAMIC SPORTS " 180 | "BOKU DRACURA KUN" "DORAEMON2 " "GB TAACHIYAN " "KORODICE " 181 | "BOMB JACK " "DORAKYURADENSETU" "GB TAMAGOTCH 1 " "KRUSTY " 182 | "BOMBER BOY " "DORASUREGAIDEN " "GB TAMAGOTCHI " "KUNIO " 183 | "BOMBER KING S2 " "DOUBLE DRAGON " "GB TARURU-TO 1 " "KWIRK " 184 | "BOMBER MAN GB " "DOUBLE DRAGON 2 " "GB TARURU-TO 2 " "KYORCHANLANDHIRO" 185 | "BOMBERMAN GB " "DOUBLE DRAGON 3 " "GB TEKKAMANBLADE" "LAMBORGHINI " 186 | "BONK'S ADVENTURE" "DOUBLE DRIBBLE " "GB ULTRAMANCLUB1" "LANG TRNSLTR FRN" 187 | "BOOBY BOYS " "DOUBLEYAKUMAN2 " "GB UNDOUKAI " "LANG TRNSLTR SPN" 188 | "BOUKENJIMA2 " "DR FRANKEN " "GBGENJIN2 " "LAST ACTION HERO" 189 | "BOULDER DASH " "DR FRANKEN " "GBWARS " "LAST BIBLE " 190 | "BOULDER DASH " "DR FRANKEN 2 " "GEMGEM " "LAST BIBLE2 " 191 | "BOXING " "DR.MARIO " "GENERATIONS " "LAWNMOWER MAN " 192 | "BOXXLE " "DRACULA " "GENSAN " "LAZLOS LEAP " 193 | "BOXXLE2 " "DRACURA2 " "GENSAN " "LEGEND " 194 | "BOY AND BLOB GB1" "DRAGON SLAYER 1 " "GENSAN2 " "LEGEND OF ZERD " 195 | "BOY AND BLOB GB2" "DRAGONHEART " "GEORGE F. BOXING" "LEMMINGS " 196 | "BOY AND BLOB GB2" "DRAGONHEART " "GHOSTBUSTERS 2 " "LEMMINGS 2 " 197 | "BRAINBENDER " "DRAGONS LAIR " "GHOSTBUSTERS II " "LETHAL WEAPON " 198 | "BREAKTHRU! " "DRAGONTAILBIT2 " "GINGA " "LITTLE MASTER " 199 | "BT2RAGNAROKWORLD" "DROPZONE " "GO GO TANK " "LITTLE MASTER 2 " 200 | "BUBBLE BOBBLE " "DUCK TALES " "GOAL! " "LITTLE MERMAID " 201 | "BUBBLE BOBBLE " "DUCK TALES " "GOD MEDICINE " "LOCK'N CHASE " 202 | "BUBBLE GHOST " "DUCK TALES 2 " "GODZILLA " "LOLO " 203 | "BUBBLE GHOST " "DUCK TALES 2 " "GOLF " "LOONEY TUNES " 204 | "BUBBLEBOBBLE2 " "DUNGEONLAND " "GOLF CLASSIC " "LOOPZ " 205 | "BUBBLEBOBBLEJR " "DYNABLASTER " "GOURMET PARADISE" "LUCKY MONKEY " 206 | "BUBSY II " "EARTHWORM JIM " "GRADIUS " "LUCLE " 207 | "BUGS BUNNY " "ELEVATOR ACTION " "GREMLINS 2 " "LUNA LANDER " 208 | "BUGSCRAZYCASTLE2" "ELEVATOR ACTION " "HARIMANADA " "MADDEN 95 " 209 | 210 | 211 | 212 | "MADDEN 96 " "OLYMPUS " "ROAD RASH " "SQ DSV DMG " 213 | "MAGNETIC SOCCER " "ON THE TILES " "ROBIN HOOD " "SQUARE DEAL " 214 | "MAHOUJINGURUGURU" "ONI " "ROBOCOP " "SRJ DMG " 215 | "MAKAIMURAGAIDEN " "ONI 5 " "ROBOCOP " "STAR SAVER " 216 | "MANSELL " "ONI-PACHINKOTEN " "ROBOCOP2 " "STAR STACKER " 217 | "MARBLE MADNESS " "OPERATION C " "ROCK'N! MONSTER!" "STAR TREK " 218 | "MARIO & YOSHI " "OTHELLO " "ROCKMAN WORLD " "STAR TREK " 219 | "MARIO'S PICROSS " "OUT BURST " "ROCKMAN WORLD2 " "STAR WARS " 220 | "MARIOLAND2 " "OUT OF GAS " "ROCKMANWORLD3 " "STARGATE " 221 | "MARU'S MISSION " "PAC-IN-TIME " "ROCKMANWORLD4 " "STREET FIGHTER 2" 222 | "MASTER KARATEKA " "PAC-MAN " "ROCKMANWORLD5 " "SUMO FIGHTER " 223 | "MCDONALDLAND " "PAC-MAN " "ROCKY BULLWINKLE" "SUMOU FIGHTER " 224 | "MEGA MAN 2 " "PAC-MAN " "RODLAND " "SUPER B DAMAN " 225 | "MEGA MAN 2 " "PAC-PANIC " "RODLAND " "SUPER BLUES " 226 | "MEGA MAN 2 " "PACHINKO TIME " "ROGER RABBIT " "SUPER BOMBLISS " 227 | "MEGALIT " "PAINTERMOMOPIE " "ROLAN'S CURSE 2 " "SUPER CHINESE 2 " 228 | "MEGAMAN " "PALAMEDES " "ROLANS CURSE " "SUPER HUNCHBACK " 229 | "MEGAMAN3 " "PANG " "RTYPE " "SUPER HUNCHBACK " 230 | "MEGAMAN3 " "PAPERBOY " "RTYPE " "SUPER KICK OFF " 231 | "MEGAMAN3 " "PAPUWAKUNN " "RTYPE 2 " "SUPER MARIOLAND " 232 | "MEGAMAN4 " "PARASOL STARS " "RTYPE 2 " "SUPER MARIOLAND " 233 | "MERCENARY FORCE " "PARASORU HEMBEI " "RUBBLE SAVER 2 " "SUPER MARIOLAND " 234 | "METALJACK " "PARODIUS " "RUBBLESA " "SUPER MARIOLAND " 235 | "METROID2 " "PARODIUS DA! " "RUNES OF VIRTUE " "SUPER OFF ROAD " 236 | "MICKEY 4 " "PEETAN " "RUNES OF VIRTUE2" "SUPER RC PRO-AM " 237 | "MICKEY 5 " "PENGUIN BOY " "RVT " "SUPER ROBOT WAR " 238 | "MICKEY MOUSE " "PENGUIN LAND " "S S BASKET BALL2" "SUPERCHINESELAND" 239 | "MICKEY MOUSE " "PENGUIN WARS " "SAGA " "SUPERMARIOLAND3 " 240 | "MICKEY MOUSE " "PENGUINKUNWARSVS" "SAGA " "SUPERROBOTWAR 2G" 241 | "MICKEY MOUSE 2 " "PENTADRAGON " "SAGA2 " "SUPERWWF " 242 | "MICKEYS CHASE " "PERSONAL ORGANIZ" "SAGA2 " "SUPERWWF " 243 | "MICRO MACHINES " "PGA EURO TOUR " "SAGA3 " "SWAMP THING " 244 | "MICRO MACHINES 2" "PGA TOUR 96 " "SAGA3 " "TAIKYOKU RENJU " 245 | "MIGRAIN ACCLAIM " "PHANTASM " "SAGAIA " "TAIL GATOR " 246 | "MIKENEKO HOLMES " "PINBALL " "SAMURAI SHODOWN " "TALE SPIN " 247 | "MILLI/CENTI/PEDE" "PINBALL " "SANGOKUSHI " "TARZAN " 248 | "MILON CASTLE " "PINBALL " "SANRIO CARNIVAL " "TASMANIA STORY " 249 | "MINER 2049ER " "PINBALL " "Saved game " "TASMANIA STORY " 250 | "MINESWEEPER " "PINBALL DELUXE " "SCOTLANDYARD " "TAZ-MANIA " 251 | "MINI PUTT " "PINBALL DREAMS " "SD HIRYUNOKEN " "TECMO BOWL " 252 | "MISSILE COMMAND " "PINBALL FANTASIE" "SD LUPIN THE 3RD" "TEKKYUFIGHT! " 253 | "MM ULT CHALLENGE" "PINBALL MANIA " "SD SEINTPARADA01" "TENCHIWOKURAU " 254 | "MOGURA DE PON! " "PINBALL PARTY " "SDGUNDAMKUNITORI" "TENJIN KAISEN 2 " 255 | "MOGURANYA " "PIPE DREAM " "SDSENGOKUDEN2 " "TENJINKAISEN " 256 | "MOMOTARO DENGEKI" "PIT FIGHTER " "SDSENGOKUDEN3 " "TENNIS " 257 | "MOMOTARODENGEKI2" "PITMAN " "SEASIDE VOLLEY " "TENSAIBAKABON " 258 | "MOMOTETU " "POCAHONTAS " "SEIKEN DENSETSU " "TERMINATOR 2 " 259 | "MONOPOLY " "POCKET BATTLE " "SEIKEN DENSETSU " "TERMINATOR 2 TAG" 260 | "MONOPOLY " "POCKET STADIUM " "SELECTION " "TESSERAE " 261 | "MONSTER MAKER J " "POKONYAN! " "SENGOKUNINJAKUN " "TETRIS " 262 | "MONSTER MAKER J2" "POP UP " "SENSIBLE SOCCER " "TETRIS ATTACK " 263 | "MONSTER MAX " "POPEYE " "SERPENT " "TETRIS BLAST " 264 | "MONSTERTRUCK " "POPEYE 2 " "SHADOW WARRIORS " "TETRIS FLASH " 265 | "MORTAL KOMBAT " "POPEYE 2 " "SHANGHAI " "TETRIS PLUS " 266 | "MORTAL KOMBAT 3 " "POPULOUS " "SHANGHAI " "TETRIS2 " 267 | "MORTAL KOMBAT II" "POWER MISSION " "SHIKINJYO " "THE CHESSMASTER " 268 | "MOTOCROSSMANIACS" "POWER MISSION " "SHIPPO DE BUN " "THE FIDGETTS " 269 | "MOUSE TRAP HOTEL" "POWER RACER " "SHISENSYO " "THE FIDGETTS " 270 | "MR NUTZ " "POWER RANGERS " "SHOOT " "THE FLASH " 271 | "MR.DO! " "PREHISTORIK MAN " "SHOOT " "THE FLINTSTONES " 272 | "MS.PAC-MAN " "PRIMAL RAGE " "SHOUGI " "THE GETAWAY " 273 | "MUHAMMAD ALI " "PRINCE OF PERSIA" "SI KIDS " "THE GETAWAY " 274 | "MYSTERIUM " "PRINCE OF PERSIA" "SIDE POCKET " "THE HUMANS " 275 | "MYSTIC QUEST " "PRIPRI " "SIMPSON ESCAPE " "THE JETSONS " 276 | "MYSTIC QUEST " "PRO SOCCER " "SIMPSONS 2 " "THE LION KING " 277 | "MYSTIC QUEST " "PROBOTECTOR " "SIMPSONS3 " "THE PAGEMASTER " 278 | "NAIL N SCALE " "PROBOTECTOR 2 " "SKATE OR DIE BAD" "THE PUNISHER " 279 | "NAMCOCLASSIC " "PROWRES " "SMURFS " "THE SWORD OFHOPE" 280 | "NASCARFASTTRACKS" "PROWRES " "SNEAKY SNAKES " "THE SWORD OFHOPE" 281 | "NAVY BLUE " "PURO STADIUM '91" "SNOOPY " "THEGAMEOFHARMONY" 282 | "NAVY BLUE 90 " "PUYOPUYO " "SNOOPY " "THUNDERBIRDS " 283 | "NAVY SEALS " "PUZZLE BOY " "SNOW BROS.JR " "TINTIN AU TIBET " 284 | "NBA JAM " "PUZZLE BOY2 " "SOCCER " "TINY TOON 2 " 285 | "NBA JAM TE " "PUZZLE ROAD " "SOCCER BOY " "TINY TOON 3 " 286 | "NEKOJARA " "PUZZNIC " "SOCCER MANIA " "TINY TOON ADVENT" 287 | "NEMESIS " "PYRAMIDS OF RA " "SOLARSTRIKER " "TINY TOON ADVENT" 288 | "NEMESIS 2 " "Q*BERT II " "SOLDAM GB " "TINY TOON WACKY " 289 | "NETTOU KOF 95 " "Q*BERT II " "SOLITAIRE FUNPAK" "TITUS THE FOX " 290 | "NETTOU SAMURAI " "QBILLION " "SOLOMON'S CLUB " "TMHT BACK FROM S" 291 | "NETTOU TOSHINDEN" "QIX " "SOLOMON'S CLUB " "TMNT " 292 | "NETTOU WH2JET " "QUARTH " "SOUKOBAN " "TMNT 2 " 293 | "NETTOU WH2JET " "QUARTH " "SOUKOBAN2 " "TMNT BACK FROM S" 294 | "NETTOUGAROU2 " "RACE DAYS " "SPACE INVADERS " "TMNT FOOT CLAN " 295 | "NEW CHESSMASTER " "RACE DRIVIN' " "SPACE INVADERS " "TMNT3 " 296 | "NFL FOOTBALL " "RACING DAMASHII " "SPANKY'S QUEST " "TMNT3 " 297 | "NFL QB CLUB 96 " "RADARMISSION " "SPARTAN X " "TOM AND JERRY " 298 | "NHL HOCKEY 95 " "RADARMISSION " "SPARTAN X " "TOM AND JERRY " 299 | "NINJA BOY " "RAGING FIGHTER " "SPEED BALL 2 " "TOM AND JERRY " 300 | "NINJA BOY 2 " "RAIJINOU " "SPEEDY GONZALES " "TOPGUN 2 " 301 | "NINJA GAIDEN " "RAMPART_GB " "SPEEDY GONZALES " "TOPRANKTENNIS " 302 | "NINJA GAIDEN " "RANMA 1/2 " "SPELL CHECKER " "TORPEDO RANGE " 303 | "NINJA RYUKENDEN " "RANMA1/2 PART2 " "SPIDER-MAN " "TOTAL CARNAGE " 304 | "NINJA SPIRIT " "RANMA1/2KAKUGEKI" "SPIDER-MAN 2 " "TOTSUGEKI TANK " 305 | "NINJATARO " "RAY THUNDER " "SPIDER-MAN 3 DMG" "TOUR DE THRASH " 306 | "NOBUNAGA " "REAL GHOSTBUSTER" "SPIDERMAN XMEN " "TOXIC CRUSADERS " 307 | "NOBUNAGA " "RED ARREMER " "SPIROU " "TOY STORY " 308 | "NORTH STAR " "RED OCTOBER " "SPOT " "TRACK MEET " 309 | "OBELIX " "RED OCTOBER " "SPOT " "TRACK MEET " 310 | "OIRA JAJAMARU " "RIDDICK BOWE " "SPOT COOL ADV " "TRACK MEET HIRO " 311 | "OLYMPIC GAMES " "RING RAGE " "SPUDS ADVENTURE " "TRACK&FIELD " 312 | 313 | 314 | 315 | "TRAPPERS TENGOKU" "VEGAS STAKES " "WORLD BOWLING " "YUUYUU-2 " 316 | "TRAX " "VEGAS STAKES " "WORLD BOWLING " "YUUYUU-3 " 317 | "TRIP WORLD " "VELIOUS 2 " "WORLD CUP " "YUUYUU-4 " 318 | "TRSI RULEZ " "VERSUS HERO " "WORLD CUP " "ZELDA " 319 | "TRUE LIES " "VIRTUAL WARS " "WORLD CUP USA 94" "ZELDA " 320 | "TSUMEGO 01 " "VITAMINA KINGDOM" "WORLD CUP USA 94" "ZELDA " 321 | "TUBASA VS " "VOLLEY FIRE " "WORLD ICE HOKKEY" "ZELDA " 322 | "TUMBLE POP " "VS BATTLER " "WORMS " "ZEN " 323 | "TUMBLE POP " "W CIRCUIT SERIES" "WWF RAW " "ZEOTH " 324 | "TURN AND BURN " "WARIO BLAST " "WWF SUPERSTARS " "ZOIDS J1 " 325 | "TURRICAN " "WARRIOR " "WWF SUPERSTARS " "ZOOL " 326 | "TWIN " "WATER WORLD " "WWFKOR " "ZOOP " 327 | "TWIN-BEE DA!! " "WAVERACE " "WWFKOR " 328 | "ULTRA GOLF " "WAYNE'S WORLD " "XXZZ " 329 | "ULTRAMAN " "WEREBACK BC " "XENON 2 " 330 | "ULTRAMAN BALL " "WH2JET " "XENON 2 " 331 | "ULTRAMAN GEKIDEN" "WHEEL OF FORTUNE" "XERD!! " 332 | "UNDER COVER COPS" "WILDSNAKE " "YAIBA " 333 | "UNIVERSALSOLDIER" "WINNING GOAL " "YAKUMAN " 334 | "UNO2SMALL WORLD " "WINTER GOLD " "YAMATO " 335 | "UOOZU " "WINTER OLYMPICS " "YOGIS GOLDRUSH " 336 | "URUSEIYATSURA " "WIZARDRY SOQ " "YOSHI'S COOKIE " 337 | "VALATIONS " "WIZARDS WARRIORS" "YOSSY NO TAMAGO " 338 | "VATTLE GIUCE " "WORDTRIS " "YOSSY NO TAMAGO " 339 | "VEEDIOTS       "         "WORDZAP         "           "YUUYUU-1       " 340 | ``` 341 | ### 342 | # Add new games ?? 343 | ### 344 | 345 | Now, you can put new games with the possibility of creating a Json with the list of games that you want. 346 | 347 | You only need to generate a list of items list. 348 | The index 0 corresponds to the columns and the rest of the elements to the rows. 349 | 350 | Automaticly will be generated the columns and rows of game list 351 | 352 | 353 | ```kotlin 354 | [ 355 | ["Load", "ROM Game", "Game Name", "ROM Type", "Size (in bytes)"], 356 | [false, "YYYY.GB "," --- YYYY --- ", "XXX+ZZZZ ", 65.536], 357 | [ true, "XXXX.GB "," --- XXXX --- ", "YYY+ZZZZ ", 65.536], 358 | [ ...., ".....GB "," --- .... --- ", " ...... ", ......] 359 | ] 360 | ``` 361 | 362 | 363 | --->>> [Repo: Getting Started Kotlin](https://github.com/vicboma1/GettingStartedKotlin) <<<--- 364 | 365 | --->>> [Repo: Kotlin Koans](https://github.com/vicboma1/Kotlin-Koans) <<<--- 366 | 367 | --->>> [Repo: Kotlin Problems](https://github.com/vicboma1/Kotlin-Examples-Problems) <<<--- 368 | 369 | --->>> [Repo: Kotlin Mobile](https://github.com/vicboma1/KotlinMobilePoC_MasterUV2018) <<<--- 370 | 371 | --->>> [Repo: Kotlin JavaScript](https://github.com/vicboma1/kotlinJavaScript) <<< 372 | 373 | --->>> [Repo: Kotlin Native - iOS ](https://github.com/vicboma1/Kotlin-Native-iOS) <<<--- 374 | 375 | --->>> [Repo: Ktor Examples](https://github.com/vicboma1/ktor-API-examples) <<<--- 376 | 377 | 378 | @Author : Victor Bolinches Marin 379 | 380 | @Author : [vicboma1](https://twitter.com/vicboma1) 381 | 382 | # Note: 383 | # This homebrew project does not contain ROMs & Images 384 | -------------------------------------------------------------------------------- /Versioning.md: -------------------------------------------------------------------------------- 1 | Semantic Versioning 2 | ========= 3 | 4 | ``` 5 | Given a version number MAJOR.MINOR.PATCH, increment the: 6 | 7 | MAJOR version when you make incompatible API changes, 8 | MINOR version when you add functionality in a backwards-compatible manner, and 9 | PATCH version when you make backwards-compatible bug fixes. 10 | Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. 11 | ``` 12 | 13 | #### version 0.2.3 - WIP 14 | ``` 15 | MenuBar Options 16 | MenuItemView { Delay load Async - Permits } / Dynamic configuration with sliderBar 17 | Custom Sempahore 18 | Add MenuItemsView Grid by Rom Name 19 | Processing with Coroutine + async 20 | Selection cell in row (Grid) 21 | ``` 22 | ## Averaging Time to load 2546 covers - 12 executions [ version 0.2.3 ] 23 | 24 | |                   | Coroutine | Coroutine |     Coroutine     |     Coroutine     | 25 | |:------------------: |:-----------: |:-----------: |:-----------------: |:-----------------: | 26 | | RunBlocking | True | True | True | True | 27 | | | launch | launch | async | async | 28 | | Context | CommonPool | CommonPool | CommonPool | CommonPool | 29 | | Mutex Optimization | False | True | False | True | 30 | | Time [ms] | 70 - 90 | 70 - 80 | 65 - 90 | 50 - 60 | 31 | | Job | join | join | | | 32 | | Time [ms] | 70 - 110 | 70 - 95 | | | 33 | | Deffered | | | CompletableFuture | CompletableFuture | 34 | | Time [ms] | | | 65-80 | 50-79 | 35 | 36 | 37 | #### version 0.2.2 38 | ``` 39 | Add MenuItemsView Grid by scale { 1x, 2x, 3x, 4x} 40 | Create Images in memory 41 | Asynchronous GridView 42 | ``` 43 | 44 | #### version 0.2.1 45 | ``` 46 | Add MenutItemView { Grid - List } 47 | Grid {View - Model - Scroll} based in Table with multiple rows cached 48 | Model { Image - NameRom } 49 | ``` 50 | ## Averaging Time to load 2546 - 12 executions [ version 0.2.1 ] 51 | 52 | | | ThreadPool | ThreadPool | ThreadPool | ThreadPoolExecutor | Thread | Thread | 53 | |:----------------------: |:------------: |:-----------: |:-----------: |:-------------------: |:-----------------: |:-----------------: | 54 | | Executor | Cached | Fixed(1) | Fixed(4) | Fixed(4) | ForkJoinPool(4) | ForkJoinPool(1) | 55 | | Concurrent EDA | LinkedDeque | LinkedDeque | LinkedDeque | LinkedBlockingDeque | LinkedQueue | LinkedQueue | 56 | | Parallelism | False | False | False | True | True | True | 57 | | wait-free Optimization | False | False | False | True | False | False | 58 | | Time [ms] | 1970 - 2250 | 2100 - 2450 | 1700 - 1900 | 1200 - 1300 | 1200 - 1340 | 1900 - 2100 | 59 | | CompletableFuture | Supplier | Supplier | Supplier | Supplier | Supplier | Supplier | 60 | | Time [ms] | 1500 - 1950 | 1500 - 2000 | 1420 - 1700 | 1100 - 1350 | 700 - 1240 | 1500 - 1700 | 61 | 62 | 63 | #### version 0.2.0 64 | ``` 65 | External dependencies of the list of games with json protocol (DDD) 66 | MessageDialog to show the absolutePath of the rom when press enter key 67 | Asynchronous window minimization 68 | Optimize tab selection 69 | ``` 70 | 71 | #### version 0.1.1 72 | ``` 73 | Fixed row boolean table sort 74 | Optimization 75 | Repaint table with daemon 76 | Circular navigation tab 77 | 78 | ``` 79 | 80 | #### version 0.1.0 81 | ``` 82 | Table List 83 | Listerner InputKey - [ Left - Right ] 84 | Initialize sort column by game 85 | 86 | Circular navigation for tab pane child 87 | 88 | ``` 89 | 90 | #### version 0.0.2 91 | ``` 92 | Fixed navigation table list Up - Down limits 93 | Fixed status bar with static text 94 | Fixed selected row 95 | 96 | Table List 97 | Enable row 98 | Listerner InputKey - [ Up - Down - Enter ] 99 | 100 | Tab Pane 101 | Cartridge, snapshot Component 102 | Main image 103 | Background image 104 | 105 | Rom, cartridge, snapshot folders 106 | ``` 107 | 108 | #### version 0.0.1 109 | ``` 110 | Status Bar 111 | * Animation text 112 | 113 | Split Pane 114 | * Table List 115 | ColumnHeader - [ load - rom - game - type - size ] 116 | RowHeader 117 | Game list 118 | Disable row 119 | AutoScroll - [ H - V ] 120 | Listerner - [ ColumnHeader - RowHeader ] 121 | Transparent delimiter row 122 | 123 | * Tab Pane 124 | Cover Component 125 | Image 126 | 127 | Cover folder 128 | ``` 129 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.kotlin.jframe.standalone.start.checkbutton.application.async 8 | start-async-checkbutton-application 9 | 1.0-SNAPSHOT 10 | 11 | jar 12 | 13 | Example of start async application with checkbutton 14 | 15 | 16 | 17 | 18 | central 19 | http://jcenter.bintray.com 20 | 21 | 22 | 23 | 24 | 25 | 26 | 1.1.2 27 | 4.12 28 | kotlin.main 29 | UTF-8 30 | UTF-8 31 | 1.8 32 | 4.0.0 33 | yyyy-MM-dd'T'HH:mm:ss'Z' 34 | ${maven.build.timestamp} 35 | UTF-8 36 | 37 | 38 | 39 | 40 | org.jetbrains.kotlin 41 | kotlin-stdlib 42 | ${kotlin.version} 43 | 44 | 45 | 46 | junit 47 | junit 48 | ${junit.version} 49 | test 50 | 51 | 52 | org.jetbrains.kotlinx 53 | kotlinx-coroutines-core 54 | 0.15 55 | 56 | 57 | org.jetbrains.kotlin 58 | kotlin-test-junit 59 | ${kotlin.version} 60 | test 61 | 62 | 63 | com.github.salomonbrys.kotson 64 | kotson 65 | 2.3.0 66 | 67 | 68 | commons-io 69 | commons-io 70 | 2.5 71 | 72 | 73 | commons-codec 74 | commons-codec 75 | 1.10 76 | 77 | 78 | com.google.code.gson 79 | gson 80 | 2.8.0 81 | 82 | 83 | 84 | 85 | 86 | 87 | kotlin-maven-plugin 88 | org.jetbrains.kotlin 89 | 1.0.0-beta-1038 90 | 91 | 92 | compile 93 | compile 94 | 95 | 96 | ${project.basedir}/src/main/kotlin 97 | 98 | 99 | 100 | 101 | test-compile 102 | test-compile 103 | 104 | 105 | ${project.basedir}/src/test/kotlin 106 | 107 | 108 | 109 | 110 | 111 | 112 | org.apache.maven.plugins 113 | maven-compiler-plugin 114 | 3.1 115 | 116 | 117 | 118 | default-compile 119 | none 120 | 121 | 122 | 123 | default-testCompile 124 | none 125 | 126 | 127 | java-compile 128 | compile 129 | compile 130 | 131 | 132 | java-test-compile 133 | test-compile 134 | testCompile 135 | 136 | 137 | 138 | 139 | org.apache.maven.plugins 140 | maven-jar-plugin 141 | 2.5 142 | 143 | 144 | 145 | true 146 | ${main.class} 147 | 148 | 149 | 150 | 151 | 152 | org.apache.maven.plugins 153 | maven-assembly-plugin 154 | 2.2 155 | 156 | 157 | make-assembly 158 | package 159 | single 160 | 161 | 162 | 163 | ${main.class} 164 | 165 | 166 | 167 | jar-with-dependencies 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /src/main/kotlin/GBEE.kt: -------------------------------------------------------------------------------- 1 | package src 2 | 3 | 4 | import assets.frame.Frame 5 | import kotlinx.coroutines.experimental.launch 6 | import src.app.ApplicationImpl 7 | import src.configuration.ConfigurationImpl 8 | import utils.swing.Swing 9 | import java.util.concurrent.ExecutionException 10 | 11 | /** 12 | * Created by vicboma on 02/12/16. 13 | */ 14 | object GBEE { 15 | 16 | val version = "v.0.2.3" 17 | 18 | @JvmStatic fun main(args: Array) { 19 | launch(Swing) { 20 | 21 | if (System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0) 22 | // Setter JmenuBar in MenuBar for iOS 23 | System.setProperty("apple.laf.useScreenMenuBar", "true") 24 | 25 | 26 | try { 27 | //loader 28 | val classLoader = Thread.currentThread().getContextClassLoader() 29 | //Frame 30 | val mainFrame = Frame.create() 31 | //configuration 32 | val configure = ConfigurationImpl.create(classLoader, mainFrame) 33 | //Application 34 | val app = ApplicationImpl 35 | .create(mainFrame) 36 | .startAsync(configure) 37 | 38 | } catch (e: InterruptedException) { 39 | e.printStackTrace() 40 | } catch (e: ExecutionException) { 41 | e.printStackTrace() 42 | } finally { 43 | 44 | 45 | } 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/kotlin/app/Application.kt: -------------------------------------------------------------------------------- 1 | package src.app 2 | 3 | import src.configuration.ConfigurationImpl 4 | 5 | /** 6 | * Created by vicboma on 02/12/16. 7 | */ 8 | interface Application { 9 | fun startAsync(configuration : ConfigurationImpl) 10 | } 11 | -------------------------------------------------------------------------------- /src/main/kotlin/app/ApplicationImpl.kt: -------------------------------------------------------------------------------- 1 | package src.app 2 | 3 | import src.configuration.ConfigurationImpl 4 | import java.awt.BorderLayout 5 | import java.util.concurrent.CompletableFuture 6 | import javax.swing.JFrame 7 | import javax.swing.JPanel 8 | 9 | /** 10 | * Created by vicboma on 02/12/16. 11 | */ 12 | class ApplicationImpl internal constructor(private val frame: JFrame) : Application { 13 | 14 | private var configuration : ConfigurationImpl? = null 15 | 16 | companion object { 17 | fun create(frame: JFrame): Application { 18 | return ApplicationImpl(frame) 19 | } 20 | } 21 | 22 | override fun startAsync(configuration : ConfigurationImpl) { 23 | this.configuration = configuration 24 | var future = CompletableFuture() 25 | runAsync(future).get() 26 | } 27 | 28 | private fun runAsync(result: CompletableFuture) : CompletableFuture { 29 | CompletableFuture.runAsync { 30 | this.let { 31 | setLayout() 32 | setTitle() 33 | setCloseOp() 34 | setMenuBar() 35 | setStatusBar() 36 | frame.pack() 37 | setSize() 38 | setVisible() 39 | result.complete(this) 40 | } 41 | } 42 | 43 | return result 44 | } 45 | 46 | private fun setCloseOp() { 47 | frame.defaultCloseOperation = configuration?.display?.closeOp!! 48 | } 49 | 50 | private fun setTitle() { 51 | frame.setTitle(configuration?.display?.title!!) 52 | } 53 | 54 | private fun setLayout() { 55 | frame.setLayout(configuration?.display?.layout) 56 | } 57 | 58 | private fun setSize() { 59 | frame.setSize(configuration?.display?.widht!!, configuration?.display?.heigth!!) 60 | frame.isResizable = false 61 | } 62 | 63 | private fun setLocation() { 64 | frame.setLocationRelativeTo(configuration?.display?.location) 65 | } 66 | 67 | private fun setVisible() { 68 | frame.isVisible = configuration?.display?.visible!! 69 | } 70 | 71 | private fun setMenuBar() { 72 | frame.jMenuBar = configuration?.jmenuBar 73 | } 74 | 75 | private fun setStatusBar() { 76 | frame.contentPane.add(configuration?.statusBar as JPanel, BorderLayout.SOUTH); 77 | } 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/menuBar/View/MenuView.kt: -------------------------------------------------------------------------------- 1 | package app.components.menuBar.view 2 | 3 | import app.components.panel.ContentPaneParentImpl 4 | import assets.frame.Frame 5 | import assets.menuBarExt.child.dialog.MenuBarViewGrid 6 | import assets.menuBarExt.child.dialog.MenuBarViewList 7 | import assets.progressBar.StatusBar 8 | import assets.progressBar.addMenuItem 9 | import javax.swing.JMenu 10 | 11 | /** 12 | * Created by vicboma on 02/01/17. 13 | */ 14 | fun JMenu.MenuView(frame : Frame, statusBar : StatusBar, contentPaneParentImpl : ContentPaneParentImpl) = 15 | JMenu("View") 16 | .apply{ 17 | addMenuItem(MenuBarViewGrid(frame,statusBar,contentPaneParentImpl)) 18 | addMenuItem(MenuBarViewList(frame,statusBar,contentPaneParentImpl)) 19 | } 20 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/menuBar/View/subItem/grid/MenuBarViewGrid.kt: -------------------------------------------------------------------------------- 1 | package assets.menuBarExt.child.dialog 2 | 3 | import app.components.panel.ContentPaneParentImpl 4 | import assets.button.addActionListenerAsync 5 | import assets.frame.Frame 6 | import assets.progressBar.StatusBar 7 | import assets.progressBar.add 8 | import assets.progressBar.addMenuItem 9 | import assets.table.GRID_COVER 10 | import javax.swing.ButtonGroup 11 | import javax.swing.JMenu 12 | import javax.swing.JRadioButtonMenuItem 13 | 14 | /** 15 | * Created by vicboma on 12/12/16. 16 | */ 17 | fun JMenu.MenuBarViewGrid(frame: Frame, statusBar : StatusBar, contentPaneParentImpl : ContentPaneParentImpl) : JMenu { 18 | 19 | fun actionVisibility(frame: Frame, row: Int, cover: GRID_COVER) { 20 | frame.jMenuBar.isEnabled = false 21 | contentPaneParentImpl 22 | .coverScreen({ 23 | contentPaneParentImpl.visiblePanelListView(false) 24 | contentPaneParentImpl.visiblePanelGridView(false) 25 | }, true, row, cover) 26 | .thenRunAsync { 27 | println("****** FIN COMPLETABLE FUTURES *******") 28 | frame.jMenuBar.isEnabled = true 29 | } 30 | 31 | } 32 | 33 | val radioButtonList = listOf( 34 | JRadioButtonMenuItem("1x cover", false).apply { 35 | addActionListenerAsync { 36 | actionVisibility(frame, 1, GRID_COVER.ONE) 37 | } 38 | }, 39 | JRadioButtonMenuItem("2x cover", false).apply { 40 | addActionListener { 41 | actionVisibility(frame, 2, GRID_COVER.TWO) 42 | } 43 | }, 44 | JRadioButtonMenuItem("3x cover", false).apply { 45 | addActionListener { 46 | actionVisibility(frame, 3, GRID_COVER.THREE) 47 | } 48 | }, 49 | JRadioButtonMenuItem("4x cover", false).apply { 50 | addActionListener { 51 | actionVisibility(frame, 4, GRID_COVER.FOUR) 52 | } 53 | }, 54 | JRadioButtonMenuItem("Rom Name", false).apply { 55 | addActionListener { 56 | actionVisibility(frame, 13, GRID_COVER.FOUR) 57 | } 58 | } 59 | ) 60 | 61 | val radioGroup = ButtonGroup().add(radioButtonList) 62 | 63 | return JMenu("Grid") 64 | .apply { 65 | addMenuItem(radioButtonList) 66 | } 67 | } 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/menuBar/View/subItem/list/MenuBarViewList.kt: -------------------------------------------------------------------------------- 1 | package assets.menuBarExt.child.dialog 2 | 3 | import app.components.panel.ContentPaneParentImpl 4 | import assets.button.addActionListenerAsync 5 | import assets.frame.Frame 6 | import assets.progressBar.StatusBar 7 | import javax.swing.JMenu 8 | import javax.swing.JMenuItem 9 | 10 | /** 11 | * Created by vicboma on 12/12/16. 12 | */ 13 | fun JMenu.MenuBarViewList(frame: Frame, statusBar : StatusBar, contentPaneParentImpl: ContentPaneParentImpl) = 14 | JMenuItem("List").apply{ 15 | addActionListenerAsync { 16 | frame.jMenuBar.isEnabled = false 17 | contentPaneParentImpl.visiblePanelListView(true) 18 | contentPaneParentImpl.visiblePanelGridView(false) 19 | frame.jMenuBar.isEnabled = true 20 | } 21 | 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/menuBar/options/MenuOptions.kt: -------------------------------------------------------------------------------- 1 | package app.components.menuBar.view 2 | 3 | import app.components.menuBar.options.subItem.options.MenuBarOptions 4 | import app.configuration.properties.Properties 5 | import assets.frame.Frame 6 | import assets.progressBar.StatusBar 7 | import assets.progressBar.addMenuItem 8 | import javax.swing.JMenu 9 | 10 | /** 11 | * Created by vicboma on 02/01/17. 12 | */ 13 | fun JMenu.MenuOptions(frame : Frame, statusBar : StatusBar, properties: Properties) = 14 | JMenu("Options").apply { 15 | addMenuItem(MenuBarOptions(frame,statusBar,properties)) 16 | } 17 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/menuBar/options/subItem/options/MenuBarOptions.kt: -------------------------------------------------------------------------------- 1 | package app.components.menuBar.options.subItem.options 2 | 3 | import app.configuration.properties.Properties 4 | import app.configuration.properties.PropertiesEnum 5 | import assets.frame.Frame 6 | import assets.progressBar.StatusBar 7 | import assets.progressBar.addMenuItem 8 | import javax.swing.JMenu 9 | import javax.swing.JMenuItem 10 | import javax.swing.JSlider 11 | 12 | /** 13 | * Created by vicboma on 01/05/17. 14 | */ 15 | fun JMenu.MenuBarOptions(frame: Frame, statusBar : StatusBar, properties : Properties) : JMenu { 16 | 17 | var labelAsync = "Async load time :" 18 | var textAsync = "$labelAsync 5000 ms" 19 | 20 | var labelAPermits = "Set of permits :" 21 | var textPermits = "$labelAPermits 5 units" 22 | 23 | var labelIncremeteGrid = "Increment scrollGrid :" 24 | var textIncrementGrid = "$labelIncremeteGrid 16 units" 25 | 26 | 27 | val asyncLoadTimeLabel = JMenuItem(textAsync) 28 | val setOfPermits = JMenuItem(textPermits) 29 | val incrementGridLabel = JMenuItem(textIncrementGrid) 30 | 31 | 32 | val sliderAsync = JSlider(JSlider.HORIZONTAL,0,10000, properties.get(PropertiesEnum.SLIDER_ASYNC_TIME_LOAD)).apply{ 33 | setLabelTable(this@apply.createStandardLabels(5000)) 34 | setMinorTickSpacing(1000) 35 | setMajorTickSpacing(2000) 36 | setPaintTicks(true) 37 | setPaintLabels(true) 38 | addChangeListener { 39 | val source = it.source as JSlider 40 | properties.put( PropertiesEnum.SLIDER_ASYNC_TIME_LOAD ,source.value) 41 | asyncLoadTimeLabel.text = "$labelAsync ${source.value} ms " 42 | } 43 | } 44 | 45 | val sliderPermits = JSlider(JSlider.HORIZONTAL,1,11,properties.get(PropertiesEnum.SLIDER_PERMITS)).apply{ 46 | setLabelTable(this@apply.createStandardLabels(5)) 47 | setMinorTickSpacing(1) 48 | setMajorTickSpacing(2) 49 | setPaintTicks(true) 50 | setPaintLabels(true) 51 | addChangeListener { 52 | val source = it.source as JSlider 53 | properties.put(PropertiesEnum.SLIDER_PERMITS, source.value) 54 | setOfPermits.text = "$labelAPermits ${source.value} units " 55 | } 56 | isEnabled = false 57 | } 58 | 59 | val sliderIncrementScrollGrid = JSlider(JSlider.HORIZONTAL,0,100,properties.get(PropertiesEnum.SLIDER_INCREMENT_SCROLL_GRID)).apply{ 60 | setLabelTable(this@apply.createStandardLabels(50)) 61 | setMinorTickSpacing(10) 62 | setMajorTickSpacing(20) 63 | setPaintTicks(true) 64 | setPaintLabels(true) 65 | addChangeListener { 66 | val source = it.source as JSlider 67 | properties.put(PropertiesEnum.SLIDER_INCREMENT_SCROLL_GRID, source.value) 68 | incrementGridLabel.text = "$labelIncremeteGrid ${source.value} units " 69 | } 70 | } 71 | 72 | return JMenu("View") 73 | .apply { 74 | addMenuItem(asyncLoadTimeLabel) 75 | addMenuItem(sliderAsync) 76 | addSeparator() 77 | addMenuItem(setOfPermits) 78 | addMenuItem(sliderPermits) 79 | addSeparator() 80 | addMenuItem(incrementGridLabel) 81 | addMenuItem(sliderIncrementScrollGrid) 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /src/main/kotlin/app/components/panel/ContentPaneParentImpl.kt: -------------------------------------------------------------------------------- 1 | package app.components.panel 2 | 3 | import TableColumnHeaderAdapter 4 | import TableRowAdapter 5 | import app.components.panel.grid.CacheGrid 6 | import app.components.panel.grid.TableGridScrollPaneImpl 7 | import app.configuration.properties.Properties 8 | import assets.frame.Frame 9 | import assets.panel.multipleImages.PanelCartridge 10 | import assets.panel.multipleImages.PanelCover 11 | import assets.panel.multipleImages.PanelSnapshot 12 | import assets.panel.tab.TabPane 13 | import assets.panel.tab.TabPaneListener 14 | import assets.progressBar.Split 15 | import assets.progressBar.SplitImpl 16 | import assets.progressBar.StatusBarImpl 17 | import assets.table.GRID_COVER 18 | import assets.table.TableGridImpl 19 | import assets.table.TableImpl 20 | import assets.table.comparator.TableHeaderComparator 21 | import assets.table.listener.rowKey.TableRowKeyListener 22 | import assets.table.model.TableModelImpl 23 | import main.kotlin.utils.image.createBufferedImage 24 | import main.kotlin.utils.listGames.ListGames 25 | import src.configuration.Display 26 | import java.awt.BorderLayout 27 | import java.awt.Component 28 | import java.awt.Container 29 | import java.awt.Dimension 30 | import java.awt.image.BufferedImage 31 | import java.util.concurrent.CompletableFuture 32 | import javax.swing.ImageIcon 33 | import javax.swing.JPanel 34 | import javax.swing.JScrollPane 35 | import javax.swing.UIManager 36 | 37 | /** 38 | * Created by vicboma on 12/02/17. 39 | */ 40 | class ContentPaneParentImpl internal constructor(val classLoader : ClassLoader, val frame : Frame, val statusBar: StatusBarImpl, val properties : Properties) { 41 | 42 | private val listGames: ListGames 43 | private val dimension : Dimension 44 | private val tableModelImpl : TableModelImpl 45 | private val table: TableImpl 46 | private val tabbedPane: TabPane 47 | private val panelListView: SplitImpl 48 | 49 | private var scrollGrid = JScrollPane() 50 | 51 | companion object { 52 | fun create (classLoader: ClassLoader, frame: Frame, statusBar: StatusBarImpl, properties : Properties) = ContentPaneParentImpl(classLoader, frame, statusBar,properties) 53 | } 54 | 55 | init { 56 | 57 | listGames = ListGames.create(classLoader, "list/listGame.json") 58 | dimension = Dimension(Display.WIDHT, Display.HEIGTH) 59 | tableModelImpl = TableModelImpl.create(listGames.columnNames, listGames.rowNames) 60 | table = TableImpl.create( classLoader, tableModelImpl, dimension) 61 | tabbedPane = 62 | TabPane(TabPaneListener.create(table)) 63 | .apply{ 64 | add("Cover", ImageIcon(), PanelCover(classLoader,"cover/_bg.png", "cover/addamsf.png"), 0) 65 | add("Snapshot", ImageIcon(), PanelSnapshot(classLoader,"snapshot/_bg.png", "snapshot/addamsf.png"), 1) 66 | add("Cartridge", ImageIcon(), PanelCartridge(classLoader,"cartridge/_bg.png", "cartridge/addamsf.png"), 2) 67 | } 68 | 69 | panelListView = 70 | SplitImpl.create( 71 | Split.HORIZONTAL, 72 | Frame.create(table.scrollPane(), BorderLayout.CENTER).contentPane, 73 | Frame.create(tabbedPane.scrollPane(), BorderLayout.CENTER).contentPane, 74 | UIManager.getBoolean("SplitPane.continuousLayout"), 75 | Display.WIDHT/2) 76 | 77 | 78 | table.apply { 79 | addMouseListenerColumn(TableColumnHeaderAdapter.create(classLoader, this, TableHeaderComparator.create())) 80 | addMouseListenerRow(TableRowAdapter.create(this, statusBar, tabbedPane)) 81 | addKeyListenerInput(TableRowKeyListener.create(frame, this, statusBar, tabbedPane)) 82 | } 83 | 84 | //visiblePanelListView(true) 85 | 86 | /* coverScreen({ visiblePanelListView(false) }, true, 13, GRID_COVER.FOUR) 87 | .thenRunAsync { 88 | println("****** FIN COMPLETABLE FUTURES *******") 89 | } 90 | */ 91 | } 92 | 93 | fun visiblePanelGridView(state : Boolean) = visiblePanelView(state,scrollGrid) 94 | 95 | fun visiblePanelListView(state : Boolean) = visiblePanelView(state,panelListView) 96 | 97 | fun visiblePanelView(state : Boolean, component: Component){ 98 | if(state) 99 | frame.contentPane.add(component) 100 | else 101 | frame.contentPane.remove(component) 102 | 103 | (frame.contentPane as JPanel).revalidate() 104 | frame.repaint() 105 | } 106 | 107 | fun coverScreen(componentVisible:() -> Unit, listGridVisible:Boolean , row : Int, coverIndex: GRID_COVER) : CompletableFuture { 108 | fun recalculeSize(column: Int): Int { 109 | var size = listGames.rowNames!!.size / column 110 | val resto = listGames.rowNames!!.size % column == 0 111 | if (!resto) 112 | size++ 113 | 114 | return size 115 | } 116 | 117 | val column = row 118 | componentVisible.invoke() 119 | 120 | val tableModel = TableModelImpl.create(column, recalculeSize(column), row) 121 | val jtable = TableGridImpl(classLoader, tableModel, coverIndex) 122 | scrollGrid = TableGridScrollPaneImpl(jtable, properties) 123 | 124 | visiblePanelGridView(listGridVisible) 125 | 126 | val sizeImage = CacheGrid.mapSizeImageCover.get(coverIndex) 127 | val bufferedImageDefault = ImageIcon().createBufferedImage(sizeImage!!.first,sizeImage!!.second, BufferedImage.TYPE_INT_ARGB) 128 | 129 | return CacheGrid.createRefImage(statusBar,listGames, classLoader, bufferedImageDefault, jtable,coverIndex,properties) 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/panel/grid/CacheGrid.kt: -------------------------------------------------------------------------------- 1 | package app.components.panel.grid 2 | 3 | import app.configuration.properties.Properties 4 | import app.configuration.properties.PropertiesEnum 5 | import assets.progressBar.StatusBar 6 | import assets.table.GRID_COVER 7 | import kotlinx.coroutines.experimental.CommonPool 8 | import kotlinx.coroutines.experimental.Deferred 9 | import kotlinx.coroutines.experimental.async 10 | import kotlinx.coroutines.experimental.runBlocking 11 | import kotlinx.coroutines.experimental.sync.Mutex 12 | import main.kotlin.utils.image.BufferedImageMemoryFromComponent 13 | import main.kotlin.utils.image.createBufferedImage 14 | import main.kotlin.utils.image.scale 15 | import main.kotlin.utils.listGames.ListGames 16 | import utils.thread.DynamicSemaphore 17 | import java.awt.Color 18 | import java.awt.Component 19 | import java.awt.Container 20 | import java.awt.Dimension 21 | import java.awt.image.BufferedImage 22 | import java.lang.Exception 23 | import java.security.SecureRandom 24 | import java.util.* 25 | import java.util.concurrent.CompletableFuture 26 | import javax.swing.* 27 | 28 | 29 | /** 30 | * Created by vicboma on 13/04/17. 31 | */ 32 | object CacheGrid { 33 | 34 | val mapNameRom = mutableMapOf() 35 | val mapSizeImageCover = mapOf(Pair(GRID_COVER.FOUR,Pair(240,200)),Pair(GRID_COVER.THREE,Pair(320,300)),Pair(GRID_COVER.TWO,Pair(550,500)),Pair(GRID_COVER.ONE,Pair(680,650))) 36 | val random = SecureRandom() 37 | var state = CacheState.STOP 38 | val mutex = Mutex() 39 | 40 | fun createRefImage(statusBar : StatusBar,listGames: ListGames, classLoader: ClassLoader, bufferedDefault : BufferedImage, jTable:JTable, coverSize : GRID_COVER , properties : Properties) : CompletableFuture { 41 | var job : CompletableFuture 42 | 43 | return runBlocking> { 44 | 45 | println("****** INIT LOAD ASYNC *******") 46 | 47 | mapNameRom.clear() 48 | 49 | val semaphore = DynamicSemaphore(0, true) 50 | val futures = ArrayList>>() 51 | 52 | state = CacheState.LOADING 53 | 54 | val imageDefault = ImageIcon().scale(bufferedDefault, classLoader.getResource("cover/_gbNotFound.png").file.toString()) 55 | 56 | val timeInit = System.currentTimeMillis() 57 | 58 | try { 59 | 60 | val rows = listGames.rowNames?.size 61 | var cols = jTable.model.columnCount 62 | for (row in 0..rows!!) { 63 | for (col in 0..cols - 1) { 64 | 65 | val index = (row * cols) + col 66 | if (index > rows || state == CacheState.STOP) 67 | break 68 | 69 | futures.add(CompletableFuture.supplyAsync { 70 | 71 | async(CommonPool) { 72 | val permits = properties.get(PropertiesEnum.SLIDER_PERMITS) 73 | val delay = properties.get(PropertiesEnum.SLIDER_ASYNC_TIME_LOAD) 74 | 75 | mutex.lock(this@async) 76 | /* semaphore.apply { 77 | setMaxPermits(permits) 78 | acquire() 79 | } 80 | */ 81 | try { 82 | 83 | val pairSize = mapSizeImageCover.get(coverSize) 84 | val bufferImage = ImageIcon().createBufferedImage(pairSize!!.first, pairSize!!.second, BufferedImage.TYPE_INT_ARGB) 85 | val nameRom = listGames.rowNames!![(row * cols) + col][1].toString() 86 | val nameImage = nameRom.toLowerCase().split(".")[0].toString().plus(".png") 87 | val resource = classLoader.getResource("cover/$nameImage") 88 | val image = when (resource) { 89 | null -> imageDefault 90 | else -> ImageIcon().scale(bufferImage, resource.file.toString()) 91 | } 92 | 93 | // println(StringBuffer("($row * $cols) + $col = ${(row * cols) + col}").append(" $nameRom - $nameImage ").toString()) 94 | 95 | val imageIcon = ImageIcon( 96 | BufferedImageMemoryFromComponent.invoke( 97 | JPanel().apply { 98 | size = Dimension(bufferImage.width, bufferImage.height) 99 | isOpaque = false 100 | setBackground(Color(0, 0, 0)) 101 | 102 | layout = boxLayout(this).apply { 103 | setBackground(Color(0, 0, 0)) 104 | isOpaque = false 105 | } 106 | 107 | add(jLabelFactory(" ")) 108 | add(jLabelFactory(ImageIcon(image))) 109 | add(jLabelFactory(" ")) 110 | add(jLabelFactory(nameRom)) 111 | } 112 | ) 113 | ) 114 | 115 | // println(delayLoadAsync) 116 | // Thread.sleep((random.nextInt(delay + 1)).toLong()) 117 | kotlinx.coroutines.experimental.delay((random.nextInt(delay + 1)).toLong()) 118 | //yield() 119 | if (state != CacheState.STOP) 120 | jTable.setValueAt(imageIcon, row, col) 121 | 122 | mapNameRom.put(index,nameRom) 123 | 124 | true 125 | } catch(e: Exception) { 126 | false 127 | } finally { 128 | mutex.unlock(this@async) 129 | // semaphore.release() 130 | } 131 | } 132 | 133 | }) 134 | 135 | } 136 | 137 | } 138 | 139 | } catch(e: Exception) { 140 | println(e.message) 141 | e.stackTrace 142 | } finally { 143 | state = CacheState.FINISH 144 | job = CompletableFuture.allOf(*futures.toTypedArray()) 145 | job.thenRunAsync { 146 | println("****** ${System.currentTimeMillis() - timeInit} ms ******") 147 | statusBar.text("Time to load process : ${System.currentTimeMillis() - timeInit} ms ******") 148 | } 149 | } 150 | 151 | job 152 | } 153 | 154 | } 155 | 156 | private fun boxLayout(container : Container) = BoxLayout(container, BoxLayout.Y_AXIS) 157 | 158 | private fun jLabelFactory(name : String ) = JLabel(name).apply { 159 | setBackground(Color(0, 0, 0)) 160 | isOpaque = false 161 | setAlignmentX(Component.CENTER_ALIGNMENT) 162 | } 163 | 164 | private fun jLabelFactory(imageIcon : ImageIcon ) = JLabel(imageIcon).apply { 165 | setBackground(Color(0, 0, 0)) 166 | isOpaque = false 167 | setAlignmentX(Component.CENTER_ALIGNMENT) 168 | } 169 | 170 | } 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /src/main/kotlin/app/components/panel/grid/CacheState.kt: -------------------------------------------------------------------------------- 1 | package app.components.panel.grid 2 | 3 | /** 4 | * Created by vicboma on 05/05/17. 5 | */ 6 | enum class CacheState { 7 | STOP, LOADING, FINISH 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/app/components/panel/grid/TableGridImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.table 2 | 3 | import assets.table.model.TableModelImpl 4 | import javax.swing.JTable 5 | import javax.swing.event.ListSelectionEvent 6 | import javax.swing.event.ListSelectionListener 7 | 8 | 9 | 10 | /** 11 | * Created by vbolinch on 02/01/2017. 12 | */ 13 | class TableGridImpl internal constructor(val classLoader: ClassLoader, dm: TableModelImpl?, coverIndex: GRID_COVER) : JTable(dm) { 14 | 15 | private val mapCover by lazy { mapOf(Pair(GRID_COVER.ONE,700),Pair(GRID_COVER.TWO,570),Pair(GRID_COVER.THREE,350),Pair(GRID_COVER.FOUR,250)) } 16 | 17 | companion object{ 18 | fun create(classLoader: ClassLoader, dm : TableModelImpl?,coverIndex: GRID_COVER) = TableGridImpl(classLoader,dm,coverIndex) 19 | } 20 | 21 | init { 22 | 23 | this.apply { 24 | showVerticalLines = false 25 | showHorizontalLines = false 26 | autoResizeMode = JTable.AUTO_RESIZE_ALL_COLUMNS 27 | val rowH = getRowHeigthToCover(coverIndex)!! 28 | setRowHeight(rowH) 29 | rowSelectionAllowed = false 30 | columnSelectionAllowed = false 31 | cellSelectionEnabled = true 32 | 33 | selectionModel.addListSelectionListener(object: ListSelectionListener { 34 | override fun valueChanged(event: ListSelectionEvent) { 35 | if(!selectionModel.isSelectionEmpty){ 36 | val rowIndex = selectedRow 37 | val colIndex = selectedColumn 38 | val image = model.getValueAt(rowIndex,colIndex) 39 | javax.swing.JOptionPane.showMessageDialog(null,image) 40 | } 41 | 42 | selectionModel.clearSelection() 43 | } 44 | }) 45 | 46 | setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION) 47 | } 48 | } 49 | 50 | private fun getRowHeigthToCover(coverIndex: GRID_COVER) = mapCover.get(coverIndex) 51 | 52 | } 53 | 54 | 55 | enum class GRID_COVER { ONE, TWO, THREE, FOUR, NAME_ROM } -------------------------------------------------------------------------------- /src/main/kotlin/app/components/panel/grid/TableGridScrollPaneImpl.kt: -------------------------------------------------------------------------------- 1 | package app.components.panel.grid 2 | 3 | import app.configuration.properties.Properties 4 | import app.configuration.properties.PropertiesEnum 5 | import javax.swing.JScrollPane 6 | import javax.swing.JTable 7 | 8 | /** 9 | * Created by vicboma on 14/04/17. 10 | */ 11 | class TableGridScrollPaneImpl internal constructor(table : JTable, properties: Properties) : JScrollPane(table) { 12 | 13 | init { 14 | val slideIncrement = properties.get(PropertiesEnum.SLIDER_INCREMENT_SCROLL_GRID) 15 | verticalScrollBar.setUnitIncrement(slideIncrement) 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/app/configuration/Configuration.kt: -------------------------------------------------------------------------------- 1 | package src.configuration 2 | 3 | /** 4 | * Created by vicboma on 02/12/16. 5 | */ 6 | interface Configuration { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/kotlin/app/configuration/ConfigurationImpl.kt: -------------------------------------------------------------------------------- 1 | package src.configuration 2 | 3 | 4 | import app.components.menuBar.view.MenuOptions 5 | import app.components.menuBar.view.MenuView 6 | import app.components.panel.ContentPaneParentImpl 7 | import app.configuration.properties.Properties 8 | import assets.frame.Frame 9 | import assets.progressBar.StatusBar 10 | import assets.progressBar.StatusBarImpl 11 | import assets.progressBar.addMenu 12 | import src.configuration.properties.PropertiesImpl 13 | import java.awt.BorderLayout 14 | import javax.swing.JMenu 15 | import javax.swing.JMenuBar 16 | 17 | /** 18 | * Created by vicboma on 02/12/16. 19 | */ 20 | class ConfigurationImpl internal constructor(classLoader: ClassLoader, frame: Frame) { 21 | 22 | val properties: Properties 23 | val statusBar: StatusBar 24 | val contentPaneParent: ContentPaneParentImpl 25 | val jmenuBar: JMenuBar 26 | val display: Display 27 | 28 | companion object { 29 | fun create(classLoader: ClassLoader, frame: Frame) = ConfigurationImpl(classLoader, frame) 30 | } 31 | 32 | init { 33 | 34 | properties = PropertiesImpl.create() 35 | 36 | display = DisplayImpl.create(Display.KFRAME_JAVA, Display.WIDHT, Display.HEIGTH, Display.VISIBLE, BorderLayout()) 37 | 38 | statusBar = StatusBarImpl.create(Display.WIDHT) 39 | 40 | contentPaneParent = ContentPaneParentImpl( 41 | classLoader, 42 | frame, 43 | statusBar, 44 | properties 45 | ) 46 | 47 | jmenuBar = JMenuBar().apply { 48 | addMenu( 49 | listOf( 50 | JMenu().MenuView(frame, statusBar, contentPaneParent), 51 | JMenu().MenuOptions(frame, statusBar, properties) 52 | ) 53 | ) 54 | } 55 | 56 | } 57 | 58 | } 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/main/kotlin/app/configuration/properties/PropertiesEnum.kt: -------------------------------------------------------------------------------- 1 | package app.configuration.properties 2 | 3 | /** 4 | * Created by vicboma on 07/05/17. 5 | */ 6 | enum class PropertiesEnum { 7 | SLIDER_ASYNC_TIME_LOAD, 8 | SLIDER_PERMITS, 9 | SLIDER_INCREMENT_SCROLL_GRID 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/app/configuration/properties/PropertiesImpl.kt: -------------------------------------------------------------------------------- 1 | package src.configuration.properties 2 | 3 | /** 4 | * Created by vicboma on 02/12/16. 5 | */ 6 | import app.configuration.properties.Properties 7 | import app.configuration.properties.PropertiesEnum 8 | import java.util.concurrent.ConcurrentHashMap 9 | 10 | class PropertiesImpl () : Properties { 11 | 12 | override fun put(key: PropertiesEnum, value: T) = map.put(key, value) 13 | 14 | override fun get(str: PropertiesEnum) = map[str] as (T) 15 | 16 | private val map: ConcurrentHashMap 17 | 18 | companion object { 19 | fun create() = PropertiesImpl() 20 | } 21 | 22 | init { 23 | map = ConcurrentHashMap( 24 | mapOf( 25 | Pair(PropertiesEnum.SLIDER_ASYNC_TIME_LOAD, 1), 26 | Pair(PropertiesEnum.SLIDER_PERMITS, 11), 27 | Pair(PropertiesEnum.SLIDER_INCREMENT_SCROLL_GRID,16) 28 | ) 29 | ) 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/app/configuration/properties/Propierties.kt: -------------------------------------------------------------------------------- 1 | package app.configuration.properties 2 | 3 | /** 4 | * Created by vicboma on 07/05/17. 5 | */ 6 | interface Properties { 7 | fun get(key: PropertiesEnum): T 8 | fun put(key: PropertiesEnum, value: T) : Any? 9 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/Component.kt: -------------------------------------------------------------------------------- 1 | package assets 2 | 3 | /** 4 | * Created by vicboma on 05/12/16. 5 | */ 6 | interface Component { 7 | fun component() : T 8 | } 9 | 10 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/Renderable.kt: -------------------------------------------------------------------------------- 1 | package assets 2 | 3 | /** 4 | * Created by vicboma on 05/12/16. 5 | */ 6 | interface Renderable { 7 | fun asyncUI() 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/button/ButtonAbstractExt.kt: -------------------------------------------------------------------------------- 1 | package assets.button 2 | 3 | import kotlinx.coroutines.experimental.CommonPool 4 | import kotlinx.coroutines.experimental.CoroutineScope 5 | import utils.swing.Swing 6 | import javax.swing.AbstractButton 7 | 8 | /** 9 | * Created by vicboma on 14/05/17. 10 | */ 11 | fun AbstractButton.addActionListenerAsync(block: suspend CoroutineScope.() -> Unit){ 12 | addActionListener { 13 | kotlinx.coroutines.experimental.runBlocking { 14 | kotlinx.coroutines.experimental.async(CommonPool) { 15 | block.invoke(this@async) 16 | } 17 | } 18 | } 19 | } 20 | 21 | fun AbstractButton.addActionListernerSwing(block: suspend CoroutineScope.() -> Unit) { 22 | addActionListener { 23 | kotlinx.coroutines.experimental.runBlocking { 24 | kotlinx.coroutines.experimental.launch(Swing) { 25 | block.invoke(this@launch) 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/button/group/ButtonGroupExt.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import javax.swing.AbstractButton 4 | import javax.swing.ButtonGroup 5 | 6 | /** 7 | * Created by vicboma on 05/12/16. 8 | */ 9 | 10 | fun ButtonGroup.add(list: List) { 11 | for( it in list){ 12 | this.add(it as AbstractButton ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/chooser/color/ColorChooser.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import java.awt.Color 4 | 5 | /** 6 | * Created by vicboma on 15/12/16. 7 | */ 8 | interface ColorChooser{ 9 | fun showDialog(callback: (color: Color) -> Unit) 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/chooser/color/ColorChooserImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import java.awt.Color 4 | import javax.swing.JColorChooser 5 | 6 | 7 | 8 | /** 9 | * Created by vicboma on 05/12/16. 10 | */ 11 | class ColorChooserImpl internal constructor(private val title: String, private val _color : Color) : JColorChooser(), ColorChooser { 12 | 13 | companion object { 14 | fun create(title : String, _color : Color) = ColorChooserImpl(title, _color) 15 | } 16 | 17 | init { 18 | 19 | } 20 | 21 | override fun showDialog(callback: (color: Color) -> Unit) { 22 | val color = JColorChooser.showDialog(null, title, color) 23 | if(null != color) 24 | callback.invoke( color) 25 | } 26 | 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/chooser/file/FileChooser.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | /** 4 | * Created by vicboma on 15/12/16. 5 | */ 6 | interface FileChooser { 7 | fun showDialog(callback: (str: String) -> Unit) 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/chooser/file/FileChooserImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import javax.swing.JFileChooser 4 | import javax.swing.JFrame 5 | 6 | 7 | /** 8 | * Created by vicboma on 05/12/16. 9 | */ 10 | class FileChooserImpl internal constructor(private val frame : JFrame) : javax.swing.JFileChooser(), FileChooser { 11 | 12 | companion object { 13 | fun create(frame : JFrame) = FileChooserImpl(frame) 14 | } 15 | 16 | init { 17 | 18 | } 19 | 20 | override fun showDialog(callback: (str: String) -> Unit) { 21 | val file = javax.swing.JFileChooser(); 22 | file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 23 | 24 | val res = file.showOpenDialog(frame) 25 | 26 | when (res) { 27 | JFileChooser.APPROVE_OPTION -> callback.invoke(file.selectedFile.toString()) 28 | JFileChooser.CANCEL_OPTION -> callback.invoke("CANCEL_OPTION") 29 | else -> callback.invoke("ERROR_OPTION") 30 | } 31 | } 32 | 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/EnumDialog.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.message 2 | 3 | /** 4 | * Created by vicboma on 10/12/16. 5 | */ 6 | enum class EnumDialog constructor(val value : Int){ 7 | // 8 | // Message types. Used by the UI to determine what icon to display, 9 | // and possibly what behavior to give based on the type. 10 | // 11 | /** Used for error messages. */ 12 | ERROR_MESSAGE(0), 13 | /** Used for information messages. */ 14 | INFORMATION_MESSAGE(1), 15 | /** Used for warning messages. */ 16 | WARNING_MESSAGE(2), 17 | /** Used for questions. */ 18 | QUESTION_MESSAGE(3), 19 | /** No icon is used. */ 20 | PLAIN_MESSAGE(-1) 21 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/confirm/Confirm.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.confirm 2 | 3 | /** 4 | * Created by vicboma on 10/12/16. 5 | */ 6 | interface Confirm { 7 | fun showDialog(yes : () -> Unit) 8 | fun showDialog(yes : () -> Unit,no : () -> Unit) 9 | fun showDialog(yes : () -> Unit, no : () -> Unit, cancel : () -> Unit) 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/confirm/ConfirmImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.confirm 2 | 3 | import java.awt.Frame 4 | import javax.swing.JOptionPane 5 | 6 | /** 7 | * Created by vicboma on 10/12/16. 8 | */ 9 | class ConfirmImpl internal constructor(private val frame : Frame, private val pair : Pair, private val option : Int) : Confirm { 10 | 11 | companion object { 12 | fun create(frame: Frame, pair: Pair, option: Int ) = ConfirmImpl(frame, pair, option) 13 | } 14 | 15 | init { 16 | 17 | } 18 | 19 | override fun showDialog(yes : () -> Unit) = showDialog(yes,{},{}); 20 | 21 | override fun showDialog(yes : () -> Unit,no : () -> Unit) = showDialog(yes,no,{}); 22 | 23 | override fun showDialog(yes : () -> Unit, no : () -> Unit, cancel : () -> Unit) { 24 | val res = JOptionPane.showConfirmDialog(frame, pair.second, pair.first, option) 25 | when (res){ 26 | JOptionPane.YES_OPTION -> yes.invoke() 27 | JOptionPane.NO_OPTION -> no.invoke() 28 | JOptionPane.CANCEL_OPTION -> cancel.invoke() 29 | JOptionPane.CLOSED_OPTION -> System.out.println("Clode Dialog") 30 | else -> { 31 | throw RuntimeException("Error JOptionPane input buttons !!!!") 32 | } 33 | } 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/input/Input.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.confirm 2 | 3 | /** 4 | * Created by vicboma on 10/12/16. 5 | */ 6 | interface Input { 7 | fun showDialog(callback: (str : String) -> Unit) 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/input/InputImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.confirm 2 | 3 | import assets.dialog.message.EnumDialog 4 | import java.awt.Frame 5 | import java.util.* 6 | import javax.swing.Icon 7 | import javax.swing.JOptionPane 8 | 9 | /** 10 | * Created by vicboma on 10/12/16. 11 | */ 12 | class InputImpl internal constructor(private val frame : Frame, private val pair : Pair, private val option : EnumDialog, private val icon : Icon?, private val selectionValues: ArrayList?, private val initialSelectionValue : Object?) : Input { 13 | 14 | companion object { 15 | 16 | fun create(frame: Frame, pair: Pair, option: EnumDialog) = 17 | InputImpl(frame, pair, option, null, null, null) 18 | 19 | fun create(frame: Frame, pair: Pair, option: EnumDialog, icon: Icon?, selectionValues: ArrayList?, initialSelectionValue: Object?) = 20 | InputImpl(frame, pair, option, icon, selectionValues, initialSelectionValue) 21 | } 22 | 23 | init { 24 | 25 | } 26 | 27 | override fun showDialog(callback: (str: String) -> Unit) { 28 | val res = JOptionPane.showInputDialog(frame, pair.second, pair.first, option.value, icon, selectionValues?.toArray(), initialSelectionValue) 29 | if(null != res) 30 | callback.invoke(res.toString()) 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/message/Message.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.message 2 | 3 | /** 4 | * Created by vicboma on 10/12/16. 5 | */ 6 | interface Message { 7 | fun showDialog() 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/dialog/message/MessageImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.dialog.message 2 | 3 | import java.awt.Frame 4 | import javax.swing.ImageIcon 5 | import javax.swing.JOptionPane 6 | 7 | /** 8 | * Created by vicboma on 10/12/16. 9 | */ 10 | class MessageImpl internal constructor(private val frame : Frame, val pair : Pair, val option : EnumDialog, val icon : ImageIcon?) : Message { 11 | 12 | companion object { 13 | fun create(frame: Frame, pair: Pair, option: EnumDialog) = 14 | MessageImpl(frame, pair, option, null) 15 | 16 | fun create(frame: Frame, pair: Pair, option: EnumDialog, icon: ImageIcon) = 17 | MessageImpl(frame, pair, option, icon) 18 | } 19 | 20 | init { 21 | } 22 | 23 | override fun showDialog() = JOptionPane.showMessageDialog(frame, pair.second, pair.first, option.value, icon) 24 | 25 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/display/Display.kt: -------------------------------------------------------------------------------- 1 | package src.configuration 2 | 3 | import src.GBEE 4 | import java.awt.Component 5 | import java.awt.GraphicsEnvironment 6 | import java.awt.LayoutManager 7 | 8 | /** 9 | * Created by vicboma on 02/12/16. 10 | */ 11 | interface Display { 12 | 13 | companion object { 14 | private val localGraphics = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds() 15 | val KFRAME_JAVA = "GB Emulator Environment ${GBEE.version}" 16 | val WIDHT = localGraphics.width // 1280 17 | val HEIGTH = localGraphics.height // 773 18 | val VISIBLE = true 19 | } 20 | 21 | var title: String 22 | val widht: Int? 23 | val heigth: Int? 24 | val visible: Boolean? 25 | val layout: LayoutManager? 26 | val closeOp: Int? 27 | val location: Component? 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/display/DisplayImpl.kt: -------------------------------------------------------------------------------- 1 | package src.configuration 2 | 3 | import java.awt.Component 4 | import java.awt.LayoutManager 5 | import javax.swing.JFrame 6 | 7 | /** 8 | * Created by vicboma on 02/12/16. 9 | */ 10 | class DisplayImpl internal constructor(override var title: String, override val widht: Int?, override val heigth: Int?, override val visible: Boolean?, override val closeOp: Int?, override val layout: LayoutManager?, override val location: Component?) : Display { 11 | 12 | companion object { 13 | fun create(title: String, widht: Int?, heigth: Int?, visible: Boolean?, layout: LayoutManager?)= 14 | DisplayImpl(title, widht, heigth, visible, JFrame.EXIT_ON_CLOSE, layout, null) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/frame/Frame.kt: -------------------------------------------------------------------------------- 1 | package assets.frame 2 | 3 | import java.awt.BorderLayout 4 | import java.awt.Toolkit 5 | import java.awt.event.ComponentListener 6 | import javax.swing.ImageIcon 7 | import javax.swing.JComponent 8 | import javax.swing.JFrame 9 | 10 | /** 11 | * Created by vicboma on 06/01/17. 12 | */ 13 | class Frame internal constructor() : JFrame() { 14 | 15 | private val APP_MAIN = "app/main.png" 16 | 17 | companion object{ 18 | 19 | fun create() = Frame() 20 | 21 | fun create(component: JComponent, index: String) = 22 | Frame().apply { 23 | contentPane.add(component, index) 24 | } 25 | } 26 | 27 | init { 28 | 29 | layout = BorderLayout() 30 | //if(utils.system.isMac()) 31 | setIconImage(Toolkit.getDefaultToolkit().getImage(APP_MAIN)); 32 | com.apple.eawt.Application.getApplication().setDockIconImage(ImageIcon(APP_MAIN).getImage()); 33 | // else 34 | 35 | } 36 | 37 | fun addComponent(componentListener : ComponentListener) { 38 | addComponentListener(componentListener) 39 | } 40 | 41 | 42 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/frame/component/ComponentListenerScreen.kt: -------------------------------------------------------------------------------- 1 | package assets.frame.component 2 | 3 | import assets.frame.Frame 4 | import java.awt.event.ComponentEvent 5 | import java.awt.event.ComponentListener 6 | 7 | /** 8 | * Created by vicboma on 06/01/17. 9 | */ 10 | class ComponentListenerScreen internal constructor(var component: Frame) : ComponentListener { 11 | 12 | override fun componentMoved(e: ComponentEvent?) { 13 | // throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 14 | } 15 | 16 | override fun componentResized(e: ComponentEvent?) { 17 | val component = e?.component!! 18 | if(!component.isVisible) 19 | return 20 | 21 | // // throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 22 | } 23 | 24 | override fun componentShown(e: ComponentEvent?) { 25 | // throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 26 | } 27 | 28 | override fun componentHidden(e: ComponentEvent?) { 29 | // throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/menu/MenuImplExt.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import java.awt.Component 4 | import java.awt.Menu 5 | import java.awt.MenuItem 6 | import javax.swing.JComponent 7 | import javax.swing.JMenu 8 | import javax.swing.JMenuItem 9 | 10 | /** 11 | * Created by vicboma on 15/12/16. 12 | */ 13 | 14 | fun JMenu.addMenuItem(name : T) = this.add(name) 15 | fun JMenu.addMenuItem(name : T) = this.add(name) 16 | fun JMenu.addMenuItem(name : T) = this.addMenuItem(name as JComponent) 17 | fun JMenu.addMenuItem(list : List) { 18 | for (it in list) 19 | this.addMenuItem(it) 20 | } 21 | 22 | fun JMenu.addMenuItem(name : MenuItem) = this.addMenuItem(name as JComponent) 23 | 24 | fun Menu.addMenuItem(name : T) = this.add(name) 25 | fun Menu.addMenuItem(name : T) = this.add(name) 26 | 27 | fun Menu.addMenuItem(list : List) { 28 | for (it in list) 29 | this.addMenuItem(it) 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/menuBarExt/JMenuBarImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import javax.swing.JComponent 4 | import javax.swing.JMenu 5 | import javax.swing.JMenuBar 6 | 7 | 8 | /** 9 | * Created by vicboma on 05/12/16. 10 | */ 11 | 12 | fun JMenuBar.createSubMenu(parent: JMenuBar?, child: JComponent?) = (parent as JMenu).add(child) 13 | 14 | fun JMenuBar.createSubMenu(parent: JMenuBar?, child: MutableList) { 15 | for (it in child) 16 | (parent as JMenu).add(it) 17 | } 18 | 19 | fun JMenuBar.addMenu(menu: JMenu) = this.add(menu) 20 | 21 | fun JMenuBar.addMenu(menuList: List) : JMenuBar { 22 | for (it in menuList) 23 | this.addMenu(it) 24 | 25 | return this 26 | } 27 | 28 | fun JMenuBar.visibilityAll(opc:Boolean) = this.components.forEach { 29 | it.isEnabled = opc 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/Panel.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | /** 4 | * Created by vicboma on 05/12/16. 5 | */ 6 | interface Panel { 7 | 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/PanelImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import java.awt.Container 4 | import java.awt.LayoutManager 5 | import javax.swing.BoxLayout 6 | import javax.swing.JPanel 7 | 8 | /** 9 | * Created by vicboma on 05/12/16. 10 | */ 11 | class PanelImpl internal constructor(private val layoutManager: LayoutManager, private val pair: Pair) : JPanel(layoutManager) , Panel { 12 | 13 | companion object { 14 | fun create(layout: LayoutManager, pair: Pair) = PanelImpl(layout, pair) 15 | } 16 | 17 | init { 18 | //setBorder(BorderFactory.createTitledBorder("")) 19 | setAlignmentX(java.awt.Component.CENTER_ALIGNMENT) 20 | setLayout(BoxLayout(this, BoxLayout.Y_AXIS)) 21 | 22 | 23 | this.add(pair.first) 24 | this.add(pair.second) 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/grid/PanelGridLayoutImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.grid 2 | 3 | /** 4 | * Created by vicboma on 12/02/17. 5 | */ 6 | /*class PanelGridLayoutImpl internal constructor( 7 | private val _rows: Int, 8 | private val _cols: Int, 9 | private val _hgap: Int, 10 | private val _vgap: Int, 11 | private val dimension : Dimension, 12 | private val tableModelImpl : TableModelImpl) : JPanel() { 13 | 14 | private var container: Container 15 | private val scrollSize by lazy { ScrollPane.create(this, dimension) } 16 | 17 | companion object { 18 | fun create(_rows: Int, _cols: Int, _hgap: Int, _vgap: Int, dimension: Dimension,tableModelImpl : TableModelImpl) = PanelGridLayoutImpl(_rows, _cols, _hgap, _vgap, dimension,tableModelImpl) 19 | fun create(_rows: Int, _cols: Int,dimension: Dimension, tableModelImpl : TableModelImpl) = PanelGridLayoutImpl(_rows, _cols, 0, 0, dimension,tableModelImpl) 20 | fun create(dimension: Dimension, tableModelImpl : TableModelImpl) = PanelGridLayoutImpl(1, 0, 0, 0, dimension,tableModelImpl) 21 | } 22 | 23 | init { 24 | container = Frame.create(scrollSize, BorderLayout.CENTER).contentPane 25 | 26 | val grid = GridLayout(_rows, _cols, _hgap, _vgap) 27 | setLayout(grid) 28 | 29 | for (row in 0.._rows - 1) { 30 | for (col in 0.._cols - 1) { 31 | val nameRom = this.tableModelImpl.getValueAt((row * _cols) + col, 1).toString() 32 | val nameGame = nameRom.toLowerCase().split(".")[0].toString().plus(".png") 33 | // println(nameGame) 34 | val image = Thread.currentThread().contextClassLoader.getResource("cover/$nameGame") 35 | var bufferedImage : BufferedImage? 36 | bufferedImage = when(image){ 37 | null -> ImageIcon().scale(350, 300,Thread.currentThread().contextClassLoader.getResource("cover/_gbNotFound_.png").file.toString()) 38 | else -> ImageIcon().scale(350, 300, image.file.toString()) 39 | } 40 | val panel = JPanel(GridBagLayout()).apply{ 41 | layout = BoxLayout(this, BoxLayout.Y_AXIS) 42 | add(JLabel(ImageIcon(bufferedImage)).apply { setAlignmentX(Component.CENTER_ALIGNMENT) }) 43 | add(JLabel(" ").apply { setAlignmentX(Component.CENTER_ALIGNMENT) }) 44 | add(JLabel(nameRom).apply { setAlignmentX(Component.CENTER_ALIGNMENT) }) 45 | } 46 | 47 | add(panel).setLocation(row, col) 48 | } 49 | //b.addActionListener() 50 | } 51 | } 52 | 53 | 54 | fun scrollPane() : Container = container 55 | 56 | override fun setVisible(aFlag: Boolean) { 57 | container.setVisible(aFlag) 58 | } 59 | 60 | }*/ -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/multipleImages/PanelCartridge.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.multipleImages 2 | 3 | import assets.panel.multipleImages.base.PanelMultipleImages 4 | import src.configuration.Display 5 | import java.awt.Graphics 6 | import java.awt.Graphics2D 7 | 8 | /** 9 | * Created by vicboma on 08/01/17. 10 | */ 11 | class PanelCartridge internal constructor(private val classLoader:ClassLoader,_back: String, val _front: String) : PanelMultipleImages(classLoader,_back,_front) { 12 | 13 | companion object { 14 | fun create(classLoader:ClassLoader,_back: String,_front: String) = PanelCartridge(classLoader,_back,_front) 15 | } 16 | 17 | override fun paintComponent(g: Graphics) { 18 | super.paintComponents(g) 19 | var g2 = g as Graphics2D 20 | 21 | if(list[0] != null) 22 | g2.drawImage(list[0], (this.width * 0.07).toInt() , (this.height * 0.07).toInt(), null) 23 | 24 | if(list[1] != null) 25 | g2.drawImage(list[1],(this.width * 0.337).toInt() , (this.height * 0.39).toInt(), ((Display.WIDHT / 3) * 0.495).toInt(), ((Display.HEIGTH / 2) * 0.495).toInt(), null) 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/multipleImages/PanelCover.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.multipleImages 2 | 3 | import assets.panel.multipleImages.base.PanelMultipleImages 4 | import src.configuration.Display 5 | import java.awt.Graphics 6 | import java.awt.Graphics2D 7 | 8 | /** 9 | * Created by vicboma on 08/01/17. 10 | */ 11 | class PanelCover internal constructor(private val classLoader:ClassLoader,_back: String, private val _front: String) : PanelMultipleImages(classLoader,_back,_front) { 12 | 13 | companion object { 14 | fun create(classLoader:ClassLoader,_back: String,_front: String) = PanelCover(classLoader,_back,_front) 15 | } 16 | 17 | override fun paintComponent(g: Graphics) { 18 | super.paintComponents(g) 19 | var g2 = g as Graphics2D 20 | if(list[0] != null) 21 | g2.drawImage(list[0], (this.width * 0.07).toInt() , (this.height * 0.07).toInt(), null) 22 | 23 | if(list[1] != null) 24 | g2.drawImage(list[1],(this.width * 0.138).toInt() , (this.height * 0.14).toInt(),((Display.WIDHT / 3) * 1.04).toInt(), ((Display.HEIGTH / 2) * 1.20).toInt(), null) 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/multipleImages/PanelSnapshot.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.multipleImages 2 | 3 | import assets.panel.multipleImages.base.PanelMultipleImages 4 | import src.configuration.Display 5 | import java.awt.Graphics 6 | import java.awt.Graphics2D 7 | 8 | /** 9 | * Created by vicboma on 08/01/17. 10 | */ 11 | class PanelSnapshot internal constructor(private val classLoader:ClassLoader,_back: String, val _front: String) : PanelMultipleImages(classLoader,_back,_front) { 12 | 13 | companion object { 14 | fun create(classLoader:ClassLoader,_back: String,_front: String) = PanelSnapshot(classLoader,_back,_front) 15 | } 16 | 17 | override fun paintComponent(g: Graphics) { 18 | super.paintComponents(g) 19 | var g2 = g as Graphics2D 20 | 21 | if(list[0] != null) 22 | g2.drawImage(list[0], (this.width * 0.07).toInt() , (this.height * 0.07).toInt(), null) 23 | 24 | if(list[1] != null) 25 | g2.drawImage(list[1],(this.width * 0.132).toInt() , (this.height * 0.182).toInt(),((Display.WIDHT / 3) * 1.055).toInt(), ((Display.HEIGTH / 2) * 1.058).toInt(), null) 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/multipleImages/base/PanelMultipleImages.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.multipleImages.base 2 | 3 | import main.kotlin.utils.image.createBufferedImage 4 | import main.kotlin.utils.image.scale 5 | import src.configuration.Display 6 | import java.awt.BorderLayout 7 | import java.awt.image.BufferedImage 8 | import java.util.concurrent.CopyOnWriteArrayList 9 | import javax.swing.ImageIcon 10 | import javax.swing.JPanel 11 | 12 | /** 13 | * Created by vicboma on 08/01/17. 14 | */ 15 | open class PanelMultipleImages internal constructor(private val classLoader: ClassLoader, private val back: String, private val front:String) : JPanel() { 16 | 17 | protected var list: CopyOnWriteArrayList = CopyOnWriteArrayList() 18 | 19 | 20 | init { 21 | layout = BorderLayout() 22 | val resourceBack = classLoader.getResource(back) 23 | val bufferedImageBack = ImageIcon().createBufferedImage(((Display.WIDHT / 3) * 1.25).toInt(), ((Display.HEIGTH / 2) * 1.45).toInt(), BufferedImage.TYPE_INT_ARGB) 24 | 25 | if(resourceBack != null) 26 | list.add(0,ImageIcon().scale(bufferedImageBack, resourceBack.file.toString())) 27 | 28 | val resourceFront = classLoader.getResource(front) 29 | val bufferedImageFront = ImageIcon().createBufferedImage(((Display.WIDHT / 3) * 1.25).toInt(), ((Display.HEIGTH / 2) * 1.45).toInt(), BufferedImage.TYPE_INT_ARGB) 30 | 31 | if(resourceFront != null) 32 | list.add(1,ImageIcon().scale(bufferedImageFront, resourceFront.file.toString())) 33 | } 34 | 35 | fun setBack(back:String) { 36 | val resourceSetBack = classLoader.getResource(back) 37 | if(resourceSetBack!=null) { 38 | val bufferedImageBack = ImageIcon().createBufferedImage(((Display.WIDHT / 3) * 1.25).toInt(), ((Display.HEIGTH / 2) * 1.45).toInt(), BufferedImage.TYPE_INT_ARGB) 39 | list.set(0, ImageIcon().scale(bufferedImageBack, resourceSetBack.file.toString())) 40 | } 41 | } 42 | 43 | fun setFront(front:String) { 44 | var file : String = "" 45 | val resourceSetFront = classLoader.getResource(front) 46 | 47 | if(null != resourceSetFront) 48 | file = resourceSetFront.file.toString() 49 | 50 | val bufferedImageFront = ImageIcon().createBufferedImage(((Display.WIDHT / 3) * 1.25).toInt(), ((Display.HEIGTH / 2) * 1.45).toInt(), BufferedImage.TYPE_INT_ARGB) 51 | val buffered = ImageIcon().scale(bufferedImageFront,file) 52 | list.set(1,buffered) 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/split/Split.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Component 4 | import assets.Renderable 5 | import javax.swing.JProgressBar 6 | import javax.swing.JSlider 7 | import javax.swing.JSplitPane 8 | 9 | /** 10 | * Created by vicboma on 05/12/16. 11 | */ 12 | interface Split { 13 | companion object{ 14 | val VERTICAL = JSplitPane.VERTICAL_SPLIT 15 | val HORIZONTAL = JSplitPane.HORIZONTAL_SPLIT 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/split/SplitImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import java.awt.Component 4 | import java.awt.Container 5 | import javax.swing.JSplitPane 6 | import javax.swing.UIManager 7 | 8 | /** 9 | * Created by vicboma on 05/12/16. 10 | */ 11 | class SplitImpl internal constructor( 12 | newOrientation : Int, 13 | _leftComponent : K , 14 | _rightComponent : K , 15 | newContinuousLayout : Boolean = UIManager.getBoolean("SplitPane.continuousLayout"), 16 | _dividerLocation : Int = -1 17 | ) : JSplitPane(newOrientation, newContinuousLayout, _leftComponent, _rightComponent) , Split { 18 | 19 | companion object { 20 | 21 | fun create( newOrientation : Int, _leftComponent: K, _rightComponent : K) = 22 | SplitImpl(newOrientation, _leftComponent, _rightComponent) 23 | 24 | fun create( newOrientation : Int, _leftComponent: K, _rightComponent : K, newContinuousLayout : Boolean ) = 25 | SplitImpl(newOrientation, _leftComponent, _rightComponent,newContinuousLayout) 26 | 27 | fun create( newOrientation : Int, _leftComponent: K, _rightComponent : K, newContinuousLayout : Boolean, _dividerLocation : Int ) = 28 | SplitImpl(newOrientation, _leftComponent, _rightComponent,newContinuousLayout, _dividerLocation) 29 | } 30 | 31 | init{ 32 | oneTouchExpandable = true 33 | dividerLocation = _dividerLocation 34 | alignmentX = Component.CENTER_ALIGNMENT 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/tab/TabPane.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.tab 2 | 3 | import assets.scroll.ScrollPane 4 | import java.awt.BorderLayout 5 | import java.awt.Dimension 6 | import javax.swing.Icon 7 | import javax.swing.JComponent 8 | import javax.swing.JTabbedPane 9 | import javax.swing.event.ChangeListener 10 | 11 | /** 12 | * Created by vicboma on 15/01/17. 13 | */ 14 | class TabPane internal constructor(changeListener: ChangeListener, private val dimension: Dimension = Dimension(0,0)) : JTabbedPane(){ 15 | 16 | companion object { 17 | fun create(changeListener: ChangeListener, dimension: Dimension) = TabPane(changeListener, dimension) 18 | } 19 | 20 | init { 21 | layout = BorderLayout() 22 | addChangeListener(changeListener) 23 | setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 24 | } 25 | 26 | fun add(name:String, image: Icon, pane: JComponent, index:Int, key : Int = -1){ 27 | addTab(name,image , pane, "") 28 | setMnemonicAt(index, key) 29 | } 30 | 31 | fun scrollPane() : ScrollPane = ScrollPane.create(this, dimension) 32 | 33 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/panel/tab/TabPaneListener.kt: -------------------------------------------------------------------------------- 1 | package assets.panel.tab 2 | 3 | import assets.panel.multipleImages.base.PanelMultipleImages 4 | import assets.table.TableImpl 5 | import javax.swing.JTabbedPane 6 | import javax.swing.event.ChangeEvent 7 | import javax.swing.event.ChangeListener 8 | 9 | /** 10 | * Created by vicboma on 15/01/17. 11 | */ 12 | class TabPaneListener internal constructor(private val table: TableImpl) : ChangeListener { 13 | 14 | companion object{ 15 | fun create(table: TableImpl) = TabPaneListener(table) 16 | } 17 | 18 | override fun stateChanged(e: ChangeEvent?) { 19 | val source = e?.getSource() 20 | if (source is JTabbedPane) { 21 | 22 | var selectedRow = table.selectedRow 23 | if(selectedRow != -1) { 24 | 25 | val selectedIntdexTab = source.selectedIndex 26 | val folder = source.getTitleAt(selectedIntdexTab).toLowerCase() 27 | val model = table.getModel() 28 | val available = model?.getValueAt(selectedRow!!, 0).toString().toUpperCase() 29 | val nameRom = model?.getValueAt(selectedRow!!, 1).toString().toLowerCase().split(".")[0].toString().plus(".png") 30 | 31 | 32 | val panel = source.getComponent(selectedIntdexTab) as PanelMultipleImages 33 | val path = folder.plus("/$nameRom") 34 | panel.setFront(path) 35 | //panel.setBack("_bg.png") 36 | 37 | val IsVisible = source.isVisible 38 | if ( IsVisible ) 39 | source.repaint(); 40 | } 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/progressBar/ProgressBar.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | 5 | /** 6 | * Created by vicboma on 05/12/16. 7 | */ 8 | interface ProgressBar : Renderable { 9 | companion object{ 10 | val MIN = 0 11 | val MAX = 100 12 | } 13 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/progressBar/ProgressBarImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | import kotlinx.coroutines.experimental.launch 5 | import utils.swing.Swing 6 | import java.awt.Component 7 | import java.util.concurrent.CompletableFuture 8 | import javax.swing.JProgressBar 9 | 10 | /** 11 | * Created by vicboma on 05/12/16. 12 | */ 13 | class ProgressBarImpl internal constructor(val min: Int, val max: Int) : JProgressBar(min,max) , ProgressBar { 14 | 15 | companion object { 16 | fun create(min: Int, max: Int): Renderable { 17 | return ProgressBarImpl(min,max) 18 | } 19 | } 20 | 21 | init{ 22 | value = 0 23 | isStringPainted = true 24 | setAlignmentX(Component.CENTER_ALIGNMENT) 25 | } 26 | 27 | override fun asyncUI() { 28 | launch(Swing) { 29 | CompletableFuture.runAsync { 30 | for (i in min..max) { 31 | Thread.sleep(30) 32 | value = i * 1 33 | } 34 | }.thenAcceptAsync { 35 | Thread.sleep(500) 36 | value = 0 37 | asyncUI() 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/scroll/ScrollPane.kt: -------------------------------------------------------------------------------- 1 | package assets.scroll 2 | 3 | import java.awt.Dimension 4 | import javax.swing.JComponent 5 | import javax.swing.JScrollPane 6 | 7 | /** 8 | * Created by vicboma on 15/01/17. 9 | */ 10 | class ScrollPane internal constructor (private val component : JComponent, private val dimension : Dimension) : JScrollPane(component){ 11 | 12 | 13 | companion object { 14 | fun create(component : JComponent , dimension: Dimension) = ScrollPane(component,dimension) 15 | } 16 | 17 | init { 18 | this.preferredSize = dimension 19 | this.verticalScrollBarPolicy = javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED 20 | this.horizontalScrollBarPolicy = javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/slider/Slider.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | import javax.swing.JSlider 5 | 6 | /** 7 | * Created by vicboma on 05/12/16. 8 | */ 9 | interface Slider : Renderable { 10 | companion object{ 11 | val POSITION = JSlider.HORIZONTAL 12 | val MIN = 0 13 | val MAX = 100 14 | val VALUE = 100 15 | } 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/slider/SliderImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | import kotlinx.coroutines.experimental.launch 5 | import utils.swing.Swing 6 | import java.awt.Component 7 | import java.util.concurrent.CompletableFuture 8 | import javax.swing.JSlider 9 | 10 | /** 11 | * Created by vicboma on 05/12/16. 12 | */ 13 | class SliderImpl internal constructor(private val position : Int, private val min: Int,private val max: Int, private val _value : Int) : JSlider(position,min,max,_value) , Slider { 14 | 15 | companion object { 16 | fun create(position: Int, min: Int, max: Int, _value: Int): Renderable { 17 | return SliderImpl(position, min,max, _value) 18 | } 19 | } 20 | 21 | init{ 22 | this.apply { 23 | value = 0 24 | setMajorTickSpacing(10); 25 | setMinorTickSpacing(1); 26 | setPaintTicks(true); 27 | setPaintLabels(true); 28 | setAlignmentX(Component.CENTER_ALIGNMENT) 29 | } 30 | } 31 | 32 | override fun asyncUI() { 33 | launch(Swing) { 34 | CompletableFuture.runAsync { 35 | Thread.sleep(100) 36 | for (i in min..max) { 37 | Thread.sleep(30) 38 | value = i * 1 39 | } 40 | }.thenAcceptAsync { 41 | Thread.sleep(500) 42 | for (i in max downTo min) { 43 | Thread.sleep(30) 44 | value = i * 1 45 | } 46 | asyncUI() 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/statusBar/StatusBar.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | /** 4 | * Created by vicboma on 05/12/16. 5 | */ 6 | interface StatusBar { 7 | fun text(str:String) 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/statusBar/StatusBarImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import kotlinx.coroutines.experimental.launch 4 | import kotlinx.coroutines.experimental.runBlocking 5 | import utils.swing.Swing 6 | import utils.swing.delay 7 | import java.awt.BorderLayout 8 | import java.awt.Dimension 9 | import javax.swing.* 10 | import javax.swing.border.BevelBorder 11 | 12 | /** 13 | * Created by vicboma on 05/12/16. 14 | */ 15 | class StatusBarImpl internal constructor(private val _width : Int) : JPanel() , StatusBar { 16 | 17 | 18 | private var labelAEST = JLabel(" ") 19 | private var labelWEST = JLabel(" Load async frame") 20 | 21 | 22 | companion object { 23 | fun create(_width: Int) = StatusBarImpl(_width) 24 | } 25 | 26 | init{ 27 | border = BevelBorder(BevelBorder.LOWERED) 28 | preferredSize = Dimension(_width, 19) 29 | layout = BoxLayout(this, BoxLayout.X_AXIS) 30 | this.add(JPanel().apply { 31 | layout = BorderLayout() 32 | add(labelWEST) 33 | } ,BorderLayout.WEST) 34 | 35 | this.add(JSeparator(SwingConstants.VERTICAL)) 36 | this.add(JPanel().apply { add(labelAEST) },BorderLayout.EAST) 37 | 38 | } 39 | 40 | override fun text (str:String) { 41 | runBlocking { 42 | launch(Swing) { 43 | labelWEST.text = " $str" 44 | Swing.delay(1) 45 | } 46 | } 47 | } 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/TableImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.table 2 | 3 | import assets.scroll.ScrollPane 4 | import assets.table.model.TableModelImpl 5 | import java.awt.Component 6 | import java.awt.Dimension 7 | import java.awt.event.KeyListener 8 | import java.awt.event.MouseAdapter 9 | import java.io.File 10 | import javax.swing.JScrollPane 11 | import javax.swing.JTable 12 | import javax.swing.table.TableCellRenderer 13 | 14 | /** 15 | * Created by vbolinch on 02/01/2017. 16 | */ 17 | class TableImpl internal constructor(private val classLoader: ClassLoader,/*private val timer: TableDaemon, */private val dm: TableModelImpl?, private val dimension : Dimension) : JTable(dm) { 18 | 19 | private val scrollSize : ScrollPane 20 | 21 | companion object{ 22 | fun create(classLoader: ClassLoader, dm: TableModelImpl?, dimenasion : Dimension) = TableImpl(classLoader,/*timer,*/dm , dimenasion) 23 | } 24 | 25 | init { 26 | 27 | scrollSize = ScrollPane.create(this, dimension) 28 | 29 | showVerticalLines = false 30 | showHorizontalLines = false 31 | autoResizeMode = JTable.AUTO_RESIZE_ALL_COLUMNS 32 | 33 | } 34 | 35 | override fun prepareRenderer(renderer: TableCellRenderer, row: Int, column: Int): Component { 36 | return super@TableImpl.prepareRenderer(renderer, row, column) 37 | .apply { 38 | val nameGame = this@TableImpl.model.getValueAt(row, 1).toString().toLowerCase().trim() 39 | val file = classLoader.getResource("rom/$nameGame") 40 | when (file) { 41 | null -> { 42 | isEnabled = false 43 | } 44 | else -> { 45 | val f = File(file.toURI()) 46 | var setter = false 47 | 48 | if (f.exists() && !f.isDirectory()) 49 | setter = true 50 | 51 | isEnabled = setter 52 | } 53 | } 54 | } 55 | } 56 | 57 | fun addMouseListenerColumn(mouseAdapter : MouseAdapter ) = 58 | tableHeader.apply { 59 | updateTableInRealTime = true 60 | addMouseListener(mouseAdapter) 61 | reorderingAllowed = true 62 | } 63 | 64 | fun addMouseListenerRow(mouseAdapter : MouseAdapter ) = this.addMouseListener(mouseAdapter) 65 | 66 | fun addKeyListenerInput(keyListener : KeyListener) = this.addKeyListener(keyListener) 67 | 68 | fun scrollPane() : JScrollPane = scrollSize 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/comparator/TableHeaderComparator.kt: -------------------------------------------------------------------------------- 1 | package assets.table.comparator 2 | 3 | import java.lang.Exception 4 | import java.util.* 5 | 6 | /** 7 | * Created by vbolinch on 02/01/2017. 8 | */ 9 | class TableHeaderComparator internal constructor() : Comparator> { 10 | 11 | var isSortAsc : Boolean 12 | var columnIndex : Int 13 | 14 | companion object { 15 | fun create() = TableHeaderComparator() 16 | } 17 | 18 | init { 19 | isSortAsc = true 20 | columnIndex = 0 21 | } 22 | 23 | 24 | override fun compare(o1: Array?, o2: Array?): Int { 25 | var param1 = o1?.get(columnIndex) 26 | var param2 = o2?.get(columnIndex) 27 | 28 | var result = 0 29 | try { 30 | result = when (param1) { 31 | is Double -> param1.compareTo(param2 as Double) 32 | is Int -> param1.compareTo(param2 as Int) 33 | is String -> param1.compareTo(param2.toString()) 34 | //is Boolean -> { 35 | else ->{ 36 | val b1 = param1 37 | val b2 = param2 38 | if (b1.toString().equals(b2.toString())) { 39 | 0 40 | } else if (b1.toString().equals("true")) { 41 | 1 42 | } else { 43 | -1 44 | } 45 | } 46 | // else -> 0 47 | } 48 | }catch(e: Exception){ 49 | println(e.message) 50 | } 51 | 52 | if (!isSortAsc) 53 | result = result * -1 54 | 55 | return result 56 | } 57 | 58 | override fun hashCode(): Int { 59 | return super.hashCode() 60 | } 61 | 62 | override fun equals(obj: Any?): Boolean { 63 | var res = false 64 | if (obj is TableHeaderComparator) { 65 | res = (obj.isSortAsc == isSortAsc) 66 | } 67 | return res 68 | } 69 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/daemon/TableDaemon.kt: -------------------------------------------------------------------------------- 1 | package assets.table.daemon 2 | 3 | import assets.table.TableImpl 4 | import assets.table.model.TableModelImpl 5 | import utils.thread.CustomExecutor 6 | import java.awt.Component 7 | import java.io.File 8 | import java.lang.Exception 9 | import java.util.concurrent.CompletableFuture 10 | import java.util.concurrent.ConcurrentLinkedDeque 11 | import javax.swing.Timer 12 | import javax.swing.table.TableCellRenderer 13 | 14 | /** 15 | * Created by vicboma on 20/01/17. 16 | */ 17 | class TableDaemon internal constructor(private val classLoader: ClassLoader) { 18 | 19 | private var table : TableImpl? = null 20 | private var queue: ConcurrentLinkedDeque> = ConcurrentLinkedDeque() 21 | 22 | companion object{ 23 | fun create(classLoader: ClassLoader) = TableDaemon(classLoader) 24 | } 25 | 26 | init { 27 | 28 | Timer(50, { 29 | 30 | CustomExecutor.instance.addPriority { 31 | 32 | // taleCellRenrender?.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column) 33 | 34 | try { 35 | 36 | while(queue.isNotEmpty()){ 37 | 38 | 39 | var poll: Map ? = null 40 | try { 41 | val size = queue.size 42 | CompletableFuture.runAsync { 43 | for (i in 0..size - 1) { 44 | poll = queue.poll() 45 | 46 | val completable = (poll?.get("completable") as CompletableFuture>) 47 | val component = (poll?.get("component") as Component) 48 | val row = (poll?.get("rowIndex") as Int) 49 | val column = (poll?.get("columnIndex") as Int) 50 | val tableModel = table?.model as TableModelImpl 51 | 52 | tableModel.isEditable = true 53 | tableModel.isCellEditable(row, column) 54 | 55 | val nameGame = tableModel.getValueAt(row, 1).toString().toLowerCase().trim() 56 | val file = classLoader.getResource("rom/$nameGame") 57 | var setter = false 58 | when (file) { 59 | null -> { 60 | if(column == 0) 61 | tableModel.setValueAt(false, row, 0) 62 | // component.isEnabled = false 63 | } 64 | else -> { 65 | val f = File(file.toURI()) 66 | 67 | if (f.exists()) { 68 | setter = true 69 | if(column == 0) 70 | tableModel.setValueAt(true, row, 0) 71 | } 72 | // component.isEnabled = setter 73 | } 74 | } 75 | 76 | tableModel.isEditable = false 77 | completable.complete(Pair(component,setter)) 78 | } 79 | } 80 | } catch(e: Exception) { 81 | // queue.add(poll) 82 | e.printStackTrace() 83 | } finally { 84 | 85 | } 86 | } 87 | }catch(e: Exception){ 88 | e.printStackTrace() 89 | } 90 | finally{ 91 | // println("Execute!!!") 92 | table?.invalidate() 93 | // newModel.fireTableDataChanged() 94 | //table?.repaint() 95 | 96 | } 97 | } 98 | } 99 | ).apply{ 100 | start() 101 | } 102 | } 103 | 104 | fun setTable(table : TableImpl){ 105 | this.table = table 106 | } 107 | 108 | fun addQueue(component: Component, taleCellRenrender: TableCellRenderer, rowIndex: Int, columnIndex: Int) : CompletableFuture> { 109 | val completable = CompletableFuture>() 110 | queue.add( 111 | mapOf( 112 | Pair("completable",completable), 113 | Pair("component",component), 114 | Pair("taleCellRenrender",taleCellRenrender), 115 | Pair("rowIndex",rowIndex), 116 | Pair("columnIndex",columnIndex) 117 | )) 118 | 119 | return completable 120 | } 121 | 122 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/listener/BaseInputTableList.kt: -------------------------------------------------------------------------------- 1 | package assets.table.listener 2 | 3 | import assets.dialog.confirm.ConfirmImpl 4 | import assets.panel.multipleImages.base.PanelMultipleImages 5 | import assets.progressBar.StatusBar 6 | import kotlinx.coroutines.experimental.launch 7 | import utils.swing.Swing 8 | import java.awt.Frame 9 | import java.io.File 10 | import javax.swing.JFrame 11 | import javax.swing.JOptionPane 12 | import javax.swing.JTabbedPane 13 | import javax.swing.JTable 14 | 15 | /** 16 | * Created by vicboma on 07/01/17. 17 | */ 18 | class BaseInpuTableList internal constructor() { 19 | 20 | companion object { 21 | fun executeEnter(frame:Frame, table: JTable) { 22 | val selectedRowIndex = table.getSelectedRow() 23 | 24 | val model = table.getModel() 25 | val nameRom = model.getValueAt(selectedRowIndex, 1).toString() 26 | 27 | val pathRom = File("rom/$nameRom").absolutePath 28 | 29 | launch(Swing) { 30 | frame.setExtendedState(JFrame.ICONIFIED); 31 | ConfirmImpl.create(Frame(),Pair("Load Rom", pathRom), JOptionPane.YES_NO_CANCEL_OPTION) 32 | .showDialog({ 33 | frame.setExtendedState(JFrame.NORMAL) 34 | }, { 35 | frame.setExtendedState(JFrame.NORMAL) 36 | }, { 37 | frame.setExtendedState(JFrame.NORMAL) 38 | }) 39 | } 40 | } 41 | 42 | fun executeX(table: JTable, statusBar: StatusBar, source: JTabbedPane, key: Int) { 43 | val selectedRowIndex = table.getSelectedRow() + key 44 | 45 | if (isValid(selectedRowIndex, table)) return 46 | 47 | val model = table.getModel() 48 | val available = model.getValueAt(selectedRowIndex, 0).toString().toUpperCase() 49 | val nameRom = model.getValueAt(selectedRowIndex, 1).toString() 50 | val nameGame = model.getValueAt(selectedRowIndex, 2).toString() 51 | val romType = model.getValueAt(selectedRowIndex, 3).toString() 52 | val bytes = model.getValueAt(selectedRowIndex, 4).toString() 53 | 54 | statusBar.text("$nameRom\t\t\t$nameGame\t\t\t$romType\t\t\t$bytes") 55 | 56 | val (panel, path) = getPathAbsolute(nameRom, source) 57 | 58 | panel.setFront(path) 59 | //panel.setBack("_bg.png") 60 | 61 | val IsVisible = source.selectedComponent.isVisible 62 | if (IsVisible) 63 | source.selectedComponent.repaint(); 64 | 65 | } 66 | 67 | 68 | 69 | fun executeY( table: JTable, source: JTabbedPane, key: Int) { 70 | val selectedRowIndex = table.getSelectedRow() 71 | 72 | if (isValid(selectedRowIndex, table)) return 73 | 74 | var index = source.tabCount -1 75 | 76 | if(source.selectedIndex + key >= 0) 77 | index = (source.selectedIndex+key).mod(source.tabCount) 78 | 79 | val tab = source.getComponentAt(index) 80 | source.selectedComponent = tab 81 | 82 | val nameRom = table.model.getValueAt(selectedRowIndex, 1).toString() 83 | 84 | val (panel, path) = getPathAbsolute(nameRom, source) 85 | 86 | panel.setFront(path) 87 | 88 | val IsVisible = tab.isVisible 89 | if ( IsVisible ) 90 | tab.repaint(); 91 | } 92 | 93 | private fun getPathAbsolute(nameRom: String, source: JTabbedPane): Pair { 94 | val selectedIntdexTab = source.selectedIndex 95 | val folder = source.getTitleAt(selectedIntdexTab).toLowerCase() 96 | 97 | val _nameRom = nameRom.toLowerCase().split(".")[0].toString().plus(".png") 98 | 99 | val panel = source.getComponent(selectedIntdexTab) as PanelMultipleImages 100 | val path = folder.plus("/$_nameRom") 101 | 102 | return Pair(panel, path) 103 | } 104 | 105 | private fun isValid(selectedRowIndex: Int, table: JTable): Boolean = (selectedRowIndex == -1 || selectedRowIndex >= table.rowCount) 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/listener/adapter/TableColumnHeaderAdapter.kt: -------------------------------------------------------------------------------- 1 | 2 | import assets.table.comparator.TableHeaderComparator 3 | import assets.table.model.TableModelImpl 4 | import kotlinx.coroutines.experimental.launch 5 | import utils.swing.Swing 6 | import java.awt.event.MouseAdapter 7 | import java.awt.event.MouseEvent 8 | import java.io.File 9 | import javax.swing.JTable 10 | import javax.swing.event.TableModelEvent 11 | import javax.swing.table.TableColumnModel 12 | 13 | class TableColumnHeaderAdapter internal constructor(private val classLoader: ClassLoader, val table: JTable, val cmp : TableHeaderComparator) : MouseAdapter() { 14 | 15 | var sortCol = 0 16 | 17 | companion object { 18 | fun create(classLoader: ClassLoader,table: JTable, cmp : TableHeaderComparator) = TableColumnHeaderAdapter( classLoader, table, cmp ) 19 | } 20 | 21 | init { 22 | // selectedColumnHeaderSort(1) 23 | } 24 | 25 | private fun selectedColumnHeaderSort (selectedColumn:Int) { 26 | launch(Swing) { 27 | val colModel = table.columnModel 28 | cmp.columnIndex = selectedColumn 29 | selectedColumnHeaderSort(colModel) 30 | } 31 | } 32 | 33 | override fun mouseClicked(e: MouseEvent) { 34 | val colModel = table.columnModel 35 | cmp.columnIndex = colModel.getColumnIndexAtX(e.getX()) 36 | selectedColumnHeaderSort(colModel) 37 | } 38 | 39 | private fun selectedColumnHeaderSort(colModel: TableColumnModel) { 40 | val modelColumn = colModel.getColumn(cmp.columnIndex) 41 | val modelIndex = modelColumn.modelIndex 42 | 43 | if (modelIndex >= 0) { 44 | if (sortCol === modelIndex) 45 | cmp.isSortAsc = !cmp.isSortAsc 46 | else 47 | sortCol = modelIndex 48 | 49 | for (i in 0..colModel.columnCount - 1) { 50 | val column = colModel.getColumn(i) 51 | column.headerValue = table.model.getColumnName(column.modelIndex) 52 | } 53 | 54 | table.tableHeader.repaint() 55 | 56 | (table.model as TableModelImpl).sortWith(cmp) 57 | 58 | table.tableChanged(TableModelEvent(table.model)) 59 | repaint() 60 | } 61 | } 62 | 63 | fun repaint() { 64 | for(it in 0..table.model.rowCount-1) { 65 | val nameGame = table.model.getValueAt(it, 1).toString().toLowerCase().trim() 66 | val file = classLoader.getResource("rom/$nameGame") 67 | when (file) { 68 | null -> { 69 | table.model.setValueAt(false, it, 0) 70 | } 71 | else -> { 72 | val f = File(file.toURI()) 73 | if (f.exists() && !f.isDirectory()) 74 | table.model.setValueAt(true, it, 0) 75 | } 76 | } 77 | } 78 | table.repaint() 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/listener/adapter/TableRowAdapter.kt: -------------------------------------------------------------------------------- 1 | 2 | import assets.progressBar.StatusBar 3 | import assets.table.listener.BaseInpuTableList 4 | import java.awt.event.MouseAdapter 5 | import java.awt.event.MouseEvent 6 | import javax.swing.JComponent 7 | import javax.swing.JTabbedPane 8 | import javax.swing.JTable 9 | 10 | 11 | class TableRowAdapter internal constructor(val table: JTable, val statusBar: StatusBar, val tabbedPane: JTabbedPane) : MouseAdapter() { 12 | 13 | 14 | companion object { 15 | fun create(table: JTable, statusBar : JComponent,tabbedPane: JTabbedPane) = TableRowAdapter(table, statusBar as StatusBar,tabbedPane) 16 | } 17 | 18 | init { 19 | 20 | } 21 | 22 | override fun mouseClicked(e: MouseEvent) { 23 | BaseInpuTableList.executeX(table,statusBar,tabbedPane,0) 24 | } 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/listener/renderer/TableCellRendererComponent.kt: -------------------------------------------------------------------------------- 1 | package assets.table.listener.renderer 2 | 3 | import java.awt.Component 4 | import javax.swing.JTable 5 | import javax.swing.table.DefaultTableCellRenderer 6 | import javax.swing.table.TableCellRenderer 7 | 8 | /** 9 | * Created by vicboma on 20/01/17. 10 | */ 11 | class TableCellRendererComponent internal constructor() : TableCellRenderer { 12 | 13 | 14 | companion object{ 15 | fun create() = TableCellRendererComponent() 16 | } 17 | 18 | init { 19 | 20 | } 21 | 22 | override fun getTableCellRendererComponent(table: JTable?, value: Any?, isSelected: Boolean, hasFocus: Boolean, row: Int, column: Int): Component { 23 | val newCellRenderer = DefaultTableCellRenderer(); 24 | 25 | println("table: $table, value: &value, isSelected: $isSelected, hasFocus: $hasFocus, row: $row, column: $column") 26 | 27 | return newCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column) 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/listener/rowKey/TableRowKeyListener.kt: -------------------------------------------------------------------------------- 1 | package assets.table.listener.rowKey 2 | 3 | import assets.frame.Frame 4 | import assets.progressBar.StatusBar 5 | import assets.table.listener.BaseInpuTableList 6 | import kotlinx.coroutines.experimental.launch 7 | import utils.swing.Swing 8 | import java.awt.event.ActionEvent 9 | import java.awt.event.KeyEvent 10 | import java.awt.event.KeyListener 11 | import javax.swing.* 12 | 13 | /** 14 | * Created by vicboma on 07/01/17. 15 | */ 16 | class TableRowKeyListener internal constructor(private val frame: Frame, private val table: JTable, private val statusBar: StatusBar, private val tab: JTabbedPane) : KeyListener { 17 | 18 | companion object { 19 | fun create(frame: Frame, table: JTable, statusBar : JComponent, tab : JTabbedPane) : KeyListener { 20 | return TableRowKeyListener(frame,table, statusBar as StatusBar, tab) 21 | } 22 | } 23 | 24 | 25 | init { 26 | keyEvent_VK_Enter() 27 | } 28 | 29 | override fun keyTyped(e: KeyEvent?) { 30 | //throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 31 | } 32 | 33 | override fun keyPressed(e: KeyEvent?) { 34 | launch(Swing) { 35 | when(e?.keyCode) { 36 | 37 | KeyEvent.VK_UP -> BaseInpuTableList.executeX(table, statusBar, tab, 0) 38 | KeyEvent.VK_DOWN -> BaseInpuTableList.executeX(table, statusBar, tab, 0) 39 | KeyEvent.VK_ENTER -> BaseInpuTableList.executeEnter(frame,table) 40 | KeyEvent.VK_LEFT -> BaseInpuTableList.executeY(table, tab, -1) 41 | KeyEvent.VK_RIGHT -> BaseInpuTableList.executeY(table, tab, 1) 42 | else -> { 43 | 44 | } 45 | } 46 | } 47 | } 48 | 49 | override fun keyReleased(e: KeyEvent?) { 50 | //throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. 51 | } 52 | 53 | private fun keyEvent_VK_Enter() { 54 | table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter") 55 | table.actionMap.put("Enter", object : AbstractAction() { 56 | override fun actionPerformed(ae: ActionEvent) { 57 | } 58 | }) 59 | 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/table/model/TableModelImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.table.model 2 | 3 | import assets.table.comparator.TableHeaderComparator 4 | import java.util.stream.IntStream 5 | import javax.swing.table.AbstractTableModel 6 | 7 | /** 8 | * Created by vbolinch on 02/01/2017. 9 | */ 10 | 11 | class TableModelImpl internal constructor(val columnNames : Array?, val data: Array>?, var isEditable : Boolean = false ) : AbstractTableModel() { 12 | 13 | companion object { 14 | 15 | fun factoryArrayOf(size:Int, elements :Int) : Array>? { 16 | return Array>(size) { factoryArrayOf(elements) } 17 | } 18 | 19 | fun factoryArrayOf(elements :Int) : Array { 20 | val list = arrayListOf("") 21 | IntStream.range(0,elements-1).forEach { list.add("") } 22 | return list.toArray() 23 | } 24 | 25 | fun create(columnNames: Array?, data: Array>?) = TableModelImpl(columnNames, data) 26 | fun create(columnNames: Int, size:Int, rows:Int) = TableModelImpl( factoryArrayOf(columnNames), factoryArrayOf(size,rows)) 27 | } 28 | 29 | init { 30 | } 31 | 32 | override fun getValueAt(rowIndex: Int, columnIndex: Int) : Any = data!![rowIndex][columnIndex] 33 | 34 | override fun getColumnCount(): Int = columnNames!!.size 35 | 36 | override fun getRowCount(): Int { if(data != null) return data.size; return 0 } 37 | 38 | override fun getColumnName(col: Int): String = columnNames!![col].toString() 39 | 40 | override fun getColumnClass(columnIndex: Int) : Class<*> = this.getValueAt(0, columnIndex).javaClass 41 | 42 | override fun isCellEditable(rowIndex: Int, columnIndex: Int) = isEditable 43 | 44 | override fun setValueAt(aValue: Any?, rowIndex: Int, columnIndex: Int) { 45 | data!![rowIndex][columnIndex] = aValue!! 46 | fireTableCellUpdated(rowIndex,columnIndex) 47 | } 48 | 49 | fun sortWith(cmp : TableHeaderComparator) = data?.sortWith(cmp) 50 | 51 | fun removeAll() { 52 | for (i in getRowCount() - 1 downTo 0) 53 | data!![i] = arrayOf() 54 | } 55 | 56 | 57 | fun toString(rowIndex: Int): String { 58 | return "${getValueAt(rowIndex,0)} ${getValueAt(rowIndex,1)} ${getValueAt(rowIndex,2)} ${getValueAt(rowIndex,3)} ${getValueAt(rowIndex,4)}" 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/textArea/TextArea.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | 5 | /** 6 | * Created by vicboma on 05/12/16. 7 | */ 8 | interface TextArea : Renderable { 9 | companion object { 10 | val MOD = 380 11 | val KAFKA = "Una mañana, tras un sueño intranquilo, Gregorio Samsa se despertó convertido en un monstruoso insecto. Estaba echado de espaldas sobre un duro caparazón y, al alzar la cabeza, vio su vientre convexo y oscuro, surcado por curvadas callosidades, sobre el que casi no se aguantaba la colcha, que estaba a punto de escurrirse hasta el suelo" 12 | val LOREMIPSUM = "Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout." 13 | val TEXT = " Hello World!!!!\n Asynchronous\n Application" 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/assets/textArea/TextAreaImpl.kt: -------------------------------------------------------------------------------- 1 | package assets.progressBar 2 | 3 | import assets.Renderable 4 | import kotlinx.coroutines.experimental.launch 5 | import utils.swing.Swing 6 | import java.awt.Dimension 7 | import java.util.concurrent.CompletableFuture 8 | import javax.swing.JPanel 9 | import javax.swing.JScrollPane 10 | import javax.swing.JTextArea 11 | 12 | /** 13 | * Created by vicboma on 05/12/16. 14 | */ 15 | class TextAreaImpl internal constructor(val _text: String) : JScrollPane() , TextArea { 16 | 17 | val textArea = JTextArea(_text) 18 | 19 | companion object { 20 | 21 | fun create(text: String) : Renderable = TextAreaImpl(text) 22 | 23 | } 24 | 25 | init{ 26 | 27 | textArea.apply { 28 | lineWrap = true 29 | wrapStyleWord = true 30 | isEditable = false 31 | autoscrolls = true 32 | } 33 | 34 | this.apply { 35 | setViewportView(textArea) 36 | setPreferredSize(Dimension(380, 100)) 37 | setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) 38 | alignmentX = JPanel.CENTER_ALIGNMENT 39 | } 40 | 41 | } 42 | 43 | override fun asyncUI() { 44 | launch(Swing) { 45 | CompletableFuture.runAsync { 46 | Thread.sleep(1500) 47 | textArea.text = "" 48 | for ( i in 0.._text.length-1) { 49 | Thread.sleep(20) 50 | i.text() 51 | } 52 | }.thenAcceptAsync { 53 | Thread.sleep(1000) 54 | asyncUI() 55 | } 56 | } 57 | } 58 | 59 | private fun isMod(a : Int, b :Int) = (a % b) == 0 60 | 61 | public fun Int.text() = when { 62 | //isMod(this,TextArea.MOD) -> caretPosition = getDocument().getLength() 63 | else -> { 64 | textArea.append(_text[this].toString()) 65 | textArea.caretPosition = textArea.getDocument().getLength() 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/kotlin/utils/completable/CompletableCancelable.kt: -------------------------------------------------------------------------------- 1 | package main.kotlin.utils.completable 2 | 3 | import com.sun.org.apache.xpath.internal.operations.Bool 4 | import java.util.concurrent.CompletableFuture 5 | import java.util.concurrent.CopyOnWriteArrayList 6 | 7 | /** 8 | * Created by vbolinch on 04/01/2017. 9 | */ 10 | class CompletableCancelable constructor(val completable : CompletableFuture, val cancelable: CopyOnWriteArrayList) { 11 | 12 | fun setCancelable(value: Boolean) { 13 | cancelable[0] = value 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/event/ActionEventRunBlockingLaunchSwing.kt: -------------------------------------------------------------------------------- 1 | package utils.event 2 | 3 | import kotlinx.coroutines.experimental.Job 4 | import java.awt.event.ActionEvent 5 | import java.awt.event.ActionListener 6 | 7 | /** 8 | * Created by vicboma on 09/05/17. 9 | */ 10 | class ActionEventRunBlockingLaunchSwing(source: Any?, id: Int, command: String?) : ActionListener, () -> Job , ActionEvent(source, id, command) { 11 | override fun invoke(): Job { 12 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 13 | } 14 | 15 | override fun actionPerformed(e: ActionEvent?) { 16 | TODO("not implemented") //To change body of created functions use File | Settings | File Templates. 17 | } 18 | 19 | /* override fun invoke(p1: ActionEvent) { 20 | runBlocking { 21 | launch(Swing) { 22 | println("FDSFDSfs") 23 | } 24 | } 25 | }*/ 26 | 27 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/fps/Fps.kt: -------------------------------------------------------------------------------- 1 | package utils.fps 2 | 3 | import java.util.concurrent.CompletableFuture 4 | 5 | /** 6 | * Created by vicboma on 07/12/16. 7 | */ 8 | class Fps(private val runnable: Runnable) : Runnable { 9 | 10 | var interpolation = 0.0 11 | private set 12 | 13 | companion object { 14 | private val TICKS_PER_SECOND = 21 15 | private val SKIP_TICKS = 1000 / TICKS_PER_SECOND 16 | private val MAX_FRAMESKIP = 5 17 | } 18 | 19 | init { 20 | 21 | } 22 | 23 | override fun run() { 24 | CompletableFuture.runAsync { 25 | 26 | var nextGameTick = System.currentTimeMillis().toDouble() 27 | var loops: Int 28 | 29 | while (true) { 30 | loops = 0 31 | while (System.currentTimeMillis() > nextGameTick && loops < MAX_FRAMESKIP) { 32 | 33 | runnable.run() 34 | 35 | nextGameTick += SKIP_TICKS.toDouble() 36 | loops++ 37 | } 38 | 39 | interpolation = (System.currentTimeMillis() + SKIP_TICKS - nextGameTick / SKIP_TICKS.toDouble()) 40 | } 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/kotlin/utils/image/BufferedImageMemoryFromComponent.kt: -------------------------------------------------------------------------------- 1 | package main.kotlin.utils.image 2 | 3 | import java.awt.Component 4 | import java.awt.Container 5 | import java.awt.image.BufferedImage 6 | import javax.swing.CellRendererPane 7 | 8 | /** 9 | * Created by vbolinch on 06/04/2017. 10 | */ 11 | object BufferedImageMemoryFromComponent { 12 | 13 | fun invoke(cmp: Component): BufferedImage { 14 | fun layoutComponent(c: Component) { 15 | synchronized(c.getTreeLock()) { 16 | c.doLayout() 17 | if (c is Container) 18 | for (child in c.getComponents()) 19 | layoutComponent(child) 20 | } 21 | } 22 | 23 | cmp.setSize(cmp.getPreferredSize()) 24 | layoutComponent(cmp) 25 | val img = BufferedImage(cmp.getWidth(), cmp.getHeight(), BufferedImage.TYPE_INT_ARGB) 26 | val crp = CellRendererPane() 27 | crp.add(cmp) 28 | crp.paintComponent(img.createGraphics(), cmp, crp, cmp.getBounds()) 29 | return img 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/image/ImageIconExt.kt: -------------------------------------------------------------------------------- 1 | package main.kotlin.utils.image 2 | 3 | import java.awt.Dimension 4 | import java.awt.RenderingHints 5 | import java.awt.image.BufferedImage 6 | import javax.swing.ImageIcon 7 | 8 | import java.lang.* 9 | 10 | /** 11 | * Created by vbolinch on 04/01/2017. 12 | */ 13 | fun ImageIcon.createBufferedImage(width: Int, height: Int, imageType: Int) = BufferedImage(width, height, imageType) 14 | 15 | 16 | fun ImageIcon.scale( 17 | bufferedImage: BufferedImage, 18 | filename: String, 19 | rendereingHints: Map<*,*> = mapOf( 20 | Pair(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY), 21 | Pair(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON), 22 | Pair(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED) 23 | ) 24 | ): BufferedImage? { 25 | 26 | try { 27 | val imageIcon = ImageIcon(filename) 28 | bufferedImage.createGraphics().apply{ 29 | addRenderingHints(rendereingHints) 30 | drawImage(imageIcon.image, 0, 0, bufferedImage.width, bufferedImage.height, null) 31 | } 32 | 33 | } catch (e: Exception) { 34 | e.printStackTrace() 35 | } 36 | finally{ 37 | return bufferedImage 38 | } 39 | } 40 | 41 | fun ImageIcon.getScaledDimension(imgSize: Dimension, boundary: Dimension): Dimension { 42 | 43 | val original_width = imgSize.width 44 | val original_height = imgSize.height 45 | val bound_width = boundary.width 46 | val bound_height = boundary.height 47 | var new_width = original_width 48 | var new_height = original_height 49 | 50 | // first check if we need to scale width 51 | if (original_width > bound_width) { 52 | //scale width to fit 53 | new_width = bound_width 54 | //scale height to maintain aspect ratio 55 | new_height = new_width * original_height / original_width 56 | } 57 | 58 | // then check if we need to scale even with the new height 59 | if (new_height > bound_height) { 60 | //scale height to fit instead 61 | new_height = bound_height 62 | //scale width to maintain aspect ratio 63 | new_width = new_height * original_width / original_height 64 | } 65 | 66 | return Dimension(new_width, new_height) 67 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/listGames/ListGames.kt: -------------------------------------------------------------------------------- 1 | package main.kotlin.utils.listGames 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.reflect.TypeToken 5 | import java.io.File 6 | import java.io.FileReader 7 | import java.util.* 8 | 9 | /** 10 | * Created by vbolinch on 03/01/2017. 11 | */ 12 | class ListGames internal constructor(private val classLoader: ClassLoader, private val path: String) { 13 | 14 | var columnNames : Array? = null 15 | var rowNames : Array>? = null 16 | 17 | companion object { 18 | fun create(classLoader: ClassLoader,path: String) = ListGames(classLoader,path) 19 | } 20 | 21 | init { 22 | val gson = Gson() 23 | val type = object : TypeToken>>() {}.type 24 | val resource = classLoader.getResource(path) 25 | val file = File(resource.toURI()) 26 | val list = gson.fromJson>>(FileReader(file), type) 27 | 28 | columnNames = list[0] 29 | rowNames = Arrays.copyOfRange(list ,1,list.size) 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/map/MergeMaps.kt: -------------------------------------------------------------------------------- 1 | package utils.map 2 | 3 | import java.util.* 4 | 5 | /** 6 | * Created by vicboma on 12/12/16. 7 | */ 8 | public fun Map.mergeReduce(other: Map, reduce: (V, V) -> V = { a, b -> b } ) : Map { 9 | val newMap = LinkedHashMap(this.size + other.size) 10 | newMap.putAll(this) 11 | for(entry in other.entries) { 12 | val key = newMap.get(entry.key) 13 | when(key) { 14 | null -> newMap.put(entry.key, entry.value) 15 | else -> newMap.put(entry.key, reduce(entry.value, key)) 16 | } 17 | } 18 | return newMap 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/monitor/PerformanceMonitor.kt: -------------------------------------------------------------------------------- 1 | package utils.monitor 2 | 3 | import com.sun.management.OperatingSystemMXBean 4 | import java.lang.management.ManagementFactory 5 | 6 | /** 7 | * Created by vicboma on 07/12/16. 8 | */ 9 | class PerformanceMonitor internal constructor(val availableProcessors : Int, var lastSystemTime : Long ,var lastProcessCpuTime : Long) { 10 | 11 | val cpuUsage: Double 12 | @Synchronized get() { 13 | if (lastSystemTime == 0L) { 14 | baselineCounters() 15 | return 0.0 16 | } 17 | 18 | val systemTime = System.nanoTime() 19 | var processCpuTime: Long = 0 20 | 21 | if (ManagementFactory.getOperatingSystemMXBean() is OperatingSystemMXBean) 22 | processCpuTime = (ManagementFactory.getOperatingSystemMXBean() as OperatingSystemMXBean).processCpuTime 23 | 24 | 25 | val cpuUsage = (processCpuTime - lastProcessCpuTime).toDouble() / (systemTime - lastSystemTime) 26 | 27 | lastSystemTime = systemTime 28 | lastProcessCpuTime = processCpuTime 29 | 30 | return cpuUsage / availableProcessors 31 | } 32 | 33 | private fun baselineCounters() { 34 | lastSystemTime = System.nanoTime() 35 | 36 | if (ManagementFactory.getOperatingSystemMXBean() is OperatingSystemMXBean) 37 | lastProcessCpuTime = (ManagementFactory.getOperatingSystemMXBean() as OperatingSystemMXBean).processCpuTime 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/swing/Swing.kt: -------------------------------------------------------------------------------- 1 | package utils.swing 2 | 3 | 4 | import javax.swing.SwingUtilities 5 | import kotlin.coroutines.experimental.AbstractCoroutineContextElement 6 | import kotlin.coroutines.experimental.Continuation 7 | import kotlin.coroutines.experimental.ContinuationInterceptor 8 | 9 | /** 10 | * Created by vicboma on 08/05/17. 11 | */ 12 | object Swing : AbstractCoroutineContextElement(ContinuationInterceptor), ContinuationInterceptor { 13 | 14 | override fun interceptContinuation(continuation: Continuation): Continuation = 15 | SwingContinuation(continuation) 16 | } 17 | 18 | private class SwingContinuation(val cont: Continuation) : Continuation by cont { 19 | 20 | override fun resume(value: T) { 21 | if (SwingUtilities.isEventDispatchThread()) 22 | cont.resume(value) 23 | else SwingUtilities.invokeLater { 24 | cont.resume(value) 25 | } 26 | } 27 | 28 | override fun resumeWithException(exception: Throwable) { 29 | if (SwingUtilities.isEventDispatchThread()) 30 | cont.resumeWithException(exception) 31 | else SwingUtilities.invokeLater { 32 | cont.resumeWithException(exception) 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/swing/SwingDelay.kt: -------------------------------------------------------------------------------- 1 | package utils.swing 2 | 3 | import javax.swing.Timer 4 | import kotlin.coroutines.experimental.suspendCoroutine 5 | 6 | /** 7 | * Created by vicboma on 09/05/17. 8 | */ 9 | suspend fun Swing.delay(millis: Int): Unit = suspendCoroutine { cont -> 10 | Timer(millis) { 11 | cont.resume(Unit) }.apply { 12 | isRepeats = false 13 | start() 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/system/System.kt: -------------------------------------------------------------------------------- 1 | package utils.system 2 | 3 | /** 4 | * Created by vicboma on 14/01/17. 5 | */ 6 | 7 | public fun isWindows() = getProperty().indexOf("win") >= 0 8 | 9 | public fun isMac() = getProperty().indexOf("mac") >= 0 10 | 11 | public fun isUnix() = getProperty().indexOf("nix") >= 0 || 12 | getProperty().indexOf("nux") >= 0 || 13 | getProperty().indexOf("aix") > 0 14 | 15 | public fun isSolaris() = getProperty().indexOf("sunos") >= 0 16 | 17 | private fun getProperty() = System.getProperty("os.name").toLowerCase() -------------------------------------------------------------------------------- /src/main/kotlin/utils/thread/CustomExecutor.kt: -------------------------------------------------------------------------------- 1 | package utils.thread 2 | 3 | import java.util.concurrent.CompletableFuture 4 | import java.util.concurrent.ConcurrentLinkedDeque 5 | 6 | /** 7 | * Created by vicboma on 29/12/16. 8 | */ 9 | @Deprecated("Replacing by coroutines") 10 | class CustomExecutor{ 11 | 12 | private val MILLISECONDS_THREAD_SLEEP = 75 13 | private val MILLISECOND_THREAD_SLEEP_TASK_RESOLVED = 25 14 | 15 | private var queue: ConcurrentLinkedDeque,() -> K >>? = null 16 | 17 | private val thread by lazy { 18 | 19 | Thread { 20 | 21 | while (!Thread.currentThread().isInterrupted) { 22 | val _priorityQueue = queue 23 | 24 | if (_priorityQueue!!.isEmpty()) { 25 | try { 26 | Thread.sleep(MILLISECONDS_THREAD_SLEEP.toLong()) 27 | } catch (e: InterruptedException) { 28 | e.printStackTrace() 29 | } 30 | 31 | } else { 32 | var poll: Pair, () -> K> ? = null 33 | try { 34 | CompletableFuture.runAsync { 35 | val size = _priorityQueue.size 36 | for (i in 0..size - 1) { 37 | poll = _priorityQueue.poll() 38 | // System.out.println("Invoke $count : ${poll!!.second.invoke().toString()}") 39 | val res = poll?.second?.invoke() 40 | poll?.first?.complete(res) 41 | // System.out.println("Completed ${poll!!.first.toString()}") 42 | count++ 43 | } 44 | } 45 | } catch(e: Exception) { 46 | // _priorityQueue.add(poll) 47 | } finally { 48 | 49 | try { 50 | Thread.sleep(MILLISECOND_THREAD_SLEEP_TASK_RESOLVED.toLong()) 51 | } catch (e: InterruptedException) { 52 | e.printStackTrace() 53 | } 54 | 55 | } 56 | } 57 | } 58 | } 59 | } 60 | 61 | 62 | init { 63 | queue = ConcurrentLinkedDeque() 64 | thread.apply{ 65 | isDaemon = true 66 | start() 67 | } 68 | 69 | } 70 | 71 | private object Holder { val INSTANCE = CustomExecutor() } 72 | 73 | companion object { 74 | var count = 0 75 | val instance: CustomExecutor by lazy { Holder.INSTANCE } 76 | } 77 | 78 | fun add(processSingle : () -> K) : CompletableFuture { 79 | val completableFuture = CompletableFuture() 80 | var _pair = Pair(completableFuture,processSingle) 81 | queue?.addLast(_pair) 82 | return completableFuture 83 | } 84 | 85 | fun addPriority(processSingle: () -> K) : CompletableFuture { 86 | val completableFuture = CompletableFuture() 87 | var _pair = Pair(completableFuture,processSingle) 88 | queue?.addFirst(_pair) 89 | return completableFuture 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/thread/DynamicSemaphore.kt: -------------------------------------------------------------------------------- 1 | package utils.thread 2 | 3 | import java.lang.Exception 4 | import java.lang.IllegalArgumentException 5 | import java.util.concurrent.Semaphore 6 | 7 | 8 | /** 9 | * Created by vicboma on 02/05/17. 10 | */ 11 | @Deprecated("Replacing by Mutex -> Coroutine") 12 | class DynamicSemaphore constructor(permits: Int, val fair:Boolean) { 13 | 14 | private val semaphore = CustomSemaphore(permits,fair) 15 | 16 | private var maxPermits = 0 17 | 18 | @Throws(IllegalArgumentException::class) 19 | @Synchronized 20 | fun setMaxPermits(newMax: Int) { 21 | if (newMax < 1) 22 | throw IllegalArgumentException("Semaphore size must be at least 1 was $newMax") 23 | 24 | var delta = newMax - this.maxPermits 25 | 26 | when { 27 | delta == 0 -> return 28 | delta > 0 -> this.semaphore.release(delta) 29 | delta < 0 -> { 30 | delta *= -1 31 | this.semaphore.reducePermits(delta) 32 | } 33 | else -> throw Exception("Error! Delta value not support") 34 | } 35 | 36 | this.maxPermits = newMax 37 | } 38 | 39 | fun release() = this.semaphore.release() 40 | 41 | @Throws(InterruptedException::class) 42 | fun acquire() = this.semaphore.acquire() 43 | 44 | 45 | private class CustomSemaphore constructor( permits: Int, fair:Boolean) : Semaphore(permits, fair) { 46 | public override fun reducePermits(reduction: Int) = super.reducePermits(reduction) 47 | } 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/kotlin/utils/thread/ThreadMain.kt: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import utils.thread.CustomExecutor 4 | import javax.swing.SwingUtilities 5 | 6 | /** 7 | * Created by vicboma on 05/12/16. 8 | */ 9 | @Deprecated("Replacing by launch(Swing) -> Coroutine") 10 | object ThreadMain { 11 | 12 | fun asyncUI(runnable: () -> Unit) { 13 | 14 | if (SwingUtilities.isEventDispatchThread()) { 15 | async(runnable) 16 | } else { 17 | SwingUtilities.invokeLater { 18 | async(runnable) 19 | } 20 | } 21 | } 22 | 23 | private fun async(runnable: () -> Unit) = CustomExecutor.instance.add{ 24 | SwingUtilities.invokeLater { 25 | runnable.invoke() 26 | } 27 | } 28 | 29 | private fun asyncPriority(runnable: () -> Unit) = CustomExecutor.instance.addPriority{ 30 | SwingUtilities.invokeLater { 31 | runnable.invoke() 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/kotlin/utils/tween/Tween.kt: -------------------------------------------------------------------------------- 1 | package main.kotlin.utils.tween 2 | 3 | import kotlinx.coroutines.experimental.launch 4 | import main.kotlin.utils.completable.CompletableCancelable 5 | import utils.swing.Swing 6 | import utils.swing.delay 7 | import java.awt.Color 8 | import java.util.concurrent.CompletableFuture 9 | import java.util.concurrent.CopyOnWriteArrayList 10 | import javax.swing.JLabel 11 | 12 | /** 13 | * Created by vbolinch on 04/01/2017. 14 | */ 15 | fun JLabel.asyncSpel(str: String, delay: Long, sequence:Long) : CompletableCancelable { 16 | 17 | var completableCancelable = CompletableCancelable(CompletableFuture(), CopyOnWriteArrayList().apply { add(false) }) 18 | 19 | launch(Swing) { 20 | CompletableFuture.runAsync { 21 | completableCancelable.completable 22 | .thenAcceptAsync { 23 | Thread.sleep(delay) 24 | text = "" 25 | var i = 0 26 | while (i < str.length - 1 && !completableCancelable.cancelable[0]) { 27 | i++ 28 | Thread.sleep(sequence) 29 | text += str[i].toString() 30 | } 31 | if(completableCancelable.cancelable[0]) 32 | text = "" 33 | } 34 | } 35 | } 36 | 37 | return completableCancelable 38 | } 39 | 40 | private val COLOR_DEFAULT_UNMASK = Color(0x00313131.toInt(), true) 41 | private val COLOR_DEFAULT_MASK = Color(0xFF313131.toInt(), true) 42 | 43 | 44 | fun JLabel.asyncFadeOn(str: String, increment : Int = 2, opacityTarget_255: Int = 255, delay: Long = 50, sequence:Long = 5) : CompletableCancelable { 45 | 46 | var completableCancelable = CompletableCancelable(CompletableFuture(), CopyOnWriteArrayList().apply { add(false) }) 47 | 48 | launch(Swing) { 49 | CompletableFuture.runAsync { 50 | completableCancelable.completable 51 | .thenAcceptAsync { 52 | Thread.sleep(delay) 53 | text = str 54 | foreground = COLOR_DEFAULT_UNMASK 55 | while ( foreground.alpha <= opacityTarget_255) { 56 | Thread.sleep(sequence) 57 | val colorAlpha = foreground.alpha.plus(increment) 58 | foreground = Color( foreground.red, foreground.green, foreground.blue, colorAlpha) 59 | } 60 | if(completableCancelable.cancelable[0]) 61 | foreground = COLOR_DEFAULT_UNMASK 62 | } 63 | } 64 | } 65 | 66 | return completableCancelable 67 | } 68 | 69 | fun JLabel.asyncFadeOff(str: String, decrement : Int = 2, opacityTarget_0: Int = 0, delay: Long = 50, sequence:Long = 5 ) : CompletableCancelable { 70 | 71 | var completableCancelable = CompletableCancelable(CompletableFuture(), CopyOnWriteArrayList().apply { add(false) }) 72 | 73 | launch(Swing) { 74 | CompletableFuture.runAsync { 75 | completableCancelable.completable 76 | .thenAcceptAsync { 77 | Thread.sleep(delay) 78 | text = str 79 | foreground = COLOR_DEFAULT_MASK 80 | while ( foreground.alpha >= opacityTarget_0) { 81 | Thread.sleep(sequence) 82 | val colorAlpha = foreground.alpha.minus(decrement) 83 | foreground = Color( foreground.red, foreground.green, foreground.blue, colorAlpha) 84 | } 85 | if(completableCancelable.cancelable[0]) 86 | foreground = COLOR_DEFAULT_MASK 87 | } 88 | } 89 | } 90 | 91 | return completableCancelable 92 | } -------------------------------------------------------------------------------- /src/main/kotlin/utils/zip/Zipable.kt: -------------------------------------------------------------------------------- 1 | package utils.zip 2 | 3 | import java.io.File 4 | import java.io.FileInputStream 5 | import java.io.FileOutputStream 6 | import java.io.IOException 7 | import java.util.zip.ZipInputStream 8 | 9 | /** 10 | * Created by vicboma on 01/02/17. 11 | */ 12 | class Zipable internal constructor(private val origin : String , private val target : String ){ 13 | 14 | companion object { 15 | 16 | } 17 | 18 | init { 19 | 20 | } 21 | 22 | 23 | fun compress(){ 24 | 25 | } 26 | 27 | fun unCompress() { 28 | val buffer = ByteArray(1024) 29 | 30 | try { 31 | 32 | val folder = File(target) 33 | if (!folder.exists()) { 34 | folder.mkdir() 35 | } 36 | 37 | val zis = ZipInputStream(FileInputStream(origin)) 38 | var ze = zis.getNextEntry() 39 | 40 | while (ze != null) { 41 | 42 | val fileName = ze?.getName() 43 | val newFile = File(target + File.separator + fileName) 44 | 45 | System.out.println("file unzip : " + newFile.getAbsoluteFile()) 46 | 47 | File(newFile.getParent()).mkdirs() 48 | 49 | val fos = FileOutputStream(newFile) 50 | 51 | var len: Int = 0 52 | while ({ len = zis.read(buffer); len }() > 0) { 53 | fos.write(buffer, 0, len) 54 | } 55 | 56 | fos.close() 57 | ze = zis.getNextEntry() 58 | } 59 | 60 | zis.closeEntry() 61 | zis.close() 62 | 63 | println("Done") 64 | 65 | } catch (ex: IOException) { 66 | ex.printStackTrace() 67 | } 68 | 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/resources/app/readme.md: -------------------------------------------------------------------------------- 1 | icon.png of the app -------------------------------------------------------------------------------- /src/main/resources/cartridge/readme.md: -------------------------------------------------------------------------------- 1 | {romName}.png -------------------------------------------------------------------------------- /src/main/resources/cover/readme.md: -------------------------------------------------------------------------------- 1 | {romName}.png -------------------------------------------------------------------------------- /src/main/resources/list/listGame.json: -------------------------------------------------------------------------------- 1 | [["Load","ROM Game", "Game Name", "ROM Type", "Size (in bytes)"],[false,"ACE_STRI.GB","ACE STRIKER ","ROM+MBC1 ",131.072]] -------------------------------------------------------------------------------- /src/main/resources/rom/readme.md: -------------------------------------------------------------------------------- 1 | {romName}.png -------------------------------------------------------------------------------- /src/main/resources/snapshot/readme.md: -------------------------------------------------------------------------------- 1 | {romName}.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.0.1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.0.1.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.0.2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.0.2.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.1.0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.1.0.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.1.1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.1.1.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.0.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.1-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.1-1.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.1-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.1-2.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.1.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-1.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-2.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-3.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-4.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-5.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2-6.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.2.gif -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.3-1.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.3-2.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.3-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.3-3.png -------------------------------------------------------------------------------- /src/main/resources/version/GBEE_v.0.2.3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vicboma1/GameBoyEmulatorEnvironment/c9db8dcf5352d186e597b7a6570d9bf2144617f4/src/main/resources/version/GBEE_v.0.2.3.gif -------------------------------------------------------------------------------- /start-async-checkbutton-application.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 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 | --------------------------------------------------------------------------------