edu.mit.ai.psg.ui.outliner.awt
Class Outliner

java.lang.Object
  |
  +--edu.mit.ai.psg.ui.outliner.awt.Outliner
Direct Known Subclasses:
Jexa

public class Outliner
extends Object

Outliner --- creates expandable/collapsible outline views of objects.

Standard call to start Outliner is makeOutlineFrame(Object);

Outline elements may be expanded/collapsed by clicking on the +/- button, or double clicking on the object.

Outline created depends on class of object examined. The default ToStringComponentGenerator just creates a component based on the print string of the object and does not create any children. To use Outliner a program must initialize it with domain specific outline generators by calling Outliner.putOutlineGenerator.

When there are several applicable outline generators, the one for the most specific class or interface of the object is used. An object can be redisplayed with an alternate applicable generator invoked through a pop-up menu (mouse-2 or shift-click).

A component outline generator implements IOutlineComponentGenerator. When invoked, it returns a java.awt.Component, usually a subclass of OutlineTree so the component can be expanded to display its children.

This Outliner class is designed to manage a single table of generators in an extensible manner, yet still be invokable from static methods. An extending class can replace Outliner.outliner with an instance of its own to override implementation methods. Other tools which invoke Outliner's static methods will then invoke the implementation methods of the extending class. Generator classes can add themselves to the table of generators (putOutlineGenerator) independently of (initialized before or after) an extended outliner.


Field Summary
static Font defaultFont
          Default font for new text, e.g., new Font("SansSerif", Font.PLAIN, 11)
static IOutlineComponentGenerator defaultGenerator
          Default IOutlineComponentGenerator called if no generator found in generators
static Map generators
          Map of IOutlineComponentGenerators keyed on interface or class to which each applies.
static Rectangle initialBounds
           
static Outliner outliner
          outliner: an instance through which static methods indirectly invoke their implementation methods.
 
Constructor Summary
Outliner()
           
 
Method Summary
 void addListeners(Object object, Component newComponent)
          initialize object's outline Component by adding mouse event listeners.
 void addPopupMenuItems(PopupMenu menu, Object obj, Component component)
          addPopUpMenuItems first adds menu item "Display outline in own frame".
 Vector getAllGenerators(Object obj)
          Search class and its interfaces and superclasses for each class/interface which has a generator, and return all generators found.
 IOutlineComponentGenerator getExactOutlineGenerator(Class anInterface)
          Get the generator for exactly this interface or class (not super-interfaces or super-classes)
static IOutlineComponentGenerator getMostSpecificGenerator(Object obj)
          Search class and its interfaces and superclasses for a class/interface which has a generator, and return the most specific generator found.
 IOutlineComponentGenerator getMostSpecificGeneratorImpl(Object obj)
          Search for an outline component generator for object for the most specific class or interface declaration.
static Component makeOutlineComponent(Object obj)
          Generate a new AWT Component for obj to add to an outline.
 Component makeOutlineComponentImpl(Object obj)
          (overrideable implementation method)
static Frame makeOutlineFrame(Object obj)
          Create a Frame window with an outline for obj (static method for other tools to call)
static Frame makeOutlineFrame(Object obj, String frameLabel)
           
 Frame makeOutlineFrameImpl(Object obj)
          overrideable/extendable implementation method
 Frame makeOutlineFrameImpl(Object obj, String frameLabel)
           
static void putOutlineGenerator(Class forInterface, IOutlineComponentGenerator generator)
          Put a outline component generator for objects with this interface in table.
static void removeOutlineGenerator(Class forInterface)
          Remove the generator specific for this interface or class (not super-interfaces or super-classes)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outliner

public static Outliner outliner
outliner: an instance through which static methods indirectly invoke their implementation methods. Allows implementations of these methods to be overridden in a subclass, yet other tools can still invoke them through the static methods of this class. If overriding, initialize this with instance of subclass.

generators

public static Map generators
Map of IOutlineComponentGenerators keyed on interface or class to which each applies.
See Also:
putOutlineGenerator(Class, IOutlineComponentGenerator), getExactOutlineGenerator(Class)

defaultGenerator

public static IOutlineComponentGenerator defaultGenerator
Default IOutlineComponentGenerator called if no generator found in generators

defaultFont

public static Font defaultFont
Default font for new text, e.g., new Font("SansSerif", Font.PLAIN, 11)
See Also:
Font.Font(String, int, int)

initialBounds

public static Rectangle initialBounds
Constructor Detail

Outliner

public Outliner()
Method Detail

makeOutlineFrame

public static Frame makeOutlineFrame(Object obj)
Create a Frame window with an outline for obj (static method for other tools to call)

makeOutlineFrame

public static Frame makeOutlineFrame(Object obj,
                                     String frameLabel)

makeOutlineFrameImpl

public Frame makeOutlineFrameImpl(Object obj)
overrideable/extendable implementation method

makeOutlineFrameImpl

public Frame makeOutlineFrameImpl(Object obj,
                                  String frameLabel)

makeOutlineComponent

public static Component makeOutlineComponent(Object obj)
Generate a new AWT Component for obj to add to an outline. Uses generator for obj's most specific class or interface. (static method for other tools to call)

makeOutlineComponentImpl

public Component makeOutlineComponentImpl(Object obj)
(overrideable implementation method)

addListeners

public void addListeners(Object object,
                         Component newComponent)
initialize object's outline Component by adding mouse event listeners. Called by makeOutlineComponentImpl; may be extended/overridden to add other listeners if needed

getMostSpecificGenerator

public static IOutlineComponentGenerator getMostSpecificGenerator(Object obj)
Search class and its interfaces and superclasses for a class/interface which has a generator, and return the most specific generator found. (Calls outliner.getMostSpecificGeneratorImpl)

getMostSpecificGeneratorImpl

public IOutlineComponentGenerator getMostSpecificGeneratorImpl(Object obj)
Search for an outline component generator for object for the most specific class or interface declaration. Subclasses or interfaces declared in subclasses take precedence over superclasses or interfaces declared in superclasses. Leftmost interface within a class takes precedence. A declaration of an interface that extends other interfaces is taken to be shorthand for also declaring all the interfaces it extends.

I.e.:

.       for (c = obj.getClass(); c != null; c = c.getSuperclass()) {
.         gen = getExactOutlineGenerator(c);
.         if (gen != null) return gen;
.         interfacesStack = new Stack(c.getInterfaces());
.         while(! interfacesStack.isEmpty()) {
.           i = interfacesStack.pop();
.           gen = getExactOutlineGenerator(i);
.           if (gen != null) return gen;
.           interfacesStack.addAll(0, i.getInterfaces());
.         }           
.       }
Overrideable implementation method (called by getMostSpecificGenerator).

getAllGenerators

public Vector getAllGenerators(Object obj)
Search class and its interfaces and superclasses for each class/interface which has a generator, and return all generators found.

getExactOutlineGenerator

public IOutlineComponentGenerator getExactOutlineGenerator(Class anInterface)
Get the generator for exactly this interface or class (not super-interfaces or super-classes)

putOutlineGenerator

public static void putOutlineGenerator(Class forInterface,
                                       IOutlineComponentGenerator generator)
Put a outline component generator for objects with this interface in table.
Parameters:
forInterface - Objects with this interface or class will be outlined with this function (unless a more specific one applies)
generator - should return a java.awt.Component, typically an OutlineTree or a subclass.

removeOutlineGenerator

public static void removeOutlineGenerator(Class forInterface)
Remove the generator specific for this interface or class (not super-interfaces or super-classes)

addPopupMenuItems

public void addPopupMenuItems(PopupMenu menu,
                              Object obj,
                              Component component)
addPopUpMenuItems first adds menu item "Display outline in own frame". Then for each applicable outline component generator it adds a menu item to regenerate outline with that generator.

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu