Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Christnowx
Gephi
提交
017f801f
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,发现更多精彩内容 >>
提交
017f801f
编写于
5月 14, 2013
作者:
M
Mathieu Bastian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add dynamic attribute support in ImportAPI
上级
f4888f5d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
114 addition
and
28 deletion
+114
-28
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ColumnDraft.java
.../src/main/java/org/gephi/io/importer/api/ColumnDraft.java
+2
-0
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ContainerLoader.java
.../main/java/org/gephi/io/importer/api/ContainerLoader.java
+4
-0
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ElementDraft.java
...src/main/java/org/gephi/io/importer/api/ElementDraft.java
+13
-1
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
...main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
+8
-1
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
...c/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
+2
-11
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementDraftImpl.java
...ain/java/org/gephi/io/importer/impl/ElementDraftImpl.java
+69
-0
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ImportContainerImpl.java
.../java/org/gephi/io/importer/impl/ImportContainerImpl.java
+12
-2
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/NodeDraftImpl.java
...c/main/java/org/gephi/io/importer/impl/NodeDraftImpl.java
+2
-11
modules/ImportPlugin/src/main/java/org/gephi/io/importer/plugin/file/ImporterGraphML.java
...va/org/gephi/io/importer/plugin/file/ImporterGraphML.java
+2
-2
未找到文件。
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ColumnDraft.java
浏览文件 @
017f801f
...
...
@@ -55,6 +55,8 @@ public interface ColumnDraft {
public
Object
getDefaultValue
();
public
boolean
isDynamic
();
public
void
setTitle
(
String
title
);
public
void
setDefaultValue
(
Object
value
);
...
...
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ContainerLoader.java
浏览文件 @
017f801f
...
...
@@ -174,6 +174,10 @@ public interface ContainerLoader {
public
ColumnDraft
addEdgeColumn
(
String
key
,
Class
typeClass
);
public
ColumnDraft
addNodeColumn
(
String
key
,
Class
typeClass
,
boolean
dynamic
);
public
ColumnDraft
addEdgeColumn
(
String
key
,
Class
typeClass
,
boolean
dynamic
);
/**
* Returns the <b>factory</b> for building nodes and edges instances.
*
...
...
modules/ImportAPI/src/main/java/org/gephi/io/importer/api/ElementDraft.java
浏览文件 @
017f801f
...
...
@@ -65,7 +65,15 @@ public interface ElementDraft {
public
void
setValue
(
String
key
,
Object
value
);
public
void
setValueString
(
String
key
,
String
value
);
public
void
setValue
(
String
key
,
Object
value
,
double
timestamp
);
public
void
setValue
(
String
key
,
Object
value
,
String
dateTime
);
public
void
parseAndSetValue
(
String
key
,
String
value
);
public
void
parseAndSetValue
(
String
key
,
String
value
,
double
timestamp
);
public
void
parseAndSetValue
(
String
key
,
String
value
,
String
dateTime
);
public
void
setLabel
(
String
label
);
...
...
@@ -92,4 +100,8 @@ public interface ElementDraft {
public
void
setLabelColor
(
int
r
,
int
g
,
int
b
);
public
void
setLabelColor
(
String
color
);
public
void
addTimestamp
(
double
timestamp
);
public
void
addTimestamp
(
String
dateTime
);
}
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ColumnDraftImpl.java
浏览文件 @
017f801f
...
...
@@ -53,13 +53,15 @@ public class ColumnDraftImpl implements ColumnDraft {
protected
final
int
index
;
protected
final
String
id
;
protected
final
Class
typeClass
;
protected
final
boolean
dynamic
;
protected
String
title
;
protected
Object
defaultValue
;
public
ColumnDraftImpl
(
String
id
,
int
index
,
Class
typeClass
)
{
public
ColumnDraftImpl
(
String
id
,
int
index
,
boolean
dynamic
,
Class
typeClass
)
{
this
.
id
=
id
;
this
.
index
=
index
;
this
.
typeClass
=
typeClass
;
this
.
dynamic
=
dynamic
;
}
@Override
...
...
@@ -100,4 +102,9 @@ public class ColumnDraftImpl implements ColumnDraft {
public
void
setDefaultValueString
(
String
value
)
{
this
.
defaultValue
=
AttributeUtils
.
parse
(
value
,
typeClass
);
}
@Override
public
boolean
isDynamic
()
{
return
true
;
}
}
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/EdgeDraftImpl.java
浏览文件 @
017f801f
...
...
@@ -41,7 +41,6 @@
*/
package
org.gephi.io.importer.impl
;
import
org.gephi.attribute.api.AttributeUtils
;
import
org.gephi.io.importer.api.ColumnDraft
;
import
org.gephi.io.importer.api.EdgeDirection
;
import
org.gephi.io.importer.api.EdgeDraft
;
...
...
@@ -257,15 +256,7 @@ public class EdgeDraftImpl extends ElementDraftImpl implements EdgeDraft {
}
@Override
public
void
setValue
(
String
key
,
Object
value
)
{
ColumnDraft
column
=
container
.
addEdgeColumn
(
key
,
value
.
getClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
value
);
}
@Override
public
void
setValueString
(
String
key
,
String
value
)
{
ColumnDraft
column
=
container
.
addEdgeColumn
(
key
,
value
.
getClass
());
Object
val
=
AttributeUtils
.
parse
(
value
,
column
.
getTypeClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
val
);
ColumnDraft
getColumn
(
String
key
,
Class
type
)
{
return
container
.
addEdgeColumn
(
key
,
type
);
}
}
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ElementDraftImpl.java
浏览文件 @
017f801f
...
...
@@ -42,7 +42,10 @@
*/
package
org.gephi.io.importer.impl
;
import
it.unimi.dsi.fastutil.doubles.Double2ObjectMap
;
import
java.awt.Color
;
import
org.gephi.attribute.api.AttributeUtils
;
import
org.gephi.io.importer.api.ColumnDraft
;
import
org.gephi.io.importer.api.ElementDraft
;
/**
...
...
@@ -63,13 +66,20 @@ public abstract class ElementDraftImpl implements ElementDraft {
protected
boolean
labelVisible
=
true
;
//Attributes
protected
Object
[]
attributes
;
//Timestamps
protected
double
[]
timeStamps
;
//Dynamic values
protected
Double2ObjectMap
[]
dynamicAttributes
;
public
ElementDraftImpl
(
ImportContainerImpl
container
,
String
id
)
{
this
.
container
=
container
;
this
.
id
=
id
;
this
.
attributes
=
new
Object
[
0
];
this
.
timeStamps
=
new
double
[
0
];
}
abstract
ColumnDraft
getColumn
(
String
key
,
Class
type
);
@Override
public
String
getId
()
{
return
id
;
...
...
@@ -171,6 +181,54 @@ public abstract class ElementDraftImpl implements ElementDraft {
setLabelColor
(
Color
.
getColor
(
color
));
}
@Override
public
void
setValue
(
String
key
,
Object
value
)
{
ColumnDraft
column
=
getColumn
(
key
,
value
.
getClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
value
);
}
@Override
public
void
setValue
(
String
key
,
Object
value
,
String
dateTime
)
{
setValue
(
key
,
value
,
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
public
void
setValue
(
String
key
,
Object
value
,
double
timestamp
)
{
ColumnDraft
column
=
getColumn
(
key
,
value
.
getClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
value
,
timestamp
);
}
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
)
{
ColumnDraft
column
=
getColumn
(
key
,
value
.
getClass
());
Object
val
=
AttributeUtils
.
parse
(
value
,
column
.
getTypeClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
val
);
}
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
,
String
dateTime
)
{
parseAndSetValue
(
key
,
value
,
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
public
void
parseAndSetValue
(
String
key
,
String
value
,
double
timestamp
)
{
ColumnDraft
column
=
getColumn
(
key
,
value
.
getClass
());
Object
val
=
AttributeUtils
.
parse
(
value
,
column
.
getTypeClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
val
,
timestamp
);
}
@Override
public
void
addTimestamp
(
String
dateTime
)
{
addTimestamp
(
AttributeUtils
.
parseDateTime
(
dateTime
));
}
@Override
public
void
addTimestamp
(
double
timestamp
)
{
int
index
=
timeStamps
.
length
;
ensureTimestampArraySize
(
index
);
timeStamps
[
index
]
=
timestamp
;
}
//UTILITY
protected
void
setAttributeValue
(
int
index
,
Object
value
)
{
if
(
index
>=
attributes
.
length
)
{
...
...
@@ -181,10 +239,21 @@ public abstract class ElementDraftImpl implements ElementDraft {
attributes
[
index
]
=
value
;
}
protected
void
setAttributeValue
(
int
index
,
Object
value
,
double
timestamp
)
{
}
protected
Object
getAttributeValue
(
int
index
)
{
if
(
index
<
attributes
.
length
)
{
return
attributes
[
index
];
}
return
null
;
}
protected
void
ensureTimestampArraySize
(
int
index
)
{
if
(
index
>=
timeStamps
.
length
)
{
double
[]
newArray
=
new
double
[
index
+
1
];
System
.
arraycopy
(
timeStamps
,
0
,
newArray
,
0
,
timeStamps
.
length
);
timeStamps
=
newArray
;
}
}
}
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/ImportContainerImpl.java
浏览文件 @
017f801f
...
...
@@ -423,10 +423,15 @@ public class ImportContainerImpl implements Container, ContainerLoader, Containe
@Override
public
ColumnDraft
addNodeColumn
(
String
key
,
Class
typeClass
)
{
return
addNodeColumn
(
key
,
typeClass
,
false
);
}
@Override
public
ColumnDraft
addNodeColumn
(
String
key
,
Class
typeClass
,
boolean
dynamic
)
{
ColumnDraft
column
=
nodeColumns
.
get
(
key
);
if
(
column
==
null
)
{
int
index
=
nodeColumns
.
size
();
column
=
new
ColumnDraftImpl
(
key
,
index
,
typeClass
);
column
=
new
ColumnDraftImpl
(
key
,
index
,
dynamic
,
typeClass
);
nodeColumns
.
put
(
key
,
column
);
}
else
{
if
(!
column
.
getTypeClass
().
equals
(
typeClass
))
{
...
...
@@ -438,10 +443,15 @@ public class ImportContainerImpl implements Container, ContainerLoader, Containe
@Override
public
ColumnDraft
addEdgeColumn
(
String
key
,
Class
typeClass
)
{
return
addEdgeColumn
(
key
,
typeClass
,
false
);
}
@Override
public
ColumnDraft
addEdgeColumn
(
String
key
,
Class
typeClass
,
boolean
dynamic
)
{
ColumnDraft
column
=
edgeColumns
.
get
(
key
);
if
(
column
==
null
)
{
int
index
=
edgeColumns
.
size
();
column
=
new
ColumnDraftImpl
(
key
,
index
,
typeClass
);
column
=
new
ColumnDraftImpl
(
key
,
index
,
dynamic
,
typeClass
);
edgeColumns
.
put
(
key
,
column
);
}
else
{
if
(!
column
.
getTypeClass
().
equals
(
typeClass
))
{
...
...
modules/ImportAPI/src/main/java/org/gephi/io/importer/impl/NodeDraftImpl.java
浏览文件 @
017f801f
...
...
@@ -41,7 +41,6 @@
*/
package
org.gephi.io.importer.impl
;
import
org.gephi.attribute.api.AttributeUtils
;
import
org.gephi.io.importer.api.ColumnDraft
;
import
org.gephi.io.importer.api.NodeDraft
;
...
...
@@ -258,15 +257,7 @@ public class NodeDraftImpl extends ElementDraftImpl implements NodeDraft {
}
@Override
public
void
setValue
(
String
key
,
Object
value
)
{
ColumnDraft
column
=
container
.
addNodeColumn
(
key
,
value
.
getClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
value
);
}
@Override
public
void
setValueString
(
String
key
,
String
value
)
{
ColumnDraft
column
=
container
.
addNodeColumn
(
key
,
value
.
getClass
());
Object
val
=
AttributeUtils
.
parse
(
value
,
column
.
getTypeClass
());
setAttributeValue
(((
ColumnDraftImpl
)
column
).
getIndex
(),
val
);
ColumnDraft
getColumn
(
String
key
,
Class
type
)
{
return
container
.
addNodeColumn
(
key
,
type
);
}
}
modules/ImportPlugin/src/main/java/org/gephi/io/importer/plugin/file/ImporterGraphML.java
浏览文件 @
017f801f
...
...
@@ -348,7 +348,7 @@ public class ImporterGraphML implements FileImporter, LongTask {
ColumnDraft
column
=
container
.
getNodeColumn
(
fore
);
if
(
column
!=
null
)
{
try
{
node
.
setValueString
(
column
.
getId
(),
value
);
node
.
parseAndSetValue
(
column
.
getId
(),
value
);
}
catch
(
Exception
e
)
{
report
.
logIssue
(
new
Issue
(
NbBundle
.
getMessage
(
ImporterGraphML
.
class
,
"importerGraphML_error_datavalue"
,
fore
,
node
,
column
.
getTitle
()),
Issue
.
Level
.
SEVERE
));
}
...
...
@@ -500,7 +500,7 @@ public class ImporterGraphML implements FileImporter, LongTask {
ColumnDraft
column
=
container
.
getEdgeColumn
(
fore
);
if
(
column
!=
null
)
{
try
{
edge
.
setValueString
(
column
.
getId
(),
value
);
edge
.
parseAndSetValue
(
column
.
getId
(),
value
);
}
catch
(
Exception
e
)
{
report
.
logIssue
(
new
Issue
(
NbBundle
.
getMessage
(
ImporterGraphML
.
class
,
"importerGraphML_error_datavalue"
,
fore
,
edge
,
column
.
getTitle
()),
Issue
.
Level
.
SEVERE
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录