Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Christnowx
Gephi
提交
12e3edd4
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
12e3edd4
编写于
12月 02, 2015
作者:
M
Mathieu Bastian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Overhaul of the function discovery and refresh in Appearance
上级
bea78741
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
1271 addition
and
268 deletion
+1271
-268
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AppearanceModelImpl.java
...c/main/java/org/gephi/appearance/AppearanceModelImpl.java
+427
-96
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributeFunctionImpl.java
...main/java/org/gephi/appearance/AttributeFunctionImpl.java
+51
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributePartitionImpl.java
...ain/java/org/gephi/appearance/AttributePartitionImpl.java
+120
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributeRankingImpl.java
.../main/java/org/gephi/appearance/AttributeRankingImpl.java
+60
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/DegreeRankingImpl.java
...src/main/java/org/gephi/appearance/DegreeRankingImpl.java
+81
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
...main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
+101
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeWeightRankingImpl.java
...main/java/org/gephi/appearance/EdgeWeightRankingImpl.java
+81
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
...eAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
+26
-61
modules/AppearanceAPI/src/main/java/org/gephi/appearance/GraphFunctionImpl.java
...src/main/java/org/gephi/appearance/GraphFunctionImpl.java
+40
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/InDegreeRankingImpl.java
...c/main/java/org/gephi/appearance/InDegreeRankingImpl.java
+81
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/OutDegreeRankingImpl.java
.../main/java/org/gephi/appearance/OutDegreeRankingImpl.java
+81
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/PartitionImpl.java
...API/src/main/java/org/gephi/appearance/PartitionImpl.java
+3
-61
modules/AppearanceAPI/src/main/java/org/gephi/appearance/RankingImpl.java
...ceAPI/src/main/java/org/gephi/appearance/RankingImpl.java
+10
-34
modules/AppearanceAPI/src/main/java/org/gephi/appearance/SimpleFunctionImpl.java
...rc/main/java/org/gephi/appearance/SimpleFunctionImpl.java
+22
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/AppearanceModel.java
...c/main/java/org/gephi/appearance/api/AppearanceModel.java
+6
-7
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Function.java
...eAPI/src/main/java/org/gephi/appearance/api/Function.java
+3
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/GraphFunction.java
...src/main/java/org/gephi/appearance/api/GraphFunction.java
+50
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Interpolator.java
.../src/main/java/org/gephi/appearance/api/Interpolator.java
+1
-3
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Partition.java
...API/src/main/java/org/gephi/appearance/api/Partition.java
+3
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/PartitionFunction.java
...main/java/org/gephi/appearance/api/PartitionFunction.java
+1
-1
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Ranking.java
...ceAPI/src/main/java/org/gephi/appearance/api/Ranking.java
+4
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/RankingFunction.java
...c/main/java/org/gephi/appearance/api/RankingFunction.java
+1
-1
modules/AppearanceAPI/src/main/resources/org/gephi/appearance/Bundle.properties
...src/main/resources/org/gephi/appearance/Bundle.properties
+5
-0
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java
.../java/org/gephi/desktop/appearance/AppearanceUIModel.java
+13
-4
未找到文件。
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AppearanceModelImpl.java
浏览文件 @
12e3edd4
此差异已折叠。
点击以展开。
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributeFunctionImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.AttributeFunction
;
import
org.gephi.appearance.api.Partition
;
import
org.gephi.appearance.api.PartitionFunction
;
import
org.gephi.appearance.api.Ranking
;
import
org.gephi.appearance.api.RankingFunction
;
import
org.gephi.appearance.spi.Transformer
;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Graph
;
/**
*
* @author mbastian
*/
public
class
AttributeFunctionImpl
extends
FunctionImpl
implements
RankingFunction
,
PartitionFunction
,
AttributeFunction
{
public
AttributeFunctionImpl
(
String
id
,
Graph
graph
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
RankingImpl
ranking
)
{
super
(
id
,
null
,
graph
,
column
,
transformer
,
transformerUI
,
null
,
ranking
);
}
public
AttributeFunctionImpl
(
String
id
,
Graph
graph
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
)
{
super
(
id
,
null
,
graph
,
column
,
transformer
,
transformerUI
,
partition
,
null
);
}
@Override
public
Column
getColumn
()
{
return
column
;
}
@Override
public
Partition
getPartition
()
{
return
partition
;
}
@Override
public
Ranking
getRanking
()
{
return
ranking
;
}
@Override
public
String
toString
()
{
return
column
.
getTitle
();
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributePartitionImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Index
;
/**
*
* @author mbastian
*/
public
class
AttributePartitionImpl
extends
PartitionImpl
{
protected
final
Index
index
;
protected
final
Column
column
;
public
AttributePartitionImpl
(
Column
column
,
Index
index
)
{
super
();
this
.
column
=
column
;
this
.
index
=
index
;
}
@Override
public
Object
getValue
(
Element
element
)
{
return
element
.
getAttribute
(
column
);
}
@Override
public
Iterable
getValues
()
{
return
index
.
values
(
column
);
}
@Override
public
int
getElementCount
()
{
return
index
.
countElements
(
column
);
}
@Override
public
int
count
(
Object
value
)
{
return
index
.
count
(
column
,
value
);
}
@Override
public
float
percentage
(
Object
value
)
{
int
count
=
index
.
count
(
column
,
value
);
return
(
float
)
count
/
index
.
countElements
(
column
);
}
@Override
public
int
size
()
{
return
index
.
countValues
(
column
);
}
@Override
public
Column
getColumn
()
{
return
column
;
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
23
*
hash
+
(
this
.
column
!=
null
?
this
.
column
.
hashCode
()
:
0
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
AttributePartitionImpl
other
=
(
AttributePartitionImpl
)
obj
;
if
(
this
.
column
!=
other
.
column
&&
(
this
.
column
==
null
||
!
this
.
column
.
equals
(
other
.
column
)))
{
return
false
;
}
return
true
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributeRankingImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Index
;
/**
*
* @author mbastian
*/
public
class
AttributeRankingImpl
extends
RankingImpl
{
protected
final
Index
index
;
protected
final
Column
column
;
public
AttributeRankingImpl
(
Column
column
,
Index
index
,
Interpolator
interpolator
)
{
super
(
interpolator
);
this
.
column
=
column
;
this
.
index
=
index
;
}
@Override
protected
void
refresh
()
{
min
=
index
.
getMinValue
(
column
);
max
=
index
.
getMaxValue
(
column
);
}
@Override
public
Number
getValue
(
Element
element
)
{
return
(
Number
)
element
.
getAttribute
(
column
);
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
67
*
hash
+
(
this
.
column
!=
null
?
this
.
column
.
hashCode
()
:
0
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
AttributeRankingImpl
other
=
(
AttributeRankingImpl
)
obj
;
if
(
this
.
column
!=
other
.
column
&&
(
this
.
column
==
null
||
!
this
.
column
.
equals
(
other
.
column
)))
{
return
false
;
}
return
true
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/DegreeRankingImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Graph
;
import
org.gephi.graph.api.Node
;
/**
*
* @author mbastian
*/
public
class
DegreeRankingImpl
extends
RankingImpl
{
private
final
Graph
graph
;
public
DegreeRankingImpl
(
Graph
graph
,
Interpolator
interpolator
)
{
super
(
interpolator
);
this
.
graph
=
graph
;
}
@Override
public
Number
getValue
(
Element
element
)
{
return
graph
.
getDegree
((
Node
)
element
);
}
@Override
protected
void
refresh
()
{
if
(
graph
.
getNodeCount
()
>
0
)
{
int
minV
=
Integer
.
MAX_VALUE
;
int
maxV
=
Integer
.
MIN_VALUE
;
for
(
Node
n
:
graph
.
getNodes
())
{
int
degree
=
graph
.
getDegree
(
n
);
minV
=
Math
.
min
(
degree
,
minV
);
maxV
=
Math
.
max
(
degree
,
maxV
);
}
min
=
minV
;
max
=
maxV
;
}
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
java.util.Arrays
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Edge
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Graph
;
import
org.gephi.graph.api.GraphModel
;
/**
*
* @author mbastian
*/
public
class
EdgeTypePartitionImpl
extends
PartitionImpl
{
protected
final
Graph
graph
;
protected
final
GraphModel
model
;
public
EdgeTypePartitionImpl
(
Graph
graph
)
{
super
();
this
.
graph
=
graph
;
this
.
model
=
graph
.
getModel
();
}
@Override
public
Iterable
getValues
()
{
return
Arrays
.
asList
(
model
.
getEdgeTypeLabels
());
}
@Override
public
Object
getValue
(
Element
element
)
{
return
((
Edge
)
element
).
getTypeLabel
();
}
@Override
public
int
getElementCount
()
{
return
graph
.
getEdgeCount
();
}
@Override
public
int
count
(
Object
value
)
{
return
graph
.
getEdgeCount
(
model
.
getEdgeType
(
value
));
}
@Override
public
float
percentage
(
Object
value
)
{
int
count
=
count
(
value
);
return
(
float
)
count
/
graph
.
getEdgeCount
();
}
@Override
public
int
size
()
{
return
model
.
getEdgeTypeCount
();
}
@Override
public
Column
getColumn
()
{
return
null
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeWeightRankingImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.graph.api.Edge
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Graph
;
/**
*
* @author mbastian
*/
public
class
EdgeWeightRankingImpl
extends
RankingImpl
{
private
final
Graph
graph
;
public
EdgeWeightRankingImpl
(
Graph
graph
,
Interpolator
interpolator
)
{
super
(
interpolator
);
this
.
graph
=
graph
;
}
@Override
public
Number
getValue
(
Element
element
)
{
return
((
Edge
)
element
).
getWeight
();
}
@Override
protected
void
refresh
()
{
if
(
graph
.
getEdgeCount
()
>
0
)
{
double
minV
=
Double
.
MAX_VALUE
;
double
maxV
=
Double
.
MIN_VALUE
;
for
(
Edge
e
:
graph
.
getEdges
())
{
double
weight
=
e
.
getWeight
();
minV
=
Math
.
min
(
weight
,
minV
);
maxV
=
Math
.
max
(
weight
,
maxV
);
}
min
=
minV
;
max
=
maxV
;
}
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
浏览文件 @
12e3edd4
...
...
@@ -41,11 +41,7 @@
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Partition
;
import
org.gephi.appearance.api.PartitionFunction
;
import
org.gephi.appearance.api.Ranking
;
import
org.gephi.appearance.api.RankingFunction
;
import
org.gephi.appearance.api.SimpleFunction
;
import
org.gephi.appearance.api.Function
;
import
org.gephi.appearance.spi.PartitionTransformer
;
import
org.gephi.appearance.spi.RankingTransformer
;
import
org.gephi.appearance.spi.SimpleTransformer
;
...
...
@@ -53,35 +49,31 @@ import org.gephi.appearance.spi.Transformer;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Graph
;
/**
*
* @author mbastian
*/
public
class
FunctionImpl
implements
RankingFunction
,
PartitionFunction
,
Simple
Function
{
public
abstract
class
FunctionImpl
implements
Function
{
protected
final
AppearanceModelImpl
model
;
protected
final
String
id
;
protected
final
String
name
;
protected
final
Graph
graph
;
protected
final
Column
column
;
protected
final
Transformer
transformer
;
protected
final
TransformerUI
transformerUI
;
protected
final
PartitionImpl
partition
;
protected
final
RankingImpl
ranking
;
public
FunctionImpl
(
AppearanceModelImpl
model
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
)
{
this
(
model
,
column
,
transformer
,
transformerUI
,
null
,
null
);
}
public
FunctionImpl
(
AppearanceModelImpl
model
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
RankingImpl
ranking
)
{
this
(
model
,
column
,
transformer
,
transformerUI
,
null
,
ranking
);
}
public
FunctionImpl
(
AppearanceModelImpl
model
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
)
{
this
(
model
,
column
,
transformer
,
transformerUI
,
partition
,
null
);
}
public
FunctionImpl
(
AppearanceModelImpl
model
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
,
RankingImpl
ranking
)
{
this
.
model
=
model
;
protected
FunctionImpl
(
String
id
,
String
name
,
Graph
graph
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
,
RankingImpl
ranking
)
{
if
(
id
==
null
)
{
throw
new
NullPointerException
(
"The id can't be null"
);
}
this
.
id
=
id
;
this
.
name
=
name
;
this
.
column
=
column
;
this
.
graph
=
graph
;
try
{
this
.
transformer
=
transformer
.
getClass
().
newInstance
();
}
catch
(
Exception
ex
)
{
...
...
@@ -97,23 +89,14 @@ public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleF
if
(
isSimple
())
{
((
SimpleTransformer
)
transformer
).
transform
(
element
);
}
else
if
(
isRanking
())
{
Number
val
=
(
Number
)
element
.
getAttribute
(
column
);
Number
val
=
ranking
.
getValue
(
element
);
((
RankingTransformer
)
transformer
).
transform
(
element
,
ranking
,
val
);
}
else
if
(
isPartition
())
{
Object
val
=
element
.
getAttribute
(
column
);
Object
val
=
partition
.
getValue
(
element
);
((
PartitionTransformer
)
transformer
).
transform
(
element
,
partition
,
val
);
}
}
@Override
public
Column
getColumn
()
{
return
column
;
}
public
AppearanceModelImpl
getModel
()
{
return
model
;
}
@Override
public
Transformer
getTransformer
()
{
return
transformer
;
...
...
@@ -126,7 +109,7 @@ public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleF
@Override
public
boolean
isSimple
()
{
return
colum
n
==
null
;
return
ranking
==
null
&&
partitio
n
==
null
;
}
@Override
...
...
@@ -145,39 +128,30 @@ public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleF
}
@Override
public
Partition
getPartition
()
{
return
partition
;
}
@Override
public
Ranking
getRanking
()
{
return
ranking
;
public
Graph
getGraph
()
{
return
graph
;
}
@Override
public
String
toString
()
{
if
(
column
!=
null
)
{
if
(
column
.
getTitle
()
!=
null
)
{
return
column
.
getTitle
();
}
else
{
return
column
.
getId
();
}
if
(
name
!=
null
)
{
return
name
;
}
return
super
.
toString
()
;
return
id
;
}
@Override
public
int
hashCode
()
{
int
hash
=
5
;
hash
=
47
*
hash
+
(
this
.
column
!=
null
?
this
.
column
.
hashCode
()
:
0
);
hash
=
47
*
hash
+
(
this
.
transformer
!=
null
?
this
.
transformer
.
hashCode
()
:
0
);
hash
=
47
*
hash
+
(
this
.
partition
!=
null
?
this
.
partition
.
hashCode
()
:
0
);
hash
=
47
*
hash
+
(
this
.
ranking
!=
null
?
this
.
ranking
.
hashCode
()
:
0
);
hash
=
97
*
hash
+
(
this
.
id
!=
null
?
this
.
id
.
hashCode
()
:
0
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
...
...
@@ -185,16 +159,7 @@ public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleF
return
false
;
}
final
FunctionImpl
other
=
(
FunctionImpl
)
obj
;
if
(
this
.
column
!=
other
.
column
&&
(
this
.
column
==
null
||
!
this
.
column
.
equals
(
other
.
column
)))
{
return
false
;
}
if
(
this
.
transformer
!=
other
.
transformer
&&
(
this
.
transformer
==
null
||
!
this
.
transformer
.
equals
(
other
.
transformer
)))
{
return
false
;
}
if
(
this
.
partition
!=
other
.
partition
&&
(
this
.
partition
==
null
||
!
this
.
partition
.
equals
(
other
.
partition
)))
{
return
false
;
}
if
(
this
.
ranking
!=
other
.
ranking
&&
(
this
.
ranking
==
null
||
!
this
.
ranking
.
equals
(
other
.
ranking
)))
{
if
((
this
.
id
==
null
)
?
(
other
.
id
!=
null
)
:
!
this
.
id
.
equals
(
other
.
id
))
{
return
false
;
}
return
true
;
...
...
modules/AppearanceAPI/src/main/java/org/gephi/appearance/GraphFunctionImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.GraphFunction
;
import
org.gephi.appearance.api.Partition
;
import
org.gephi.appearance.api.PartitionFunction
;
import
org.gephi.appearance.api.Ranking
;
import
org.gephi.appearance.api.RankingFunction
;
import
org.gephi.appearance.spi.Transformer
;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Graph
;
/**
*
* @author mbastian
*/
public
class
GraphFunctionImpl
extends
FunctionImpl
implements
GraphFunction
,
RankingFunction
,
PartitionFunction
{
public
GraphFunctionImpl
(
String
id
,
String
name
,
Graph
graph
,
Transformer
transformer
,
TransformerUI
transformerUI
,
RankingImpl
ranking
)
{
super
(
id
,
name
,
graph
,
null
,
transformer
,
transformerUI
,
null
,
ranking
);
}
public
GraphFunctionImpl
(
String
id
,
String
name
,
Graph
graph
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
)
{
super
(
id
,
name
,
graph
,
null
,
transformer
,
transformerUI
,
partition
,
null
);
}
@Override
public
PartitionImpl
getPartition
()
{
return
partition
;
}
@Override
public
RankingImpl
getRanking
()
{
return
ranking
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/InDegreeRankingImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.graph.api.DirectedGraph
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Node
;
/**
*
* @author mbastian
*/
public
class
InDegreeRankingImpl
extends
RankingImpl
{
private
final
DirectedGraph
graph
;
public
InDegreeRankingImpl
(
DirectedGraph
graph
,
Interpolator
interpolator
)
{
super
(
interpolator
);
this
.
graph
=
graph
;
}
@Override
public
Number
getValue
(
Element
element
)
{
return
graph
.
getInDegree
((
Node
)
element
);
}
@Override
protected
void
refresh
()
{
if
(
graph
.
getNodeCount
()
>
0
)
{
int
minV
=
Integer
.
MAX_VALUE
;
int
maxV
=
Integer
.
MIN_VALUE
;
for
(
Node
n
:
graph
.
getNodes
())
{
int
degree
=
graph
.
getInDegree
(
n
);
minV
=
Math
.
min
(
degree
,
minV
);
maxV
=
Math
.
max
(
degree
,
maxV
);
}
min
=
minV
;
max
=
maxV
;
}
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/OutDegreeRankingImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.graph.api.DirectedGraph
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Node
;
/**
*
* @author mbastian
*/
public
class
OutDegreeRankingImpl
extends
RankingImpl
{
private
final
DirectedGraph
graph
;
public
OutDegreeRankingImpl
(
DirectedGraph
graph
,
Interpolator
interpolator
)
{
super
(
interpolator
);
this
.
graph
=
graph
;
}
@Override
public
Number
getValue
(
Element
element
)
{
return
graph
.
getOutDegree
((
Node
)
element
);
}
@Override
protected
void
refresh
()
{
if
(
graph
.
getNodeCount
()
>
0
)
{
int
minV
=
Integer
.
MAX_VALUE
;
int
maxV
=
Integer
.
MIN_VALUE
;
for
(
Node
n
:
graph
.
getNodes
())
{
int
degree
=
graph
.
getOutDegree
(
n
);
minV
=
Math
.
min
(
degree
,
minV
);
maxV
=
Math
.
max
(
degree
,
maxV
);
}
min
=
minV
;
max
=
maxV
;
}
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/PartitionImpl.java
浏览文件 @
12e3edd4
...
...
@@ -45,40 +45,19 @@ import java.awt.Color;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.gephi.appearance.api.Partition
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Index
;
/**
*
* @author mbastian
*/
public
class
PartitionImpl
implements
Partition
{
public
abstract
class
PartitionImpl
implements
Partition
{
private
final
Index
index
;
private
final
Column
column
;
private
final
Map
<
Object
,
Color
>
colorMap
;
protected
final
Map
<
Object
,
Color
>
colorMap
;
public
PartitionImpl
(
Column
column
,
Index
index
)
{
this
.
column
=
column
;
this
.
index
=
index
;
protected
PartitionImpl
()
{
this
.
colorMap
=
new
HashMap
<
Object
,
Color
>();
}
@Override
public
Iterable
getValues
()
{
return
index
.
values
(
column
);
}
@Override
public
int
getElementCount
()
{
return
index
.
countElements
(
column
);
}
@Override
public
int
count
(
Object
value
)
{
return
index
.
count
(
column
,
value
);
}
@Override
public
Color
getColor
(
Object
value
)
{
return
colorMap
.
get
(
value
);
...
...
@@ -89,41 +68,4 @@ public class PartitionImpl implements Partition {
colorMap
.
put
(
value
,
color
);
}
@Override
public
float
percentage
(
Object
value
)
{
int
count
=
index
.
count
(
column
,
value
);
return
(
float
)
count
/
index
.
countElements
(
column
);
}
@Override
public
int
size
()
{
return
index
.
countValues
(
column
);
}
@Override
public
Column
getColumn
()
{
return
column
;
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
23
*
hash
+
(
this
.
column
!=
null
?
this
.
column
.
hashCode
()
:
0
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
PartitionImpl
other
=
(
PartitionImpl
)
obj
;
if
(
this
.
column
!=
other
.
column
&&
(
this
.
column
==
null
||
!
this
.
column
.
equals
(
other
.
column
)))
{
return
false
;
}
return
true
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/RankingImpl.java
浏览文件 @
12e3edd4
...
...
@@ -43,33 +43,31 @@ package org.gephi.appearance;
import
org.gephi.appearance.api.Interpolator
;
import
org.gephi.appearance.api.Ranking
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Index
;
/**
*
* @author mbastian
*/
public
class
RankingImpl
implements
Ranking
{
public
abstract
class
RankingImpl
implements
Ranking
{
pr
ivate
final
Index
index
;
pr
ivate
final
Column
colum
n
;
pr
ivate
Interpolator
interpolator
;
pr
otected
Interpolator
interpolator
;
pr
otected
Number
mi
n
;
pr
otected
Number
max
;
public
RankingImpl
(
Column
column
,
Index
index
,
Interpolator
interpolator
)
{
this
.
column
=
column
;
this
.
index
=
index
;
protected
RankingImpl
(
Interpolator
interpolator
)
{
this
.
interpolator
=
interpolator
;
}
protected
abstract
void
refresh
();
@Override
public
Number
getMinValue
()
{
return
index
.
getMinValue
(
column
)
;
return
min
;
}
@Override
public
Number
getMaxValue
()
{
return
index
.
getMaxValue
(
column
)
;
return
max
;
}
@Override
...
...
@@ -84,29 +82,7 @@ public class RankingImpl implements Ranking {
@Override
public
float
normalize
(
Number
value
)
{
float
normalizedValue
=
(
float
)
(
value
.
doubleValue
()
-
getMinValue
().
doubleValue
())
/
(
float
)
(
getMaxValue
().
doubleValue
()
-
getMinValue
()
.
doubleValue
());
float
normalizedValue
=
(
float
)
(
value
.
doubleValue
()
-
min
.
doubleValue
())
/
(
float
)
(
max
.
doubleValue
()
-
min
.
doubleValue
());
return
interpolator
.
interpolate
(
normalizedValue
);
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
67
*
hash
+
(
this
.
column
!=
null
?
this
.
column
.
hashCode
()
:
0
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
RankingImpl
other
=
(
RankingImpl
)
obj
;
if
(
this
.
column
!=
other
.
column
&&
(
this
.
column
==
null
||
!
this
.
column
.
equals
(
other
.
column
)))
{
return
false
;
}
return
true
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/SimpleFunctionImpl.java
0 → 100644
浏览文件 @
12e3edd4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
org.gephi.appearance
;
import
org.gephi.appearance.api.SimpleFunction
;
import
org.gephi.appearance.spi.Transformer
;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Graph
;
/**
*
* @author mbastian
*/
public
class
SimpleFunctionImpl
extends
FunctionImpl
implements
SimpleFunction
{
public
SimpleFunctionImpl
(
String
id
,
Graph
graph
,
Transformer
transformer
,
TransformerUI
transformerUI
)
{
super
(
id
,
null
,
graph
,
null
,
transformer
,
transformerUI
,
null
,
null
);
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/AppearanceModel.java
浏览文件 @
12e3edd4
...
...
@@ -41,6 +41,7 @@
*/
package
org.gephi.appearance.api
;
import
org.gephi.graph.api.Graph
;
import
org.gephi.project.api.Workspace
;
/**
...
...
@@ -57,18 +58,16 @@ public interface AppearanceModel {
public
Workspace
getWorkspace
();
/**
* Returns
* <code>true</code> if rankings are using the currently visible graph as a
* scale. If
* <code>false</code> the complete graph is used to determine minimum and
* maximum values, the ranking scale.
* Returns <code>true</code> if rankings are using the currently visible
* graph as a scale. If <code>false</code> the complete graph is used to
* determine minimum and maximum values, the ranking scale.
*
* @return <code>true</code> if using a local scale, <code>false</code> if
* global scale
*/
public
boolean
isLocalScale
();
public
Function
[]
getNodeFunctions
();
public
Function
[]
getNodeFunctions
(
Graph
graph
);
public
Function
[]
getEdgeFunctions
();
public
Function
[]
getEdgeFunctions
(
Graph
graph
);
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Function.java
浏览文件 @
12e3edd4
...
...
@@ -44,6 +44,7 @@ package org.gephi.appearance.api;
import
org.gephi.appearance.spi.Transformer
;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Element
;
import
org.gephi.graph.api.Graph
;
/**
*
...
...
@@ -64,4 +65,6 @@ public interface Function {
public
boolean
isRanking
();
public
boolean
isPartition
();
public
Graph
getGraph
();
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/GraphFunction.java
0 → 100644
浏览文件 @
12e3edd4
/*
Copyright 2008-2013 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2013 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2013 Gephi Consortium.
*/
package
org.gephi.appearance.api
;
/**
*
* @author mbastian
*/
public
interface
GraphFunction
extends
Function
{
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Interpolator.java
浏览文件 @
12e3edd4
...
...
@@ -52,9 +52,7 @@ import java.awt.geom.Point2D;
public
abstract
class
Interpolator
{
/**
* Linear interpolation
* <code>x = interpolate(x)
* <code>
* Linear interpolation <code>x = interpolate(x)</code>
*/
public
static
final
Interpolator
LINEAR
=
new
Interpolator
()
{
@Override
...
...
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Partition.java
浏览文件 @
12e3edd4
...
...
@@ -43,6 +43,7 @@ package org.gephi.appearance.api;
import
java.awt.Color
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.Element
;
/**
*
...
...
@@ -56,6 +57,8 @@ public interface Partition {
public
int
count
(
Object
value
);
public
Object
getValue
(
Element
element
);
public
Color
getColor
(
Object
value
);
public
void
setColor
(
Object
value
,
Color
color
);
...
...
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/PartitionFunction.java
浏览文件 @
12e3edd4
...
...
@@ -45,7 +45,7 @@ package org.gephi.appearance.api;
*
* @author mbastian
*/
public
interface
PartitionFunction
extends
Attribute
Function
{
public
interface
PartitionFunction
extends
Function
{
public
Partition
getPartition
();
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Ranking.java
浏览文件 @
12e3edd4
...
...
@@ -41,6 +41,8 @@
*/
package
org.gephi.appearance.api
;
import
org.gephi.graph.api.Element
;
/**
*
* @author mbastian
...
...
@@ -55,5 +57,7 @@ public interface Ranking {
public
void
setInterpolator
(
Interpolator
interpolator
);
public
Number
getValue
(
Element
element
);
public
float
normalize
(
Number
value
);
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/RankingFunction.java
浏览文件 @
12e3edd4
...
...
@@ -45,7 +45,7 @@ package org.gephi.appearance.api;
*
* @author mbastian
*/
public
interface
RankingFunction
extends
Attribute
Function
{
public
interface
RankingFunction
extends
Function
{
public
Ranking
getRanking
();
}
modules/AppearanceAPI/src/main/resources/org/gephi/appearance/Bundle.properties
0 → 100644
浏览文件 @
12e3edd4
NodeGraphFunction.Degree.name
=
Degree
NodeGraphFunction.InDegree.name
=
In-Degree
NodeGraphFunction.OutDegree.name
=
Out-Degree
EdgeGraphFunction.Weight.name
=
Weight
EdgeGraphFunction.Type.name
=
Type
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java
浏览文件 @
12e3edd4
...
...
@@ -56,6 +56,9 @@ import org.gephi.appearance.spi.Transformer;
import
org.gephi.appearance.spi.TransformerCategory
;
import
org.gephi.appearance.spi.TransformerUI
;
import
static
org
.
gephi
.
desktop
.
appearance
.
AppearanceUIController
.
ELEMENT_CLASSES
;
import
org.gephi.graph.api.Graph
;
import
org.gephi.graph.api.GraphController
;
import
org.openide.util.Lookup
;
/**
*
...
...
@@ -65,6 +68,7 @@ public class AppearanceUIModel {
protected
final
AppearanceUIController
controller
;
protected
final
AppearanceModel
appearanceModel
;
protected
final
GraphController
graphController
;
protected
final
Map
<
String
,
Map
<
TransformerCategory
,
TransformerUI
>>
selectedTransformerUI
;
protected
final
Map
<
String
,
Map
<
TransformerUI
,
Function
>>
selectedFunction
;
protected
final
Map
<
String
,
TransformerCategory
>
selectedCategory
;
...
...
@@ -75,6 +79,7 @@ public class AppearanceUIModel {
public
AppearanceUIModel
(
AppearanceUIController
controller
,
AppearanceModel
model
)
{
this
.
controller
=
controller
;
this
.
appearanceModel
=
model
;
this
.
graphController
=
Lookup
.
getDefault
().
lookup
(
GraphController
.
class
);
//Init maps
selectedCategory
=
new
HashMap
<
String
,
TransformerCategory
>();
...
...
@@ -90,8 +95,9 @@ public class AppearanceUIModel {
}
private
void
initSelectedTransformerUIs
(
String
elementClass
)
{
Graph
graph
=
graphController
.
getGraphModel
(
appearanceModel
.
getWorkspace
()).
getGraph
();
Map
<
TransformerCategory
,
TransformerUI
>
newMap
=
new
HashMap
<
TransformerCategory
,
TransformerUI
>();
for
(
Function
func
:
elementClass
.
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
)
:
appearanceModel
.
getEdgeFunctions
(
))
{
for
(
Function
func
:
elementClass
.
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
graph
)
:
appearanceModel
.
getEdgeFunctions
(
graph
))
{
TransformerUI
ui
=
func
.
getUI
();
if
(
ui
!=
null
)
{
TransformerCategory
cat
=
ui
.
getCategory
();
...
...
@@ -111,7 +117,8 @@ public class AppearanceUIModel {
private
void
refreshSelectedFunctions
(
String
elementClass
)
{
Set
<
Function
>
functionSet
=
new
HashSet
<
Function
>();
for
(
Function
func
:
elementClass
.
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
()
:
appearanceModel
.
getEdgeFunctions
())
{
Graph
graph
=
graphController
.
getGraphModel
(
appearanceModel
.
getWorkspace
()).
getGraph
();
for
(
Function
func
:
elementClass
.
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
graph
)
:
appearanceModel
.
getEdgeFunctions
(
graph
))
{
TransformerUI
ui
=
func
.
getUI
();
if
(
ui
!=
null
)
{
functionSet
.
add
(
func
);
...
...
@@ -127,9 +134,10 @@ public class AppearanceUIModel {
}
public
boolean
refreshSelectedFunction
()
{
Graph
graph
=
graphController
.
getGraphModel
(
appearanceModel
.
getWorkspace
()).
getGraph
();
Function
sFunction
=
getSelectedFunction
();
if
(
sFunction
!=
null
&&
sFunction
.
isAttribute
())
{
for
(
Function
func
:
getSelectedElementClass
().
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
)
:
appearanceModel
.
getEdgeFunctions
(
))
{
for
(
Function
func
:
getSelectedElementClass
().
equals
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
graph
)
:
appearanceModel
.
getEdgeFunctions
(
graph
))
{
if
(
func
.
equals
(
sFunction
))
{
return
false
;
}
...
...
@@ -170,8 +178,9 @@ public class AppearanceUIModel {
}
public
Collection
<
Function
>
getFunctions
()
{
Graph
graph
=
graphController
.
getGraphModel
(
appearanceModel
.
getWorkspace
()).
getGraph
();
List
<
Function
>
functions
=
new
ArrayList
<
Function
>();
for
(
Function
func
:
selectedElementClass
.
equalsIgnoreCase
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
)
:
appearanceModel
.
getEdgeFunctions
(
))
{
for
(
Function
func
:
selectedElementClass
.
equalsIgnoreCase
(
AppearanceUIController
.
NODE_ELEMENT
)
?
appearanceModel
.
getNodeFunctions
(
graph
)
:
appearanceModel
.
getEdgeFunctions
(
graph
))
{
TransformerUI
ui
=
func
.
getUI
();
if
(
ui
!=
null
&&
ui
.
getDisplayName
().
equals
(
getSelectedTransformerUI
().
getDisplayName
()))
{
if
(
ui
.
getCategory
().
equals
(
selectedCategory
.
get
(
selectedElementClass
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录