Skip to content

Commit

Permalink
Custom titles for axes; a custom title for the chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpyat2 committed Feb 25, 2024
1 parent ff035be commit 987d431
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 10 deletions.
Binary file modified plugin/doc/FlexibleTextFileFormat Plug-In.docx
Binary file not shown.
Binary file modified plugin/doc/FlexibleTextFileFormat Plug-In.odt
Binary file not shown.
Binary file modified plugin/doc/FlexibleTextFileFormat Plug-In.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
// This pligin reads text files having the following format:
//
// #NAME=(object name). May appear in any line.
// #TITLEX=(axis title). May appear in any line.
// #TITLEY=(axis title). May appear in any line.
// #DATE=(date column type: JD or HJD or BJD, default: JD). May appear before observations only.
// #DELIM=(delimiter, default: comma). May appear in any line (i.e. to change delimiter)
// #FILTER=(default value, if not specified in FILTER column). May appear in any line (i.e. to change filter)
Expand Down Expand Up @@ -216,6 +218,8 @@ class FlexibleTextFileFormatRetriever extends AbstractObservationRetriever {
private String defFilter = "";
private String defObsCode = "";
private String filterVeLa = "";
private String titleX = "";
private String titleY = "";
private double magShift = 0.0;
private double dateAdd = 0.0;
private boolean ignoreValidationErrors = false;
Expand Down Expand Up @@ -495,6 +499,10 @@ else if ("Y".equalsIgnoreCase(pair[1]))
initFieldMap(pair[1].toUpperCase());
if (timeColumn < 0 || magColumn < 0)
return "#FIELDS directive must specify at least Time and Mag fields!";
} else if ("#TITLEX".equals(pair[0])) {
titleX = pair[1];
} else if ("#TITLEY".equals(pair[0])) {
titleY = pair[1];
}

}
Expand Down Expand Up @@ -849,7 +857,7 @@ public String getSourceName() {

@Override
public String getSourceType() {
return "Flexible Text Format File V1.0";
return "Flexible Text Format File V1.1";
}

@Override
Expand All @@ -863,6 +871,16 @@ public StarInfo getStarInfo() {

return new StarInfo(this, name);
}

@Override
public String getDomainTitle() {
return titleX;
}

@Override
public String getRangeTitle() {
return titleY;
}

private boolean isEmpty(String str) {
return str != null && "".equals(str.trim());
Expand Down
18 changes: 18 additions & 0 deletions src/org/aavso/tools/vstar/input/AbstractObservationRetriever.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ public String getBrightnessUnits() {
return MAGNITUDE;
}

/**
* Returns the custom domain title.
*
* @return The custom domain title.
*/
public String getDomainTitle() {
return null;
}

/**
* Returns the custom range title.
*
* @return The custom range title.
*/
public String getRangeTitle() {
return null;
}

/**
* Set the VeLa filter string.
*
Expand Down
12 changes: 11 additions & 1 deletion src/org/aavso/tools/vstar/ui/mediator/Mediator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,15 @@ public void createNewStarObservationArtefacts(NewStarType newStarType, StarInfo
getDocumentManager().addStatsInfo("Confidence Interval",
"Mean error bars denote 95% Confidence Interval (twice Standard Error)");

String plotName;
String designation = starInfo.getDesignation();
// If star's designation starts with '^', do not prefix it with "Light Curve for"
if (designation != null && designation.length() > 0 && "^".equals(designation.substring(0, 1)))
plotName = designation.substring(1);
else
plotName = LocaleProps.get("LIGHT_CURVE") + " " + LocaleProps.get("FOR") + " " + designation;
obsAndMeanChartPane = createObservationAndMeanPlotPane(
LocaleProps.get("LIGHT_CURVE") + " " + LocaleProps.get("FOR") + " " + starInfo.getDesignation(),
plotName,
null, obsAndMeanPlotModel, starInfo.getRetriever());

obsAndMeanPlotModel.getMeansChangeNotifier()
Expand Down Expand Up @@ -1572,6 +1579,9 @@ public AnalysisTypeChangeMessage createPhasePlotArtefacts(double period, double

obsAndMeanPlotModel2.getMeansChangeNotifier().addListener(meanObsTableModel);

// If star's name starts with '^', remove the first char (see "LIGHT_CURVE")
if (objName != null && objName.length() > 0 && "^".equals(objName.substring(0, 1)))
objName = objName.substring(1);
PhaseAndMeanPlotPane obsAndMeanChartPane = createPhaseAndMeanPlotPane(
LocaleProps.get("PHASE_PLOT") + " " + LocaleProps.get("FOR") + " " + objName, subTitle,
obsAndMeanPlotModel1, obsAndMeanPlotModel2, epoch, period,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,27 @@ public void chartMouseClicked(ChartMouseEvent event) {
/**
* @return The time axis label.
*/
protected static String getTimeAxisLabel(String units) {
return String.format(LocaleProps.get("TIME"));
protected static String getTimeAxisLabel(AbstractObservationRetriever retriever) {
// Custom axis title
String axis_title;
axis_title = retriever.getDomainTitle();
if (axis_title != null && !"".equals(axis_title))
return axis_title;
else
return String.format(LocaleProps.get("TIME"));
}

/**
* @return The brightness axis label.
*/
protected static String getBrightnessAxisLabel(String units) {
return String.format("%s (%s)", LocaleProps.get("BRIGHTNESS"), units);
protected static String getBrightnessAxisLabel(AbstractObservationRetriever retriever) {
// Custom axis title
String axis_title;
axis_title = retriever.getRangeTitle();
if (axis_title != null && !"".equals(axis_title))
return axis_title;
else
return String.format("%s (%s)", LocaleProps.get("BRIGHTNESS"), retriever.getBrightnessUnits());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public ObservationAndMeanPlotPane(String title, String subTitle, String domainTi
public ObservationAndMeanPlotPane(String title, String subTitle, ObservationAndMeanPlotModel obsAndMeanModel,
Dimension bounds, AbstractObservationRetriever retriever) {

this(title, subTitle, getTimeAxisLabel(retriever.getTimeUnits()),
getBrightnessAxisLabel(retriever.getBrightnessUnits()), obsAndMeanModel, bounds, retriever);
this(title, subTitle, getTimeAxisLabel(retriever),
getBrightnessAxisLabel(retriever), obsAndMeanModel, bounds, retriever);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public PhaseAndMeanPlotPane(String title, String subTitle,
AbstractObservationRetriever retriever,
PhasedObservationAndMeanPlotModel... obsAndMeanModels) {

super(title, subTitle, PHASE, getBrightnessAxisLabel(retriever
.getBrightnessUnits()), obsAndMeanModels[0], bounds, retriever);
super(title, subTitle, PHASE, getBrightnessAxisLabel(retriever), obsAndMeanModels[0], bounds, retriever);

this.epoch = epoch;
this.period = period;
Expand Down

0 comments on commit 987d431

Please sign in to comment.