[openrtm-commit:02639] r737 - in trunk/rtmtools/jp.go.aist.rtm.toolscommon: src/jp/go/aist/rtm/toolscommon/model/manager/impl src/jp/go/aist/rtm/toolscommon/util test/jp/go/aist/rtm/toolscommon/util
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 6月 18日 (日) 12:21:48 JST
Author: ga
Date: 2017-06-18 12:21:48 +0900 (Sun, 18 Jun 2017)
New Revision: 737
Added:
trunk/rtmtools/jp.go.aist.rtm.toolscommon/test/jp/go/aist/rtm/toolscommon/util/RtcProfileHandlerTest.java
Modified:
trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/manager/impl/RTCManagerImpl.java
trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java
Log:
Modified Manager View #4122
Modified: trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/manager/impl/RTCManagerImpl.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/manager/impl/RTCManagerImpl.java 2017-05-08 01:58:31 UTC (rev 736)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/model/manager/impl/RTCManagerImpl.java 2017-06-18 03:21:48 UTC (rev 737)
@@ -6,9 +6,7 @@
*/
package jp.go.aist.rtm.toolscommon.model.manager.impl;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import jp.go.aist.rtm.toolscommon.model.component.Component;
import jp.go.aist.rtm.toolscommon.model.component.ComponentFactory;
@@ -35,7 +33,6 @@
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
-import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -923,7 +920,8 @@
.get_configuration()) {
NameValue nv = ComponentFactory.eINSTANCE.createNameValue();
nv.setName(n.name);
- nv.setValue(n.value.toString());
+// nv.setValue(n.value.toString());
+ nv.setValue(SDOUtil.toAnyString(n.value));
this.configuratoins.add(nv);
}
return this.configuratoins;
Modified: trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java 2017-05-08 01:58:31 UTC (rev 736)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon/src/jp/go/aist/rtm/toolscommon/util/RtsProfileHandler.java 2017-06-18 03:21:48 UTC (rev 737)
@@ -811,19 +811,51 @@
// ベンドポイントの文字列表現からをMap表現のエントリを1つ取り出して、セットする
private String populatePoint(Map<Integer, Point> result, String content) {
- String key = content.substring(0, content.indexOf(":"));
- String value = content.substring(content.indexOf(":") + 1).trim();
- String x = value.substring(1, value.indexOf(",")).trim();
- value = value.substring(value.indexOf(",") + 1).trim();
- String y = value.substring(0, value.indexOf(")")).trim();
+ int pos = content.indexOf(":");
+ if (pos < 0) {
+ if (content.indexOf(",") >= 0) {
+ return content.substring(content.indexOf(",") + 1).trim();
+ } else {
+ return "";
+ }
+ }
+ String key = content.substring(0, pos).trim();
+ String value = content.substring(pos + 1).trim();
+ if (key.indexOf(",") >= 0) {
+ return content.substring(content.indexOf(",") + 1).trim();
+ }
+ // インデックス部の解析
+ Integer keyi = null;
+ try {
+ keyi = new Integer(key);
+ } catch (NumberFormatException e) {
+ return content.substring(content.indexOf(",") + 1).trim();
+ }
+ // 座標部の解析
+ Integer xi, yi = null;
+ if (value.startsWith("(")) {
+ value = value.substring(1).trim();
+ }
+ pos = value.indexOf(",");
+ try {
+ xi = new Integer(value.substring(0, pos).trim());
+ } catch (NumberFormatException e) {
+ return value.substring(pos + 1).trim();
+ }
+ value = value.substring(pos + 1).trim();
+ pos = value.indexOf(")");
+ try {
+ yi = new Integer(value.substring(0, pos).trim());
+ } catch (NumberFormatException e) {
+ return value;
+ }
+ value = value.substring(pos + 1).trim();
Point point = new Point();
- point.setX(Integer.parseInt(x));
- point.setY(Integer.parseInt(y));
- result.put(new Integer(key), point);
-
- if (value.indexOf(",") < 0) return "";
- return value.substring(value.indexOf(",") + 1).trim();
+ point.setX(xi);
+ point.setY(yi);
+ result.put(keyi, point);
+ return value;
}
// RTSプロファイルからEMFコンポーネントを復元する
@@ -1207,9 +1239,6 @@
private Map<Integer, Point> getBendPoint(
List<org.openrtp.namespaces.rts.version02.Property> properties) {
String bendPointString = findProperyValue(KEY_BEND_POINT, properties);
- if (bendPointString == null) {
- return null;
- }
return convertFromBendPointString(bendPointString);
}
@@ -1216,10 +1245,15 @@
// ベンドポイントの文字列表現をMap表現に変換する
public Map<Integer, Point> convertFromBendPointString(String bendPoint) {
if (StringUtils.isBlank(bendPoint)) {
- return null;
+ return new HashMap<Integer, Point>();
}
String content = bendPoint.trim();
- content = content.substring(1, content.length() - 1).trim(); // { }除去
+ if (content.startsWith("{")) {
+ content = content.substring(1).trim(); // "{"除去
+ }
+ if (content.endsWith("}")) {
+ content = content.substring(0, content.length() - 1).trim(); // "}"除去
+ }
Map<Integer, Point> result = new HashMap<Integer, Point>();
while (content.length() > 0) {
content = populatePoint(result, content);
Added: trunk/rtmtools/jp.go.aist.rtm.toolscommon/test/jp/go/aist/rtm/toolscommon/util/RtcProfileHandlerTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.toolscommon/test/jp/go/aist/rtm/toolscommon/util/RtcProfileHandlerTest.java (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.toolscommon/test/jp/go/aist/rtm/toolscommon/util/RtcProfileHandlerTest.java 2017-06-18 03:21:48 UTC (rev 737)
@@ -0,0 +1,75 @@
+package jp.go.aist.rtm.toolscommon.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import jp.go.aist.rtm.toolscommon.model.core.Point;
+
+import org.junit.Test;
+
+public class RtcProfileHandlerTest {
+
+ @Test
+ public void testConvertFromBendPointString() {
+ RtsProfileHandler handler = new RtsProfileHandler();
+
+ // ブランクパターン
+ {
+ String[] patterns = new String[] { null, "", "{}", "{", "}" };
+ for (String pattern : patterns) {
+ Map<Integer, Point> points = handler
+ .convertFromBendPointString(pattern);
+ String msg = String.format("pattern: <%s>", pattern);
+ assertNotNull(msg, points);
+ assertTrue(msg, points.isEmpty());
+ }
+ }
+
+ // 2ポイント正常+ポイント書式不正パターン
+ {
+ String[] patterns = new String[] { //
+ "{1:(100,100),2:(200,200)}", // 正常
+ " { 1 : ( 100 , 100 ) , 2 : ( 200 , 200 ) } ", // 正常(スペースあり)
+ "1:(100,100),2:(200,200)", // 正常(外括弧なし)
+ "{1:(100,100),,2:(200,200)}",
+ "{1:(100,100),3,2:(200,200)}",
+ "{1:(100,100),:,2:(200,200)}",
+ "{1:(100,100),3:,2:(200,200)}",
+ "{1:(100,100),3:(,2:(200,200)}",
+ "{1:(100,100),3:),2:(200,200)}",
+ "{1:(100,100),3:(),2:(200,200)}",
+ "{1:(100,100),3:(,),2:(200,200)}",
+ "{1:(100,100),3:(150,),2:(200,200)}",
+ "{1:(100,100),3:(,150),2:(200,200)}" };
+ for (String pattern : patterns) {
+ Map<Integer, Point> points = handler
+ .convertFromBendPointString(pattern);
+ String msg = String.format("pattern: <%s>", pattern);
+ assertNotNull(msg, points);
+ assertEquals(msg, 2, points.size());
+ assertEquals(msg, 100, points.get(1).getX());
+ assertEquals(msg, 100, points.get(1).getY());
+ assertEquals(msg, 200, points.get(2).getX());
+ assertEquals(msg, 200, points.get(2).getY());
+ }
+ }
+
+ // 3ポイント正常パターン
+ {
+ Map<Integer, Point> points = handler
+ .convertFromBendPointString("{1:(100,100),3:(150,150),2:(200,200)}");
+ assertNotNull(points);
+ assertEquals(3, points.size());
+ assertEquals(100, points.get(1).getX());
+ assertEquals(100, points.get(1).getY());
+ assertEquals(200, points.get(2).getX());
+ assertEquals(200, points.get(2).getY());
+ assertEquals(150, points.get(3).getX());
+ assertEquals(150, points.get(3).getY());
+ }
+ }
+
+}
Property changes on: trunk/rtmtools/jp.go.aist.rtm.toolscommon/test/jp/go/aist/rtm/toolscommon/util/RtcProfileHandlerTest.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
More information about the openrtm-commit
mailing list