Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After a layout manager has

...

titleToDo

...

finished turning a given diagram into its KGraph representation, the layout options manager is asked to enrich the KGraph elements with layout options. The option values can come from different sources: the user might have set some using the layout view; there might be some defaults for certain kinds of diagrams; or the programmer might have decided to attach some layout options to certain elements for just this one layout run. Whatever the source, the options manager is in charge of collecting all these layout option values and making sure they find their way to the correct KGraph element. To start off with a clean plate, it first makes sure there are no layout options attached to the KGraph elements. It then does two things: collect every eligible source of layout options, and transfer layout options to the correct KGraph elements. Sounds easy enough.

The question remains how the layout options sources work. Each source is represented by a class that implements the ILayoutConfig interface, called a layout configuration. KIML currently provides the following layout configurations, each representing a particular source of layout options:

  • DefaultLayoutConfig – Sets fixed default values defined for layout options.
  • EclipseLayoutConfig – Users can define default layout options to be set on elements that meet certain criteria via the KIML preference page. This layout configuration takes these options and applies them.
  • SemanticLayoutConfig – ???
  • GmfLayoutConfig / GraphitiLayoutConfig – These configurations apply layout options set by the user in the layout view or stored in the notation model file of a diagram.
  • VolatileLayoutConfig – A configuration whose only purpose it is to make sure certain layout options are set on certain diagram elements in a particular layout run.

The options manager collects all available and applicable layout configurations and sorts them by priority (incidentally, the configurations were sorted by increasing priority just now). For every graph element, each configuration is asked to provide layout options, starting with the default layout configuration and working through the priority chain.

A Few Details on Layout Configurations

What we just learned is a bit of a simplification of what happens. The layout options manager not only asks each layout configuration to provide layout options for each graph element. Before we look at the details, let's take a look at the methods each layout configuration provides:

Code Block
languagejava
public interface ILayoutConfig {
    int getPriority();
    
    void enrich(LayoutContext context);
    
    Object getValue(LayoutOptionData<?> optionData, LayoutContext context);
    
    void transferValues(KLayoutData layoutData, LayoutContext context);
} 

It is not hard to guess what getPriority() does: it returns the priority a given layout configuration has. If two layout configurations set a layout option to different values on a given graph element, the value set by the configuration with lower priority gets overwritten. The other three methods look a bit more obscure, so we have to provide more details on what the options manager does, exactly.

ENRICHING (+ WHAT IS A LAYOUT CONTEXT)

TRANSFERRING

GETVALUE (for the layout view?)

Implementing a Layout Configuration

deciding what options are applicable depending on the context object; setting the options;

Programmatically Setting Layout Options

...