270 likes | 284 Views
Scientific Toolkit for Java. Mark Pollack (formerly BNL-PHENIX now TIBCO Software). Goals for Toolkit (I). Develop scientific specific interfaces. Data Points with error bars, Histograms, Fitting, Functions, Plotting.
E N D
Scientific Toolkit for Java. Mark Pollack (formerly BNL-PHENIX now TIBCO Software) Scientific Toolkit for Java
Goals for Toolkit (I) • Develop scientific specific interfaces. • Data Points with error bars, Histograms, Fitting, Functions, Plotting. • Take advantage of inherit multithreaded nature of Java (Online monitoring) • Stick to Model-View-Controller design. • Avoid package dependencies. • Note: Not a attack on Java Analysis Studio… my “side” project to learn more about JDK1.2 Scientific Toolkit for Java
Goals for Toolkit (II) • Bundle together useful components for building a real world application. • Advanced GUI components, icons. • Editor. • Interpreters. • Regular Expressions. • Source code management. (cvs) • Code scrapbook. (tricks of the trade) Scientific Toolkit for Java
State of Java • Plethora of new extensions • JavaHelp • New features in JDK 1.2 • Collection classes. • Java 2D. • Growing collection of open-source components. • Reuse and integration. Scientific Toolkit for Java
Java2D Overview • Graphics2D class • Acquire g2d object for an output device • Screen, Printer, Offscreen buffer. • Set rendering context • Font, Transform, Stroke, Paint, Clip, Hints • g2d.setPaint(Color.blue); • Draw shapes, text, images • g2d.draw(aShape), g2d.drawText(“hi”) • g2d.draw(new Rectangle(0,0,100,100); Scientific Toolkit for Java
STJ Drawing Framework • Based on HotDraw framework. • Simplify Java2D API • <<GShape>> • Appearance. • Delegates drawing to a <<Renderer>>. • isFixedSize, isMoveable, isVisible. • <<ShapeChangeListner>> • draw(Graphics2D) Scientific Toolkit for Java
1 1 1 1 1..* 1..* STJ Drawing Framework Interfaces GDrawingEditor GDrawingView Implementation inherits from JComponent Current tool GDrawing Implementation inherits from JFrame GTool GLayer GShape “Text” Scientific Toolkit for Java
GShapes Scientific Toolkit for Java
Transformations • Easy to transform a Shape • Non-linear transformations. • Can use PathIterator to walk shape and convert points as necessary. “Fish-eye” Scientific Toolkit for Java
Graphs • Interfaces • <<DataPoint2D>>, <<GraphModel>> • Models • AbstractGraphModel (Listener management) • DefaultGraphModel • GraphModelEvent events fired when model changes. • View: Graph. (GAxis, <<TickMaker>>) Scientific Toolkit for Java
Simple Graph Axis scale with data changes Scientific Toolkit for Java
Histograms • Interfaces • <<HistoModel>>, <<HistoModel1D>>, <<Partition>> • Models • AbstractHistoModel, FixedPartition, FixedHistoModel1D • HistoModelEvent events fired. (manage up to 3D) • Abstract Histogram Factory • STJHistoFactory implementation. Scientific Toolkit for Java
Simple Histogram Random Number Generation via CERN Colt package. Scientific Toolkit for Java
Functions • Interfaces • <<Function>>,<<Function1D>> • Models • AbstractFunction, AbstractFunction1D • 1D: Gaussian, Exponential, Polynomial • ParsedFunction1D (use interpreter) • View: Graph, GFunction1D Scientific Toolkit for Java
Functions Math.abs(x) is a parsed function. Scientific Toolkit for Java
Interactive use • Many interpreted languages available in Java. • Allow access to Java objects. • Managed like JDBC drivers • <<InterpreterDriver>> InterpreterDriverManager • BshInterpreterDriver (Java) etc • Generic Swing console. Scientific Toolkit for Java
Interactive use It actually works! Scientific Toolkit for Java
Generic Console • For packages that do not provide a swing based console. Scientific Toolkit for Java
Persistence • Use Bridge pattern for locating and archiving objects. • <<ObjectFinder>>,<<ObjectStorer>> • Responsible for finding object and how to decompose object for storage on physical media. • RawSerializationStorer, ReflectionStorer • Physical storage <<ObjectStorage>> • JDBCStorage, RawSerializationFileStorage • Objects can be located from Serialized file “DB” and saved to JDBC Database. Scientific Toolkit for Java
keys serialized objects Persistance • Java Reflection picks apart objects • Class, Name, Value put in StorageFields. • “Basic” types, arrays to come, (SQL3 Data Types) • Bean Reflection, persistence based on public API. (more stable?) New RFC from Sun. (SQL generated on the fly) TMessage (TFile to come) File “DB” Scientific Toolkit for Java
Code snip for JDBC Storage ObjectStorage storage = new JDBCStorage(); ObjectManager.setObjectStorer(new ReflectionStorer(storage)); ObjectManager om = new ObjectManager(); Person p = new Person("mark",30,6.0f); om.storeObject(p); ObjectFinderImpl of = new JDBCObjectFinder(storage); om.setObjectFinder(of); //work with object Iterator it = om.selectAll(); //Iterator itt = om.select(QueryString) Specific Implementations Similar to ODMG DCollection OQL grammar now available in Java…. Scientific Toolkit for Java
Code snip for Serialization Storage RawObjectStorage storage = new RawSerializationFileStorage("D:\\mark\\java\\datafiles\\myfile.ser", "RECREATE"); ObjectManager om = new ObjectManager(); ObjectManager.setObjectStorer(new RawSerializationStorer(storage)); //Work with objects. GraphModel gmodel = new DefaultGraph2DModel(); om.storeObject(gmodel); ObjectFinderImpl of = new SERObjectFinder(storage); om.setObjectFinder(of); Iterator it = om.selectAll(); //work with objects. Specific Implementations Scientific Toolkit for Java
GUI Components/Icons • Nice components from Claude Duguay. • JBorder, JCalendar, JConfigure, JExplore, JGradient, JGraph, JIconEditor, JMaskField, JOutlookBar, JPalette, JReportForm, JScrollView, JSpinner. • JavaLobby, 200 20x20 icons. • Converted to 16x16. Scientific Toolkit for Java
Component Snapshots Scientific Toolkit for Java
Other Components • JavaHelp • Integration with application context. • jEdit • Extensible via plug-ins • jCVS • JUnit, framework for Unit testing. • Colt Scientific Toolkit for Java
Status • “Proof of principle” • Early stages, feedback needed. • Drawing metaphor too clumsy? • To do: Fitting Implementation, TFile support, TeX Labels. • Need to make API more concise, scripting friendly. • Performance, Interpreters + General Scientific Toolkit for Java
Contact • markp@bnl.gov • More information @ • www.phenix.bnl.gov/~markp Scientific Toolkit for Java