Skip to content
Snippets Groups Projects
Commit e8632c10 authored by BrunoDatoMeneses's avatar BrunoDatoMeneses
Browse files

CLN: visualization cleaning

parent c7b281c1
No related branches found
No related tags found
2 merge requests!2Merge dev into develop,!1Merge Master
...@@ -7,7 +7,6 @@ import java.util.HashMap; ...@@ -7,7 +7,6 @@ import java.util.HashMap;
import mas.ncs.NCS; import mas.ncs.NCS;
import mas.kernel.Config; import mas.kernel.Config;
import mas.kernel.Launcher; import mas.kernel.Launcher;
import mas.kernel.NCSMemory;
import mas.kernel.World; import mas.kernel.World;
import mas.agents.Agent; import mas.agents.Agent;
import mas.agents.percept.Percept; import mas.agents.percept.Percept;
...@@ -167,17 +166,12 @@ public class Head extends AbstractHead implements Cloneable{ ...@@ -167,17 +166,12 @@ public class Head extends AbstractHead implements Cloneable{
*/ */
public void play() { public void play() {
if(world.getScheduler().getTick() == 119) {
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TICK 119");
for(Context ctxt : activatedContexts) {
System.out.println(ctxt.getName());
}
}
for(Percept pct : this.world.getScheduler().getPercepts()) { for(Percept pct : this.world.getScheduler().getPercepts()) {
currentSituation.put(pct, pct.getValue()); currentSituation.put(pct, pct.getValue());
} }
System.out.println("HEAD ACTIVATED CONTEXT :" + activatedContexts.size());
nPropositionsReceived = activatedContexts.size(); nPropositionsReceived = activatedContexts.size();
newContextWasCreated = false; newContextWasCreated = false;
setContextFromPropositionWasSelected(false); setContextFromPropositionWasSelected(false);
......
...@@ -17,7 +17,6 @@ import visualization.view.global.PanelOneChart; ...@@ -17,7 +17,6 @@ import visualization.view.global.PanelOneChart;
import visualization.view.global.ScatterPlotExample; import visualization.view.global.ScatterPlotExample;
import visualization.view.global.PanelExoVSEndo; import visualization.view.global.PanelExoVSEndo;
import visualization.view.system.nDim.PanelParallelCoordinates; import visualization.view.system.nDim.PanelParallelCoordinates;
import visualization.view.system.twoDim.GrapheTwoDimPanelNCSMemories;
import visualization.view.system.twoDim.GrapheTwoDimPanelStandard; import visualization.view.system.twoDim.GrapheTwoDimPanelStandard;
import visualization.graphView.TemporalGraph; import visualization.graphView.TemporalGraph;
...@@ -38,13 +37,9 @@ public class MainTabbedPanel extends JTabbedPane{ ...@@ -38,13 +37,9 @@ public class MainTabbedPanel extends JTabbedPane{
/** The panel chart. */ /** The panel chart. */
private PanelChart panelChart; private PanelChart panelChart;
private PanelExoVSEndo exoVsEndo2CtxtChart;
private PanelExoVSEndo exoVsEndoNCtxtChart;
private PanelExoVSEndo exoVsEndoNCtxtByInfluenceChart;
/** The panel two dim standard. */ /** The panel two dim standard. */
private GrapheTwoDimPanelStandard panelTwoDimStandard; private GrapheTwoDimPanelStandard panelTwoDimStandard;
private GrapheTwoDimPanelNCSMemories panelTwoDimNCSMemories;
/** The panel parallel coordinates. */ /** The panel parallel coordinates. */
private PanelParallelCoordinates panelParallelCoordinates; private PanelParallelCoordinates panelParallelCoordinates;
...@@ -86,22 +81,16 @@ public class MainTabbedPanel extends JTabbedPane{ ...@@ -86,22 +81,16 @@ public class MainTabbedPanel extends JTabbedPane{
panelChart = new PanelChart(world); panelChart = new PanelChart(world);
//panelTwoDim = new GrapheTwoDimPanel(world); //panelTwoDim = new GrapheTwoDimPanel(world);
panelTwoDimStandard = new GrapheTwoDimPanelStandard(world); panelTwoDimStandard = new GrapheTwoDimPanelStandard(world);
panelTwoDimNCSMemories = new GrapheTwoDimPanelNCSMemories(world);
panelParallelCoordinates = new PanelParallelCoordinates(world); panelParallelCoordinates = new PanelParallelCoordinates(world);
consolePanel = new ConsolePanel(); consolePanel = new ConsolePanel();
exoVsEndo2CtxtChart = new PanelExoVSEndo(world, "Error Endo 2 Ctxt");
exoVsEndoNCtxtChart = new PanelExoVSEndo(world, "Error Endo N Ctxt");
exoVsEndoNCtxtByInfluenceChart = new PanelExoVSEndo(world, "Error Endo N Ctxt by Influence");
world.getScheduler().addScheduledItem(panelChart); world.getScheduler().addScheduledItem(panelChart);
world.getScheduler().addScheduledItem(exoVsEndo2CtxtChart);
world.getScheduler().addScheduledItem(exoVsEndoNCtxtChart);
world.getScheduler().addScheduledItem(exoVsEndoNCtxtByInfluenceChart);
//this.addTab("BlackBox", new JScrollPane(blackBoxPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); //this.addTab("BlackBox", new JScrollPane(blackBoxPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
//this.addTab("System", systemPanel); //this.addTab("System", systemPanel);
...@@ -111,10 +100,6 @@ public class MainTabbedPanel extends JTabbedPane{ ...@@ -111,10 +100,6 @@ public class MainTabbedPanel extends JTabbedPane{
// this.addTab("TwoDim", new JScrollPane(panelTwoDim,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); // this.addTab("TwoDim", new JScrollPane(panelTwoDim,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
// this.addTab("TwoDim", panelTwoDim); // this.addTab("TwoDim", panelTwoDim);
this.addTab("Console", new JScrollPane(consolePanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); this.addTab("Console", new JScrollPane(consolePanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
this.addTab("Exo VS endo 2 ctxt", new JScrollPane(exoVsEndo2CtxtChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
this.addTab("Exo VS endo N ctxt by distance", new JScrollPane(exoVsEndoNCtxtChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
this.addTab("Exo VS endo N ctxt by influence", new JScrollPane(exoVsEndoNCtxtByInfluenceChart,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
this.addTab("NCS Memories", new JScrollPane(panelTwoDimNCSMemories,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
((Frame) this.getTopLevelAncestor()).pack(); ((Frame) this.getTopLevelAncestor()).pack();
...@@ -128,7 +113,6 @@ public class MainTabbedPanel extends JTabbedPane{ ...@@ -128,7 +113,6 @@ public class MainTabbedPanel extends JTabbedPane{
// systemPanel.update(); // systemPanel.update();
// panelTwoDim.update(); // panelTwoDim.update();
panelTwoDimStandard.update(); panelTwoDimStandard.update();
panelTwoDimNCSMemories.updateMemories();
world.getScheduler().setWaitForGUIUpdate(false); world.getScheduler().setWaitForGUIUpdate(false);
} }
......
...@@ -235,6 +235,7 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener, ...@@ -235,6 +235,7 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener,
private Point3 requestPosition; private Point3 requestPosition;
/** /**
* Instantiates a new graphe two dim panel standard. * Instantiates a new graphe two dim panel standard.
* *
...@@ -373,8 +374,10 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener, ...@@ -373,8 +374,10 @@ public class GrapheTwoDimPanelStandard extends JPanel implements ViewerListener,
if(contexts.getSelectedItem()!=null) { if(contexts.getSelectedItem()!=null) {
Node node = graph.getNode(((Context) contexts.getSelectedItem()).getName()); highlightContexts((Context) contexts.getSelectedItem());
node.addAttribute("ui.style", "fill-color: rgba(0,255,0,150);"); }
else {
update();
} }
...@@ -1074,6 +1077,15 @@ private void startPanelController() { ...@@ -1074,6 +1077,15 @@ private void startPanelController() {
obsEle.setTick(world.getScheduler().getTick()); obsEle.setTick(world.getScheduler().getTick());
} }
// Update context comboBox
contexts.removeAllItems();
contexts.addItem(null);
for(Context ctxt : world.getScheduler().getContextsAsContext()) {
contexts.addItem(ctxt);
}
// Store values into array list of percept of observation // Store values into array list of percept of observation
ArrayList<Percept> perceptList = world.getAllPercept(); ArrayList<Percept> perceptList = world.getAllPercept();
...@@ -1220,7 +1232,7 @@ private void startPanelController() { ...@@ -1220,7 +1232,7 @@ private void startPanelController() {
b = 0.0; b = 0.0;
} }
} }
else if(coefs.length==3) { else if(coefs.length>=3) {
//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]); //System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
r = normalizePositiveValues(255, 5, Math.abs(coefs[0])); r = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
g = normalizePositiveValues(255, 5, Math.abs(coefs[1])); g = normalizePositiveValues(255, 5, Math.abs(coefs[1]));
...@@ -1328,53 +1340,7 @@ private void startPanelController() { ...@@ -1328,53 +1340,7 @@ private void startPanelController() {
return requestHashMap; return requestHashMap;
} }
public void highlightContextNeighbours(Context context) {
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (String name : world.getAgents().keySet()) {
SystemAgent a = world.getAgents().get(name);
if (a instanceof Context) {
double val = ((Context) a).getActionProposal();
if (val < min) {
min = val;
}
if (val > max) {
max = val;
}
}
}
for (String name : world.getAgents().keySet()) {
SystemAgent a = world.getAgents().get(name);
if (a instanceof Context) {
Context n = (Context)a;
Node node = graph.getNode(name);
node.addAttribute("ui.class","ContextColorDynamic");
node.setAttribute("ui.color", 0.1 );
if(context.equals(n)) {
node.setAttribute("ui.color", 0.0 );
}
}
}
}
...@@ -1411,7 +1377,7 @@ private void startPanelController() { ...@@ -1411,7 +1377,7 @@ private void startPanelController() {
b = 0.0; b = 0.0;
} }
} }
else if(coefs.length==3) { else if(coefs.length>=3) {
//System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]); //System.out.println(coefs[0] + " " + coefs[1] + " " + coefs[2]);
r = normalizePositiveValues(255, 5, Math.abs(coefs[0])); r = normalizePositiveValues(255, 5, Math.abs(coefs[0]));
g = normalizePositiveValues(255, 5, Math.abs(coefs[1])); g = normalizePositiveValues(255, 5, Math.abs(coefs[1]));
...@@ -1711,8 +1677,6 @@ private void startPanelController() { ...@@ -1711,8 +1677,6 @@ private void startPanelController() {
public void popupMenuForContextVisualization(String id) { public void popupMenuForContextVisualization(String id) {
JPopupMenu popup = new JPopupMenu("Visualization"); JPopupMenu popup = new JPopupMenu("Visualization");
JMenuItem itemShowContextNeighbours = new JMenuItem("Neighbours");
itemShowContextNeighbours.addActionListener(e -> {highlightNeighbours(id);});
JMenuItem itemShow2Dim = new JMenuItem("History of grapgh in 2 Dim"); JMenuItem itemShow2Dim = new JMenuItem("History of grapgh in 2 Dim");
itemShow2Dim.addActionListener(e -> {popupVisualization2Dim(id);}); itemShow2Dim.addActionListener(e -> {popupVisualization2Dim(id);});
JMenuItem itemShowNDim = new JMenuItem("Graph Visualization in N Dim"); JMenuItem itemShowNDim = new JMenuItem("Graph Visualization in N Dim");
...@@ -1723,8 +1687,7 @@ private void startPanelController() { ...@@ -1723,8 +1687,7 @@ private void startPanelController() {
JMenuItem itemUdateView = new JMenuItem("Update View"); JMenuItem itemUdateView = new JMenuItem("Update View");
itemUdateView.addActionListener(e -> {update();}); itemUdateView.addActionListener(e -> {update();});
itemShowAll.addActionListener( e -> {highlightNeighbours(id); popupVisualization2Dim(id); popupVisualizationNDim(id); recolorAllContexts();}); itemShowAll.addActionListener( e -> {popupVisualization2Dim(id); popupVisualizationNDim(id); recolorAllContexts();});
popup.add(itemShowContextNeighbours);
popup.add(itemShow2Dim); popup.add(itemShow2Dim);
popup.add(itemShowNDim); popup.add(itemShowNDim);
popup.add(itemShowAll); popup.add(itemShowAll);
...@@ -1760,10 +1723,7 @@ private void startPanelController() { ...@@ -1760,10 +1723,7 @@ private void startPanelController() {
// double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); // double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge());
// } // }
private void highlightNeighbours(String id) {
highlightContextNeighbours(world.getScheduler().getContextByName(id));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment