.. | .. |
---|
278 | 278 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 279 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 280 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 281 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 282 | |
---|
283 | 283 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 284 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
2072 | 2072 | |
---|
2073 | 2073 | void LoadObjFile(String fullname) |
---|
2074 | 2074 | { |
---|
2075 | | - /* |
---|
| 2075 | + System.out.println("Loading " + fullname); |
---|
| 2076 | + /**/ |
---|
2076 | 2077 | //lastFilename = fullname; |
---|
2077 | 2078 | if(loadObjThread == null) |
---|
2078 | 2079 | { |
---|
2079 | | - loadObjThread = new LoadOBJThread(); |
---|
2080 | | - loadObjThread.start(); |
---|
| 2080 | + loadObjThread = new LoadOBJThread(); |
---|
| 2081 | + loadObjThread.start(); |
---|
2081 | 2082 | } |
---|
2082 | 2083 | |
---|
2083 | 2084 | loadObjThread.add(fullname); |
---|
2084 | | - */ |
---|
| 2085 | + /**/ |
---|
2085 | 2086 | |
---|
2086 | | - System.out.println("Loading " + fullname); |
---|
2087 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2087 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2088 | 2088 | } |
---|
2089 | 2089 | |
---|
2090 | 2090 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
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(Object3D 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 | + Object3D parent = o.parent; |
---|
| 3226 | + o.parent = null; |
---|
| 3227 | + |
---|
| 3228 | + out.writeObject(o); |
---|
| 3229 | + |
---|
| 3230 | + o.parent = parent; |
---|
| 3231 | + |
---|
| 3232 | + out.flush(); |
---|
| 3233 | + |
---|
| 3234 | + zstream.close(); |
---|
| 3235 | + out.close(); |
---|
| 3236 | + |
---|
| 3237 | + return baos.toByteArray(); |
---|
| 3238 | + } catch (Exception e) |
---|
| 3239 | + { |
---|
| 3240 | + System.err.println(e); |
---|
| 3241 | + return null; |
---|
| 3242 | + } |
---|
| 3243 | + } |
---|
| 3244 | + |
---|
| 3245 | + static public Object Uncompress(byte[] bytes) |
---|
| 3246 | + { |
---|
| 3247 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3248 | + try |
---|
| 3249 | + { |
---|
| 3250 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3251 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3252 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3253 | + Object obj = in.readObject(); |
---|
| 3254 | + in.close(); |
---|
| 3255 | + |
---|
| 3256 | + return obj; |
---|
| 3257 | + } catch (Exception e) |
---|
| 3258 | + { |
---|
| 3259 | + System.err.println(e); |
---|
| 3260 | + return null; |
---|
| 3261 | + } |
---|
| 3262 | + } |
---|
| 3263 | + |
---|
3217 | 3264 | static public Object clone(Object o) |
---|
3218 | 3265 | { |
---|
3219 | 3266 | try |
---|
.. | .. |
---|
3222 | 3269 | ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
3223 | 3270 | |
---|
3224 | 3271 | out.writeObject(o); |
---|
| 3272 | + |
---|
| 3273 | + out.flush(); |
---|
| 3274 | + out.close(); |
---|
| 3275 | + |
---|
| 3276 | + byte[] bytes = baos.toByteArray(); |
---|
| 3277 | + |
---|
| 3278 | + System.out.println("clone = " + bytes.length); |
---|
3225 | 3279 | |
---|
3226 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
| 3280 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3227 | 3281 | ObjectInputStream in = new ObjectInputStream(bais); |
---|
3228 | 3282 | Object obj = in.readObject(); |
---|
3229 | 3283 | in.close(); |
---|
3230 | | - out.close(); |
---|
| 3284 | + |
---|
3231 | 3285 | return obj; |
---|
3232 | 3286 | } catch (Exception e) |
---|
3233 | 3287 | { |
---|
.. | .. |
---|
3242 | 3296 | for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
3243 | 3297 | { |
---|
3244 | 3298 | ab = (cRadio)e.nextElement(); |
---|
3245 | | - if(ab.GetObject() == client) |
---|
| 3299 | + if(ab.GetObject() == copy) |
---|
3246 | 3300 | { |
---|
3247 | 3301 | return ab; |
---|
3248 | 3302 | } |
---|
.. | .. |
---|
3251 | 3305 | return null; |
---|
3252 | 3306 | } |
---|
3253 | 3307 | |
---|
| 3308 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3309 | + |
---|
3254 | 3310 | public void Save() |
---|
3255 | 3311 | { |
---|
3256 | 3312 | cRadio tab = GetCurrentTab(); |
---|
3257 | 3313 | |
---|
| 3314 | + boolean temp = CameraPane.SWITCH; |
---|
| 3315 | + CameraPane.SWITCH = false; |
---|
| 3316 | + |
---|
| 3317 | + copy.ExtractBigData(hashtable); |
---|
| 3318 | + |
---|
3258 | 3319 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3259 | | - tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
---|
| 3320 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3260 | 3321 | |
---|
| 3322 | + copy.RestoreBigData(hashtable); |
---|
| 3323 | + |
---|
| 3324 | + CameraPane.SWITCH = temp; |
---|
| 3325 | + |
---|
| 3326 | + //assert(hashtable.isEmpty()); |
---|
| 3327 | + |
---|
3261 | 3328 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3262 | 3329 | { |
---|
3263 | 3330 | tab.graphs[i] = null; |
---|
.. | .. |
---|
3285 | 3352 | |
---|
3286 | 3353 | void CopyChanged(Object3D obj) |
---|
3287 | 3354 | { |
---|
| 3355 | + boolean temp = CameraPane.SWITCH; |
---|
| 3356 | + CameraPane.SWITCH = false; |
---|
| 3357 | + |
---|
| 3358 | + copy.ExtractBigData(hashtable); |
---|
| 3359 | + |
---|
3288 | 3360 | copy.clear(); |
---|
3289 | 3361 | |
---|
3290 | 3362 | for (int i=0; i<obj.Size(); i++) |
---|
3291 | 3363 | { |
---|
3292 | 3364 | copy.add(obj.get(i)); |
---|
3293 | 3365 | } |
---|
| 3366 | + |
---|
| 3367 | + copy.RestoreBigData(hashtable); |
---|
| 3368 | + |
---|
| 3369 | + CameraPane.SWITCH = temp; |
---|
| 3370 | + |
---|
| 3371 | + //assert(hashtable.isEmpty()); |
---|
3294 | 3372 | |
---|
3295 | 3373 | copy.Touch(); |
---|
3296 | 3374 | |
---|
.. | .. |
---|
3331 | 3409 | |
---|
3332 | 3410 | tab.undoindex -= 1; |
---|
3333 | 3411 | |
---|
3334 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3412 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3335 | 3413 | } |
---|
3336 | 3414 | |
---|
3337 | 3415 | public void Redo() |
---|
.. | .. |
---|
3346 | 3424 | |
---|
3347 | 3425 | tab.undoindex += 1; |
---|
3348 | 3426 | |
---|
3349 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3427 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3350 | 3428 | } |
---|
3351 | 3429 | |
---|
3352 | 3430 | void ImportGFD() |
---|
.. | .. |
---|
4295 | 4373 | |
---|
4296 | 4374 | if (readobj != null) |
---|
4297 | 4375 | { |
---|
| 4376 | + Save(); |
---|
4298 | 4377 | try |
---|
4299 | 4378 | { |
---|
4300 | 4379 | //readobj.deepCopySelf(copy); |
---|