It is your application… I would advise to find a way and use the frameworks layouting mechanism, doing it yourself will be a lot of work.
If you have only the paths you have to carefully consider the order in which the Dockables are inserted into the tree, because a DockableProperty is used once to insert a Dockable, afterwards the framework never looks at it again. Placeholders allow you not to care about the order, and the class “DockSituation” allows to store the placeholders.
Anyway, this is a way to find the path containing only visible elements.
import javax.swing.JFrame;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.SplitDockStation;
import bibliothek.gui.dock.SplitDockStation.Orientation;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.ThemeMap;
import bibliothek.gui.dock.layout.DockableProperty;
import bibliothek.gui.dock.station.split.Leaf;
import bibliothek.gui.dock.station.split.Node;
import bibliothek.gui.dock.station.split.SplitDockPathProperty;
import bibliothek.gui.dock.station.split.SplitNode;
import bibliothek.gui.dock.station.split.SplitTreeFactory;
import bibliothek.gui.dock.station.split.SplitDockPathProperty.Location;
import bibliothek.gui.dock.station.support.PlaceholderMap;
import bibliothek.util.Path;
public class Dock47 {
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());
DefaultSingleCDockable a = new DefaultSingleCDockable( "a", "Aaaaa" );
DefaultSingleCDockable b = new DefaultSingleCDockable( "b", "Bbbbb" );
DefaultSingleCDockable c = new DefaultSingleCDockable( "c", "Ccccc" );
DefaultSingleCDockable d = new DefaultSingleCDockable( "d", "Ddddd" );
CGrid grid = new CGrid( control );
grid.add( 0, 0, 1, 1, a );
grid.add( 0, 1, 1, 1, b );
grid.add( 1, 0, 1, 1, c );
grid.add( 1, 1, 1, 1, d );
control.getContentArea().deploy( grid );
c.setVisible( false );
d.setVisible( false );
System.out.println( control.getContentArea().getCenter().getDockablePathProperty( a.intern() ));
System.out.println( get( control.getContentArea().getCenter(), a.intern(), true ));
System.out.println( get( control.getContentArea().getCenter(), a.intern(), false ));
frame.setBounds( 20, 20, 400, 400 );
frame.setVisible( true );
}
private static DockableProperty get( final SplitDockStation station, final Dockable dockable, final boolean placeholders ){
final SplitDockPathProperty path = new SplitDockPathProperty();
Leaf leaf = station.getRoot().getLeaf( dockable );
path.setLeafId( leaf.getId() );
SplitNode child = leaf;
SplitNode parent = leaf.getParent();
while( parent != null ){
if( parent instanceof Node){
Node node = (Node)parent;
boolean visible;
if( placeholders ){
visible = node.isVisible();
}
else{
visible = node.getLeft().isVisible() && node.getRight().isVisible();
}
if( visible ){
if( node.getLeft() == child ){
if( node.getOrientation() == Orientation.HORIZONTAL ){
path.insert( Location.LEFT, node.getDivider(), 0, node.getId() );
}
else{
path.insert( Location.TOP, node.getDivider(), 0, node.getId() );
}
}
else{
if( node.getOrientation() == Orientation.HORIZONTAL ){
path.insert( Location.RIGHT, 1.0 - node.getDivider(), 0, node.getId() );
}
else{
path.insert( Location.BOTTOM, 1.0 - node.getDivider(), 0, node.getId() );
}
}
}
}
child = parent;
parent = child.getParent();
}
return path;
}
}