use of jmri.jmrit.jython.Jynstrument in project JMRI by JMRI.
the class AppsLaunchPane method ynstrument.
public static void ynstrument(String path) {
Jynstrument it = JynstrumentFactory.createInstrument(path, _jynstrumentSpace);
if (it == null) {
log.error("Error while creating Jynstrument {}", path);
return;
}
jmri.jmrit.throttle.ThrottleFrame.setTransparent(it);
it.setVisible(true);
_jynstrumentSpace.setVisible(true);
_jynstrumentSpace.add(it);
}
use of jmri.jmrit.jython.Jynstrument in project JMRI by JMRI.
the class ThrottleFrame method ynstrument.
// #JYNSTRUMENT# here instantiate the Jynstrument, put it in a component, initialize the context and start it
public JInternalFrame ynstrument(String path) {
if (path == null) {
return null;
}
// everything is there
Jynstrument it = JynstrumentFactory.createInstrument(path, this);
if (it == null) {
log.error("Error while creating Jynstrument " + path);
return null;
}
setTransparentBackground(it);
JInternalFrame newiFrame = new JInternalFrame(it.getClassName());
newiFrame.add(it);
newiFrame.addInternalFrameListener(frameListener);
newiFrame.setDoubleBuffered(true);
newiFrame.setResizable(true);
newiFrame.setClosable(true);
newiFrame.setIconifiable(true);
newiFrame.getContentPane().addContainerListener(new ContainerListener() {
@Override
public void componentAdded(ContainerEvent e) {
}
@Override
public void componentRemoved(ContainerEvent e) {
Container c = e.getContainer();
while ((!(c instanceof JInternalFrame)) && (!(c instanceof TranslucentJPanel))) {
c = c.getParent();
}
c.setVisible(false);
remove(c);
repaint();
}
});
newiFrame.pack();
add(newiFrame, PANEL_LAYER_FRAME);
newiFrame.setVisible(true);
return newiFrame;
}
use of jmri.jmrit.jython.Jynstrument in project JMRI by JMRI.
the class ThrottleFrame method getXml.
/**
* Collect the prefs of this object into XML Element
* <ul>
* <li> Window prefs
* <li> ControlPanel
* <li> FunctionPanel
* <li> AddressPanel
* </ul>
*
*
* @return the XML of this object.
*/
public Element getXml() {
boolean switchAfter = false;
if (!isEditMode) {
switchMode();
switchAfter = true;
}
Element me = new Element("ThrottleFrame");
if (((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane() != null) {
Dimension bDim = ((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane().getPreferredSize();
me.setAttribute("border", Integer.toString(bDim.height));
}
java.util.ArrayList<Element> children = new java.util.ArrayList<Element>(1);
// children.add(WindowPreferences.getPreferences(this)); // not required as it is in ThrottleWindow
children.add(controlPanel.getXml());
children.add(functionPanel.getXml());
children.add(addressPanel.getXml());
// Save Jynstruments
Component[] cmps = getComponents();
for (int i = 0; i < cmps.length; i++) {
try {
if (cmps[i] instanceof JInternalFrame) {
Component[] cmps2 = ((JInternalFrame) cmps[i]).getContentPane().getComponents();
int j = 0;
while ((j < cmps2.length) && (!(cmps2[j] instanceof Jynstrument))) {
j++;
}
if ((j < cmps2.length) && (cmps2[j] instanceof Jynstrument)) {
Jynstrument jyn = (Jynstrument) cmps2[j];
Element elt = new Element("Jynstrument");
elt.setAttribute("JynstrumentFolder", FileUtil.getPortableFilename(jyn.getFolder()));
java.util.ArrayList<Element> jychildren = new java.util.ArrayList<Element>(1);
jychildren.add(WindowPreferences.getPreferences((JInternalFrame) cmps[i]));
Element je = jyn.getXml();
if (je != null) {
jychildren.add(je);
}
elt.setContent(jychildren);
children.add(elt);
}
}
} catch (Exception ex) {
log.debug("Got exception (no panic) " + ex);
}
}
me.setContent(children);
if (switchAfter) {
switchMode();
}
return me;
}
use of jmri.jmrit.jython.Jynstrument in project JMRI by JMRI.
the class Apps method ynstrument.
public static void ynstrument(String path) {
Jynstrument it = JynstrumentFactory.createInstrument(path, _jynstrumentSpace);
if (it == null) {
log.error("Error while creating Jynstrument {}", path);
return;
}
ThrottleFrame.setTransparent(it);
it.setVisible(true);
_jynstrumentSpace.setVisible(true);
_jynstrumentSpace.add(it);
}
use of jmri.jmrit.jython.Jynstrument in project JMRI by JMRI.
the class ThrottleWindow method ynstrument.
public Jynstrument ynstrument(String path) {
Jynstrument it = JynstrumentFactory.createInstrument(path, this);
if (it == null) {
log.error("Error while creating Jynstrument " + path);
return null;
}
ThrottleFrame.setTransparent(it, true);
it.setVisible(true);
throttleToolBar.add(it);
throttleToolBar.repaint();
return it;
}
Aggregations