Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sanbo_xyz
Gephi
提交
ab8b8b63
G
Gephi
项目概览
sanbo_xyz
/
Gephi
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
ab8b8b63
编写于
2月 12, 2022
作者:
M
Mathieu Bastian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add refresh mechanism
上级
b8294372
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
126 addition
and
17 deletion
+126
-17
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributePartitionImpl.java
...ain/java/org/gephi/appearance/AttributePartitionImpl.java
+8
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
...main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
+8
-2
modules/AppearanceAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
...eAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
+14
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/PartitionImpl.java
...API/src/main/java/org/gephi/appearance/PartitionImpl.java
+2
-0
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Function.java
...eAPI/src/main/java/org/gephi/appearance/api/Function.java
+7
-0
modules/AppearanceAPI/src/test/java/org.gephi.appearance/AttributePartitionTest.java
...est/java/org.gephi.appearance/AttributePartitionTest.java
+16
-0
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java
.../org/gephi/desktop/appearance/AppearanceTopComponent.java
+2
-0
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java
.../org/gephi/desktop/appearance/AppearanceUIController.java
+8
-10
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java
.../java/org/gephi/desktop/appearance/AppearanceUIModel.java
+9
-3
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java
.../org/gephi/desktop/appearance/AppearanceUIModelEvent.java
+1
-0
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AutoAppyTransformer.java
...ava/org/gephi/desktop/appearance/AutoAppyTransformer.java
+0
-1
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/FunctionObserverExecutor.java
...rg/gephi/desktop/appearance/FunctionObserverExecutor.java
+50
-0
pom.xml
pom.xml
+1
-1
未找到文件。
modules/AppearanceAPI/src/main/java/org/gephi/appearance/AttributePartitionImpl.java
浏览文件 @
ab8b8b63
...
...
@@ -116,6 +116,14 @@ public class AttributePartitionImpl extends PartitionImpl {
return
false
;
}
@Override
public
int
getVersion
(
Graph
graph
)
{
if
(
isValid
(
graph
))
{
return
getIndex
(
graph
.
getModel
().
getGraph
()).
getColumnIndex
(
column
.
get
()).
getVersion
();
}
return
0
;
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
...
...
modules/AppearanceAPI/src/main/java/org/gephi/appearance/EdgeTypePartitionImpl.java
浏览文件 @
ab8b8b63
...
...
@@ -88,7 +88,7 @@ public class EdgeTypePartitionImpl extends PartitionImpl {
@Override
public
float
percentage
(
Object
value
,
Graph
graph
)
{
int
count
=
count
(
value
,
graph
);
return
(
float
)
count
/
graph
.
getEdgeCount
();
return
(
(
float
)
count
)
/
graph
.
getEdgeCount
();
}
@Override
...
...
@@ -109,6 +109,12 @@ public class EdgeTypePartitionImpl extends PartitionImpl {
@Override
public
boolean
isValid
(
Graph
graph
)
{
return
graph
.
getModel
().
getEdgeTypeCount
()
>
1
;
return
graph
.
getModel
().
isMultiGraph
();
}
@Override
public
int
getVersion
(
Graph
graph
)
{
// TODO
return
0
;
}
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/FunctionImpl.java
浏览文件 @
ab8b8b63
...
...
@@ -43,6 +43,7 @@
package
org.gephi.appearance
;
import
java.util.Objects
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.gephi.appearance.api.Function
;
import
org.gephi.appearance.spi.PartitionTransformer
;
import
org.gephi.appearance.spi.RankingTransformer
;
...
...
@@ -66,6 +67,8 @@ public abstract class FunctionImpl implements Function {
protected
final
TransformerUI
transformerUI
;
protected
final
PartitionImpl
partition
;
protected
final
RankingImpl
ranking
;
// Version
protected
final
AtomicInteger
version
;
protected
FunctionImpl
(
AppearanceModelImpl
model
,
String
name
,
Class
<?
extends
Element
>
elementClass
,
Column
column
,
Transformer
transformer
,
TransformerUI
transformerUI
,
PartitionImpl
partition
,
...
...
@@ -85,6 +88,7 @@ public abstract class FunctionImpl implements Function {
this
.
transformerUI
=
transformerUI
;
this
.
partition
=
partition
;
this
.
ranking
=
ranking
;
this
.
version
=
new
AtomicInteger
(
Integer
.
MIN_VALUE
);
}
@Override
...
...
@@ -123,6 +127,16 @@ public abstract class FunctionImpl implements Function {
}
}
public
boolean
hasChanged
()
{
if
(
isSimple
())
{
return
false
;
}
else
{
Graph
graph
=
model
.
getGraph
();
int
newVersion
=
isPartition
()
?
partition
.
getVersion
(
graph
)
:
0
;
return
version
.
getAndSet
(
newVersion
)
!=
newVersion
;
}
}
public
boolean
isValid
()
{
if
(
isRanking
())
{
return
ranking
.
isValid
(
getGraph
());
...
...
modules/AppearanceAPI/src/main/java/org/gephi/appearance/PartitionImpl.java
浏览文件 @
ab8b8b63
...
...
@@ -86,4 +86,6 @@ public abstract class PartitionImpl implements Partition {
public
abstract
boolean
isValid
(
Graph
graph
);
public
abstract
Class
getValueType
();
public
abstract
int
getVersion
(
Graph
graph
);
}
modules/AppearanceAPI/src/main/java/org/gephi/appearance/api/Function.java
浏览文件 @
ab8b8b63
...
...
@@ -142,4 +142,11 @@ public interface Function {
* @return model
*/
AppearanceModel
getModel
();
/**
* Returns true if the underlying partition or ranking changed its boundaries or values since last time checked.
*
* @return true if changed, false otherwise
*/
boolean
hasChanged
();
}
modules/AppearanceAPI/src/test/java/org.gephi.appearance/AttributePartitionTest.java
浏览文件 @
ab8b8b63
...
...
@@ -103,4 +103,20 @@ public class AttributePartitionTest {
clearNodeAttributes
(
graph
);
Assert
.
assertFalse
(
p
.
isValid
(
graph
));
}
@Test
public
void
testVersion
()
{
Graph
graph
=
GraphGenerator
.
build
().
generateTinyGraph
().
addIntNodeColumn
().
getGraph
();
Column
column
=
graph
.
getModel
().
getNodeTable
().
getColumn
(
GraphGenerator
.
INT_COLUMN
);
Node
n1
=
graph
.
getNode
(
GraphGenerator
.
FIRST_NODE
);
AttributePartitionImpl
p
=
new
AttributePartitionImpl
(
column
);
int
version
=
p
.
getVersion
(
graph
);
n1
.
setAttribute
(
column
,
99
);
Assert
.
assertNotEquals
(
version
,
version
=
p
.
getVersion
(
graph
));
Assert
.
assertEquals
(
version
,
p
.
getVersion
(
graph
));
graph
.
removeNode
(
n1
);
Assert
.
assertNotEquals
(
version
,
p
.
getVersion
(
graph
));
}
}
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceTopComponent.java
浏览文件 @
ab8b8b63
...
...
@@ -152,6 +152,8 @@ public class AppearanceTopComponent extends TopComponent implements Lookup.Provi
refreshControls
();
}
else
if
(
pce
.
getPropertyName
().
equals
(
AppearanceUIModelEvent
.
ATTRIBUTE_LIST
))
{
refreshCombo
();
}
else
if
(
pce
.
getPropertyName
().
equals
(
AppearanceUIModelEvent
.
REFRESH_FUNCTION
))
{
refreshCenterPanel
();
}
// if (pce.getPropertyName().equals(RankingUIModel.LIST_VISIBLE)) {
// listButton.setSelected((Boolean) pce.getNewValue());
...
...
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIController.java
浏览文件 @
ab8b8b63
...
...
@@ -50,21 +50,12 @@ import java.util.LinkedHashMap;
import
java.util.LinkedHashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
org.gephi.appearance.api.AppearanceController
;
import
org.gephi.appearance.api.AppearanceModel
;
import
org.gephi.appearance.api.AttributeFunction
;
import
org.gephi.appearance.api.Function
;
import
org.gephi.appearance.spi.Transformer
;
import
org.gephi.appearance.spi.TransformerCategory
;
import
org.gephi.appearance.spi.TransformerUI
;
import
org.gephi.graph.api.Column
;
import
org.gephi.graph.api.ColumnObserver
;
import
org.gephi.graph.api.Graph
;
import
org.gephi.graph.api.GraphController
;
import
org.gephi.graph.api.GraphObserver
;
import
org.gephi.graph.api.TableObserver
;
import
org.gephi.project.api.ProjectController
;
import
org.gephi.project.api.Workspace
;
import
org.gephi.project.api.WorkspaceListener
;
...
...
@@ -269,11 +260,18 @@ public class AppearanceUIController {
}
public
void
refreshColumnsList
()
{
if
(
model
!=
null
)
{
if
(
model
!=
null
)
{
firePropertyChangeEvent
(
AppearanceUIModelEvent
.
ATTRIBUTE_LIST
,
null
,
null
);
}
}
public
void
refreshFunction
()
{
if
(
model
!=
null
)
{
System
.
out
.
println
(
"Refresh"
);
firePropertyChangeEvent
(
AppearanceUIModelEvent
.
REFRESH_FUNCTION
,
null
,
null
);
}
}
public
AppearanceController
getAppearanceController
()
{
return
appearanceController
;
}
...
...
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModel.java
浏览文件 @
ab8b8b63
...
...
@@ -74,6 +74,7 @@ public class AppearanceUIModel {
protected
final
Map
<
String
,
Map
<
TransformerCategory
,
AutoAppyTransformer
>>
selectedAutoTransformer
;
protected
final
Map
<
Function
,
Map
<
String
,
Object
>>
savedProperties
;
protected
final
TableObserverExecutor
tableObserverExecutor
;
protected
final
FunctionObserverExecutor
functionObserverExecutor
;
protected
String
selectedElementClass
=
AppearanceUIController
.
NODE_ELEMENT
;
public
AppearanceUIModel
(
AppearanceModel
model
)
{
...
...
@@ -91,8 +92,9 @@ public class AppearanceUIModel {
initSelectedTransformerUIs
(
ec
);
}
//Init observer
//Init observer
s
tableObserverExecutor
=
new
TableObserverExecutor
(
this
);
functionObserverExecutor
=
new
FunctionObserverExecutor
(
this
);
}
private
void
initSelectedTransformerUIs
(
String
elementClass
)
{
...
...
@@ -108,7 +110,7 @@ public class AppearanceUIModel {
TransformerCategory
cat
=
ui
.
getCategory
();
selectedCategory
.
put
(
elementClass
,
cat
);
if
(
func
.
isSimple
())
{
if
(
func
.
isSimple
())
{
selectedTransformerUI
.
get
(
elementClass
).
put
(
cat
,
ui
);
selectedFunction
.
get
(
elementClass
).
put
(
ui
,
func
);
}
...
...
@@ -124,10 +126,12 @@ public class AppearanceUIModel {
public
void
select
()
{
tableObserverExecutor
.
start
();
functionObserverExecutor
.
start
();
}
public
void
unselect
()
{
tableObserverExecutor
.
stop
();
functionObserverExecutor
.
stop
();
}
public
boolean
isLocalScale
()
{
...
...
@@ -309,6 +313,8 @@ public class AppearanceUIModel {
}
else
if
(
type
.
isArray
())
{
Class
cmp
=
type
.
getComponentType
();
return
cmp
.
isPrimitive
()
||
cmp
.
equals
(
Color
.
class
);
}
else
return
type
.
equals
(
Color
.
class
);
}
else
{
return
type
.
equals
(
Color
.
class
);
}
}
}
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AppearanceUIModelEvent.java
浏览文件 @
ab8b8b63
...
...
@@ -55,6 +55,7 @@ public class AppearanceUIModelEvent extends PropertyChangeEvent {
public
static
String
SELECTED_TRANSFORMER_UI
=
"selectedTransformerUI"
;
public
static
String
SELECTED_FUNCTION
=
"selectedFunction"
;
public
static
String
ATTRIBUTE_LIST
=
"attributeList"
;
public
static
String
REFRESH_FUNCTION
=
"refreshFunction"
;
public
static
String
START_STOP_AUTO_APPLY
=
"startStopAutoApply"
;
public
static
String
SET_AUTO_APPLY
=
"setStopAutoApply"
;
public
static
String
SET_LOCAL_SCALE
=
"setLocalScale"
;
...
...
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/AutoAppyTransformer.java
浏览文件 @
ab8b8b63
...
...
@@ -46,7 +46,6 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.TimeUnit
;
import
org.gephi.appearance.api.AppearanceController
;
import
org.gephi.appearance.api.Function
;
import
org.openide.util.Lookup
;
...
...
modules/DesktopAppearance/src/main/java/org/gephi/desktop/appearance/FunctionObserverExecutor.java
0 → 100644
浏览文件 @
ab8b8b63
package
org.gephi.desktop.appearance
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
org.gephi.appearance.api.Function
;
import
org.openide.util.Lookup
;
public
class
FunctionObserverExecutor
implements
Runnable
{
private
static
final
long
DEFAULT_DELAY
=
1000
;
//ms
private
final
AppearanceUIModel
model
;
private
final
AppearanceUIController
controller
;
private
ScheduledExecutorService
executor
;
public
FunctionObserverExecutor
(
AppearanceUIModel
model
)
{
this
.
model
=
model
;
this
.
controller
=
Lookup
.
getDefault
().
lookup
(
AppearanceUIController
.
class
);
}
public
void
start
()
{
executor
=
Executors
.
newSingleThreadScheduledExecutor
(
r
->
new
Thread
(
r
,
"Appearance Function Observer"
));
executor
.
scheduleWithFixedDelay
(
this
,
getDelayInMs
(),
getDelayInMs
(),
TimeUnit
.
MILLISECONDS
);
}
public
void
stop
()
{
if
(
executor
!=
null
&&
!
executor
.
isShutdown
())
{
executor
.
shutdown
();
}
executor
=
null
;
}
@Override
public
void
run
()
{
synchronized
(
this
)
{
Function
selectedFunction
=
model
.
getSelectedFunction
();
if
(
selectedFunction
!=
null
&&
selectedFunction
.
hasChanged
())
{
controller
.
refreshFunction
();
}
}
}
public
boolean
isRunning
()
{
return
executor
!=
null
;
}
private
long
getDelayInMs
()
{
return
DEFAULT_DELAY
;
}
}
pom.xml
浏览文件 @
ab8b8b63
...
...
@@ -137,7 +137,7 @@
<netbeans.version>
RELEASE126
</netbeans.version>
<!-- GraphStore version -->
<graphstore.version>
0.6.
1
</graphstore.version>
<graphstore.version>
0.6.
2
</graphstore.version>
<!-- Localization ZIP version, from 'http://netbeans.org/project_downloads/nblocalization' -->
<gephi.platform.localization.version>
1.1-NB80
</gephi.platform.localization.version>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录