Package org.flexdock.docking.state.tree

Examples of org.flexdock.docking.state.tree.SplitNode


* @version $Id: SplitNodeSerializer.java,v 1.9 2005-07-06 18:10:48 winnetou25 Exp $
*/
public class SplitNodeSerializer extends AbstractLayoutNodeSerializer implements ISerializer {

    public Element serialize(Document document, Object object) {
        SplitNode splitNode = (SplitNode) object;

        Element splitNodeElement = super.serialize(document, object);

        if (splitNode.getSiblingId() != null && !"".equals(splitNode.getSiblingId())) {
            splitNodeElement.setAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_SIBLING_ID, splitNode.getSiblingId());
        }
        splitNodeElement.setAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_ORIENTATION, splitNode.getOrientationDesc());
        splitNodeElement.setAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_REGION, splitNode.getRegionDesc());
        splitNodeElement.setAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_PERCENTAGE, String.valueOf(splitNode.getPercentage()));

        if (splitNode.getDockingRegion() != null) {
            splitNodeElement.setAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_DOCKING_REGION, splitNode.getDockingRegion().toLowerCase());
        }

        return splitNodeElement;
    }
View Full Code Here


        return document.createElement(PersistenceConstants.SPLIT_NODE_ELEMENT_NAME);
    }

    public Object deserialize(Element element) {

        SplitNode splitNode = (SplitNode) super.deserialize(element);

        String siblingId = element.getAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_SIBLING_ID);
        String orientationString = element.getAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_ORIENTATION);
        String regionString = element.getAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_REGION);
        String percentage = element.getAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_PERCENTAGE);
        String dockingRegion = element.getAttribute(PersistenceConstants.SPLIT_NODE_ATTRIBUTE_DOCKING_REGION);

        int orientation = DockingConstants.UNINITIALIZED;
        if (orientationString.equals("vertical")) {
            orientation = DockingConstants.VERTICAL;
        } else if (orientationString.equals("horizontal")) {
            orientation = DockingConstants.HORIZONTAL;
        }

        int region = DockingConstants.UNINITIALIZED;
        if (regionString.equals("top")) {
            region = DockingConstants.TOP;
        } else if (regionString.equals("bottom")) {
            region = DockingConstants.BOTTOM;
        } else if (regionString.equals("left")) {
            region = DockingConstants.LEFT;
        } else if (regionString.equals("right")) {
            region = DockingConstants.RIGHT;
        }

        splitNode.setOrientation(orientation);
        splitNode.setRegion(region);
        splitNode.setPercentage(Float.parseFloat(percentage));
        if (siblingId != null && !"".equals(siblingId)) {
            splitNode.setSiblingId(siblingId);
        }
        if (dockingRegion != null && !dockingRegion.equals("")) {
            splitNode.setDockingRegion(dockingRegion.toUpperCase());
        }

        return splitNode;
    }
View Full Code Here

        return splitNode;
    }

    protected LayoutNode createLayoutNode() {
        return new SplitNode(-1, -1, -1.0f, null);
    }
View Full Code Here

        }

        List splitNodes = dockingPath.getNodes();
        ISerializer splitNodeSerializer = SerializerRegistry.getSerializer(SplitNode.class);
        for (Iterator it = splitNodes.iterator(); it.hasNext();) {
            SplitNode splitNode = (SplitNode) it.next();
            Element splitNodeElement = splitNodeSerializer.serialize(document, splitNode);
            dockingPathElement.appendChild(splitNodeElement);
        }

        return dockingPathElement;
View Full Code Here

        ISerializer layoutNodeSerializer = SerializerRegistry.getSerializer(LayoutNode.class);
        NodeList splitNodeList = element.getElementsByTagName(PersistenceConstants.SPLIT_NODE_ELEMENT_NAME);
        if (splitNodeList.getLength() > 0 && splitNodeList.item(0) instanceof Element) {
            Element splitNodeElement = (Element) splitNodeList.item(0);
            SplitNode splitNode = (SplitNode) layoutNodeSerializer.deserialize(splitNodeElement);
            dockingPath.getNodes().add(splitNode);
        }

        return dockingPath;
    }
View Full Code Here

    private void reconstruct(DockingPortNode node) {
        DefaultDockingPort port = (DefaultDockingPort) node.getDockingPort();

        if (node.isSplit()) {
            SplitNode child = (SplitNode) node.getChildAt(0);
            JSplitPane split = child.getSplitPane();
            // float percentage = child.getPercentage();
            port.setComponent(split);
            port.evaluateDockingBorderStatus();
            return;
        }
View Full Code Here

      for (int i = 0; i < len; i++) {
    ((SplitNode) splitNodes.get(i)).getSplitPane().setVisible(false);
      }
     
      // first, check to see if we're ready for rendering
      SplitNode node = (SplitNode) splitNodes.get(0);
      JSplitPane split = node.getSplitPane();
      int size = split.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? split.getWidth() : split.getHeight();
      // if we're not ready to render, then defer processing again until later
      if (!split.isValid() || size == 0) {
    // try to validate first
    if (!split.isValid())
        split.validate();
    // now redispatch
    return;
      }
     
      timer.stop();
      timer = null;
     
      // if we're ready to render, then loop through all the splitNodes and
      // set the split dividers to their appropriate locations.
      for (int i = 0; i < len; i++) {
    node = (SplitNode) splitNodes.get(i);
    split = node.getSplitPane();
    size = split.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? split.getWidth() : split.getHeight();
    float percent = node.getPercentage();
    int divLoc = (int) ((float) size * percent);
    // System.err.println("percent: " + percent + ", divLoc: " +
    // divLoc);
    split.setDividerLocation(percent);
   
View Full Code Here

        Component comp = dockable.getComponent();

        Container parent = comp.getParent();
        while(!isDockingRoot(parent)) {
            if(parent instanceof DockingPort) {
                SplitNode node = createNode((DockingPort)parent);
                path.addNode(node);
            }
            parent = parent.getParent();
        }
        if(isDockingRoot(parent))
View Full Code Here

            percentage = (float) ((DockingSplitPane) split).getPercent();
        } else {
            percentage = (float)divLoc / (float)size;
        }

        return new SplitNode(orientation, region, percentage, siblingId);
    }
View Full Code Here

    public String toString() {
        if(stringForm==null) {
            StringBuffer sb = new StringBuffer("/RootPort[id=").append(rootPortId).append("]");
            for(Iterator it=nodes.iterator(); it.hasNext();) {
                SplitNode node = (SplitNode)it.next();
                sb.append("/").append(node.toString());
            }
            sb.append("/Dockable");
            stringForm = sb.toString();
        }
        return stringForm;
View Full Code Here

TOP

Related Classes of org.flexdock.docking.state.tree.SplitNode

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.