Skip to content

Commit

Permalink
Specsize as percentage and px for issue #259
Browse files Browse the repository at this point in the history
Relative width as percentage and px
  • Loading branch information
phystem committed Apr 10, 2015
1 parent 766b989 commit 035a11d
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -88,5 +88,18 @@ protected Range convertRange(Range range, PageValidation pageValidation) throws
throw new ValidationErrorException(format("Cannot convert range: " + ex.getMessage()));
}
}

protected String getRangeAndValue(Range specRange, Range convertedRange, double realValue) {
String dimension = "px";
String originalValue = realValue + dimension;
String rangeValue = convertedRange.getErrorMessageSuffix();
if (specRange.isPercentage()) {
double size = convertedRange.getFrom() / specRange.getFrom() * 100.0;
dimension = "%";
originalValue = format("%f%s [%s]", realValue / size * 100.0, dimension, originalValue);
rangeValue = format("%s [%s]", specRange.getErrorMessageSuffix(dimension), convertedRange.toString());
}
return format("%s %s", originalValue, rangeValue);
}

}

0 comments on commit 035a11d

Please sign in to comment.