From d0dc7ff35d71919d503ae35592478b173cf3cfd3 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 10 Jun 2019 23:45:04 -0400 Subject: [PATCH] Extract big data. --- ObjEditor.java | 67 ++++++++++++++++++++++++++++++++- 1 files changed, 65 insertions(+), 2 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index b7c343d..2cb5163 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -3214,6 +3214,47 @@ objEditor.refreshContents(); } + static public byte[] Compress(Object o) + { + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); + ObjectOutputStream out = new ObjectOutputStream(zstream); + + out.writeObject(o); + + out.flush(); + + zstream.close(); + out.close(); + + return baos.toByteArray(); + } catch (Exception e) + { + System.err.println(e); + return null; + } + } + + static public Object Uncompress(byte[] bytes) + { + try + { + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); + ObjectInputStream in = new ObjectInputStream(istream); + Object obj = in.readObject(); + in.close(); + + return obj; + } catch (Exception e) + { + System.err.println(e); + return null; + } + } + static public Object clone(Object o) { try @@ -3222,12 +3263,19 @@ ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(o); + + out.flush(); + out.close(); + + byte[] bytes = baos.toByteArray(); + + System.out.println("clone = " + bytes.length); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream in = new ObjectInputStream(bais); Object obj = in.readObject(); in.close(); - out.close(); + return obj; } catch (Exception e) { @@ -3251,13 +3299,21 @@ return null; } + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); + public void Save() { cRadio tab = GetCurrentTab(); + copy.ExtractBigData(hashtable); + //EditorFrame.m_MainFrame.requestFocusInWindow(); tab.graphs[tab.undoindex++] = (Object3D)clone(copy); + copy.RestoreBigData(hashtable); + + //assert(hashtable.isEmpty()); + for (int i = tab.undoindex; i < tab.graphs.length; i++) { tab.graphs[i] = null; @@ -3285,12 +3341,18 @@ void CopyChanged(Object3D obj) { + copy.ExtractBigData(hashtable); + copy.clear(); for (int i=0; i<obj.Size(); i++) { copy.add(obj.get(i)); } + + copy.RestoreBigData(hashtable); + + //assert(hashtable.isEmpty()); copy.Touch(); @@ -4295,6 +4357,7 @@ if (readobj != null) { + Save(); try { //readobj.deepCopySelf(copy); -- Gitblit v1.6.2