Joi Mint Graphical objects and their XML configuration

Joi. Mint Graphical objects and their XML configuration files Piotr K. Bartkiewicz, DESY, MST-1

Agenda Only graphical aspects of the Joi. Mint project! • • Joi. Mint graphical objects: a short overview Graphical Objects – implementation Visible. Object: a base class functionality Joi. Button – an example of Joi. Mint Graphical Object • Loadable. Object interface • An example of XML configuration file • Final remarks

Joi. Mint 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 Obj. Container. Frame extends JFrame implements Loadable. Object • Visible Object: public abstract class Visible. Obj extends JPanel implements Loadable. Object • questionable approach

Visible. Object: a base class functionality • • Connection to the Joi. Mint registry Handling “own” XML section – Content Handler for SAX parser, automatic properties ( “joi” properties) recognition and execution (java. lang. reflect*) – Auto. Config: an XML section is generated automatically • • • Important feature, which makes the Joi. Mint ‘open’, new objects can be added just by delivering a jar file Connection to the Object. Container 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

Joi. Button – an example of Joi. Mint Graphical Object • • • Joi. Button public class Joi. Button extends Visible. Obj implements Loadable. Object { JButton b; Joi. Button(Obj. Container. Frame parent. Frame) { super(parent. Frame); Text. set. Default("Joi. Button"); Value. set. Can. Be. Active(); set. Default. Size(120, 50); //default joi. Set. Text(get. Type. Name()); b = new JButton(); • • • add(b); b. add. Mouse. Listener(new Mouse. Action()); Main. Frame. property. Table. Show(this, false); } public void set. Size(int width, int height) { super. set. Size(width, height); b. set. Bounds(5, 5, width-10, height-25); } JButton Visible. Object base

import java. io. *; import java. util. Vector; interface Loadable. Object { public void save. Config(Indent. Output. Stream. Writer sw) throws IOException; public void save. Config(File file) throws IOException; public int load. Config(Xml. Processor xp, String closing. Tag) throws Exception; public String get. Type. Name(); public Vector get. Properties(); public Property get. Property(String prop. Name); public void add. Property(Property p); public void property. Changed(Property p, int change. Code ); public void destroy(); // all below might be a part of another inetrface, eg. Auto. Configuarble. Object Interface public void joi. Set. Text(String text); public void joi. Set. X(String x); public void joi. Set. Y(String y); public void joi. Set. Width(String w); public void joi. Set. Height(String h); public void joi. Set. Name( String name ); public void joi. Set. Parent. Name( String pname ); public void joi. Set. Value( String value ); public String joi. Get. Name(); public String joi. Get. Parent. Name(); public String joi. Get. Text(); public String joi. Get. X(); public String joi. Get. Y(); public String joi. Get. Width(); public String joi. Get. Height(); public String joi. Get. Value(); }

<? xml version="1. 0" encoding="UTF-8"? > <config> <joi. Set. Name arg="Obj. Container. Frame-1" /> <joi. Set. X arg="88" /> <joi. Set. Y arg="449" /> <joi. Set. Width arg="644" /> <joi. Set. Height arg="194" /> <object type = "Joi. Text. Field"> <joi. Set. Name arg="Joi. Text. Field-2" /> <joi. Set. Value flag="active" arg="NEW|01" /> <joi. Set. Value arg="0" /> <joi. Set. Text arg="0" /> <joi. Set. X arg="154" /> <joi. Set. Y arg="21" /> </object> <object type = "Joi. Text. Field"> <joi. Set. Name arg="Joi. Text. Field-3" /> <joi. Set. Value arg="+" /> <joi. Set. Text arg="+" /> <joi. Set. X arg="134" /> <joi. Set. Y arg="15" /> </object> <object type = "Joi. Text. Field"> <joi. Set. Name arg="Joi. Text. Field-4" /> <joi. Set. Value flag="active" arg="NEW|02" /> <joi. Set. Value arg="0" /> <joi. Set. Text arg="0" /> <joi. Set. X arg="21" /> </object> <object type = "Joi. Calc"> <joi. Set. Name arg="Joi. Calc-5" /> <joi. Set. Value arg="0. 0" /> <joi. Set. Text arg="0. 0" /> <joi. Set. X arg="291" /> <joi. Set. Y arg="17" /> <joi. Set. Width arg="335" /> <joi. Set. Height arg="57" /> <joi. Set. A flag="dynamic" arg="NEW|01" /> <joi. Set. B flag="dynamic" arg="NEW|02" /> <joi. Set. Expression arg="A+B" /> </object> <object type = "Joi. Text. Field"> <joi. Set. Name arg="Joi. Text. Field-6" /> <joi. Set. Text arg="=" /> <joi. Set. X arg="268" /> <joi. Set. Y 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 Visible. Objects. – implementation of Object. Containers: 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
- Slides: 9