@Override DependencyNode getTarget() { if (target == null) { target = new ImageAssetNode(2); target.addChild(new EngineNode<Image>(1, new Image("@drawable/man_stand_w_1.png"))); target.setBase(new File(getDir(), AssetHandlerImpl.PROJECT_INTERNAL_PATH)); } return target; }
public static void main(String[] args) { Log4jConfig.configForConsole(Log4jConfig.Slf4jLevel.Info); // initialize launcher & reflection Injector injector = Guice.createInjector(new DesktopModule(), new EditorGuiceModule(), new JavaToolsModule()); ReflectionClassLoader.init(injector.getInstance(ReflectionClassLoader.class)); Controller c = injector.getInstance(Controller.class); EditorModelImpl mi = (EditorModelImpl) c.getModel(); mi.getLoader().setSaveDir(new File("src/main/resources/")); final AssetViewer rootAssetViewer = c.createAssetViewer(); final ArrayList<EditorNode> ians = new ArrayList<EditorNode>(); Identified root = new BasicElement(); root.setId("fakeRoot"); mi.addNode(null, null, root, false); for (int i = 0; i < 100; i++) { ImageAssetNode ian = new ImageAssetNode(i); Image image = new Image("@drawable/EditorIcon128x128.png"); image.setId("id" + i); mi.addNode(mi.getNodeFor(root), "mock", image, false); ian.addChild(mi.getNodeFor(image)); ian.setBase(new File("src/main/resources/", AssetHandlerImpl.PROJECT_INTERNAL_PATH)); ians.add(ian); mi.registerEditorNodeWithGraph(ian); } final ThumbnailPanel tnp = new ThumbnailPanel(); JButton jb = new JButton("click to add nodes"); jb.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tnp.setNodes(ians); } }); JButton jbg = new JButton("grab a capture"); jbg.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Image i = (Image) ians.get(0).getFirst().getContent(); System.err.println("Setting drawable to something: " + i + " " + i.getUri()); rootAssetViewer.setDrawable(i); } }); PropertiesTablePanel ptp = new PropertiesTablePanel(); ptp.setNodes(ians); ptp.setController(c); JTabbedPane jtp = new JTabbedPane(); jtp.add("Icons", tnp); jtp.add("Table", ptp); JFrame jf = new JFrame(); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.add(jtp); JPanel buttonPanel = new JPanel(); buttonPanel.add(jb); buttonPanel.add(jbg); jf.add(buttonPanel, BorderLayout.SOUTH); jf.setSize(800, 600); jf.setLocationRelativeTo(null); jf.setVisible(true); jtp.add("assetViewer", rootAssetViewer.getCanvas()); }