« prev next »
Java Docking Home> Developer Guide> Visualizers (Minimizers, Maximizers, and Externalizers)

How to Use Visualizers (Minimizers, Maximizers, and Externalizers)

:: Visualizers ::

A Visualizer shows a Dockable in a special state. The special state is usually DockableState.MAXIMIZED or DockableState.MINIMIZED.

We call a visualizer that shows a dockable in the state MAXIMIZED a maximizer. We call a visualizer that shows a dockable in the state MINIMIZED a minimizer.

Visualizers have to be registered in the dock model with a key:

		dockModel.addVisualizer("minimizer", minimizePanel, frame);

:: Using a simple minimizer, maximizer, and externalizer ::

A very simple minimizer is LineMinimizer. It shows the minimized dockables in a line at the bottom of a panel.
The maximizer that is usually used is a SingleMaximizer. It shows one maximized dockable in a panel.
The externalizer that is usually used is a FloatExternalizer.

In this example there is a minimizer around the root dock. Around the minimizer is a maximizer.

		// Create an externalizer.
		FloatExternalizer externalizer = new FloatExternalizer(frame);
		dockModel.addVisualizer("externalizer", externalizer, frame);

		// Create a minimizer.
		LineMinimizer minimizePanel = new LineMinimizer(splitDock);
		dockModel.addVisualizer("minimizer", minimizePanel, frame);
		// Create a maximizer.
		SingleMaximizer maximizePanel = new SingleMaximizer(minimizePanel);
		dockModel.addVisualizer("maximizer", maximizePanel, frame);
		// Minimize dockables.
		// Externalize dockable.
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Point location = new Point((screenSize.width - 200) / 2, (screenSize.height - 200) / 2);
		externalizer.externalizeDockable(dockable9, location);

:: Using a docking minimizer ::

A more complicated minimizer is DockingMinimizer. It shows the minimized dockables in lines at the borders of a border dock. The minimized dockables can move in their lines, be dragged to other lines, or even be made floating.

In this example there is a maximizer around the root dock. Around the maximizer is a docking minimizer. The minimizer uses a border dock in mode MODE_MINIMIZE_BAR. This dock is a root dock and has to be registered in the dock model as root dock:

		// Create a maximizer and add it to the dock model.
		SingleMaximizer maximizePanel = new SingleMaximizer(splitDock);
		dockModel.addVisualizer("maximizePanel", maximizePanel, frame);
		// Create a docking minimizer.
		BorderDock borderDock = new BorderDock(new ToolBarDockFactory());
		BorderDocker borderDocker = new BorderDocker();
		DockingMinimizer minimizer = new DockingMinimizer(borderDocker);
		// Add the minimizer to the dock model, add also the border dock used by the minimizer to the dock model.
		dockModel.addVisualizer("minimizePanel", minimizer, frame);
		dockModel.addRootDock("minimizerBorderDock", borderDock, frame);
		// Add the border dock of the minimizer to this panel.
		this.add(borderDock, BorderLayout.CENTER);
		// Minimize dockables 5, 6, 7, and 8.

:: Create a custom minimizer ::

If you want to minimize your dockables in a different way, you have to create your own visualizer implementation. This is shown in WindowMinimizerExample. The minimizer shows its minimized components in a dialog.

:: Headers used by minimizers and maximizers ::

When a dockable is maximized, a maximize header is displayed above the dockable. When a dockable is minimized, the dockable is represented by a minimize header. The SwComponentFactory is responsible for creating those headers:

The following example uses a little image of the dockable component, when the dockable is minimized:
		// Set our custom component factory that creates headers for minimized dockables with an image.
		DockingManager.setComponentFactory(new CustomComponentFactory());


	 * The header of a minimized dockable will be an image of the dockable component.
	private class CustomComponentFactory extends DefaultSwComponentFactory

		// Overwritten methods.

		public SelectableHeader createMinimizeHeader(Dockable dockable, int position)
			return new ImageMinimzeHeader(dockable, position);

The source code of the samples can be found in:

VisualizersExampleShows the usage of a minimizer, maximizer, and externalizer.
DockingMinimizerExampleShows the usage of a docking minimizer.
ImageDockingMinimizerExampleShows the usage of a docking minimizer with images.
WindowMinimizerExampleShows the creation of a new minimizer.
ExternalizerExampleShows the usage of an externalizer.

« prev next »