90 likes | 218 Views
JoiMint. Graphical objects and their XML configuration files. Piotr K. Bartkiewicz, DESY, MST-1. Agenda. Only graphical aspects of the JoiMint project! JoiMint graphical objects: a short overview Graphical Objects – implementation VisibleObject: a base class functionality
E N D
JoiMint Graphical objects and their XML configuration files Piotr K. Bartkiewicz, DESY, MST-1
Agenda Only graphical aspects of the JoiMint project! • JoiMint graphical objects: a short overview • Graphical Objects – implementation • VisibleObject: a base class functionality • JoiButton – an example of JoiMint Graphical Object • LoadableObject interface • An example of XML configuration file • Final remarks
JoiMint Graphical Objects By design: • two base types of objects: • Object container: a frame, which contains other graphical objects (including object containers) • Visible objects: plots, buttons, text fields etc. • User can create his synoptic table by adding graphical objects to object container, and afterwards, by locating, resizing, and setting object properties • The synoptic table project is stored as an XML file • Configuration of object container knows the list of contained objects • Each graphical object is capable to generate the XML section, which describes his properties • Each graphical object is capable to parse his XML description
Graphical Objects - implementation • Object container: public class ObjContainerFrame extends JFrame implements LoadableObject • Visible Object: public abstract class VisibleObj extends JPanel implements LoadableObject • questionable approach
VisibleObject: a base class functionality • Connection to the JoiMint registry • Handling “own” XML section • Content Handler for SAX parser, automatic properties ( “joi” properties) recognition and execution (java.lang.reflect*) • AutoConfig: an XML section is generated automatically • Important feature, which makes the JoiMint ‘open’, new objects can be added just by delivering a jar file • Connection to the ObjectContainer • Standard actions like: move, resize, copy, paste, delete • “Right mouse click” menu • Property list • missing: property window, which might offer easier property manipulation than a ‘default’ property table
JoiButton – an example of JoiMint Graphical Object JoiButton • public class JoiButton extends VisibleObj implements LoadableObject • { • JButton b; • JoiButton(ObjContainerFrame parentFrame) • { • super(parentFrame); • Text.setDefault("JoiButton"); • Value.setCanBeActive(); • setDefaultSize(120, 50);//default • joiSetText(getTypeName()); b = new JButton(); • add(b); • b.addMouseListener(new MouseAction()); MainFrame.propertyTableShow(this, false); • } • public void setSize(int width, int height) • { • super.setSize(width,height); • b.setBounds(5,5,width-10,height-25); • } JButton VisibleObject base
import java.io.*; import java.util.Vector; interface LoadableObject { public void saveConfig(IndentOutputStreamWriter sw) throws IOException; public void saveConfig(File file) throws IOException; public int loadConfig(XmlProcessor xp, String closingTag) throws Exception; public String getTypeName(); public Vector getProperties(); public Property getProperty(String propName); public void addProperty(Property p); public void propertyChanged(Property p, int changeCode ); public void destroy(); // all below might be a part of another inetrface, eg. AutoConfiguarbleObject Interface public void joiSetText(String text); public void joiSetX(String x); public void joiSetY(String y); public void joiSetWidth(String w); public void joiSetHeight(String h); public void joiSetName( String name ); public void joiSetParentName( String pname ); public void joiSetValue( String value ); public String joiGetName(); public String joiGetParentName(); public String joiGetText(); public String joiGetX(); public String joiGetY(); public String joiGetWidth(); public String joiGetHeight(); public String joiGetValue(); }
<?xml version="1.0" encoding="UTF-8"?> <config> <joiSetName arg="ObjContainerFrame-1" /> <joiSetX arg="88" /> <joiSetY arg="449" /> <joiSetWidth arg="644" /> <joiSetHeight arg="194" /> <object type = "JoiTextField"> <joiSetName arg="JoiTextField-2" /> <joiSetValue flag="active" arg="NEW|01" /> <joiSetValue arg="0" /> <joiSetText arg="0" /> <joiSetX arg="154" /> <joiSetY arg="21" /> </object> <object type = "JoiTextField"> <joiSetName arg="JoiTextField-3" /> <joiSetValue arg="+" /> <joiSetText arg="+" /> <joiSetX arg="134" /> <joiSetY arg="15" /> </object> <object type = "JoiTextField"> <joiSetName arg="JoiTextField-4" /> <joiSetValue flag="active" arg="NEW|02" /> <joiSetValue arg="0" /> <joiSetText arg="0" /> <joiSetX arg="21" /> </object> <object type = "JoiCalc"> <joiSetName arg="JoiCalc-5" /> <joiSetValue arg="0.0" /> <joiSetText arg="0.0" /> <joiSetX arg="291" /> <joiSetY arg="17" /> <joiSetWidth arg="335" /> <joiSetHeight arg="57" /> <joiSetA flag="dynamic" arg="NEW|01" /> <joiSetB flag="dynamic" arg="NEW|02" /> <joiSetExpression arg="A+B" /> </object> <object type = "JoiTextField"> <joiSetName arg="JoiTextField-6" /> <joiSetText arg="=" /> <joiSetX arg="268" /> <joiSetY arg="18" /> </object> </config>
Final remarks • Probably correct: • concept of object containers and visible objects • concept of parsing the XML configuration file • To be considered: • implementation of VisibleObjects. • implementation of ObjectContainers: run/edit mode? • Wrong or missing: • not enough time/discussions about object relationships, inheritance, interfaces • a language for project description, object relationships, interactions etc. (UML?) • documentation generation tools