Advertisement
adas291

Untitled

Feb 7th, 2023
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.38 KB | None | 0 0
  1.     function drawTimes(stopInfo, dc as Graphics.Dc) {
  2.         if (stopInfo[:busID].size() == 0) {
  3.             drawNotification(dc, Ui.loadResource(Rez.Strings.noTraffic));
  4.         } else {
  5.             var lineNumber = 0;
  6.             var positionY = tableY;
  7.             for (var i = $.pageIndex * 4; lineNumber < 4 && i < stopInfo[:busID].size(); i++) {
  8.                 lineNumber++;
  9.                 var busId = stopInfo[:busID][i];
  10.                 var busType = busId.substring(0, 1);
  11.                 var busNumber = busId.substring(1, busId.length());
  12.  
  13.                 var color;
  14.                 if (busType.equals("T")) {
  15.                     //green for trolley
  16.                     color = 0x00aa00;
  17.                 } else if (busNumber.find("G") == null) {
  18.                     color = 0xff0000;
  19.                 } else {
  20.                     color = 0x0000ff;
  21.                 }
  22.  
  23.                 dc.setColor(0x000000, -1);
  24.                 dc.drawRoundedRectangle(cellStart, positionY - rowHeight * 0.5, cellWidth, rowHeight, cornerRadius);
  25.  
  26.                 //------------------Bus number--------------------
  27.                 dc.setColor(color, -1);
  28.                 //Check for longer names
  29.                 if (busNumber.length() < 3) {
  30.                     //for regular numbers
  31.                     dc.fillRoundedRectangle(contentX, positionY - contentHeight / 2, defaultNumberWidth, contentHeight, cornerRadius);
  32.                     dc.setColor(0xffffff, -1);
  33.                     dc.drawText(contentX + defaultNumberWidth / 2, positionY, Graphics.FONT_SMALL, busNumber, Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
  34.                 } else {
  35.                     //for 3 character transport like 10A
  36.                     //red for bus
  37.                     var textWidth = dc.getTextWidthInPixels(busNumber, Graphics.FONT_MEDIUM);
  38.                     dc.fillRoundedRectangle(contentX, positionY - contentHeight / 2, textWidth, contentHeight, cornerRadius);
  39.                     dc.setColor(0xffffff, -1);
  40.                     dc.drawText(contentX + textWidth * 0.5, positionY, Graphics.FONT_SMALL, busNumber, Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
  41.                 }
  42.  
  43.                 //---------------Difference-----------------------------
  44.                 dc.setColor(0x000000, -1);
  45.  
  46.                 var difference = stopInfo[:differences][i];
  47.                 var timeType = "m";
  48.  
  49.                 if (difference > 60) {
  50.                     difference = difference / 60;
  51.                     timeType = "h";
  52.                 }
  53.  
  54.                 dc.drawText(differenceX, positionY, Graphics.FONT_SMALL, difference.toString(), Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER);
  55.                 //-------------------------time symbol-----------------------------
  56.                 dc.drawText(timeSymbolX, positionY + timeSymbolOffset, Graphics.FONT_XTINY, timeType, Graphics.TEXT_JUSTIFY_VCENTER);
  57.                 positionY += rowHeight - 1;
  58.             }
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement