.. | .. |
---|
2927 | 2927 | return; |
---|
2928 | 2928 | } else if (event.getSource() == toggleSwitchItem) |
---|
2929 | 2929 | { |
---|
2930 | | - cameraView.ToggleRandom(); |
---|
| 2930 | + cameraView.ToggleSwitch(); |
---|
2931 | 2931 | cameraView.repaint(); |
---|
2932 | 2932 | return; |
---|
2933 | 2933 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
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 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3243 | + try |
---|
| 3244 | + { |
---|
| 3245 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3246 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3247 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3248 | + Object obj = in.readObject(); |
---|
| 3249 | + in.close(); |
---|
| 3250 | + |
---|
| 3251 | + return obj; |
---|
| 3252 | + } catch (Exception e) |
---|
| 3253 | + { |
---|
| 3254 | + System.err.println(e); |
---|
| 3255 | + return null; |
---|
| 3256 | + } |
---|
| 3257 | + } |
---|
| 3258 | + |
---|
3217 | 3259 | static public Object clone(Object o) |
---|
3218 | 3260 | { |
---|
3219 | 3261 | try |
---|
.. | .. |
---|
3222 | 3264 | ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
3223 | 3265 | |
---|
3224 | 3266 | out.writeObject(o); |
---|
| 3267 | + |
---|
| 3268 | + out.flush(); |
---|
| 3269 | + out.close(); |
---|
| 3270 | + |
---|
| 3271 | + byte[] bytes = baos.toByteArray(); |
---|
| 3272 | + |
---|
| 3273 | + System.out.println("clone = " + bytes.length); |
---|
3225 | 3274 | |
---|
3226 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
| 3275 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3227 | 3276 | ObjectInputStream in = new ObjectInputStream(bais); |
---|
3228 | 3277 | Object obj = in.readObject(); |
---|
3229 | 3278 | in.close(); |
---|
3230 | | - out.close(); |
---|
| 3279 | + |
---|
3231 | 3280 | return obj; |
---|
3232 | 3281 | } catch (Exception e) |
---|
3233 | 3282 | { |
---|
.. | .. |
---|
3242 | 3291 | for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
3243 | 3292 | { |
---|
3244 | 3293 | ab = (cRadio)e.nextElement(); |
---|
3245 | | - if(ab.GetObject() == client) |
---|
| 3294 | + if(ab.GetObject() == copy) |
---|
3246 | 3295 | { |
---|
3247 | 3296 | return ab; |
---|
3248 | 3297 | } |
---|
.. | .. |
---|
3251 | 3300 | return null; |
---|
3252 | 3301 | } |
---|
3253 | 3302 | |
---|
| 3303 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3304 | + |
---|
3254 | 3305 | public void Save() |
---|
3255 | 3306 | { |
---|
3256 | 3307 | cRadio tab = GetCurrentTab(); |
---|
3257 | 3308 | |
---|
| 3309 | + boolean temp = CameraPane.SWITCH; |
---|
| 3310 | + CameraPane.SWITCH = false; |
---|
| 3311 | + |
---|
| 3312 | + copy.ExtractBigData(hashtable); |
---|
| 3313 | + |
---|
3258 | 3314 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3259 | | - tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
---|
| 3315 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3260 | 3316 | |
---|
| 3317 | + copy.RestoreBigData(hashtable); |
---|
| 3318 | + |
---|
| 3319 | + CameraPane.SWITCH = temp; |
---|
| 3320 | + |
---|
| 3321 | + //assert(hashtable.isEmpty()); |
---|
| 3322 | + |
---|
3261 | 3323 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3262 | 3324 | { |
---|
3263 | 3325 | tab.graphs[i] = null; |
---|
.. | .. |
---|
3285 | 3347 | |
---|
3286 | 3348 | void CopyChanged(Object3D obj) |
---|
3287 | 3349 | { |
---|
| 3350 | + boolean temp = CameraPane.SWITCH; |
---|
| 3351 | + CameraPane.SWITCH = false; |
---|
| 3352 | + |
---|
| 3353 | + copy.ExtractBigData(hashtable); |
---|
| 3354 | + |
---|
3288 | 3355 | copy.clear(); |
---|
3289 | 3356 | |
---|
3290 | 3357 | for (int i=0; i<obj.Size(); i++) |
---|
3291 | 3358 | { |
---|
3292 | 3359 | copy.add(obj.get(i)); |
---|
3293 | 3360 | } |
---|
| 3361 | + |
---|
| 3362 | + copy.RestoreBigData(hashtable); |
---|
| 3363 | + |
---|
| 3364 | + CameraPane.SWITCH = temp; |
---|
| 3365 | + |
---|
| 3366 | + //assert(hashtable.isEmpty()); |
---|
3294 | 3367 | |
---|
3295 | 3368 | copy.Touch(); |
---|
3296 | 3369 | |
---|
.. | .. |
---|
3331 | 3404 | |
---|
3332 | 3405 | tab.undoindex -= 1; |
---|
3333 | 3406 | |
---|
3334 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3407 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3335 | 3408 | } |
---|
3336 | 3409 | |
---|
3337 | 3410 | public void Redo() |
---|
.. | .. |
---|
3346 | 3419 | |
---|
3347 | 3420 | tab.undoindex += 1; |
---|
3348 | 3421 | |
---|
3349 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3422 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3350 | 3423 | } |
---|
3351 | 3424 | |
---|
3352 | 3425 | void ImportGFD() |
---|
.. | .. |
---|
4295 | 4368 | |
---|
4296 | 4369 | if (readobj != null) |
---|
4297 | 4370 | { |
---|
| 4371 | + Save(); |
---|
4298 | 4372 | try |
---|
4299 | 4373 | { |
---|
4300 | 4374 | //readobj.deepCopySelf(copy); |
---|