Package com.vlsolutions.swing.docking.event

Examples of com.vlsolutions.swing.docking.event.DockingActionSplitComponentEvent


          }
         
          if (anchoredTop) {
            if (anchoredLeft) {
              if (anchoredBottom) {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, split, DockingConstants.SPLIT_LEFT, proportionW);
              } else {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, top, DockingConstants.SPLIT_LEFT, proportionW);
              }
            } else if (anchoredRight) {
              if (anchoredBottom) {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, split, DockingConstants.SPLIT_RIGHT, 1-proportionW);
              } else {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, top, DockingConstants.SPLIT_RIGHT, 1-proportionW);
              }
            } else {
              // just anchored top
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, top, DockingConstants.SPLIT_TOP, proportionTopH);
            }
          } else if (anchoredBottom) { // but not anchoredTop
            if (anchoredLeft) {
              if (anchoredRight) {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bottom, DockingConstants.SPLIT_BOTTOM, 1-proportionBottomH);
              } else {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bottom, DockingConstants.SPLIT_LEFT, proportionW);
              }
            } else if (anchoredRight) {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bottom, DockingConstants.SPLIT_RIGHT, 1-proportionW);
            } else {
              // just anchored bottom
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bottom, DockingConstants.SPLIT_BOTTOM, 1-proportionBottomH);
            }
          } else if (anchoredLeft) { // not anchored on top / bottom
            if (anchoredRight){ //2005/10/10
              // left + right on a vertical split, means we have to insert a new component
              // in between
              int yTop = y;
              int yBottom = split.getHeight() - y - h;
              int splitTop = top.getHeight();
              int splitBottom = bottom.getHeight();
             
              /*SplitContainer newSplit = new SplitContainer(JSplitPane.
                  VERTICAL_SPLIT);
              DockingUtilities.replaceChild(split, bestComp, newSplit);*/
             
              if (bestComp == top){
                float hParent =( split.getHeight() - yBottom)/(float) split.getHeight() ;
                float hChild = yTop/(float) split.getHeight();
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bestComp, DockingConstants.SPLIT_BOTTOM, hChild, hParent);
              } else {
                float hChild =  h/(float) splitBottom;
                float hParent = yTop/(float) split.getHeight();
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bestComp, DockingConstants.SPLIT_TOP, hChild, hParent);
              }
            } else {// only left
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_LEFT, proportionW);
            }
          } else if (anchoredRight) {
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, bestComp, DockingConstants.SPLIT_RIGHT, 1-proportionW);
          } else { // not anchored at all, split verticaly and add
           
            SplitContainer newSplit = new SplitContainer(JSplitPane.
                VERTICAL_SPLIT);
            DockingUtilities.replaceChild(split, bestComp, newSplit);
            if (bestCenter.y < centerY) {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_BOTTOM, 1-proportionBottomH);
            } else {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_TOP, proportionTopH);
            }
          }
        } else {
         
         
          // horizontal split
          // proportions used when splitting a horizontal split horizontally
          float proportionLeftW = w / (float)left.getWidth();
          float proportionRightW = w / (float)right.getWidth();
          if (proportionLeftW >= 0.8f){ // not too big
            proportionLeftW = 0.8f;
          }
          if (proportionRightW >= 0.8f){ // not too big
            proportionRightW = 0.8f;
          }
          // proportions used when splitting a horizontal split vertically
          int splitH = split.getHeight();
          float proportionH = h / (float) splitH;
          if (proportionH >= 0.6f){ // not too big
            proportionH = 0.6f;
          }
         
          if (anchoredTop) {
            if (anchoredLeft) {
              if (anchoredBottom) {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, left, DockingConstants.SPLIT_LEFT, proportionLeftW);
              } else if (anchoredRight){
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, split, DockingConstants.SPLIT_TOP, proportionH);
              } else { // just anchored top/left
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, left, DockingConstants.SPLIT_TOP, proportionH);
              }
            } else if (anchoredRight) {
              if (anchoredBottom) { // top + right + bottom
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, right, DockingConstants.SPLIT_RIGHT, 1-proportionRightW);
              } else { // top + right
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, right, DockingConstants.SPLIT_TOP, proportionH);
              }
            } else if (anchoredBottom){ //2005/10/10
              // top + bottom : create a horizontal split
              // as we are inserting a vertical element into a horizontal split
              // we have to adjust the width on both sides
              int xLeft = x;
              int xRight = split.getWidth() - x - w;
              int splitLeft = left.getWidth();
              int splitRight = right.getWidth();
             
              /*SplitContainer newSplit = new SplitContainer(JSplitPane.
                  HORIZONTAL_SPLIT);
              DockingUtilities.replaceChild(split, bestComp, newSplit);*/
             
              if (bestComp == left){
                float parentW = (split.getWidth() - xRight)/(float) split.getWidth();
                float childW = xLeft/(float) split.getWidth();
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bestComp, DockingConstants.SPLIT_RIGHT, childW, parentW);
              } else {
                float parentW = xLeft/(float) split.getWidth();
                float childW =  w/(float) splitRight;
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, bestComp, DockingConstants.SPLIT_LEFT, childW, parentW);
              }
            } else {
              // just anchored top
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_TOP, proportionH);
            }
          } else if (anchoredBottom) { // but not anchoredTop
            if (anchoredLeft) {
              if (anchoredRight) {
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, split, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
               
              } else { // bottom + left
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, left, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
              }
            } else if (anchoredRight) { // bottom + right
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, right, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            } else {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            }
          } else if (anchoredLeft) { // not anchored on top / bottom
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, left, DockingConstants.SPLIT_LEFT, proportionLeftW);
          } else if (anchoredRight) {
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, right, DockingConstants.SPLIT_RIGHT, 1-proportionRightW);
          } else { // not anchored at all, split verticaly and add
            /*SplitContainer newSplit = new SplitContainer(JSplitPane.
                VERTICAL_SPLIT);
            DockingUtilities.replaceChild(split, bestComp, newSplit);*/
            if (bestCenter.y < centerY) {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            } else {
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, bestComp, DockingConstants.SPLIT_TOP, proportionH);
            }
          }
        }
      } else { // 2004/04/01 (this part was missing) ------------------------------
        // one component, but not a split container
        // heuristics : try to find an anchor
        boolean anchoredTop = y < 5;
        boolean anchoredLeft = x < 5;
        boolean anchoredBottom = Math.abs(y + h - relativeAncestorContainer.getHeight()) < 5;
        boolean anchoredRight = Math.abs(x + w - relativeAncestorContainer.getWidth()) < 5;
        Component singleComp = relativeAncestorContainer.getComponent(0);
       
        float proportionW = w / (float) relativeAncestorContainer.getWidth();
        if (proportionW >= 0.8f){ // not too big
          proportionW = 0.8f;
        }
        float proportionH = h / (float) relativeAncestorContainer.getHeight();
        if (proportionH >= 0.6f){ // not too big
          proportionH = 0.6f;
        }
       
       
        if (anchoredTop){
          if (anchoredLeft){
            if (anchoredBottom){
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_LEFT, proportionW);
            } else if (anchoredRight){ // top + left + right == TOP
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
            } else { // top + left... what should we do ?
              if (w > h){ // vsplit
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
              } else { // hsplit
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_LEFT, proportionW);
              }
            }
          } else if (anchoredRight){ // top + right (not left)
            if (anchoredBottom){ // top + right + bottom == on the right
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_RIGHT, 1-proportionW);
            } else { // top + right
              if (w > h){ // on top
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
              } else { // on the right
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_RIGHT, 1-proportionW);
              }
            }
          } else { // top only
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
          }
        } else if (anchoredLeft){ //left (but not top)
          if (anchoredBottom){ // left + bot
            if (anchoredRight){ // == bottom
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            } else { // left + bottom
              if (w > h){ // bottom
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
              } else { // on the left
                return new DockingActionSplitComponentEvent(desktop, dockable,
                    initialState, nextState, singleComp, DockingConstants.SPLIT_LEFT, proportionW);
              }
            }
          } else if (anchoredRight){ // left + right, but not top/bottom...
            if (centerY < relativeAncestorContainer.getHeight()/2){ // center is upper part
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
            } else { // lower part
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            }
          } else { // left only
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, singleComp, DockingConstants.SPLIT_LEFT, proportionW);
          }
        } else if (anchoredBottom){ // bottom, but not top/left
          if (anchoredRight){
            if (w > h){ // bottom
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
            } else { // on the right
              return new DockingActionSplitComponentEvent(desktop, dockable,
                  initialState, nextState, singleComp, DockingConstants.SPLIT_RIGHT, 1-proportionW);
            }
          } else { // just bottom
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
          }
        } else if (anchoredRight){ // just right
          return new DockingActionSplitComponentEvent(desktop, dockable,
              initialState, nextState, singleComp, DockingConstants.SPLIT_RIGHT, 1-proportionW);
        } else { // no anchors
          if (centerY < relativeAncestorContainer.getHeight()/2){ // center is upper part
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, singleComp, DockingConstants.SPLIT_TOP, proportionH);
          } else {
            return new DockingActionSplitComponentEvent(desktop, dockable,
                initialState, nextState, singleComp, DockingConstants.SPLIT_BOTTOM, 1-proportionH);
          }
        }
      }
    }
View Full Code Here


        relativeAncestorContainer.repaint();
        return dockableContainer;
      case DockingActionEvent.ACTION_SPLIT_COMPONENT:
        dockableContainer = DockableContainerFactory.getFactory().
            createDockableContainer(dockable, DockableContainerFactory.ParentType.PARENT_SPLIT_CONTAINER);
        DockingActionSplitComponentEvent splitAction = (DockingActionSplitComponentEvent) action;
        Component base = splitAction.getBase();
        float div = splitAction.getDividorLocation();
        DockingConstants.Split splitPosition = splitAction.getSplitPosition();
        float parentDiv = splitAction.getParentDividorLocation();
        switch (splitPosition.value()){
          case DockingConstants.INT_SPLIT_TOP:
            vSplitAndResize(base, (Container) dockableContainer, base, div);
            break;
          case DockingConstants.INT_SPLIT_LEFT:
View Full Code Here

      if (dragContainer instanceof TabbedDockableContainer){
         event.setDockingAction(new DockingActionSplitDockableContainerEvent(
             event.getDesktop(), initialState, nextState,
             this, dragContainer, position, 0.5f));
      } else {
         event.setDockingAction(new DockingActionSplitComponentEvent(
             event.getDesktop(), dockable, initialState, nextState,
             this, position, 0.5f));
      }
      ( (DockDragEvent) event).acceptDrag(shape);       
    }
View Full Code Here

TOP

Related Classes of com.vlsolutions.swing.docking.event.DockingActionSplitComponentEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.