Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
fb41a529
Commit
fb41a529
authored
Nov 22, 2017
by
Tobias Meuser
Browse files
Made selection of active layers persisent
parent
f7c16e22
Changes
2
Show whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/visualization/ComponentVisManager.java
View file @
fb41a529
...
@@ -26,14 +26,15 @@ import java.util.List;
...
@@ -26,14 +26,15 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
javax.swing.JComponent
;
import
javax.swing.JComponent
;
import
javax.swing.JMenu
;
import
com.google.common.collect.ArrayListMultimap
;
import
com.google.common.collect.ArrayListMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimap
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.SimControlPanel
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationComponent
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationComponent
;
import
de.tud.kom.p2psim.impl.util.guirunner.Config
;
/**
/**
* This manager keeps track of all components that are added to the UI. It can
* This manager keeps track of all components that are added to the UI. It can
...
@@ -148,8 +149,14 @@ public class ComponentVisManager {
...
@@ -148,8 +149,14 @@ public class ComponentVisManager {
* @param component
* @param component
*/
*/
public
void
toggleComponent
(
String
name
)
{
public
void
toggleComponent
(
String
name
)
{
boolean
first
=
true
;
for
(
JComponent
component
:
nameToComponentMap
.
get
(
name
))
{
for
(
JComponent
component
:
nameToComponentMap
.
get
(
name
))
{
toggleComponent
(
component
);
toggleComponent
(
component
);
if
(
first
)
{
Config
.
setValue
(
SimControlPanel
.
getConfMainPath
(
name
),
component
.
isVisible
());
first
=
false
;
}
}
}
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/views/visualization/ui/SimControlPanel.java
View file @
fb41a529
...
@@ -43,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza
...
@@ -43,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisInfo
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisInfo
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisualizationListener
;
import
de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisualizationListener
;
import
de.tud.kom.p2psim.impl.util.guirunner.Config
;
/**
/**
* Menu-Bar containing means to alter the simulation speed, pause and un-pause
* Menu-Bar containing means to alter the simulation speed, pause and un-pause
...
@@ -51,8 +52,9 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.V
...
@@ -51,8 +52,9 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.V
* @author Bjoern Richerzhagen
* @author Bjoern Richerzhagen
* @version 1.0, 27.08.2012
* @version 1.0, 27.08.2012
*/
*/
public
class
SimControlPanel
extends
JMenuBar
public
class
SimControlPanel
extends
JMenuBar
implements
ActionListener
,
ChangeListener
,
VisualizationListener
{
implements
ActionListener
,
ChangeListener
,
VisualizationListener
{
private
static
final
String
CONF_PATH
=
"GUIRunner/Menu/Layels/"
;
private
static
final
long
serialVersionUID
=
-
914578954798611308L
;
private
static
final
long
serialVersionUID
=
-
914578954798611308L
;
...
@@ -119,7 +121,14 @@ public class SimControlPanel extends JMenuBar
...
@@ -119,7 +121,14 @@ public class SimControlPanel extends JMenuBar
@Override
@Override
public
void
visualizationAdded
(
VisInfo
visInfo
)
{
public
void
visualizationAdded
(
VisInfo
visInfo
)
{
JCheckBoxMenuItem
checkBox
=
new
JCheckBoxMenuItem
(
visInfo
.
getName
());
JCheckBoxMenuItem
checkBox
=
new
JCheckBoxMenuItem
(
visInfo
.
getName
());
checkBox
.
setSelected
(
visInfo
.
isActiveByDefault
());
boolean
isActive
=
visInfo
.
isActiveByDefault
();
isActive
=
Config
.
getValue
(
getConfMainPath
(
visInfo
.
getName
()),
isActive
);
checkBox
.
setSelected
(
isActive
);
if
(!
isActive
)
{
getVisManager
().
deactivateComponent
(
visInfo
.
getName
());
}
checkBox
.
addActionListener
(
new
ActionListener
()
{
checkBox
.
addActionListener
(
new
ActionListener
()
{
@Override
@Override
public
void
actionPerformed
(
ActionEvent
arg0
)
{
public
void
actionPerformed
(
ActionEvent
arg0
)
{
...
@@ -221,4 +230,22 @@ public class SimControlPanel extends JMenuBar
...
@@ -221,4 +230,22 @@ public class SimControlPanel extends JMenuBar
}
}
}
}
/**
* @return the confPath
*/
public
static
String
getConfPath
(
String
pName
)
{
return
CONF_PATH
+
pName
.
replace
(
":"
,
""
).
replaceAll
(
" "
,
""
);
}
/**
* @return the confPath
*/
public
static
String
getConfMainPath
(
String
pName
)
{
String
newName
=
"Layer_"
+
pName
.
replace
(
":"
,
""
).
replaceAll
(
" "
,
""
).
replace
(
"/"
,
"_"
);
if
(
newName
.
length
()
>
1
)
{
return
CONF_PATH
+
newName
+
"/Main"
;
}
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment