Did you spot something wrong or missing on this page? If you have an account on this TWiki, you can fix it yourself by editing the page. If you don't have an account, you can leave a message at the bottom of the page to tell us about it. Thank you in advance!
Adding components to existing views
The contents of certain views can be extended by developers, such as the Outline View and the Editor Area. Both are examples of the system reacting on a data selection made by the user.
Here we explain how you can contribute to the outline view and the editor area.
Whenever the user selects a session variable in the VariablesView, a SelectionEvent is sent around.
The OutlineView is listening to such event and it tries to find the appropriate component that can show the outline information of that variable.
The contract for outline components is:
Register your implementation to the Extension Registry in the __init__.py
The recommended way of implementing OutlineComponent is by extending ObjectOutline, which provides a table with basic information about the variable.
Methods getExtraTableInfo() and getExtraComponent() may be overriden as needed for providing extra information about your type.
For example, suppose you want to create an outline for FineTime variables to show their contents in the outline view whenever a session variable of that type is selected by the user.
Component Implementation
In this example, we simply add an entry to the ObjectOutline with the contents of the FineTime.
public class FineTimeOutline extends ObjectOutline {
@Override
protected Object[][] getExtraTableInfo() {
Object time = getSelection().getValue();
return new Object[][] { { "time", time.toString() } };
}
}
Component Registry
The following snippet would go into your __init__.py:
# Register to the variable outline factory
REGISTRY.register(COMPONENT,Extension(
"My FineTime Outline",
"resides.in.java.package.FineTimeOutline",
"factory.outline.variable",
"herschel.share.fltdyn.time.FineTime"))
If you have a sub-class of e.g. a product, you can also create a dedicated OutlineComponent for that sub-class, which will be picked up instead of the default ProductOutline.
FITS Preview Outline
A special kind of outline is devoted to show previews of FITS files (for images, cubes, spectra...).
This is managed by FitsFileOutline, which reads the product contained in the FITS file in the background, and shows an image preview for it when done.
For this to work properly, any type that is meaningful to produce a preview should:
1. Extend herschel.ia.gui.kernel.PreviewMaker. For example, for images (herschel.ia.gui.image.Image):
import herschel.ia.gui.image.Image;
public class ImagePreviewMaker extends PreviewMaker<Image> {
// PreviewFactory needs that every preview maker provides a default public constructor
public ImagePreviewMaker() {
super(Image.class);
}
// Either override this method
@Override public java.awt.Image makeImage(Object o) {
if (!(o instanceof Image)) return null;
Image image = (Image)o;
// create a Java image from the dataset image object
}
// or this one, by returning a visible component that will be used for drawing the image
@Override protected java.awt.Component makeComponent(Image image) {
// create a Java component from the dataset image
}
}
2. Register the preview maker in the corresponding __init__.py:
The above showed an example of extending the outline view by adding an OutlineComponent. Similarly, you can contribute by developing a specific EditorComponent.
Editor components are editors (optionally read-only) of data contents of a specific variable that is selected within in the HIPE session.
They are triggered by double-clicking on a variable, or through the Open With menu. Editor components are opened in the editor area.
The contract for editor components is: