MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / setPlotDimensions

Method setPlotDimensions

src/tsd/GraphHandler.java:665–695  ·  view source on GitHub ↗

Parses the wxh query parameter to set the graph dimension.

(final HttpQuery query, final Plot plot)

Source from the content-addressed store, hash-verified

663
664 /** Parses the {@code wxh} query parameter to set the graph dimension. */
665 static void setPlotDimensions(final HttpQuery query, final Plot plot) {
666 String wxh = query.getQueryStringParam("wxh");
667 if (wxh != null && !wxh.isEmpty()) {
668 wxh = URLDecoder.decode(wxh.trim());
669 if (!WXH_VALIDATOR.matcher(wxh).find()) {
670 throw new IllegalArgumentException("'wxh' was invalid. "
671 + "Must satisfy the pattern " + WXH_VALIDATOR.toString());
672 }
673 final int wxhlength = wxh.length();
674 if (wxhlength < 7) { // 100x100 minimum.
675 throw new BadRequestException("Parameter wxh too short: " + wxh);
676 }
677 final int x = wxh.indexOf('x', 3); // Start at 2 as min size is 100x100
678 if (x < 0) {
679 throw new BadRequestException("Invalid wxh parameter: " + wxh);
680 }
681 try {
682 final short width = Short.parseShort(wxh.substring(0, x));
683 final short height = Short.parseShort(wxh.substring(x + 1, wxhlength));
684 try {
685 plot.setDimensions(width, height);
686 } catch (IllegalArgumentException e) {
687 throw new BadRequestException("Invalid wxh parameter: " + wxh + ", "
688 + e.getMessage());
689 }
690 } catch (NumberFormatException e) {
691 throw new BadRequestException("Can't parse wxh '" + wxh + "': "
692 + e.getMessage());
693 }
694 }
695 }
696
697 /**
698 * Formats and quotes the given string so it's a suitable Gnuplot string.

Callers 1

doGraphMethod · 0.95

Calls 6

isEmptyMethod · 0.80
setDimensionsMethod · 0.80
getMessageMethod · 0.65
getQueryStringParamMethod · 0.45
decodeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected