Skip to content

Commit

Permalink
Merge branch 'feature/chart-panel-title' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
paulosousadias committed Dec 19, 2024
2 parents a0f9571 + 5f12ddb commit 220db57
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/java/pt/lsts/neptus/mra/MRAChartPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion src/java/pt/lsts/neptus/mra/plots/GenericPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

}
Expand Down
40 changes: 40 additions & 0 deletions src/java/pt/lsts/neptus/mra/plots/MRATimeSeriesPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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") || chartType.contains("Timeline")){
Map<String, List<String>> seriesMap = new HashMap<String, List<String>>();

String seriesStr = chartTitle;
seriesStr = seriesStr.substring(seriesStr.indexOf("[") + 1);
seriesStr = seriesStr.substring(0, seriesStr.indexOf("]"));
List<String> seriesList = new ArrayList<String>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/java/pt/lsts/neptus/mra/plots/ReplayPlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 220db57

Please sign in to comment.