/** * Calculates how much of the rectangle given by the property lies inside * this node and how much of this node lies in the rectangle. The result * is a value between 0 and 1 which is 1 only if this node and the rectangle * are identical. The result is 0 if they do not have a shared area. * @param property the property that gives a rectangle * @return Area of intersection divided by the maxima of the area * of the rectangle and of this node. */ public double intersection( SplitDockProperty property ){ double rx1 = Math.max( x, property.getX() ); double ry1 = Math.max( y, property.getY() ); double rx2 = Math.min( x+width, property.getX() + property.getWidth() ); double ry2 = Math.min( y+height, property.getY() + property.getHeight() ); if( rx1 > rx2 || ry1 > ry2 ) return 0; if( property.getWidth() == 0 || property.getHeight() == 0 ) return 0; double max = Math.max( property.getWidth()*property.getHeight(), width*height ); return (rx2-rx1)*(ry2-ry1) / max; }
/** * Creates a new location by creating the child location of <code>location</code> using * <code>property</code> for that step. * @param location the location to expand * @param property the property that is the source of the next location * @return the new location or <code>null</code> if no conversion is possible */ protected CLocation expand( CLocation location, SplitDockProperty property ){ if( !(location instanceof CSplitLocation )){ location = new CSplitLocation( location ); } return new CRectangleLocation( (CSplitLocation)location, property.getX(), property.getY(), property.getWidth(), property.getHeight() ); }
/** * Creates a new location by creating the child location of <code>location</code> using * <code>property</code> for that step. * @param location the location to expand * @param property the property that is the source of the next location * @return the new location or <code>null</code> if no conversion is possible */ protected CLocation expand( CLocation location, SplitDockProperty property ){ if( !(location instanceof CSplitLocation )){ location = new CSplitLocation( location ); } return new CRectangleLocation( (CSplitLocation)location, property.getX(), property.getY(), property.getWidth(), property.getHeight() ); }