Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Christnowx
Gephi
提交
2b38907d
G
Gephi
项目概览
Christnowx
/
Gephi
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gephi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b38907d
编写于
11月 25, 2015
作者:
M
Mathieu Bastian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix import container factory and add addTimestamps() and addIntervals() methods to ElementDraft
上级
daafd56b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
16 deletion
+80
-16
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ElementDraft.java
...src/main/java/org/gephi/io/importer/api/ElementDraft.java
+5
-0
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementDraftImpl.java
...ain/java/org/gephi/io/importer/impl/ElementDraftImpl.java
+73
-14
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementFactoryImpl.java
...n/java/org/gephi/io/importer/impl/ElementFactoryImpl.java
+2
-2
未找到文件。
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ElementDraft.java
浏览文件 @
2b38907d
...
...
@@ -42,6 +42,7 @@
package
org.gephi.io.importer.api
;
import
java.awt.Color
;
import
org.gephi.graph.api.Interval
;
import
org.gephi.graph.api.types.TimeSet
;
/**
...
...
@@ -370,10 +371,14 @@ public interface ElementDraft {
public
void
addTimestamp
(
String
dateTime
);
public
void
addTimestamps
(
String
timestamps
);
public
void
addInterval
(
double
start
,
double
end
);
public
void
addInterval
(
String
startDateTime
,
String
endDateTime
);
public
void
addIntervals
(
String
intervals
);
public
TimeSet
getTimeSet
();
public
Iterable
<
ColumnDraft
>
getColumns
();
...
...
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementDraftImpl.java
浏览文件 @
2b38907d
...
...
@@ -45,6 +45,7 @@ package org.gephi.io.importer.impl;
import
java.awt.Color
;
import
org.gephi.graph.api.AttributeUtils
;
import
org.gephi.graph.api.Interval
;
import
org.gephi.graph.api.TimeFormat
;
import
org.gephi.graph.api.TimeRepresentation
;
import
org.gephi.graph.api.types.IntervalMap
;
import
org.gephi.graph.api.types.IntervalSet
;
...
...
@@ -230,7 +231,7 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
setValue
(
String
key
,
Object
value
,
String
dateTime
)
{
setValue
(
key
,
value
,
AttributeUtils
.
parseDateTime
(
dateTime
));
setValue
(
key
,
value
,
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
dateTime
)
:
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
...
...
@@ -246,7 +247,18 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
setValue
(
String
key
,
Object
value
,
String
startDateTime
,
String
endDateTime
)
{
setValue
(
key
,
value
,
AttributeUtils
.
parseDateTime
(
startDateTime
),
AttributeUtils
.
parseDateTime
(
endDateTime
));
double
start
,
end
;
if
(
startDateTime
==
null
||
startDateTime
.
isEmpty
()
||
"-inf"
.
equalsIgnoreCase
(
startDateTime
)
||
"-infinity"
.
equalsIgnoreCase
(
startDateTime
))
{
start
=
Double
.
NEGATIVE_INFINITY
;
}
else
{
start
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
startDateTime
)
:
AttributeUtils
.
parseDateTime
(
startDateTime
);
}
if
(
endDateTime
==
null
||
endDateTime
.
isEmpty
()
||
"inf"
.
equalsIgnoreCase
(
endDateTime
)
||
"infinity"
.
equalsIgnoreCase
(
endDateTime
))
{
end
=
Double
.
POSITIVE_INFINITY
;
}
else
{
end
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
endDateTime
)
:
AttributeUtils
.
parseDateTime
(
endDateTime
);
}
setValue
(
key
,
value
,
start
,
end
);
}
@Override
...
...
@@ -264,13 +276,23 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
)
{
ColumnDraft
column
=
getColumn
(
key
);
Object
val
=
AttributeUtils
.
parse
(
value
,
column
.
getTypeClass
());
Class
typeClass
;
if
(
column
.
isDynamic
())
{
if
(
container
.
getTimeRepresentation
().
equals
(
TimeRepresentation
.
INTERVAL
))
{
typeClass
=
AttributeUtils
.
getIntervalMapType
(
column
.
getTypeClass
());
}
else
{
typeClass
=
AttributeUtils
.
getTimestampMapType
(
column
.
getTypeClass
());
}
}
else
{
typeClass
=
column
.
getTypeClass
();
}
Object
val
=
AttributeUtils
.
parse
(
value
,
typeClass
);
setValue
(
key
,
val
);
}
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
,
String
dateTime
)
{
parseAndSetValue
(
key
,
value
,
AttributeUtils
.
parseDateTime
(
dateTime
));
parseAndSetValue
(
key
,
value
,
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
dateTime
)
:
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
...
...
@@ -283,15 +305,15 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
,
String
startDateTime
,
String
endDateTime
)
{
double
start
,
end
;
if
(
startDateTime
==
null
||
"-inf
"
.
equalsIgnoreCase
(
startDateTime
))
{
if
(
startDateTime
==
null
||
startDateTime
.
isEmpty
()
||
"-inf"
.
equalsIgnoreCase
(
startDateTime
)
||
"-infinity
"
.
equalsIgnoreCase
(
startDateTime
))
{
start
=
Double
.
NEGATIVE_INFINITY
;
}
else
{
start
=
AttributeUtils
.
parseDateTime
(
startDateTime
);
start
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
startDateTime
)
:
AttributeUtils
.
parseDateTime
(
startDateTime
);
}
if
(
endDateTime
==
null
||
"inf
"
.
equalsIgnoreCase
(
endDateTime
))
{
if
(
endDateTime
==
null
||
endDateTime
.
isEmpty
()
||
"inf"
.
equalsIgnoreCase
(
endDateTime
)
||
"infinity
"
.
equalsIgnoreCase
(
endDateTime
))
{
end
=
Double
.
POSITIVE_INFINITY
;
}
else
{
end
=
AttributeUtils
.
parseDateTime
(
endDateTime
);
end
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
endDateTime
)
:
AttributeUtils
.
parseDateTime
(
endDateTime
);
}
parseAndSetValue
(
key
,
value
,
start
,
end
);
}
...
...
@@ -305,7 +327,7 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
addTimestamp
(
String
dateTime
)
{
addTimestamp
(
AttributeUtils
.
parseDateTime
(
dateTime
));
addTimestamp
(
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
dateTime
)
:
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
...
...
@@ -321,6 +343,23 @@ public abstract class ElementDraftImpl implements ElementDraft {
timeSet
.
add
(
timestamp
);
}
@Override
public
void
addTimestamps
(
String
timestamps
)
{
if
(!
container
.
getTimeRepresentation
().
equals
(
TimeRepresentation
.
TIMESTAMP
))
{
String
message
=
NbBundle
.
getMessage
(
ElementDraftImpl
.
class
,
"ElementDraftException_NotTimestampRepresentation"
,
id
);
container
.
getReport
().
logIssue
(
new
Issue
(
message
,
Issue
.
Level
.
SEVERE
));
return
;
}
TimestampSet
t
=
(
TimestampSet
)
AttributeUtils
.
parse
(
timestamps
,
TimestampSet
.
class
);
if
(
timeSet
==
null
)
{
timeSet
=
t
;
}
else
{
for
(
Double
d
:
t
.
toArray
())
{
timeSet
.
add
(
d
);
}
}
}
@Override
public
TimeSet
getTimeSet
()
{
return
timeSet
;
...
...
@@ -329,19 +368,36 @@ public abstract class ElementDraftImpl implements ElementDraft {
@Override
public
void
addInterval
(
String
intervalStartDateTime
,
String
intervalEndDateTime
)
{
double
start
,
end
;
if
(
intervalStartDateTime
==
null
||
"-inf
"
.
equalsIgnoreCase
(
intervalStartDateTime
))
{
if
(
intervalStartDateTime
==
null
||
intervalStartDateTime
.
isEmpty
()
||
"-inf"
.
equalsIgnoreCase
(
intervalStartDateTime
)
||
"-infinity
"
.
equalsIgnoreCase
(
intervalStartDateTime
))
{
start
=
Double
.
NEGATIVE_INFINITY
;
}
else
{
start
=
AttributeUtils
.
parseDateTime
(
intervalStartDateTime
);
start
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
intervalStartDateTime
)
:
AttributeUtils
.
parseDateTime
(
intervalStartDateTime
);
}
if
(
intervalEndDateTime
==
null
||
"inf
"
.
equalsIgnoreCase
(
intervalEndDateTime
))
{
if
(
intervalEndDateTime
==
null
||
intervalEndDateTime
.
isEmpty
()
||
"inf"
.
equalsIgnoreCase
(
intervalEndDateTime
)
||
"infinity
"
.
equalsIgnoreCase
(
intervalEndDateTime
))
{
end
=
Double
.
POSITIVE_INFINITY
;
}
else
{
end
=
AttributeUtils
.
parseDateTime
(
intervalStartDateTime
);
end
=
container
.
getTimeFormat
().
equals
(
TimeFormat
.
DOUBLE
)
?
Double
.
parseDouble
(
intervalEndDateTime
)
:
AttributeUtils
.
parseDateTime
(
intervalStartDateTime
);
}
addInterval
(
start
,
end
);
}
@Override
public
void
addIntervals
(
String
intervals
)
{
if
(!
container
.
getTimeRepresentation
().
equals
(
TimeRepresentation
.
INTERVAL
))
{
String
message
=
NbBundle
.
getMessage
(
ElementDraftImpl
.
class
,
"ElementDraftException_NotIntervalRepresentation"
,
id
);
container
.
getReport
().
logIssue
(
new
Issue
(
message
,
Issue
.
Level
.
SEVERE
));
return
;
}
IntervalSet
s
=
(
IntervalSet
)
AttributeUtils
.
parse
(
intervals
,
IntervalSet
.
class
);
if
(
timeSet
==
null
)
{
timeSet
=
s
;
}
else
{
for
(
Interval
i
:
s
.
toArray
())
{
timeSet
.
add
(
i
);
}
}
}
@Override
public
void
addInterval
(
double
intervalStart
,
double
intervalEnd
)
{
if
(!
container
.
getTimeRepresentation
().
equals
(
TimeRepresentation
.
INTERVAL
))
{
...
...
@@ -401,7 +457,7 @@ public abstract class ElementDraftImpl implements ElementDraft {
throw
new
RuntimeException
(
"The expected value class was "
+
typeClass
.
getSimpleName
()
+
" and "
+
value
.
getClass
().
getSimpleName
()
+
" was found"
);
}
if
(!
column
.
isDynamic
())
{
//TODO
throw
new
RuntimeException
(
"Can't set a dynamic value to a static column"
);
}
if
(
index
>=
attributes
.
length
)
{
Object
[]
newArray
=
new
Object
[
index
+
1
];
...
...
@@ -423,6 +479,9 @@ public abstract class ElementDraftImpl implements ElementDraft {
if
(!
value
.
getClass
().
equals
(
typeClass
))
{
throw
new
RuntimeException
(
"The expected value class was "
+
typeClass
.
getSimpleName
()
+
" and "
+
value
.
getClass
().
getSimpleName
()
+
" was found"
);
}
if
(!
column
.
isDynamic
())
{
throw
new
RuntimeException
(
"Can't set a dynamic value to a static column"
);
}
Interval
interval
=
new
Interval
(
start
,
end
);
if
(
index
>=
attributes
.
length
)
{
Object
[]
newArray
=
new
Object
[
index
+
1
];
...
...
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementFactoryImpl.java
浏览文件 @
2b38907d
...
...
@@ -58,7 +58,7 @@ public class ElementFactoryImpl implements ElementDraft.Factory {
@Override
public
NodeDraftImpl
newNodeDraft
()
{
NodeDraftImpl
node
=
new
NodeDraftImpl
(
container
,
"n"
+
NODE_IDS
.
getAndIncrement
(
));
NodeDraftImpl
node
=
new
NodeDraftImpl
(
container
,
String
.
valueOf
(
NODE_IDS
.
getAndIncrement
()
));
return
node
;
}
...
...
@@ -74,7 +74,7 @@ public class ElementFactoryImpl implements ElementDraft.Factory {
@Override
public
EdgeDraftImpl
newEdgeDraft
()
{
EdgeDraftImpl
edge
=
new
EdgeDraftImpl
(
container
,
"e"
+
EDGE_IDS
.
getAndIncrement
(
));
EdgeDraftImpl
edge
=
new
EdgeDraftImpl
(
container
,
String
.
valueOf
(
EDGE_IDS
.
getAndIncrement
()
));
return
edge
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录