From 0bb25338edcc82f39a02d8a4d3780b5ef5155925 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Fri, 15 Nov 2024 16:26:03 +0000 Subject: [PATCH 1/6] mra/MRAChartPanel: Messages chart titles are now overwritten in order to reduce amount of redundant information in label. --- .../pt/lsts/neptus/mra/MRAChartPanel.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java index f9820fb898..4278ec082c 100644 --- a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java +++ b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java @@ -41,7 +41,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Vector; import javax.swing.AbstractAction; @@ -360,6 +363,8 @@ public void regeneratePanel() { cpanel.getChart().getXYPlot().setDomainPannable(true); cpanel.getChart().getXYPlot().setRangePannable(true); + parseChartTitle(cpanel); + cpanel.getPopupMenu().add(I18n.text("Add Mark")).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -451,4 +456,41 @@ public void chartMouseMoved(ChartMouseEvent e) { lblX.setText(dx + ""); lblY.setText(dy + ""); } + + private void parseChartTitle(ChartPanel cpanel) { + String chartTitle = cpanel.getChart().getTitle().getText(); + String newTitle; + + if (chartTitle.contains("Messages plot")) { + MRATimeSeriesPlot chart = (MRATimeSeriesPlot) this.chart; + Map> seriesMap = new HashMap>(); + if (chart.getSeriesNames().isEmpty()) { + String series = chartTitle.split(" ")[0]; + series = series.replace("[", "").replace("]", ""); + String[] seriesVariables = series.split("\\."); + String seriesName = seriesVariables[0]; + String seriesVariable = seriesVariables[1]; + newTitle = seriesName + " [" + seriesVariable + "] Messages plot"; + cpanel.getChart().setTitle(newTitle); + return; + } + + for (String series : chart.getSeriesNames()) { + String[] seriesVariables = series.split("\\."); + String seriesName = seriesVariables[seriesVariables.length - 2]; + String seriesVariable = seriesVariables[seriesVariables.length - 1]; + if (!seriesMap.containsKey(seriesName)) { + seriesMap.put(seriesName, new ArrayList<>()); + } + if (!seriesMap.get(seriesName).contains(seriesVariable)) { + seriesMap.get(seriesName).add(seriesVariable); + } + } + + newTitle = seriesMap.toString(); + newTitle = newTitle.substring(1,newTitle.length()-1).replace('=',' '); + newTitle += " Messages plot"; + cpanel.getChart().setTitle(newTitle); + } + } } From d74cd8199efa279cc0f7907b399f11b43a688783 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Mon, 18 Nov 2024 08:47:45 +0000 Subject: [PATCH 2/6] mra/MRAChartPanel: Chart title is now constructed based on the original title instead of its series. --- src/java/pt/lsts/neptus/mra/MRAChartPanel.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java index 4278ec082c..5f7c494649 100644 --- a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java +++ b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java @@ -462,20 +462,14 @@ private void parseChartTitle(ChartPanel cpanel) { String newTitle; if (chartTitle.contains("Messages plot")) { - MRATimeSeriesPlot chart = (MRATimeSeriesPlot) this.chart; Map> seriesMap = new HashMap>(); - if (chart.getSeriesNames().isEmpty()) { - String series = chartTitle.split(" ")[0]; - series = series.replace("[", "").replace("]", ""); - String[] seriesVariables = series.split("\\."); - String seriesName = seriesVariables[0]; - String seriesVariable = seriesVariables[1]; - newTitle = seriesName + " [" + seriesVariable + "] Messages plot"; - cpanel.getChart().setTitle(newTitle); - return; - } - for (String series : chart.getSeriesNames()) { + String seriesStr = chartTitle; + seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1); + seriesStr = seriesStr.substring(0, seriesStr.indexOf("]")); + List seriesList = new ArrayList(Arrays.asList(seriesStr.split(", "))); + + for (String series : seriesList) { String[] seriesVariables = series.split("\\."); String seriesName = seriesVariables[seriesVariables.length - 2]; String seriesVariable = seriesVariables[seriesVariables.length - 1]; From b3ce6bbbb53d7f1eea750b71f069254a3ad66c73 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Mon, 16 Dec 2024 15:15:14 +0000 Subject: [PATCH 3/6] plots/GenericPlot: Chart title is now constructed at the GenericPlot class level, having the title attribute equal to the parsing result. --- .../pt/lsts/neptus/mra/MRAChartPanel.java | 33 ---------------- .../pt/lsts/neptus/mra/plots/GenericPlot.java | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java index 5f7c494649..be4a038cac 100644 --- a/src/java/pt/lsts/neptus/mra/MRAChartPanel.java +++ b/src/java/pt/lsts/neptus/mra/MRAChartPanel.java @@ -363,8 +363,6 @@ public void regeneratePanel() { cpanel.getChart().getXYPlot().setDomainPannable(true); cpanel.getChart().getXYPlot().setRangePannable(true); - parseChartTitle(cpanel); - cpanel.getPopupMenu().add(I18n.text("Add Mark")).addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -456,35 +454,4 @@ public void chartMouseMoved(ChartMouseEvent e) { lblX.setText(dx + ""); lblY.setText(dy + ""); } - - private void parseChartTitle(ChartPanel cpanel) { - String chartTitle = cpanel.getChart().getTitle().getText(); - String newTitle; - - if (chartTitle.contains("Messages plot")) { - Map> seriesMap = new HashMap>(); - - String seriesStr = chartTitle; - seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1); - seriesStr = seriesStr.substring(0, seriesStr.indexOf("]")); - List seriesList = new ArrayList(Arrays.asList(seriesStr.split(", "))); - - for (String series : seriesList) { - String[] seriesVariables = series.split("\\."); - String seriesName = seriesVariables[seriesVariables.length - 2]; - String seriesVariable = seriesVariables[seriesVariables.length - 1]; - if (!seriesMap.containsKey(seriesName)) { - seriesMap.put(seriesName, new ArrayList<>()); - } - if (!seriesMap.get(seriesName).contains(seriesVariable)) { - seriesMap.get(seriesName).add(seriesVariable); - } - } - - newTitle = seriesMap.toString(); - newTitle = newTitle.substring(1,newTitle.length()-1).replace('=',' '); - newTitle += " Messages plot"; - cpanel.getChart().setTitle(newTitle); - } - } } diff --git a/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java b/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java index 58412fe895..c98c549127 100644 --- a/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java @@ -32,7 +32,11 @@ */ package pt.lsts.neptus.mra.plots; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Vector; import javax.swing.ImageIcon; @@ -57,7 +61,7 @@ protected GenericPlot(String[] fieldsToPlot, MRAPanel panel, String postfixTile) this.postfixTile = postfixTile; StringBuilder sb = new StringBuilder(Arrays.toString(fieldsToPlot)); sb.append(" " + this.postfixTile); - this.name = sb.toString(); + this.name = parseChartTitle(sb); this.fieldsToPlot = fieldsToPlot; } @@ -130,4 +134,36 @@ public void process(LsfIndex source) { } } } + + private String parseChartTitle(StringBuilder sb) { + String chartTitle = String.valueOf(sb); + String newTitle; + + if (chartTitle.contains("Messages") || chartTitle.contains("Compare") || chartTitle.contains("Timeline")) { + Map> seriesMap = new HashMap>(); + + String seriesStr = chartTitle; + seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1); + seriesStr = seriesStr.substring(0, seriesStr.indexOf("]")); + List seriesList = new ArrayList(Arrays.asList(seriesStr.split(", "))); + + for (String series : seriesList) { + String[] seriesVariables = series.split("\\."); + String seriesName = seriesVariables[seriesVariables.length - 2]; + String seriesVariable = seriesVariables[seriesVariables.length - 1]; + if (!seriesMap.containsKey(seriesName)) { + seriesMap.put(seriesName, new ArrayList<>()); + } + if (!seriesMap.get(seriesName).contains(seriesVariable)) { + seriesMap.get(seriesName).add(seriesVariable); + } + } + + newTitle = seriesMap.toString(); + newTitle = newTitle.substring(1,newTitle.length()-1).replace('=',' '); + newTitle += " " + this.postfixTile; + return newTitle; + } + return chartTitle; + } } From 969908b1e5f727ec358987c6d8fa60a9d62ffc50 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Mon, 16 Dec 2024 15:50:50 +0000 Subject: [PATCH 4/6] plots/GenericMultiAxisPlot: Plot title does not duplicate the word plot anymore. --- src/java/pt/lsts/neptus/mra/plots/GenericMultiAxisPlot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/pt/lsts/neptus/mra/plots/GenericMultiAxisPlot.java b/src/java/pt/lsts/neptus/mra/plots/GenericMultiAxisPlot.java index 5af03cb095..fe66198655 100644 --- a/src/java/pt/lsts/neptus/mra/plots/GenericMultiAxisPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/GenericMultiAxisPlot.java @@ -53,7 +53,7 @@ public class GenericMultiAxisPlot extends GenericPlot implements IMultiAxisPlots { public GenericMultiAxisPlot(String[] fieldsToPlot, MRAPanel panel) { - super(fieldsToPlot, panel , "Compare Plot"); + super(fieldsToPlot, panel , "Compare"); } // public ImageIcon getIcon() { From add00f7e387efae463f27b1c4b3205768b6b1bd7 Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Mon, 16 Dec 2024 15:58:23 +0000 Subject: [PATCH 5/6] plots/MRATimeSeriesPlot: Chart title is now constructed at the MRATimeSeriesPlot class level. --- .../pt/lsts/neptus/mra/plots/GenericPlot.java | 32 --------------- .../neptus/mra/plots/MRATimeSeriesPlot.java | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java b/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java index c98c549127..218a34a8bd 100644 --- a/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/GenericPlot.java @@ -134,36 +134,4 @@ public void process(LsfIndex source) { } } } - - private String parseChartTitle(StringBuilder sb) { - String chartTitle = String.valueOf(sb); - String newTitle; - - if (chartTitle.contains("Messages") || chartTitle.contains("Compare") || chartTitle.contains("Timeline")) { - Map> seriesMap = new HashMap>(); - - String seriesStr = chartTitle; - seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1); - seriesStr = seriesStr.substring(0, seriesStr.indexOf("]")); - List seriesList = new ArrayList(Arrays.asList(seriesStr.split(", "))); - - for (String series : seriesList) { - String[] seriesVariables = series.split("\\."); - String seriesName = seriesVariables[seriesVariables.length - 2]; - String seriesVariable = seriesVariables[seriesVariables.length - 1]; - if (!seriesMap.containsKey(seriesName)) { - seriesMap.put(seriesName, new ArrayList<>()); - } - if (!seriesMap.get(seriesName).contains(seriesVariable)) { - seriesMap.get(seriesName).add(seriesVariable); - } - } - - newTitle = seriesMap.toString(); - newTitle = newTitle.substring(1,newTitle.length()-1).replace('=',' '); - newTitle += " " + this.postfixTile; - return newTitle; - } - return chartTitle; - } } diff --git a/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java b/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java index 2b4387b2a1..1e22375614 100644 --- a/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java @@ -34,12 +34,17 @@ import java.awt.Color; import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.TimeZone; import java.util.Vector; @@ -132,6 +137,41 @@ public void addValue(long timeMillis, String trace, double value) { series.get(trace).addOrUpdate(new Millisecond(new Date(timeMillis), TimeZone.getTimeZone("UTC"), Locale.getDefault()), value); } + public String parseChartTitle(StringBuilder sb) { + String chartTitle = String.valueOf(sb); + String newTitle; + + String chartType = chartTitle.substring(chartTitle.indexOf("] ") + 1); + + if (chartType.contains("Messages") || chartType.contains("Compare")){ + Map> seriesMap = new HashMap>(); + + String seriesStr = chartTitle; + seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1); + seriesStr = seriesStr.substring(0, seriesStr.indexOf("]")); + List seriesList = new ArrayList(Arrays.asList(seriesStr.split(", "))); + + for (String series : seriesList) { + String[] seriesVariables = series.split("\\."); + String seriesName = seriesVariables[seriesVariables.length - 2]; + String seriesVariable = seriesVariables[seriesVariables.length - 1]; + if (!seriesMap.containsKey(seriesName)) { + seriesMap.put(seriesName, new ArrayList<>()); + } + if (!seriesMap.get(seriesName).contains(seriesVariable)) { + seriesMap.get(seriesName).add(seriesVariable); + } + } + + newTitle = seriesMap.toString(); + newTitle = newTitle.substring(1,newTitle.length()-1).replace('=',' '); + newTitle += " " + chartType; + + return newTitle; + } + return chartTitle; + } + @Override public Component getComponent(IMraLogGroup source, double timestep) { MRAChartPanel fcp = new MRAChartPanel(this, source, mraPanel); From 5f12ddbf57d37a4290811fdac3961ed7ef83657e Mon Sep 17 00:00:00 2001 From: Miguel Carvalho Date: Mon, 16 Dec 2024 16:11:19 +0000 Subject: [PATCH 6/6] plots/MRATimeSeriesPlot: Chart title construction now supports Timeline plots. --- src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java | 2 +- src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java b/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java index 1e22375614..e2707496ab 100644 --- a/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java @@ -143,7 +143,7 @@ public String parseChartTitle(StringBuilder sb) { String chartType = chartTitle.substring(chartTitle.indexOf("] ") + 1); - if (chartType.contains("Messages") || chartType.contains("Compare")){ + if (chartType.contains("Messages") || chartType.contains("Compare") || chartType.contains("Timeline")){ Map> seriesMap = new HashMap>(); String seriesStr = chartTitle; diff --git a/src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java b/src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java index 4f3f30b825..e82236eb3b 100644 --- a/src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java +++ b/src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java @@ -109,7 +109,7 @@ public Component getComponent(IMraLogGroup source, double timestep) { public String getName() { StringBuilder sb = new StringBuilder(Arrays.toString(fieldsToPlot)); sb.append(" Timeline"); - return sb.toString(); + return parseChartTitle(sb); } @Override