private void applyRectangleStyle(Rectangle r, Offset offset) {
   Color customColor = myInputApi.getHolidayColor(offset.getOffsetStart());
   if (customColor != null) {
     r.setBackgroundColor(customColor);
     r.setOpacity(1.0f);
   }
   if ((offset.getDayMask() & DayMask.HOLIDAY) == DayMask.HOLIDAY) {
     r.setStyle("calendar.holiday");
     return;
   }
   if ((offset.getDayMask() & DayMask.WEEKEND) == DayMask.WEEKEND) {
     r.setStyle("calendar.weekend");
     return;
   }
 }
 // This method creates colored vertical stripes on the chart which correspond
 // to weekend days and holidays. It is not necessary that colored stripe is
 // a non-working day, though: e.g. we may show weekends but count them as working days.
 private void renderNonWorkingDayColumns() {
   List<Offset> defaultOffsets = myInputApi.getAtomUnitOffsets();
   int curX = defaultOffsets.get(0).getOffsetPixels();
   if (curX > 0) {
     curX = 0;
   }
   for (final Offset offset : defaultOffsets) {
     int dayMask = offset.getDayMask();
     CalendarEvent event = myInputApi.getEvent(offset.getOffsetStart());
     final int _curX = curX;
     Runnable r =
         new Runnable() {
           @Override
           public void run() {
             // Create a holiday/weekend day bar in the main area
             renderNonWorkingDay(_curX, offset);
             // And expand it to the timeline area.
             Rectangle r =
                 myTimelineCanvas.createRectangle(
                     _curX,
                     getLineTopPosition(),
                     offset.getOffsetPixels() - _curX,
                     getLineBottomPosition() - getLineTopPosition());
             applyRectangleStyle(r, offset);
           }
         };
     if ((dayMask & (DayMask.WEEKEND)) != 0) {
       // We render weekends always. If there is a colored event its color will be applied
       // in applyRectangleStyle because getholidaycolor returns non-null
       r.run();
     } else if (event != null) {
       // It is not a weekends but it is an event
       // Holidays should always be painted, but neutral and working days should not unless
       // they have a custom color
       if (event.getType() == CalendarEvent.Type.HOLIDAY || event.getColor() != null) {
         r.run();
       }
     }
     curX = offset.getOffsetPixels();
   }
 }