Version 5 (modified by welberge, 6 years ago) (diff)


JComponentEnvironment and constructing Swing user interfaces using the VirtualHumanSpec

The JComponentEnvironment can be used to set up the user interface layout of demo in which the different UI elements are later filled out using the XML specification. The layout can be created using JPanels (or any other JComponent):

JFrame jframe = new JFrame();
final AsapEnvironment ee = new AsapEnvironment();
final JComponentEnvironment jce = new JComponentEnvironment();
    SwingUtilities.invokeAndWait(new Runnable()

        public void run()
            JPanel jPanel = new JPanel();
            jce.registerComponent("panel1", jPanel);
            jframe.setLayout(new BorderLayout());
            jframeadd(jPanel, BorderLayout.SOUTH);
catch (InvocationTargetException e)
    throw new RuntimeException(e);
catch (InterruptedException e)
    throw new RuntimeException(e);
ArrayList<Environment> environments = new ArrayList<Environment>();
ee.init(environments, clock);
ee.loadVirtualHuman("humanoid", "", "humanoid.xml", "AsapRealizer demo");

The registered component can then be hooked up to a JComponentEmbodimentLoader in the VirtualHumanSpec?:

<Loader id="panelembodiment" loader="hmi.jcomponentenvironment.JComponentEmbodimentLoader">
  <JComponent id="panel1"/>             

Which can be used in any other loader, for example in a JLabelTextEmbodiment:

<Loader id="textembodiment" loader="asap.textengine.JLabelTextEmbodiment" requiredloaders="panelembodiment"/>
<Loader id="textengine" loader="asap.textengine.loader.TextEngineLoader" requiredloaders="textembodiment"/>