/* Ċ The ĠMIT ĠLicense Ġ( MIT ) Ċ Ċ Copyright Ġ( c ) Ġ 2 0 1 6 ĠTom ĠNeed ham Ċ Ċ Permission Ġis Ġhereby Ġgranted , Ġfree Ġof Ġcharge , Ġto Ġany Ġperson Ġobtaining Ġa Ġcopy Ċ of Ġthis Ġsoftware Ġand Ġassociated Ġdocumentation Ġfiles Ġ( the Ġ" Software "), Ġto Ġdeal Ċ in Ġthe ĠSoftware Ġwithout Ġrestriction , Ġincluding Ġwithout Ġlimitation Ġthe Ġrights Ċ to Ġuse , Ġcopy , Ġmodify , Ġmerge , Ġpublish , Ġdistribute , Ġsublicense , Ġand / or Ġsell Ċ copies Ġof Ġthe ĠSoftware , Ġand Ġto Ġpermit Ġpersons Ġto Ġwhom Ġthe ĠSoftware Ġis Ċ furnished Ġto Ġdo Ġso , Ġsubject Ġto Ġthe Ġfollowing Ġconditions : Ċ Ċ The Ġabove Ġcopyright Ġnotice Ġand Ġthis Ġpermission Ġnotice Ġshall Ġbe Ġincluded Ġin Ġall Ċ copies Ġor Ġsubstantial Ġportions Ġof Ġthe ĠSoftware . Ċ Ċ THE ĠSOFTWARE ĠIS ĠPROVIDED Ġ" AS ĠIS ", ĠWITHOUT ĠWARRANTY ĠOF ĠANY ĠKIND , ĠEXPRESS ĠOR Ċ IMPLIED , ĠINCLUDING ĠBUT ĠNOT ĠLIMITED ĠTO ĠTHE ĠWARRANTIES ĠOF ĠMERCHANTABILITY , Ċ FITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE ĠAND ĠNONINFRINGEMENT . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE Ċ AUTHORS ĠOR ĠCOPYRIGHT ĠHOLDERS ĠBE ĠLIABLE ĠFOR ĠANY ĠCLAIM , ĠDAMAGES ĠOR ĠOTHER Ċ LIABILITY , ĠWHETHER ĠIN ĠAN ĠACTION ĠOF ĠCONTRACT , ĠTORT ĠOR ĠOTHERWISE , ĠARISING ĠFROM , Ċ OUT ĠOF ĠOR ĠIN ĠCONNECTION ĠWITH ĠTHE ĠSOFTWARE ĠOR ĠTHE ĠUSE ĠOR ĠOTHER ĠDEALINGS ĠIN ĠTHE Ċ SOFTWARE . Ċ Ġ*/ Ċ package Ġcom . th omas . need ham . ne uro ph idea . actions Ċ Ċ import Ġcom . intellij . ide . util . Properties Component Ċ import Ġcom . intellij . openapi . action System . An Action Ċ import Ġcom . intellij . openapi . action System . An ActionEvent Ċ import Ġcom . intellij . openapi . file Chooser . FileChooser Ċ import Ġcom . intellij . openapi . file Chooser . FileChooser Descriptor Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . ui . Messages Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġcom . intellij . util . Consumer Ċ import Ġcom . th omas . need ham . ne uro ph idea . Constants . NETWORK _ CONFIGURATION _ TO _ OPEN _ LOCATION _ KEY Ċ import Ġcom . th omas . need ham . ne uro ph idea . consum ers . Open Network Configuration Consumer Ċ import Ġcom . th omas . need ham . ne uro ph idea . data structures . Learning Rules Ċ import Ġcom . th omas . need ham . ne uro ph idea . data structures . Network Configuration Ċ import Ġcom . th omas . need ham . ne uro ph idea . data structures . Network Types Ċ import Ġcom . th omas . need ham . ne uro ph idea . data structures . Transfer Functions Ċ import Ġjava . io .* Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠThomas ĠNeed ham Ġon Ġ 2 7 / 0 5 / 2 0 1 6 . Ċ Ġ* Ċ Ġ* ĠAction Ġperformed Ġwhen Ġop w ning Ġan Ġexiting Ġnetwork Ċ Ġ*/ Ċ class ĠOpen Existing Network Configuration Action Ġ: ĠAn Action () Ġ{ ĊĉĊ ĉ comp anion Ġobject ĠData Ġ{ Ċĉ ĉ var Ġproject : ĠProject ? Ġ= Ġnull Ċĉ ĉ var Ġproject Directory : ĠString ? Ġ= Ġ"" Ċĉ ĉ var ĠisOpen : ĠBoolean ? Ġ= Ġfalse Ċĉ ĉ val Ġproperties Ġ= ĠProperties Component . getInstance () Ċĉ ĉ val Ġfile Desc : ĠFile Chooser Descriptor Ġ= ĠFile Chooser Descriptor ( true , Ġfalse , Ġfalse , Ġfalse , Ġfalse , Ġfalse ) Ċĉ ĉ val Ġconsumer : ĠOpen Network Configuration Consumer ? Ġ= ĠOpen Network Configuration Consumer () Ċĉ ĉ val Ġcreate Action : ĠShow Create Network Form Action ? Ġ= ĠShow Create Network Form Action () Ċĉ ĉ val Ġget Network : Ġ( String ) Ġ-> ĠNetwork Configuration ? Ġ= Ġ{ Ġpath Ġ-> Ċĉĉ ĉ // Use ĠSome ĠKotlin ĠS orc ery Ċĉĉ ĉ val Ġnetwork : ĠNetwork Configuration ? Ċĉĉ ĉ try Ġ{ Ċĉĉĉ ĉ val Ġfile Ġ= ĠFile ( path ) Ċĉĉĉ ĉ val Ġfis Ġ= ĠFileInputStream ( file ) Ċĉĉĉ ĉ val Ġo is Ġ= ĠObject InputStream ( fis ) Ċĉĉĉ ĉ network Ġ= Ġo is . read Object () Ġas ĠNetwork Configuration ? Ċĉĉĉ ĉ network Ċĉĉ ĉ } Ġcatch Ġ( io e : ĠIOException ) Ġ{ Ċĉĉĉ ĉ io e . printStackTrace ( System . err ) Ċĉĉĉ ĉ Messages . show Error Dialog ( Open Existing Network Configuration Action . project , Ġ" Error ĠReading ĠNetwork ĠFrom Ġfile ", Ġ" Error ") Ċĉĉĉ ĉ null Ċĉĉ ĉ } Ġcatch Ġ( fn fe : ĠFileNotFoundException ) Ġ{ Ċĉĉĉ ĉ fn fe . printStackTrace ( System . err ) Ċĉĉĉ ĉ Messages . show Error Dialog ( Open Existing Network Configuration Action . project , Ġ" No ĠNetwork ĠConfiguration ĠFound Ġat : Ġ" Ġ+ Ġproperties . getValue ( NETWORK _ CONFIGURATION _ TO _ OPEN _ LOCATION _ KEY , Ġ""), Ġ" Error ") Ċĉĉĉ ĉ null Ċĉĉ ĉ } Ċĉ ĉ } ĊĉĉĊ ĉ } ĊĉĊ ĉ /** Ċĉ Ġ* ĠFunction Ġcalled Ġwhen Ġaction Ġis Ġperformed . Ċĉ Ġ*/ Ċ ĉ override Ġfun ĠactionPerformed ( e : ĠAn ActionEvent ) Ġ{ Ċĉ ĉ project Ġ= ĠInitial isation Action . project Ċĉ ĉ project Directory Ġ= ĠInitial isation Action . project Directory Ċĉ ĉ isOpen Ġ= Ġproject ?. isOpen Ċĉ ĉ FileChooser . choose File ( file Desc , Ġproject , Ġnull , Ġconsumer Ġas ĠConsumer < Virtual File ?> ) Ċĉ ĉ val Ġnetwork : ĠNetwork Configuration ? Ġ= Ġget Network ( properties . getValue ( NETWORK _ CONFIGURATION _ TO _ OPEN _ LOCATION _ KEY , Ġ"")) Ċĉĉĉ ĉ ?: Ġreturn Ċĉ ĉ val Ġget Layers String : Ġ( Array < Int >) Ġ-> ĠString Ġ= Ġ{ Ġlayers Ġ-> Ċĉĉ ĉ // Use ĠSome ĠKotlin ĠS orc ery Ġto Ġconvert ĠArray < Int > Ġto Ġcomma Ġdelimited Ġstring Ċĉĉ ĉ var Ġresult Ġ= Ġ"" Ċĉĉ ĉ for Ġ( i Ġin ĠInt Range ( 0 , Ġlayers . size Ġ- Ġ 1 )) Ġ{ Ċĉĉĉ ĉ if Ġ( i Ġ== Ġlayers . size Ġ- Ġ 1 ) Ċĉĉĉĉ ĉ result Ġ+= Ġlayers [ i ]. toString () Ċĉĉĉ ĉ else Ċĉĉĉĉ ĉ result Ġ+= Ġ( layers [ i ]. toString () Ġ+ Ġ", ") Ċĉĉ ĉ } Ċĉĉ ĉ result Ċĉ ĉ } Ċĉ ĉ create Action ?. action Performed ( e ) Ċĉ ĉ create Action ?. form ?. isVisible Ġ= Ġfalse Ċĉ ĉ create Action ?. form ?. txt Network Name ?. text Ġ= Ġnetwork ?. network Name Ċĉ ĉ create Action ?. form ?. txt Layers ?. text Ġ= Ġget Layers String ( network ?. network Layers !! ) Ċĉ ĉ create Action ?. form ?. cmb Network Type ?. selected Item Ġ= ĠNetwork Types . friendly Names [ network ?. network Type ?. ordinal !! ] Ċĉ ĉ create Action ?. form ?. cmb Learning Rule ?. selected Item Ġ= ĠLearning Rules . friendly Names [ network ?. network Learning Rule ?. ordinal !! ] Ċĉ ĉ create Action ?. form ?. cmb Transfer Function ?. selected Item Ġ= ĠTransfer Functions . friendly Names [ network ?. network Transfer Function ?. ordinal !! ] Ċĉ ĉ create Action ?. form ?. txt Training Data ?. text Ġ= Ġnetwork ?. network Training Data Path Ċĉ ĉ create Action ?. form ?. txt Testing Data ?. text Ġ= Ġnetwork ?. network Testing Data Path Ċĉ ĉ create Action ?. form ?. txt Network Output Path ?. text Ġ= Ġnetwork ?. network Output Path Ċĉ ĉ create Action ?. form ?. rep aint ( Long . MAX _ VALUE , Ġ 0 , Ġ 0 , Ġcreate Action ?. form ?. width !! , Ġcreate Action ?. form ?. height !! ) Ċĉ ĉ create Action ?. form ?. isVisible Ġ= Ġtrue ĊĉĉĊ ĉ } Ċ } Ċ