Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Christnowx
Gephi
提交
f89c39f2
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 搜索 >>
提交
f89c39f2
编写于
12月 02, 2015
作者:
M
Mathieu Bastian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix various ranking UI issues
上级
153bbde9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
63 deletion
+65
-63
modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java
...hi/ui/appearance/plugin/RankingColorTransformerPanel.java
+53
-51
modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RecentPalettes.java
...n/java/org/gephi/ui/appearance/plugin/RecentPalettes.java
+12
-12
未找到文件。
modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RankingColorTransformerPanel.java
浏览文件 @
f89c39f2
...
...
@@ -47,6 +47,8 @@ import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ObjectInputStream
;
...
...
@@ -61,6 +63,7 @@ import org.gephi.appearance.api.RankingFunction;
import
org.gephi.appearance.plugin.RankingElementColorTransformer
;
import
org.gephi.ui.components.PaletteIcon
;
import
org.gephi.ui.components.gradientslider.GradientSlider
;
import
org.gephi.ui.components.gradientslider.MultiThumbSlider
;
import
org.gephi.utils.PaletteUtils
;
import
org.gephi.utils.PaletteUtils.Palette
;
import
org.openide.util.NbBundle
;
...
...
@@ -78,76 +81,67 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
public
RankingColorTransformerPanel
()
{
initComponents
();
this
.
recentPalettes
=
new
RecentPalettes
();
//Init slider
gradientSlider
=
new
GradientSlider
(
GradientSlider
.
HORIZONTAL
);
gradientSlider
.
putClientProperty
(
"GradientSlider.includeOpacity"
,
"false"
);
gradientSlider
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
@Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
colorTransformer
!=
null
&&
((!
gradientSlider
.
isValueAdjusting
()
&&
evt
.
getPropertyName
().
equals
(
MultiThumbSlider
.
VALUES_PROPERTY
))
||
(
evt
.
getPropertyName
().
equals
(
MultiThumbSlider
.
ADJUST_PROPERTY
)
&&
evt
.
getNewValue
().
equals
(
Boolean
.
FALSE
))))
{
Color
[]
colors
=
gradientSlider
.
getColors
();
float
[]
positions
=
gradientSlider
.
getThumbPositions
();
if
(!
Arrays
.
equals
(
positions
,
colorTransformer
.
getColorPositions
())
||
!
Arrays
.
deepEquals
(
colors
,
colorTransformer
.
getColors
()))
{
colorTransformer
.
setColors
(
Arrays
.
copyOf
(
colors
,
colors
.
length
));
colorTransformer
.
setColorPositions
(
Arrays
.
copyOf
(
positions
,
positions
.
length
));
try
{
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
putByteArray
(
getPositionKey
(),
serializePositions
(
positions
));
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
putByteArray
(
getColorKey
(),
serializeColors
(
colors
));
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
addRecentPalette
();
}
// prepareGradientTooltip();
}
}
});
gradientPanel
.
add
(
gradientSlider
,
BorderLayout
.
CENTER
);
//Color Swatch
colorSwatchButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
JPopupMenu
popupMenu
=
getPalettePopupMenu
();
popupMenu
.
show
(
colorSwatchToolbar
,
-
popupMenu
.
getPreferredSize
().
width
,
0
);
}
});
}
public
void
setup
(
RankingFunction
function
)
{
colorTransformer
=
(
RankingElementColorTransformer
)
function
.
getTransformer
();
final
String
POSITIONS
=
"RankingColorTransformerPanel_"
+
colorTransformer
.
getClass
().
getSimpleName
()
+
"_positions"
;
final
String
COLORS
=
"RankingColorTransformerPanel_"
+
colorTransformer
.
getClass
().
getSimpleName
()
+
"_colors"
;
float
[]
positionsStart
=
colorTransformer
.
getColorPositions
();
Color
[]
colorsStart
=
colorTransformer
.
getColors
();
try
{
positionsStart
=
deserializePositions
(
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
getByteArray
(
POSITIONS
,
serializePositions
(
positionsStart
)));
colorsStart
=
deserializeColors
(
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
getByteArray
(
COLORS
,
serializeColors
(
colorsStart
)));
positionsStart
=
deserializePositions
(
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
getByteArray
(
getPositionKey
()
,
serializePositions
(
positionsStart
)));
colorsStart
=
deserializeColors
(
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
getByteArray
(
getColorKey
()
,
serializeColors
(
colorsStart
)));
colorTransformer
.
setColorPositions
(
positionsStart
);
colorTransformer
.
setColors
(
colorsStart
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
//Gradient
gradientSlider
=
new
GradientSlider
(
GradientSlider
.
HORIZONTAL
,
positionsStart
,
colorsStart
);
gradientSlider
.
putClientProperty
(
"GradientSlider.includeOpacity"
,
"false"
);
gradientSlider
.
addChangeListener
(
new
ChangeListener
()
{
@Override
public
void
stateChanged
(
ChangeEvent
e
)
{
Color
[]
colors
=
gradientSlider
.
getColors
();
float
[]
positions
=
gradientSlider
.
getThumbPositions
();
colorTransformer
.
setColors
(
Arrays
.
copyOf
(
colors
,
colors
.
length
));
colorTransformer
.
setColorPositions
(
Arrays
.
copyOf
(
positions
,
positions
.
length
));
try
{
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
putByteArray
(
POSITIONS
,
serializePositions
(
positions
));
NbPreferences
.
forModule
(
RankingColorTransformerPanel
.
class
).
putByteArray
(
COLORS
,
serializeColors
(
colors
));
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
// prepareGradientTooltip();
}
});
gradientPanel
.
add
(
gradientSlider
,
BorderLayout
.
CENTER
);
gradientSlider
.
setValues
(
positionsStart
,
colorsStart
);
// prepareGradientTooltip();
//Context
// setComponentPopupMenu(getPalettePopupMenu());
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mousePressed
(
MouseEvent
evt
)
{
if
(
evt
.
isPopupTrigger
())
{
JPopupMenu
popupMenu
=
getPalettePopupMenu
();
popupMenu
.
show
(
evt
.
getComponent
(),
evt
.
getX
(),
evt
.
getY
());
}
}
@Override
public
void
mouseReleased
(
MouseEvent
evt
)
{
if
(
evt
.
isPopupTrigger
())
{
JPopupMenu
popupMenu
=
getPalettePopupMenu
();
popupMenu
.
show
(
evt
.
getComponent
(),
evt
.
getX
(),
evt
.
getY
());
}
}
});
//Color Swatch
colorSwatchButton
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
ae
)
{
JPopupMenu
popupMenu
=
getPalettePopupMenu
();
popupMenu
.
show
(
colorSwatchToolbar
,
-
popupMenu
.
getPreferredSize
().
width
,
0
);
}
});
}
// private void prepareGradientTooltip() {
...
...
@@ -257,6 +251,14 @@ public class RankingColorTransformerPanel extends javax.swing.JPanel {
return
array
;
}
private
String
getPositionKey
()
{
return
"RankingColorTransformerPanel_"
+
colorTransformer
.
getClass
().
getSimpleName
()
+
"_positions"
;
}
private
String
getColorKey
()
{
return
"RankingColorTransformerPanel_"
+
colorTransformer
.
getClass
().
getSimpleName
()
+
"_colors"
;
}
private
byte
[]
serializeColors
(
Color
[]
colors
)
throws
Exception
{
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
out
=
new
ObjectOutputStream
(
bos
);
...
...
modules/AppearancePluginUI/src/main/java/org/gephi/ui/appearance/plugin/RecentPalettes.java
浏览文件 @
f89c39f2
...
...
@@ -46,8 +46,7 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.LinkedList
;
import
java.util.prefs.BackingStoreException
;
import
java.util.prefs.Preferences
;
import
org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient
;
...
...
@@ -62,14 +61,14 @@ public class RecentPalettes {
protected
static
String
DEFAULT_NODE_NAME
=
"prefs"
;
public
static
final
String
COLORS
=
"PaletteColors"
;
public
static
final
String
POSITIONS
=
"PalettePositions"
;
private
List
<
LinearGradient
>
gradients
;
private
int
maxSize
;
private
final
Linked
List
<
LinearGradient
>
gradients
;
private
final
int
maxSize
;
protected
String
nodeName
=
null
;
public
RecentPalettes
()
{
nodeName
=
"recentpalettes"
;
maxSize
=
14
;
gradients
=
new
ArrayList
<
LinearGradient
>(
maxSize
);
gradients
=
new
LinkedList
<
LinearGradient
>(
);
retrieve
();
}
...
...
@@ -78,9 +77,9 @@ public class RecentPalettes {
gradients
.
remove
(
gradient
);
// add to the top
gradients
.
add
(
0
,
gradient
);
gradients
.
push
(
new
LinearGradient
(
gradient
.
getColors
(),
gradient
.
getPositions
())
);
while
(
gradients
.
size
()
>
maxSize
)
{
gradients
.
remove
(
gradients
.
size
()
-
1
);
gradients
.
remove
Last
(
);
}
store
();
...
...
@@ -90,7 +89,7 @@ public class RecentPalettes {
return
gradients
.
toArray
(
new
LinearGradient
[
0
]);
}
pr
otected
void
store
()
{
pr
ivate
void
store
()
{
Preferences
prefs
=
getPreferences
();
// clear the backing store
...
...
@@ -99,18 +98,19 @@ public class RecentPalettes {
}
catch
(
BackingStoreException
ex
)
{
}
for
(
int
i
=
0
;
i
<
gradients
.
size
();
i
++)
{
LinearGradient
gradient
=
gradients
.
get
(
i
);
int
i
=
0
;
for
(
LinearGradient
gradient
:
gradients
)
{
try
{
prefs
.
putByteArray
(
COLORS
+
i
,
serializeColors
(
gradient
.
getColors
()));
prefs
.
putByteArray
(
POSITIONS
+
i
,
serializePositions
(
gradient
.
getPositions
()));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
i
++;
}
}
pr
otected
void
retrieve
()
{
pr
ivate
void
retrieve
()
{
gradients
.
clear
();
Preferences
prefs
=
getPreferences
();
...
...
@@ -122,7 +122,7 @@ public class RecentPalettes {
Color
[]
colors
=
deserializeColors
(
cols
);
float
[]
posisitons
=
deserializePositions
(
poss
);
LinearGradient
linearGradient
=
new
LinearGradient
(
colors
,
posisitons
);
gradients
.
add
(
linearGradient
);
gradients
.
add
Last
(
linearGradient
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录