1 16 17 package com.buchuki.ensmer.builtin; 18 19 import com.buchuki.ensmer.*; 20 import com.buchuki.ensmer.object.Backend; 21 import com.buchuki.annotations.*; 22 import java.io.Serializable ; 23 import javax.vecmath.*; 24 25 34 public class ClassIcon extends Backend { 35 36 39 public ClassIcon() {} 40 41 46 public ClassIcon(Serializable data) { 47 representedClass = (Class ) data; 48 } 49 50 54 @Override 55 public Serializable getSerializable() { 56 return representedClass; 57 } 58 59 63 public Class getRepresentedClass() { 64 return representedClass; 65 } 66 67 71 public void setRepresentedClass(Class backendClass) { 72 this.representedClass = backendClass; 73 fireChangeEvent(); 74 } 75 76 84 public void addObjectToPrevious() { 85 try { 86 AreaManager man = EnsmerManager.instance().getAreaManager(); 87 96 if (representedClass.getName().equals("com.buchuki.ensmer.builtin.Static")) { 97 SpecialAreaManager spec = EnsmerManager.instance().getSpecialAreaManager(); 98 spec.buildAddStaticArea(); 99 man.setCurrentArea(spec.getAreaID(spec.ADD_STATIC_OBJECT)); 100 return; 101 } 102 int count = 0; 103 Area prev; 104 do { 105 Long prevId = man.getHistoricalAreaID(count); 106 if (prevId == null) { 107 return; } 109 prev = man.getArea(prevId); 110 count++; 111 } while (prev.isReadOnly()); 112 Backend backend = (Backend) representedClass.newInstance(); 113 Matrix4f location = SceneGraphUtils.positionInFrontOfUser(prev); 114 prev.newObject(backend, location); 115 for (int i = 0; i < count - 1; i++) { 117 man.previousArea(); 118 } 119 EnsmerManager.instance().getUserManager().getInputManager().systemMode(); 121 EnsmerManager.instance().getSelectionManager().clearSelection(); 122 EnsmerManager.instance().getSelectionManager().toggleSelection(backend.getId()); 123 } catch (Exception e) { 124 e.printStackTrace(); 125 } 126 } 127 128 129 private Class representedClass; 130 } 131 | Popular Tags |