Title: Scientific Toolkit for Java'
1Scientific Toolkit for Java.
- Mark Pollack
- (formerly BNL-PHENIX now
- TIBCO Software)
2Goals 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
3Goals 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)
4State 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.
5Java2D 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)
6STJ Drawing Framework
- Based on HotDraw framework.
- Simplify Java2D API
- ltltGShapegtgt
- Appearance.
- Delegates drawing to a ltltRenderergtgt.
- isFixedSize, isMoveable, isVisible.
- ltltShapeChangeListnergtgt
- draw(Graphics2D)
7STJ Drawing Framework Interfaces
GDrawingView
GDrawingEditor
Implementation inherits from JComponent
Current tool
GDrawing
Implementation inherits from JFrame
GTool
GLayer
GShape
Text
8GShapes
9Transformations
- Easy to transform a Shape
- Non-linear transformations.
- Can use PathIterator to walk shape and convert
points as necessary.
Fish-eye
10Graphs
- Interfaces
- ltltDataPoint2Dgtgt, ltltGraphModelgtgt
- Models
- AbstractGraphModel (Listener management)
- DefaultGraphModel
- GraphModelEvent events fired when model changes.
- View Graph. (GAxis, ltltTickMakergtgt)
11Simple Graph
Axis scale with data changes
12Histograms
- Interfaces
- ltltHistoModelgtgt, ltltHistoModel1Dgtgt, ltltPartitiongtgt
- Models
- AbstractHistoModel, FixedPartition,
FixedHistoModel1D - HistoModelEvent events fired. (manage up to 3D)
- Abstract Histogram Factory
- STJHistoFactory implementation.
13Simple Histogram
Random Number Generation via CERN Colt package.
14Functions
- Interfaces
- ltltFunctiongtgt,ltltFunction1Dgtgt
- Models
- AbstractFunction, AbstractFunction1D
- 1D Gaussian, Exponential, Polynomial
- ParsedFunction1D (use interpreter)
- View Graph, GFunction1D
15Functions
Math.abs(x) is a parsed function.
16Interactive use
- Many interpreted languages available in Java.
- Allow access to Java objects.
- Managed like JDBC drivers
- ltltInterpreterDrivergtgt InterpreterDriverManager
- BshInterpreterDriver (Java) etc
- Generic Swing console.
17Interactive use
It actually works!
18Generic Console
- For packages that do not provide a swing based
console.
19Persistence
- Use Bridge pattern for locating and archiving
objects. - ltltObjectFindergtgt,ltltObjectStorergtgt
- Responsible for finding object and how to
decompose object for storage on physical media. - RawSerializationStorer, ReflectionStorer
- Physical storage ltltObjectStoragegtgt
- JDBCStorage, RawSerializationFileStorage
- Objects can be located from Serialized file DB
and saved to JDBC Database.
20Persistance
- 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
21Code 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.
22Code snip for Serialization Storage
RawObjectStorage storage new
RawSerializationFileStorage("D\\mark\\java\\dataf
iles\\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
23GUI 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.
24Component Snapshots
25Other Components
- JavaHelp
- Integration with application context.
- jEdit
- Extensible via plug-ins
- jCVS
- JUnit, framework for Unit testing.
- Colt
26Status
- 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
27Contact
- markp_at_bnl.gov
- More information _at_
- www.phenix.bnl.gov/markp