| .. | .. |
|---|
| 3214 | 3214 | objEditor.refreshContents(); |
|---|
| 3215 | 3215 | } |
|---|
| 3216 | 3216 | |
|---|
| 3217 | + static public byte[] Compress(Object o) |
|---|
| 3218 | + { |
|---|
| 3219 | + try |
|---|
| 3220 | + { |
|---|
| 3221 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|---|
| 3222 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
|---|
| 3223 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
|---|
| 3224 | + |
|---|
| 3225 | + out.writeObject(o); |
|---|
| 3226 | + |
|---|
| 3227 | + out.flush(); |
|---|
| 3228 | + |
|---|
| 3229 | + zstream.close(); |
|---|
| 3230 | + out.close(); |
|---|
| 3231 | + |
|---|
| 3232 | + return baos.toByteArray(); |
|---|
| 3233 | + } catch (Exception e) |
|---|
| 3234 | + { |
|---|
| 3235 | + System.err.println(e); |
|---|
| 3236 | + return null; |
|---|
| 3237 | + } |
|---|
| 3238 | + } |
|---|
| 3239 | + |
|---|
| 3240 | + static public Object Uncompress(byte[] bytes) |
|---|
| 3241 | + { |
|---|
| 3242 | + try |
|---|
| 3243 | + { |
|---|
| 3244 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
|---|
| 3245 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
|---|
| 3246 | + ObjectInputStream in = new ObjectInputStream(istream); |
|---|
| 3247 | + Object obj = in.readObject(); |
|---|
| 3248 | + in.close(); |
|---|
| 3249 | + |
|---|
| 3250 | + return obj; |
|---|
| 3251 | + } catch (Exception e) |
|---|
| 3252 | + { |
|---|
| 3253 | + System.err.println(e); |
|---|
| 3254 | + return null; |
|---|
| 3255 | + } |
|---|
| 3256 | + } |
|---|
| 3257 | + |
|---|
| 3217 | 3258 | static public Object clone(Object o) |
|---|
| 3218 | 3259 | { |
|---|
| 3219 | 3260 | try |
|---|
| .. | .. |
|---|
| 3222 | 3263 | ObjectOutputStream out = new ObjectOutputStream(baos); |
|---|
| 3223 | 3264 | |
|---|
| 3224 | 3265 | out.writeObject(o); |
|---|
| 3266 | + |
|---|
| 3267 | + out.flush(); |
|---|
| 3268 | + out.close(); |
|---|
| 3269 | + |
|---|
| 3270 | + byte[] bytes = baos.toByteArray(); |
|---|
| 3271 | + |
|---|
| 3272 | + System.out.println("clone = " + bytes.length); |
|---|
| 3225 | 3273 | |
|---|
| 3226 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
|---|
| 3274 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
|---|
| 3227 | 3275 | ObjectInputStream in = new ObjectInputStream(bais); |
|---|
| 3228 | 3276 | Object obj = in.readObject(); |
|---|
| 3229 | 3277 | in.close(); |
|---|
| 3230 | | - out.close(); |
|---|
| 3278 | + |
|---|
| 3231 | 3279 | return obj; |
|---|
| 3232 | 3280 | } catch (Exception e) |
|---|
| 3233 | 3281 | { |
|---|
| .. | .. |
|---|
| 3251 | 3299 | return null; |
|---|
| 3252 | 3300 | } |
|---|
| 3253 | 3301 | |
|---|
| 3302 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
|---|
| 3303 | + |
|---|
| 3254 | 3304 | public void Save() |
|---|
| 3255 | 3305 | { |
|---|
| 3256 | 3306 | cRadio tab = GetCurrentTab(); |
|---|
| 3257 | 3307 | |
|---|
| 3308 | + copy.ExtractBigData(hashtable); |
|---|
| 3309 | + |
|---|
| 3258 | 3310 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
|---|
| 3259 | 3311 | tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
|---|
| 3260 | 3312 | |
|---|
| 3313 | + copy.RestoreBigData(hashtable); |
|---|
| 3314 | + |
|---|
| 3315 | + //assert(hashtable.isEmpty()); |
|---|
| 3316 | + |
|---|
| 3261 | 3317 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
|---|
| 3262 | 3318 | { |
|---|
| 3263 | 3319 | tab.graphs[i] = null; |
|---|
| .. | .. |
|---|
| 3285 | 3341 | |
|---|
| 3286 | 3342 | void CopyChanged(Object3D obj) |
|---|
| 3287 | 3343 | { |
|---|
| 3344 | + copy.ExtractBigData(hashtable); |
|---|
| 3345 | + |
|---|
| 3288 | 3346 | copy.clear(); |
|---|
| 3289 | 3347 | |
|---|
| 3290 | 3348 | for (int i=0; i<obj.Size(); i++) |
|---|
| 3291 | 3349 | { |
|---|
| 3292 | 3350 | copy.add(obj.get(i)); |
|---|
| 3293 | 3351 | } |
|---|
| 3352 | + |
|---|
| 3353 | + copy.RestoreBigData(hashtable); |
|---|
| 3354 | + |
|---|
| 3355 | + //assert(hashtable.isEmpty()); |
|---|
| 3294 | 3356 | |
|---|
| 3295 | 3357 | copy.Touch(); |
|---|
| 3296 | 3358 | |
|---|
| .. | .. |
|---|
| 4295 | 4357 | |
|---|
| 4296 | 4358 | if (readobj != null) |
|---|
| 4297 | 4359 | { |
|---|
| 4360 | + Save(); |
|---|
| 4298 | 4361 | try |
|---|
| 4299 | 4362 | { |
|---|
| 4300 | 4363 | //readobj.deepCopySelf(copy); |
|---|