svnno****@sourc*****
svnno****@sourc*****
2009年 2月 6日 (金) 00:24:17 JST
Revision: 2616 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2616 Author: daisuke_m Date: 2009-02-06 00:24:17 +0900 (Fri, 06 Feb 2009) Log Message: ----------- DomSerializer、XMLは完全一致に到達!>< Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-04 07:45:14 UTC (rev 2615) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-05 15:24:17 UTC (rev 2616) @@ -21,6 +21,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import java.io.ByteArrayInputStream; @@ -249,6 +250,9 @@ FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + "_test1_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8); + assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); + assertEquals(xml1, xml2); + assertThat(equals, is(true)); assertThat(xml2, is(xml1)); } @@ -294,6 +298,9 @@ FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + "_test2_gtree2.txt"), EqualsUtil.leftGTree, CharEncoding.UTF_8); + assertEquals(EqualsUtil.rightGTree, EqualsUtil.leftGTree); + assertEquals(xml1, xml2); + assertThat(equals, is(true)); assertThat(xml2, is(xml1)); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-04 07:45:14 UTC (rev 2615) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-05 15:24:17 UTC (rev 2616) @@ -174,6 +174,21 @@ } } + protected enum ForeignKeyComparator implements Comparator<ForeignKeyModel> { + + /** singleton instance */ + INSTANCE; + + public int compare(ForeignKeyModel o1, ForeignKeyModel o2) { + int classNameComparison = o1.getClass().getName().compareTo(o2.getClass().getName()); + if (classNameComparison != 0) { + return classNameComparison; + } + + return o1.getId().compareTo(o2.getId()); + } + } + protected static class TableRefComparator implements Comparator<TableRef> { private final Jiemamy jiemamy; Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-04 07:45:14 UTC (rev 2615) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-05 15:24:17 UTC (rev 2616) @@ -22,9 +22,9 @@ import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.lang.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -130,7 +130,10 @@ boundaryElement.setAttribute("y", Integer.toString(nodeProfile.getLayout().y)); boundaryElement.setAttribute("width", Integer.toString(nodeProfile.getLayout().width)); boundaryElement.setAttribute("height", Integer.toString(nodeProfile.getLayout().height)); - boundaryElement.setAttribute("color", ObjectUtils.toString(nodeProfile.getColor())); + JmColor color = nodeProfile.getColor(); + if (color != null) { + boundaryElement.setAttribute("color", color.toString()); + } logger.info(" boundary: " + boundaryElement); } Element connectionLayoutsElement = DomUtil.newChild(presentationElement, ViewQName.CONNECTION_LAYOUTS); @@ -215,7 +218,8 @@ int width = Integer.valueOf(XpathUtil.getAttr(nodeLayoutNode, "view:boundary/@width").getValue()); int height = Integer.valueOf(XpathUtil.getAttr(nodeLayoutNode, "view:boundary/@height").getValue()); JmRectangle rect = new JmRectangle(x, y, width, height); - JmColor color = JmColor.parse(XpathUtil.getAttr(nodeLayoutNode, "view:boundary/@color").getValue()); + Attr colorAttr = XpathUtil.getAttr(nodeLayoutNode, "view:boundary/@color"); + JmColor color = colorAttr == null ? null : JmColor.parse(colorAttr.getValue()); PresentationUtil.setLayout(presentation, nodeAdapter, rect); PresentationUtil.setColor(presentation, nodeAdapter, color); Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-04 07:45:14 UTC (rev 2615) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-05 15:24:17 UTC (rev 2616) @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Comparator; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.TreeMap; @@ -79,7 +78,8 @@ } else if (clazz == DiagramPresentationModel.class) { assert product == null; DiagramPresentationModelImpl presentation = new DiagramPresentationModelImpl(jiemamy, id); - presentation.setConnectionLayouts(new HashMap<ConnectionAdapter, List<JmPoint>>()); + presentation.setConnectionLayouts(new TreeMap<ConnectionAdapter, List<JmPoint>>( + ConnectionComparator.INSTANCE)); presentation.setDisplayTargetSet(new HashSet<DisplayItem>()); presentation.setNodeLayouts(new TreeMap<NodeAdapter, NodeProfile>(NodeComparator.INSTANCE)); product = clazz.cast(presentation); @@ -96,6 +96,26 @@ } } + protected enum ConnectionComparator implements Comparator<ConnectionAdapter> { + + /** singleton instance */ + INSTANCE; + + public int compare(ConnectionAdapter o1, ConnectionAdapter o2) { + ForeignKeyModel f1 = o1.unwrap(); + ForeignKeyModel f2 = o2.unwrap(); + if (f1 != null && f2 != null) { + return FactoryExtension.ForeignKeyComparator.INSTANCE.compare(f1, f2); + } else if (f1 != null) { + return 1; + } else if (f2 != null) { + return -1; + } else { + return 0; + } + } + } + /** * エンティティのソートオーダーを決めるコンパレータ。 * Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java 2009-02-04 07:45:14 UTC (rev 2615) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ViewTestModelBuilder.java 2009-02-05 15:24:17 UTC (rev 2616) @@ -27,6 +27,7 @@ import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.NodeProfile; import org.jiemamy.model.connection.ConnectionAdapter; +import org.jiemamy.model.geometory.JmColor; import org.jiemamy.model.geometory.JmPoint; import org.jiemamy.model.geometory.JmRectangle; import org.jiemamy.model.node.NodeAdapter; @@ -153,6 +154,7 @@ PresentationUtil.setLayout(presentation, viewHighSal.getAdapter(NodeAdapter.class), new JmRectangle(60, 270)); PresentationUtil.setLayout(presentation, sticky, new JmRectangle(360, 270)); + PresentationUtil.setColor(presentation, sticky, new JmColor(10, 11, 12)); List<JmPoint> bendpoints = new ArrayList<JmPoint>(); NodeProfile nodeProf = presentation.getFigureProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-04 07:45:14 UTC (rev 2615) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-05 15:24:17 UTC (rev 2616) @@ -495,32 +495,32 @@ <view:sticky id="43beb884-2562-4480-8030-bb797f701783"> <view:contents>メモーー</view:contents> </view:sticky> - <view:boundary color="#ff00ff" height="-1" width="-1" x="360" y="270"/> + <view:boundary color="#0a0b0c" height="-1" width="-1" x="360" y="270"/> </view:nodeLayout> <view:nodeLayout> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> - <view:boundary color="#ff00ff" height="-1" width="-1" x="360" y="60"/> + <view:boundary height="-1" width="-1" x="360" y="60"/> </view:nodeLayout> <view:nodeLayout> <view:nodeObjectRef ref="d7489ed6-0add-443d-95cf-234376eb0455"/> - <view:boundary color="#ff00ff" height="-1" width="-1" x="60" y="60"/> + <view:boundary height="-1" width="-1" x="60" y="60"/> </view:nodeLayout> <view:nodeLayout> <view:nodeObjectRef ref="516f7961-cb7b-48e2-990b-7fb0c750c3a4"/> - <view:boundary color="#ff00ff" height="-1" width="-1" x="60" y="270"/> + <view:boundary height="-1" width="-1" x="60" y="270"/> </view:nodeLayout> </view:nodeLayouts> <view:connectionLayouts> <view:connectionLayout> - <view:connectionObjectRef ref="e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed"/> - </view:connectionLayout> - <view:connectionLayout> <view:connectionObjectRef ref="e43d3c43-33c8-4b02-aa42-83f2d868cfe6"/> <view:bendpoints> <view:bendpoint x="310" y="60"/> <view:bendpoint x="360" y="10"/> </view:bendpoints> </view:connectionLayout> + <view:connectionLayout> + <view:connectionObjectRef ref="e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed"/> + </view:connectionLayout> </view:connectionLayouts> </view:diagramPresentation> <view:diagramPresentation id="53c7cdb7-1512-46c7-8ee3-aadec6007896"> @@ -528,11 +528,11 @@ <view:nodeLayouts> <view:nodeLayout> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> - <view:boundary color="#ff00ff" height="-1" width="-1" x="60" y="60"/> + <view:boundary height="-1" width="-1" x="60" y="60"/> </view:nodeLayout> <view:nodeLayout> <view:nodeObjectRef ref="516f7961-cb7b-48e2-990b-7fb0c750c3a4"/> - <view:boundary color="#ff00ff" height="-1" width="-1" x="270" y="270"/> + <view:boundary height="-1" width="-1" x="270" y="270"/> </view:nodeLayout> </view:nodeLayouts> <view:connectionLayouts>