Fixed size use case: solved

Beni, hello;

I have the following “fixed size use case”:

  1. I would like to have fixed-size dockables, which are automatically padded
    by “invisible” flexible-size dockables; so from the user perspecitve, she
    can see just a fixed-size widget which can be moved around and landed
    only on some permitted stations; can be grouped with other widgets, etc.
    resize by user is permitted; resize by framework - not permitted;

visual metaphor: a card game, when cards are not permitted to overlap,
and cards have a fixed size;

  1. what is the best way to achieve this in “docking-frames”?
    which of the existing “docking-frames” examples are a good start for this?
    are there some third-party application using “docking-frames” that resemble this?

thank you

Andrei

As I understand your requirements, the Dockables would float around as if they were JInternalFrames; they just can be grouped and do not overlap? I think that would mean to implement a new DockStation. That is quite some work, but the framework is designed to allow such things. Have a look at the “Chess” Demonstration, it shows how far customisation can go.

If I misunderstood: in Common each CDockable offers the methods “setResizeLocked”. The framework will try not to change the size of such a dockable, although you can always create a layout where the framework has no other choice than to resize. You might want to have a look at the “Size & Color” Demonstration, you can lock the size there (each panel has some checkboxes “width/height locked during resize”).

Preventing some grouping is not an issue, the interface “DockAcceptance” can accomplish that.

Beni, hi;

thanks for getting back on this; both of your answers are very good;

  1. I will try to start with “setResizeLocked” to see if this is sufficient for me;

  2. if not - I will proceed with “new DockStation” based on Chess Demo;

cheers,

Andrei

If 2) is necessary let me know, I can write you a skeleton class. It will be much easier if you don’t have to search all required classes by yourself…

wow! cool, thanks!

Beni, hello;

I am on the path #1;

in the example below:

a) “setResizeLocked” works OK if I resize the whole station;

b) when I move “red” from first row “gray1” to the second row “gray2”,
the “green” becomes twice wide; how can I prevent this?

Thank you;

Andrei

package docking_frames.test_02;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.layout.FullLockConflictResolver;

public class Example {

	public static void main(String[] args) {

		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		//

		CControl control = new CControl(frame);
		frame.add(control.getContentArea());

		control.putProperty(CControl.RESIZE_LOCK_CONFLICT_RESOLVER,
				new FullLockConflictResolver());

		frame.setLayout(new GridLayout(1, 1));

		//

		DefaultSingleCDockable red = create("Red", Color.RED);
		DefaultSingleCDockable green = create("Green", Color.GREEN);
		DefaultSingleCDockable blue = create("Blue", Color.BLUE);

		DefaultSingleCDockable gray1 = create("gray1", Color.GRAY);
		DefaultSingleCDockable gray2 = create("gray2", Color.GRAY);

		//
		control.add(red);
		control.add(green);
		control.add(blue);

		control.add(gray1);
		control.add(gray2);

		//

		CGrid grid = new CGrid();

		grid.add(0, 0, 1, 1, red);
		grid.add(1, 0, 1, 1, green);
		grid.add(2, 0, 1, 1, blue);

		grid.add(3, 0, 1, 1, gray1);
		grid.add(1, 1, 3, 1, gray2);

		control.getContentArea().deploy(grid);

		//

		freeze(red);
		freeze(blue);
		freeze(green);

		//

		frame.setSize(new Dimension(500, 500));
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);

	}

	static void freeze(DefaultSingleCDockable dockable) {
		dockable.setCloseable(false);
		dockable.setMaximizable(false);
		dockable.setMinimizable(false);
		dockable.setResizeLocked(true);
	}

	static DefaultSingleCDockable create(String title, Color color) {

		JPanel panel = new JPanel();
		panel.setOpaque(true);
		panel.setBackground(color);

		DefaultSingleCDockable dockable = new DefaultSingleCDockable(title,
				title, panel);

		return dockable;

	}

}

c) I would expect “green” and “blue” stay same size, and shift left, since they are “frozen”
and have station to adjust “grey1” width instead since it is not “frozen”;

d) another option would be to put an “invisible” placeholder instead of
just-removed “red” dockable - with the same size;
is it something available out of the box?

Hm, there was an event missing that tells the LayoutManager to take special care of such a situation. I’ll have a bugfix uploaded soon (crappy internet connection… always takes some time).

The invisible placeholder does not exist out of the box and it would be hard to create one, actually the SplitDockStation would need to be modified (and this class already is very complex).

you mean I should switch to
a) latest 1.0.8 zip download
or
b) build myself from trunk?

Switch to the latest 1.0.8. (=1.0.8p5e) It is almost the final, stable version anyawy.

just got 1.0.8p5e;

wow! magic! it works!

this is enough to get me going for now;

Beni, you are the best! thank you.

do you know how to change the subject, so it reads:
“fixed size use case: solved!”
?

Only by editing your first post, and posts can only be edited for an hour or so.

(The restriction exists because of some idiots which constantly edited their posts such that noone understood the initial problem nor the discussion or solution)

cool!