/** * Deletes all pending commands that were collected by the <code>grid*</code> methods. A call to this * method does not change the current layout of this area, but a call to {@link #gridDeploy()} will. * @see #gridDeploy() */ public void gridClear(){ grid = new PerspectiveSplitDockGrid(); }
/** * Adds a constraint to the algorithm that is executed by {@link #gridDeploy()}, the constraint tells that * there should be a horizontal divider from <code>x1/y</code> to <code>x2/y</code>. * @param x1 the beginning of the divider * @param x2 the end of the divider * @param y the vertical position of the divider */ public void gridHorizontal( double x1, double x2, double y ){ gridChanges = true; grid.addHorizontalDivider( x1, x2, y ); }
/** * Adds placeholders at location <code>x/y</code> with size <code>width/height</code> to * an internal list of pending commands to execute. This method does not change the layout of this area, but a call * to {@link #gridDeploy()} will.<br> * Calling this method several times with the same location and size has the same effect as calling it once, * but with a bigger array that contains all the dockables that would otherwise be added through many calls. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param placeholders the placeholders to add, should contain at least one element and no <code>null</code> elements * @see #gridClear() * @see #gridDeploy() * @throws IllegalArgumentException if not all dockables have a placeholder */ public void gridPlaceholder( double x, double y, double width, double height, Path... placeholders ){ gridChanges = true; grid.addPlaceholders( x, y, width, height, placeholders ); }
/** * Adds <code>dockables</code> at location <code>x/y</code> with size <code>width/height</code> to an internal * list of pending commands to execute. This method does not change the layout of this area, but a call * to {@link #gridDeploy()} will.<br> * Calling this method several times with the same location and size has the same effect as calling it once, * but with a bigger array that contains all the dockables that would otherwise be added through many calls. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param dockables the elements to add, should contain at least one item * @see #gridClear() * @see #gridDeploy() */ public void gridAdd( double x, double y, double width, double height, CDockablePerspective... dockables ){ gridChanges = true; grid.addDockable( x, y, width, height, convert( dockables ) ); }
/** * Gets all the nodes of the grid. Each node is a set of {@link PerspectiveDockable}s and their location and size. * @return the nodes, may be empty, is unmodifiable */ public List<GridNode<PerspectiveDockable>> getGridNodes(){ return grid.getGridNodes(); }
/** * Adds a constraint to the algorithm that is executed by {@link #gridDeploy()}, the constraint tells that * there should be a vertical divider from <code>x/y1</code> to <code>x/y2</code>. * @param x the horizontal position of the divider * @param y1 the beginning of the divider * @param y2 the end of the divider */ public void gridVertical( double x, double y1, double y2 ){ gridChanges = true; grid.addVerticalDivider( x, y1, y2 ); }
/** * Unpacks the stations (e.g. a stack) that is stored at <code>x,y,width,height</code>. The result * is like removing all children and add them again with {@link #gridAdd(double, double, double, double, CDockablePerspective...)}. * @param x the x-coordinate of a set of {@link CDockablePerspective}, can be any number * @param y the y-coordinate of a set of {@link CDockablePerspective}, can be any number * @param width the width of a set of {@link CDockablePerspective}, can be any number greater than 0 * @param height the height of a set of {@link CDockablePerspective}, can be any number greater than 0 */ public void unpack( double x, double y, double width, double height ){ gridChanges = true; grid.unpack( x, y, width, height ); }
/** * Converts the current grid into a tree. * @return the tree which represents this grid * @see SplitDockStation#dropTree(SplitDockTree) */ public PerspectiveSplitDockTree toTree(){ PerspectiveSplitDockTree tree = new PerspectiveSplitDockTree(); fillTree( tree ); return tree; }
/** * Using location <code>x/y</code> and size <code>width/height</code> as key, this method set the selection * in a group of dockables. This method does not change the layout directly, but a call to {@link #gridDeploy()} will. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param selection the element that should be selected, must already be in the group * @see #gridClear() * @see #gridDeploy() */ public void gridSelect( double x, double y, double width, double height, CDockablePerspective selection ){ gridChanges = true; grid.setSelected( x, y, width, height, selection == null ? null : selection.intern().asDockable() ); }
/** * Removes all children of this area, then executes pending commands that add dockables at specified locations.<br> * In particular this method analyzes all the commands that were generated by calls to the <code>grid*</code> methods * and merges them into a layout that fits the locations and sizes the client specified as good as possible.<br> * If {@link #isAutoDeploy()} returns <code>true</code>, then this method is called automatically before storing * the layout of this area.<br> * This method will silently return if the list of pending commands was never accessed directly or indirectly * by the client. * @see #isAutoDeploy() * @see #gridAdd(double, double, double, double, CDockablePerspective...) * @see #gridSelect(double, double, double, double, CDockablePerspective) * @see #gridHorizontal(double, double, double) * @see #gridVertical(double, double, double) * @see #gridClear() */ public void gridDeploy(){ if( gridChanges ) { gridChanges = false; try { onDeploy = true; delegate().read( grid.toTree(), null ); } finally { onDeploy = false; } } }
/** * Adds <code>dockables</code> at location <code>x/y</code> with size <code>width/height</code> to an internal * list of pending commands to execute. This method does not change the layout of this area, but a call * to {@link #gridDeploy()} will.<br> * Calling this method several times with the same location and size has the same effect as calling it once, * but with a bigger array that contains all the dockables that would otherwise be added through many calls. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param dockables the elements to add, should contain at least one item * @see #gridClear() * @see #gridDeploy() */ public void gridAdd( double x, double y, double width, double height, CDockablePerspective... dockables ){ gridChanges = true; grid.addDockable( x, y, width, height, convert( dockables ) ); }
/** * Gets all the nodes of the grid. Each node is a set of {@link PerspectiveDockable}s and their location and size. * @return the nodes, may be empty, is unmodifiable */ public List<GridNode<PerspectiveDockable>> getGridNodes(){ return grid.getGridNodes(); }
/** * Adds a constraint to the algorithm that is executed by {@link #gridDeploy()}, the constraint tells that * there should be a vertical divider from <code>x/y1</code> to <code>x/y2</code>. * @param x the horizontal position of the divider * @param y1 the beginning of the divider * @param y2 the end of the divider */ public void gridVertical( double x, double y1, double y2 ){ gridChanges = true; grid.addVerticalDivider( x, y1, y2 ); }
/** * Unpacks the stations (e.g. a stack) that is stored at <code>x,y,width,height</code>. The result * is like removing all children and add them again with {@link #gridAdd(double, double, double, double, CDockablePerspective...)}. * @param x the x-coordinate of a set of {@link CDockablePerspective}, can be any number * @param y the y-coordinate of a set of {@link CDockablePerspective}, can be any number * @param width the width of a set of {@link CDockablePerspective}, can be any number greater than 0 * @param height the height of a set of {@link CDockablePerspective}, can be any number greater than 0 */ public void unpack( double x, double y, double width, double height ){ gridChanges = true; grid.unpack( x, y, width, height ); }
/** * Converts the current grid into a tree. * @return the tree which represents this grid * @see SplitDockStation#dropTree(SplitDockTree) */ public PerspectiveSplitDockTree toTree(){ PerspectiveSplitDockTree tree = new PerspectiveSplitDockTree(); fillTree( tree ); return tree; }
/** * Using location <code>x/y</code> and size <code>width/height</code> as key, this method set the selection * in a group of dockables. This method does not change the layout directly, but a call to {@link #gridDeploy()} will. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param selection the element that should be selected, must already be in the group * @see #gridClear() * @see #gridDeploy() */ public void gridSelect( double x, double y, double width, double height, CDockablePerspective selection ){ gridChanges = true; grid.setSelected( x, y, width, height, selection == null ? null : selection.intern().asDockable() ); }
/** * Removes all children of this area, then executes pending commands that add dockables at specified locations.<br> * In particular this method analyzes all the commands that were generated by calls to the <code>grid*</code> methods * and merges them into a layout that fits the locations and sizes the client specified as good as possible.<br> * If {@link #isAutoDeploy()} returns <code>true</code>, then this method is called automatically before storing * the layout of this area.<br> * This method will silently return if the list of pending commands was never accessed directly or indirectly * by the client. * @see #isAutoDeploy() * @see #gridAdd(double, double, double, double, CDockablePerspective...) * @see #gridSelect(double, double, double, double, CDockablePerspective) * @see #gridHorizontal(double, double, double) * @see #gridVertical(double, double, double) * @see #gridClear() */ public void gridDeploy(){ if( gridChanges ) { gridChanges = false; try { onDeploy = true; delegate().read( grid.toTree(), null ); } finally { onDeploy = false; } } }
private void handle( Entry entry, double x, double y, double width, double height ){ if( entry != null ){ if( entry.asLeaf() != null ) { PerspectiveDockable dockable = entry.asLeaf().getDockable(); if( dockable != null ) { grid.addDockable( x, y, width, height, dockable ); } } else{ Node node = entry.asNode(); double divider = node.getDivider(); if( node.getOrientation() == Orientation.HORIZONTAL ){ handle( node.getChildA(), x, y, width*divider, height ); handle( node.getChildB(), x+width*divider, y, width*(1-divider), height ); } else{ handle( node.getChildA(), x, y, width, height*divider ); handle( node.getChildB(), x, y+height*divider, width, height*(1-divider) ); } } } }
/** * Adds <code>dockables</code> as placeholder at location <code>x/y</code> with size <code>width/height</code> to * an internal list of pending commands to execute. This method does not change the layout of this area, but a call * to {@link #gridDeploy()} will.<br> * Calling this method several times with the same location and size has the same effect as calling it once, * but with a bigger array that contains all the dockables that would otherwise be added through many calls. * @param x the x-coordinate of <code>dockables</code>, can be any number * @param y the y-coordinate of <code>dockables</code>, can be any number * @param width the width of <code>dockables</code>, can be any number greater than 0 * @param height the height of <code>dockables</code>, can be any number greater than 0 * @param dockables the elements whose placeholders to add, should contain at least one item * @see #gridClear() * @see #gridDeploy() * @throws IllegalArgumentException if not all dockables have a placeholder */ public void gridPlaceholder( double x, double y, double width, double height, CDockablePerspective... dockables ){ gridChanges = true; Path[] placeholders = new Path[ dockables.length ]; for( int i = 0; i < dockables.length; i++ ){ placeholders[i] = dockables[i].intern().asDockable().getPlaceholder(); if( placeholders[i] == null ){ throw new IllegalArgumentException( "dockable '" + i + "' does not have a placeholder: " + dockables[i] ); } } grid.addPlaceholders( x, y, width, height, placeholders ); }
/** * Deletes all pending commands that were collected by the <code>grid*</code> methods. A call to this * method does not change the current layout of this area, but a call to {@link #gridDeploy()} will. * @see #gridDeploy() */ public void gridClear(){ grid = new PerspectiveSplitDockGrid(); }