(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



BeginPackage["FusionAtlas`Java`",{"FusionAtlas`","JLink`","FusionAtlas`Bigraphs`","FusionAtlas`GraphPairs`"}]


FusionAtlasJavaDirectory::usage="";FusionAtlasScalaDirectory::usage="";


GraphToScalaObject;AsScalaSet;AsScalaList;UnpackJavaLists;UnpackJavaObjects;


RestartJava;


Begin["`Private`"];


FusionAtlasJavaDirectory[]:=ToFileName[FusionAtlasDirectory[],"java"]


FusionAtlasScalaDirectory[]:=ToFileName[FusionAtlasDirectory[],"scala"]


RestartJava[]:=
Module[{},
If[!IntegerQ[Global`$JVMHeap]\[Or]Global`$JVMHeap<256,Global`$JVMHeap=256];
ReinstallJava[CommandLine->"java",JVMArguments->"-Xmx"<>ToString[Global`$JVMHeap]<>"m"];
AllowRaggedArrays[True];
LoadJavaClass["org.fusionatlas.v1.odometer.GradedBigraph"];
LoadJavaClass["org.fusionatlas.v1.odometer.Proxy"];
]


AddToClassPath[ToFileName[FusionAtlasJavaDirectory[],"target"],ToFileName[FusionAtlasJavaDirectory[],"jars"],ToFileName[FusionAtlasScalaDirectory[],"target"],ToFileName[FusionAtlasScalaDirectory[],"jars"],ToFileName[FusionAtlasScalaDirectory[],"lib"]];


AllowRaggedArrays[True];


LoadJavaClass["org.fusionatlas.v1.odometer.GradedBigraph"];
LoadJavaClass["org.fusionatlas.v1.odometer.Proxy"];
LoadJavaClass["org.fusionatlas.enumerators.QueueEnumerator"];


LoadJavaClass["org.fusionatlas.graphs.PairOfBigraphsWithDuals","AllowShortContext"->False];
LoadJavaClass["org.fusionatlas.graphs.Bigraph$","AllowShortContext"->False];
LoadJavaClass["org.fusionatlas.graphs.BigraphWithDuals","AllowShortContext"->False];
LoadJavaClass["scala.collection.immutable.List$","AllowShortContext"->False];LoadJavaClass["scala.collection.immutable.Set$","AllowShortContext"->False];
LoadJavaClass["java.util.Arrays","AllowShortContext"->False];
LoadJavaClass["scala.collection.JavaConversions","AllowShortContext"->False];


GraphToScalaObject[g_GradedBigraph]:=org`fusionatlas`graphs`Bigraph$`MODULE$@apply[GraphToString[g]]


GraphToScalaObject[g_BigraphWithDuals]:=org`fusionatlas`graphs`BigraphWithDuals`apply[GraphToString[g]]


GraphToScalaObject[{g1_BigraphWithDuals,g2_BigraphWithDuals}]:=org`fusionatlas`graphs`PairOfBigraphsWithDuals`apply[GraphToString[g1],GraphToString[g2]]


AsScalaSet[list_]:=scala`collection`JavaConversions`asSet[JavaNew["java.util.HashSet",java`util`Arrays`asList[MakeJavaObject[list]]]]
AsScalaSet[{}]:=scala`collection`immutable`Set$`MODULE$@empty[]


AsScalaList[list_]:=scala`collection`JavaConversions`asBuffer[java`util`Arrays`asList[MakeJavaObject[list]]]@toList[]
AsScalaList[{}]:=scala`collection`immutable`List$`MODULE$@empty[]


UnpackJavaLists[X_]:=X//.{Y_/;InstanceOf[Y,"scala.collection.immutable.List"]:>JavaConversions`asList[Y],Y_/;InstanceOf[Y,"scala.Tuple2"]->Y@productIterator[]@toList[],Y_/;InstanceOf[Y,"java.util.List"]:>Y@toArray[]}


UnpackJavaObjects[X_]:=UnpackJavaLists[X]//.{Y_/;InstanceOf[Y,"net.tqft.toolkit.MathematicaExpression"]:>ToExpression[Y@toMathematicaInputString[]]}


End[];


EndPackage[];
