Skip to content

Commit

Permalink
Changed a comment for LIntegerField. Changed ability for LDoubleField…
Browse files Browse the repository at this point in the history
… to return 0.0 for a call to .getValue() if the field is an empty string (so that its behavior is identical to the LIntegerField)
  • Loading branch information
mgporter authored and hbitteur committed Apr 1, 2024
1 parent 126216b commit 5d4acae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/main/org/audiveris/omr/ui/field/LDoubleField.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,19 @@ public LDoubleField (String label,
// getValue //
//----------//
/**
* Extract the double value from the field.
* Extract the double value from the field (a blank field is assumed to mean 0.0).
*
* @return the value as double
*/
public double getValue ()
{
return Double.parseDouble(getText());
String str = getField().getText().trim();

if (str.length() == 0) {
return 0.0;
} else {
return Double.parseDouble(str);
}
}

//-----------//
Expand All @@ -134,7 +140,7 @@ public double getValue ()
/**
* Adds the filter to the input field's document.
*/
private void setFilter() {
private void setFilter () {
AbstractDocument doc = (AbstractDocument) getField().getDocument();
doc.setDocumentFilter(new DoubleFilter());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/org/audiveris/omr/ui/field/LIntegerField.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public LIntegerField (String label,
/**
* Extract the current integer value form the text field.
*
* @return current integer value (a blank field is assumed to mean 0)
* @return current integer value (a blank field is assumed to mean 0).
*/
public int getValue ()
{
Expand All @@ -111,7 +111,7 @@ public int getValue ()
/**
* Adds the filter to the input field's document.
*/
private void setFilter() {
private void setFilter () {
AbstractDocument doc = (AbstractDocument) getField().getDocument();
doc.setDocumentFilter(new IntFilter());
}
Expand Down

0 comments on commit 5d4acae

Please sign in to comment.