changeset 246:4b4e3f25ca1b Implementation_of_communication

implement put omnigraffle for jungle Tree
author tatsuki
date Tue, 05 Jul 2016 01:56:11 +0900
parents 725a0176a873
children bf7c96516dd0
files src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/App.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/CreateXmlDocument.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/InsertNodePositionData.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/NodePoint.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/InterfaceTraverser.java
diffstat 5 files changed, 710 insertions(+), 190 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/App.java	Tue Jul 05 01:56:11 2016 +0900
@@ -0,0 +1,39 @@
+package jp.ac.u_ryukyu.ie.cr.jungle.store.omnigraffle;
+
+import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle;
+import jp.ac.u_ryukyu.ie.cr.jungle.Jungle;
+import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor;
+import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser;
+import jp.ac.u_ryukyu.ie.cr.jungle.xml.reader.XmlReader;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+
+public class App {
+
+    public static void main(String args[]) throws IOException, SAXException, ParserConfigurationException, URISyntaxException, TransformerException {
+
+        Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()));
+        JungleTree tree = jungle.createNewTree("tree");
+        if (tree == null)
+            tree = jungle.getTreeByName("tree");
+        new XmlReader().start("/Users/e115731/workspace/jungle-core/xml/drink" + ".xml", tree);
+        new InsertNodePositionData(tree).InsertPositionData();
+
+
+        if (args.length < 1) {
+            System.out.println("書き出すファイル名を指定してください");
+            return ;
+        }
+
+        CreateXmlDocument creater = new CreateXmlDocument(args[0], tree);
+        creater.createJungleTreeClassDiagramGraphics();
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/CreateXmlDocument.java	Tue Jul 05 01:56:11 2016 +0900
@@ -0,0 +1,503 @@
+package jp.ac.u_ryukyu.ie.cr.jungle.store.omnigraffle;
+
+
+import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeAttributes;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeChildren;
+import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.TreeMap;
+
+
+public class CreateXmlDocument {
+
+    private String file_name;
+    private Document document;
+    private String PUBLIC_ID = "-//Apple//DTD PLIST 1.0//EN";
+    private String SYSTEM_ID = "http://www.apple.com/DTDs/PropertyList-1.0.dtd";
+    private JungleTree tree;
+    private String FONT_SIZE = "14";
+
+
+    CreateXmlDocument(String file_name, JungleTree tree) throws ParserConfigurationException, IOException, URISyntaxException, TransformerException {
+        this.file_name = file_name;
+        this.tree = tree;
+
+        DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+        assert documentBuilder != null;
+
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder builder = factory.newDocumentBuilder();
+
+        DOMImplementation domImpl = builder.getDOMImplementation();
+
+        DocumentType docType = domImpl.createDocumentType("plist", PUBLIC_ID, SYSTEM_ID);
+        document = domImpl.createDocument("", "plist", docType);
+    }
+
+    void createJungleTreeClassDiagramGraphics() throws IOException, TransformerException {
+
+        createXMLHead();
+        createJungleTreeGraphics();
+        createXMLTail();
+        write();
+    }
+
+    private void createXMLHead() throws IOException {//jungleとは関係ない部分をここで記述する
+        Element plist = document.getDocumentElement();
+        plist.setAttribute("version", "1.0");
+
+        Element dict = createElement("dict");
+        plist.appendChild(dict);
+
+        dict.appendChild(createElement("key", "ActiveLayerIndex"));
+        dict.appendChild(createElement("integer", "0"));
+        dict.appendChild(createElement("key", "ApplicationVersion"));
+
+        Element array = createElement("array");
+        dict.appendChild(array);
+
+        array.appendChild(createElement("string", "com.omnigroup.OmniGraffle"));
+        array.appendChild(createElement("string", "139.16.0.171715"));
+
+        dict.appendChild(createElement("key", "AutoAdjust"));
+        dict.appendChild(createElement("true"));
+        dict.appendChild(createElement("key", "BackgroundGraphic"));
+
+
+        Element dictChild = createElement("dict");
+        dict.appendChild(dictChild);
+        dictChild.appendChild(createElement("key", "Bounds"));
+        dictChild.appendChild(createElement("string", "{{0, 0}, {0,0}}"));//キャンパスサイズ 図形とかに応じて勝手に変更されるから0でいい? 複数個集まった時のやつ? {558.99997329711914, 783}
+        dictChild.appendChild(createElement("key", "Class"));
+        dictChild.appendChild(createElement("string", "SolidGraphic"));
+        dictChild.appendChild(createElement("key", "ID"));
+        dictChild.appendChild(createElement("integer", "0"));
+        dictChild.appendChild(createElement("key", "Style"));
+
+        Element dictShadow = createElement("dict");
+        dictChild.appendChild(dictShadow);
+
+        dictShadow.appendChild(createElement("key", "shadow"));
+
+        Element dictShadowDraws = createElement("dict");
+        dictShadow.appendChild(dictShadowDraws);
+        dictShadowDraws.appendChild(createElement("key", "Draws"));
+        dictShadowDraws.appendChild(createElement("string", "NO"));
+
+        dictShadow.appendChild(createElement("key", "stroke"));
+
+        Element dictStrokeDraws = createElement("dict");
+        dictShadow.appendChild(dictStrokeDraws);
+        dictStrokeDraws.appendChild(createElement("key", "Draws"));
+        dictStrokeDraws.appendChild(createElement("string", "NO"));
+
+        dict.appendChild(createElement("key", "BaseZoom"));
+        dict.appendChild(createElement("integer", "0"));
+        dict.appendChild(createElement("key", "CanvasOrigin"));
+        dict.appendChild(createElement("string", "{0, 0}"));
+        dict.appendChild(createElement("key", "ColumnAlign"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "ColumnSpacing"));
+        dict.appendChild(createElement("real", "36"));
+        dict.appendChild(createElement("key", "Creator"));
+        dict.appendChild(createElement("string", "sister_clown")); //作成者の名前
+        dict.appendChild(createElement("key", "DisplayScale"));
+        dict.appendChild(createElement("string", "1.000 cm = 1.000 cm"));
+        dict.appendChild(createElement("key", "GraphDocumentVersion"));
+        dict.appendChild(createElement("integer", "8"));
+        dict.appendChild(createElement("key", "GraphicsList"));
+
+
+    }
+
+
+    private void createJungleTreeGraphics() throws UnsupportedEncodingException {
+
+        TreeMap<TreeNode, NodePoint> treeMap = new InsertNodePositionData(tree).InsertPositionData();
+        Element plist = document.getDocumentElement();
+        Element dict = (Element) plist.getLastChild();
+
+        Element graphicsArray = createElement("array");
+        dict.appendChild(graphicsArray);
+
+        int graphicsId = 1;
+        for (TreeNode node : treeMap.keySet()) {
+            Pair<Element, Integer> squarePair = createSquare(node, treeMap, graphicsId);
+            graphicsId = squarePair.right();
+            graphicsArray.appendChild(squarePair.left());
+
+            Pair<LinkedList<Element>, Integer> linePair = createLine(node, treeMap, graphicsId);
+            graphicsId = linePair.right();
+
+            for (Element lineDict : linePair.left()) {
+                graphicsArray.appendChild(lineDict);
+            }
+        }
+
+
+    }
+
+    private Pair<LinkedList<Element>, Integer> createLine(TreeNode node, TreeMap<TreeNode, NodePoint> treeMap, int graphicsId) {
+        TreeNodeChildren children = node.getChildren();
+        NodePoint currentNodePoint = treeMap.get(node);
+        int startLineX = currentNodePoint.getX() + (currentNodePoint.getWidth() / 2);
+        int startLineY = currentNodePoint.getY() + (currentNodePoint.getHeight());
+        LinkedList<Element> lineGraphicsList = new LinkedList<>();
+
+        for (TreeNode child : children) {
+            NodePoint childNodePoint = treeMap.get(child);
+            int endLineX = childNodePoint.getX() + (childNodePoint.getWidth() / 2);
+            int endLineY = childNodePoint.getY();
+
+            Element graphicsDict = createElement("dict");
+            graphicsDict.appendChild(createElement("key", "Class"));
+            graphicsDict.appendChild(createElement("string", "LineGraphic"));
+            graphicsDict.appendChild(createElement("key", "ID"));
+            graphicsDict.appendChild(createElement("integer", String.valueOf(graphicsId)));
+            graphicsDict.appendChild(createElement("key", "Points"));
+
+            Element pointArray = createElement("array");
+            graphicsDict.appendChild(pointArray);
+            String startLine = "{" + startLineX + "," + startLineY + "}" ;
+            pointArray.appendChild(createElement("string", startLine));
+            String endLine = "{" + endLineX + "," + endLineY + "}" ;
+            pointArray.appendChild(createElement("string", endLine));
+
+            graphicsDict.appendChild(createElement("key", "Style"));
+
+            Element styleDict = createElement("dict");
+            graphicsDict.appendChild(styleDict);
+            styleDict.appendChild(createElement("key", "stroke"));
+
+            Element strokeDict = createElement("dict");
+            styleDict.appendChild(strokeDict);
+            strokeDict.appendChild(createElement("key","HeadArrow"));
+            strokeDict.appendChild(createElement("string","0"));
+            strokeDict.appendChild(createElement("key","Join"));
+            strokeDict.appendChild(createElement("integer","0"));
+            strokeDict.appendChild(createElement("key","Legacy"));
+            strokeDict.appendChild(createElement("true"));
+            strokeDict.appendChild(createElement("key","TailArrow"));
+            strokeDict.appendChild(createElement("string","0"));
+            lineGraphicsList.add(graphicsDict);
+            graphicsId++;
+        }
+        return new Pair<>(lineGraphicsList,graphicsId);
+    }
+
+    private Pair<Element, Integer> createSquare(TreeNode node, TreeMap<TreeNode, NodePoint> treeMap, int graphicsId) throws UnsupportedEncodingException {
+
+        NodePoint np = treeMap.get(node);
+        Element graphicsDict = createElement("dict");
+        graphicsDict.appendChild(createElement("key", "Bounds"));
+
+        int x = np.getX();
+        int y = np.getY();
+        int height = np.getHeight();
+        int width = np.getWidth();
+        String squareCoordinate = "{{" + x + "," + y + "},{" + width + "," + height + "}}";
+        graphicsDict.appendChild(createElement("string", squareCoordinate));
+        graphicsDict.appendChild(createElement("key", "Class"));
+        graphicsDict.appendChild(createElement("string", "ShapedGraphic"));
+        graphicsDict.appendChild(createElement("key", "FontInfo"));
+
+        Element fontDict = createElement("dict");
+        graphicsDict.appendChild(fontDict);
+        fontDict.appendChild(createElement("key", "Font"));
+        fontDict.appendChild(createElement("string", "HiraKakuProN-W3")); //fontの指定 下の方でもいろいろやってるからあれかも?
+        fontDict.appendChild(createElement("key", "Size"));
+        fontDict.appendChild(createElement("real", FONT_SIZE));
+
+        graphicsDict.appendChild(createElement("key", "ID"));
+        graphicsDict.appendChild(createElement("integer", String.valueOf(graphicsId)));
+        graphicsDict.appendChild(createElement("key", "Magnets"));
+
+        Element magnetArray = createElement("array");
+        graphicsDict.appendChild(magnetArray);
+        magnetArray.appendChild(createElement("string", "{0, 1}"));
+        magnetArray.appendChild(createElement("string", "{0, -1}"));
+        magnetArray.appendChild(createElement("string", "{1, 0}"));
+        magnetArray.appendChild(createElement("string", "{-1, 0}"));
+
+        graphicsDict.appendChild(createElement("key", "Shape"));
+        graphicsDict.appendChild(createElement("string", "Rectangle"));
+        graphicsDict.appendChild(createElement("key", "Style"));
+
+        Element styleDict = createElement("dict");
+        graphicsDict.appendChild(styleDict);
+        styleDict.appendChild(createElement("key", "shadow"));
+
+        Element shadowDict = createElement("dict");
+        styleDict.appendChild(shadowDict);
+        shadowDict.appendChild(createElement("key", "Draws"));
+        shadowDict.appendChild(createElement("string", "NO"));
+
+        graphicsDict.appendChild(createElement("key", "Text"));
+        Element textDict = createElement("dict");
+        graphicsDict.appendChild(textDict);
+        textDict.appendChild(createElement("key", "Text"));
+        String text = getText(node);
+        textDict.appendChild(createElement("string", text));
+        textDict.appendChild(createElement("key", "VerticalPad"));
+        textDict.appendChild(createElement("integer", "0"));
+        return new Pair<>(graphicsDict, graphicsId + 1);
+    }
+
+    private String getText(TreeNode node) throws UnsupportedEncodingException {
+        TreeNodeAttributes nodeAttribute = node.getAttributes();
+
+        Iterator<String> keys = nodeAttribute.getKeys();
+        String nodeValue = "";
+        while (keys.hasNext()) {
+            String key = keys.next();
+            String value = nodeAttribute.getString(key);
+            nodeValue += convertSjis(key);
+            nodeValue += ("  " + convertSjis(":") + "  ");
+            nodeValue += convertSjis(value);
+            nodeValue += "\\\n";
+        }
+
+        return "{\\rtf1\\ansi\\ansicpg932\\cocoartf1343\\cocoasubrtf140\n" +
+                "\\cocoascreenfonts1{\\fonttbl\\f0\\fnil\\fcharset128 HiraKakuProN-W3;}\n" +
+                "{\\colortbl;\\red255\\green255\\blue255;}\n" +
+                "\\pard\\tx560\\tx1120\\tx1680\\tx2240\\tx2800\\tx3360\\tx3920\\tx4480\\tx5040\\tx5600\\tx6160\\tx6720\\pardirnatural\\qc\n" +
+                "\n" + "\\f0\\fs24" + " \\cf0 " + nodeValue + "}";
+    }
+
+    private String convertSjis(String str) throws UnsupportedEncodingException {
+        String text = "";
+        byte[] bytes = str.getBytes("SJIS");
+        for (int count = 0; count < bytes.length; count++) {
+            String sjisByteCode1 = Integer.toHexString(bytes[count] & 0xFF);
+
+            text = text + "\\'" + sjisByteCode1;
+        }
+        return text;
+    }
+
+    private void createXMLTail() {
+        Element plist = document.getDocumentElement();
+        Element dict = (Element) plist.getLastChild();
+        dict.appendChild(createElement("key", "GridInfo"));//ここもまだ使いそう?
+        dict.appendChild(createElement("dict"));
+
+        dict.appendChild(createElement("key", "GuidesLocked"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "GuidesVisible"));
+        dict.appendChild(createElement("string", "YES"));
+        dict.appendChild(createElement("key", "HPages"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "ImageCounter"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "KeepToScale"));
+        dict.appendChild(createElement("false"));
+        dict.appendChild(createElement("key", "Layers"));
+
+        Element layerArray = createElement("array");
+        dict.appendChild(layerArray);
+
+        Element layerDict = createElement("dict");
+        layerArray.appendChild(layerDict);
+
+        layerDict.appendChild(createElement("key", "Lock"));
+        layerDict.appendChild(createElement("string", "NO"));
+        layerDict.appendChild(createElement("key", "Name"));
+        layerDict.appendChild(createElement("string", "レイヤー 1"));
+        layerDict.appendChild(createElement("key", "Print"));
+        layerDict.appendChild(createElement("string", "YES"));
+        layerDict.appendChild(createElement("key", "View"));
+        layerDict.appendChild(createElement("string", "YES"));
+
+        dict.appendChild(createElement("key", "LayoutInfo"));
+
+        Element layoutInfoDict = createElement("dict");
+        dict.appendChild(layoutInfoDict);
+
+        layoutInfoDict.appendChild(createElement("key", "Animate"));
+        layoutInfoDict.appendChild(createElement("string", "NO"));
+        layoutInfoDict.appendChild(createElement("key", "circoMinDist"));
+        layoutInfoDict.appendChild(createElement("real", "18"));
+        layoutInfoDict.appendChild(createElement("key", "circoSeparation"));
+        layoutInfoDict.appendChild(createElement("real", "0.0"));
+        layoutInfoDict.appendChild(createElement("key", "layoutEngine"));
+        layoutInfoDict.appendChild(createElement("string", "dot"));
+        layoutInfoDict.appendChild(createElement("key", "neatoSeparation"));
+        layoutInfoDict.appendChild(createElement("real", "0.0"));
+        layoutInfoDict.appendChild(createElement("key", "twopiSeparation"));
+        layoutInfoDict.appendChild(createElement("real", "0.0"));
+
+        dict.appendChild(createElement("key", "LinksVisible"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "MagnetsVisible"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "MasterSheets"));
+
+        Element mastersheetArray = createElement("array");
+        dict.appendChild(mastersheetArray);
+
+        dict.appendChild(createElement("key", "Modifier"));
+        dict.appendChild(createElement("string", "sister_clown"));
+        dict.appendChild(createElement("key", "NotesVisible"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "Orientation"));
+        dict.appendChild(createElement("string", "2"));
+        dict.appendChild(createElement("key", "OriginVisible"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "PageBreaks"));
+        dict.appendChild(createElement("string", "YES"));
+        dict.appendChild(createElement("key", "PrintInfo"));
+
+        Element printInfoDict = createElement("dict");
+        dict.appendChild(printInfoDict);
+        printInfoDict.appendChild(createElement("key", "NSBottomMargin"));
+
+        Element NSBottomMarginArray = createElement("array");
+        printInfoDict.appendChild(NSBottomMarginArray);
+        NSBottomMarginArray.appendChild(createElement("string", "float"));
+        NSBottomMarginArray.appendChild(createElement("string", "41"));
+
+        printInfoDict.appendChild(createElement("key", "NSHorizonalPagination"));
+        Element NSHorizonalPaginationArray = createElement("array");
+        printInfoDict.appendChild(NSHorizonalPaginationArray);
+
+        NSHorizonalPaginationArray.appendChild(createElement("string", "coded"));
+        NSHorizonalPaginationArray.appendChild(createElement("string", "BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG"));
+
+        printInfoDict.appendChild(createElement("key", "NSLeftMargin"));
+        Element NSLeftMarginArray = createElement("array");
+        printInfoDict.appendChild(NSLeftMarginArray);
+        NSLeftMarginArray.appendChild(createElement("string", "float"));
+        NSLeftMarginArray.appendChild(createElement("string", "18"));
+
+        printInfoDict.appendChild(createElement("key", "NSPaperSize"));
+        Element NSPaperNameArray = createElement("array");
+        printInfoDict.appendChild(NSPaperNameArray);
+        NSPaperNameArray.appendChild(createElement("string", "size"));//キャンパスサイズっぽい
+        NSPaperNameArray.appendChild(createElement("string", "{1000,1000}"));
+
+        printInfoDict.appendChild(createElement("key", "NSPrintReverseOrientation"));
+        Element NSPrintReverseOrientationArray = createElement("array");
+        printInfoDict.appendChild(NSPrintReverseOrientationArray);
+        NSPrintReverseOrientationArray.appendChild(createElement("string", "int"));
+        NSPrintReverseOrientationArray.appendChild(createElement("string", "0"));
+
+        printInfoDict.appendChild(createElement("key", "NSRightMargin"));
+        Element NSRightMarginArray = createElement("array");
+        printInfoDict.appendChild(NSRightMarginArray);
+        NSRightMarginArray.appendChild(createElement("string", "float"));
+        NSRightMarginArray.appendChild(createElement("string", "18"));
+
+        printInfoDict.appendChild(createElement("key", "NSTopMargin"));
+        Element NSTopMarginArray = createElement("array");
+        printInfoDict.appendChild(NSTopMarginArray);
+        NSTopMarginArray.appendChild(createElement("string", "float"));
+        NSTopMarginArray.appendChild(createElement("string", "18"));
+
+        dict.appendChild(createElement("key", "PrintOnePage"));
+        dict.appendChild(createElement("false"));
+        dict.appendChild(createElement("key", "ReadOnly"));
+        dict.appendChild(createElement("string", "NO"));
+        dict.appendChild(createElement("key", "RowAlign"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "RowSpacing"));
+        dict.appendChild(createElement("real", "36"));
+        dict.appendChild(createElement("key", "SheetTitle"));
+        dict.appendChild(createElement("string", "キャンバス 1"));
+        dict.appendChild(createElement("key", "SmartAlignmentGuidesActive"));
+        dict.appendChild(createElement("string", "YES"));
+        dict.appendChild(createElement("key", "SmartDistanceGuidesActive"));
+        dict.appendChild(createElement("string", "YES"));
+        dict.appendChild(createElement("key", "UniqueID"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "UseEntirePage"));
+        dict.appendChild(createElement("false"));
+        dict.appendChild(createElement("key", "VPages"));
+        dict.appendChild(createElement("integer", "1"));
+        dict.appendChild(createElement("key", "WindowInfo"));
+
+        Element WindowInfoDict = createElement("dict");
+        dict.appendChild(WindowInfoDict);
+        WindowInfoDict.appendChild(createElement("key", "CurrentSheet"));
+        WindowInfoDict.appendChild(createElement("integer", "0"));
+        WindowInfoDict.appendChild(createElement("key", "ExpandedCanvases"));
+        WindowInfoDict.appendChild(createElement("array"));
+        WindowInfoDict.appendChild(createElement("key", "Frame"));
+        WindowInfoDict.appendChild(createElement("string", "{{513, 0}, {1122, 1154}}")); //後で変える必要があるかも?
+        WindowInfoDict.appendChild(createElement("key", "ListView"));
+        WindowInfoDict.appendChild(createElement("true"));
+        WindowInfoDict.appendChild(createElement("key", "OutlineWidth"));
+        WindowInfoDict.appendChild(createElement("integer", "142"));
+        WindowInfoDict.appendChild(createElement("key", "RightSidebar"));
+        WindowInfoDict.appendChild(createElement("false"));
+        WindowInfoDict.appendChild(createElement("key", "ShowRuler"));
+        WindowInfoDict.appendChild(createElement("true"));
+        WindowInfoDict.appendChild(createElement("key", "Sidebar"));
+        WindowInfoDict.appendChild(createElement("true"));
+        WindowInfoDict.appendChild(createElement("key", "SidebarWidth"));
+        WindowInfoDict.appendChild(createElement("integer", "120"));
+        WindowInfoDict.appendChild(createElement("key", "VisibleRegion"));
+        WindowInfoDict.appendChild(createElement("string", "{{-708, -620}, {1974, 2024}}")); //変える以下略
+        WindowInfoDict.appendChild(createElement("key", "Zoom"));
+        WindowInfoDict.appendChild(createElement("real", "1"));
+        WindowInfoDict.appendChild(createElement("key", "ZoomValues"));
+
+        Element ZoomValuesArray = createElement("array");
+        WindowInfoDict.appendChild(ZoomValuesArray);
+
+        Element ZoomValuesArrayChild = createElement("array");
+        ZoomValuesArray.appendChild(ZoomValuesArrayChild);
+        ZoomValuesArrayChild.appendChild(createElement("string", "キャンバス 1"));
+        ZoomValuesArrayChild.appendChild(createElement("real", "1"));
+        ZoomValuesArrayChild.appendChild(createElement("real", "1"));
+
+
+    }
+
+    private Element createElement(String key) {
+        return document.createElement(key);
+    }
+
+    private Element createElement(String key, String value) {
+        Element element = document.createElement(key);
+        element.appendChild(document.createTextNode(value));
+        return element;
+    }
+
+    private boolean write() throws TransformerException, FileNotFoundException {
+        TransformerFactory transFactory = TransformerFactory.newInstance();
+        Transformer transformer = transFactory.newTransformer();
+        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+        transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, SYSTEM_ID);
+        transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, PUBLIC_ID);
+        transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "8");
+
+        DOMSource source = new DOMSource(document);
+        File file = new File("omnigraffle/" + file_name + ".graffle");
+        FileOutputStream os = new FileOutputStream(file);
+        StreamResult result = new StreamResult(os);
+        transformer.transform(source, result);
+        System.out.println("put " + file_name);
+        return true;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/InsertNodePositionData.java	Tue Jul 05 01:56:11 2016 +0900
@@ -0,0 +1,126 @@
+package jp.ac.u_ryukyu.ie.cr.jungle.store.omnigraffle;
+
+import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree;
+import jp.ac.u_ryukyu.ie.cr.jungle.query.PathNodeIterator;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNodeChildren;
+import jp.ac.u_ryukyu.ie.cr.jungle.store.index.ParentIndex;
+import jp.ac.u_ryukyu.ie.cr.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.jungle.util.Error;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Optional;
+import java.util.TreeMap;
+
+public class InsertNodePositionData {
+
+    private JungleTree tree;
+    private TreeMap<TreeNode, NodePoint> treeMap = new TreeMap<>();
+    private LinkedList<TreeNode> nodeList = new LinkedList<>();
+    /*
+     *    NodeのX座標を決める際に使用する
+     *    葉の方から座標を指定していく
+     *    このListにはまだX座標が決まっていない葉Nodeが格納される
+     *    X座標格納後はそのNodeの親が格納される
+     *    この中身が空になったら全てのNodeにX座標の格納が終わったということ
+     */
+
+    private int NODE_Y_GAP = 300;
+    private final int X_GAP = 300; //ノードとノードの隙間
+    private int MAX_X = 100;
+
+
+    public InsertNodePositionData(JungleTree tree) {
+        this.tree = tree;
+    }
+
+    public TreeMap<TreeNode, NodePoint> InsertPositionData() {
+        ParentIndex parentIndex = tree.getParentIndex();
+        TreeNode rootNode = tree.getRootNode();
+        PathNodeIterator nodeIterator = new PathNodeIterator(rootNode);
+
+        NodePoint rootPoint = new NodePoint(); //まずはrootのY座標を指定する、Y座標を指定する際は親Nodeを参照するため、rootだけは別に処理を書く必要がある
+        rootPoint.setY(NODE_Y_GAP);
+        treeMap.put(rootNode, rootPoint);
+
+        while (nodeIterator.hasNext()) {
+            TreeNode currentNode = nodeIterator.next();
+            Iterator<TreeNode> children = currentNode.getChildren().iterator();
+            if (!children.hasNext()) { //子供が空の場合Listに格納する
+                nodeList.add(currentNode);
+            } else {
+                while (children.hasNext()) {//子がある場合このY座標を設定する
+                    setYPosition(currentNode, children.next());
+                }
+            }
+        }
+
+        for (int num = 0; nodeList.size() > 0; ) { //Listの中にはX座標の格納が終わっていないNodeが入る X座標は子Nodeの最初のNodeと最後のNodeのX座標を足し、2で割った値を格納する
+            TreeNode node = nodeList.get(num);
+            TreeNodeChildren children = node.getChildren();
+            int childrenSize = children.size() - 1; //childのlastを取る時に使う
+            if (childrenSize == -1) {
+                NodePoint np = treeMap.get(node);
+                np.setX(MAX_X);
+                MAX_X = MAX_X + X_GAP;
+                nodeList.remove(num);
+                Optional<TreeNode> parentNodeOp = parentIndex.get(node);//子のX座標のデータを格納したら親をListに入れ、X格納の準備をする
+                if (parentNodeOp.isPresent()) {
+                    TreeNode parentNode = parentNodeOp.get();
+                    if (!nodeList.contains(parentNode)) //親ノードがまだListに登録されていない場合登録する
+                        nodeList.add(parentNode);
+                }
+                continue;
+            }
+
+            Either<Error, TreeNode> firstChildEither = children.at(0);
+            if (firstChildEither.isA()) {
+                System.out.println("ノードが見つかりません");
+                throw new NullPointerException();
+            }
+            TreeNode firstChild = firstChildEither.b();
+
+            Either<Error, TreeNode> lastChildEither = children.at(childrenSize);
+            if (lastChildEither.isA()) {
+                System.out.println("ノードが見つかりません");
+                throw new NullPointerException();
+            }
+            TreeNode lastChild = lastChildEither.b();
+            NodePoint firstChildPoint = treeMap.get(firstChild);
+            NodePoint lastChildPoint = treeMap.get(lastChild);
+
+            if (firstChildPoint.getX() != 0 && lastChildPoint.getX() != 0) {  //最初のNodeと最後のNodeのX座標がすでに格納されている場合
+                NodePoint np = treeMap.get(node);
+                np.setX((firstChildPoint.getX() + lastChildPoint.getX()) / 2);
+                nodeList.remove(num);
+                Optional<TreeNode> parentNodeOp = parentIndex.get(node);//子のX座標のデータを格納したら親をListに入れ、X格納の準備をする
+                if (parentNodeOp.isPresent())
+                    nodeList.add(parentNodeOp.get());
+            }
+
+            if (num > nodeList.size())
+                num = 0;
+        }
+
+        for (TreeNode node : treeMap.keySet()) {
+            NodePoint point = treeMap.get(node);
+            System.out.println("----------------------------");
+            System.out.println(node.getAttributes().getString("element"));
+            System.out.println(node.getAttributes().getString("name"));
+            System.out.println("Y = " + point.getY());
+            System.out.println("X = " + point.getX());
+            System.out.println("----------------------------");
+        }
+        return treeMap;
+    }
+
+    private void setYPosition(TreeNode parrentNode, TreeNode childNode) {
+        NodePoint parrentPosition = treeMap.get(parrentNode);
+        int parrentY = parrentPosition.getY();
+        NodePoint childPosition = new NodePoint();
+        childPosition.setY(parrentY + NODE_Y_GAP);
+        treeMap.put(childNode, childPosition);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/NodePoint.java	Tue Jul 05 01:56:11 2016 +0900
@@ -0,0 +1,42 @@
+package jp.ac.u_ryukyu.ie.cr.jungle.store.omnigraffle;
+
+public class NodePoint {
+
+    private int x = 0;
+    private int y = 0;
+    private int width = 200;
+    private int height = 200;
+
+
+    public int getX() {
+        return x;
+    }
+
+    public void setX(int x) {
+        this.x = x;
+    }
+
+    public int getY() {
+        return y;
+    }
+
+    public void setY(int y) {
+        this.y = y;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/InterfaceTraverser.java	Tue Jun 28 07:06:10 2016 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/InterfaceTraverser.java	Tue Jul 05 01:56:11 2016 +0900
@@ -57,142 +57,7 @@
         parentIndex = creater.getParentIndex();
     }
 
-    /**
-     * subTree以下のNodeに対してKey,Valueのペアでindexを使って探索を行う
-     *
-     * @param query
-     * @param subTree
-     * @param key
-     * @param searchValue
-     * @return
-     */
-    // public Iterator<TreeNode> findInSubTree(final Query query, TreeNode
-    // subTree, String key, String searchValue) {
-    // /*
-    // * indexを使って取ってきたNodeのPathと、subTreeのPathを先頭から1つずつ比較し、
-    // * indexから取ってきたNodeのPathが一致した場合、そのNodeを返す
-    // */
-    // Iterator<TreeNode> nodeIterator = index.get(key, searchValue);
-    // if (nodeIterator.hasNext() && useIndex) {
-    //
-    // // ここでNode以下にあるか調べる
-    // List<TreeNode> filteredList = List.nil();
-    //
-    // for (;nodeIterator.hasNext();) {
-    // TreeNode targetNode = nodeIterator.next();
-    // TreeNode parent = targetNode;
-    // while (parent != null) {
-    // parent = parentIndex.get(parent);
-    // if (parent.equals(subTree))
-    // filteredList = filteredList.cons(targetNode);
-    // }
-    // }
-    //
-    // return filteredList.iterator();
-    //
-    // } else {
-    // final PathNodeIterator itNode = new PathNodeIterator(subTree);
-    // return new Iterator<TreeNode>() {
-    //
-    // private TreeNode matchNode = nextmatch(itNode);
-    //
-    // private TreeNode nextmatch(PathNodeIterator itNode) {
-    //
-    // for (; itNode.hasNext();) {
-    // TreeNode targetNode = itNode.next();
-    // if (query.condition(targetNode))
-    // return targetNode;
-    // }
-    // return null;
-    // }
-    //
-    // @Override
-    // public boolean hasNext() {
-    // if (matchNode == null) {
-    // return false;
-    // }
-    // return true;
-    // }
-    //
-    // @Override
-    // public TreeNode next() {
-    // TreeNode currentNode = matchNode;
-    // matchNode = nextmatch(itNode);
-    // return currentNode;
-    // }
-    //
-    // @Override
-    // public void remove() {
-    // }
-    //
-    // };
-    // }
-    // }
 
-    /**
-     * subTree以下のNodeに対してKeyに対応する値をindexを使って探索する
-     */
-    // public Iterator<TreeNode> findInSubTreeAllValue(final Query query, TreeNode
-    // subTree, String key) {
-    // /*
-    // * indexからinnerIndexを取得 取得したinnerIndexが保有するKeyを取得
-    // * そのKeyを保有するNodeとNodeのPathを取得する
-    // * indexを使って取ってきたNodeのPathと、subTreeのPathを先頭から1つずつ比較し、
-    // * indexから取ってきたNodeのPathが一致した場合、そのNodeを返す
-    // */
-    // Iterator<TreeNode> NodeIterator = index.getAll(key);
-    // if (NodeIterator != null && useIndex) {
-    // List<TreeNode> filteredList = List.nil();
-    // for (; NodeIterator.hasNext();) {
-    // TreeNode targetNode = NodeIterator.next();
-    // TreeNode parent = targetNode;
-    // while (parent != null) {
-    // parent = parentIndex.get(parent);
-    // if (parent.equals(subTree))
-    // filteredList = filteredList.cons(targetNode);
-    // }
-    // }
-    // return filteredList.iterator();
-    //
-    // } else {
-    //
-    // final PathNodeIterator itNode = new PathNodeIterator(subTree);
-    // return new Iterator<TreeNode>() {
-    //
-    // private TreeNode matchPair = nextmatch(itNode);
-    //
-    // private TreeNode nextmatch(PathNodeIterator itNode) {
-    //
-    // for (; itNode.hasNext();) {
-    // TreeNode targetNode = itNode.next();
-    // if (query.condition(targetNode))
-    // return targetNode;
-    // }
-    // return null;
-    // }
-    //
-    // @Override
-    // public boolean hasNext() {
-    // if (matchPair == null) {
-    // return false;
-    // }
-    // return true;
-    // }
-    //
-    // @Override
-    // public TreeNode next() {
-    // TreeNode currentNode = matchPair;
-    // matchPair = nextmatch(itNode);
-    // return currentNode;
-    // }
-    //
-    // @Override
-    // public void remove() {
-    // }
-    //
-    // };
-    // }
-    // }
     private TreeNode nextmatch(TreeNode node, Query query) {
         if (query.condition(node))
             return node;
@@ -253,61 +118,6 @@
         };
     }
 
-    // public Iterator<TreeNode> findAll(final Query query, final String key) {
-    //
-    // Iterator<TreeNode> nodeList = index.getAll(key);
-    // if (nodeList != null && useIndex) {
-    //
-    // return nodeList;
-    //
-    // } else {
-    //
-    // final PathNodeIterator itNode = new PathNodeIterator(node);
-    // return new Iterator<TreeNode>() {
-    //
-    // private TreeNode matchNode = nextmatch(itNode);
-    //
-    // private TreeNode nextmatch(PathNodeIterator itNode) {
-    //
-    // for (; itNode.hasNext();) {
-    // TreeNode targetNode = itNode.next();
-    // String value = targetNode.getAttributes().getString(key);
-    // if (useIndex) {
-    // if (value != null)
-    // index = index.set(key, value, targetNode);
-    // }
-    // if (parentUpdateFlag);
-    // // parentIndex = parentIndex.set(targetNode);
-    // if (query.condition(targetNode))
-    // return targetNode;
-    // }
-    // if (useIndex || parentUpdateFlag)
-    // commit();
-    // return null;
-    // }
-    //
-    // @Override
-    // public boolean hasNext() {
-    // if (matchNode == null) {
-    // return false;
-    // }
-    // return true;
-    // }
-    //
-    // @Override
-    // public TreeNode next() {
-    // TreeNode currentPair = matchNode;
-    // matchNode = nextmatch(itNode);
-    // return currentPair;
-    // }
-    //
-    // @Override
-    // public void remove() {
-    // }
-    //
-    // };
-    // }
-    // }
 
     public Iterator<TreeNode> get(String key, String value) {
         Optional<TreeMap<String, List<TreeNode>>> indexOp = indexList.get(key);