MCPcopy Create free account
hub / github.com/dumbledore/AlbiteREADER / drawProgressBar

Method drawProgressBar

src/org/albite/albite/BookCanvas.java:563–628  ·  view source on GitHub ↗
(final int w, final int h, final Graphics g)

Source from the content-addressed store, hash-verified

561 }
562
563 private void drawProgressBar(final int w, final int h, final Graphics g) {
564
565 /* Update the state */
566 repaintProgressBar = false;
567
568 /* setup some temp vars */
569 final int fillHeight = h - (statusBarHeight + progressBarHeight) / 2;
570 final int progressBarHeight_2 = progressBarHeight / 2;
571
572 /*
573 * Clearing background
574 */
575 g.setColor(currentScheme.colors[ColorScheme.COLOR_BACKGROUND]);
576
577 g.fillRect(progressBarX, h - statusBarHeight,
578 progressBarWidth, statusBarHeight);
579
580 /* drawing progress bar */
581 g.setColor(currentScheme.colors[ColorScheme.COLOR_TEXT_STATUS_2]);
582 g.drawLine(progressBarX, fillHeight + progressBarHeight_2,
583 progressBarX + progressBarWidth - 1, fillHeight + progressBarHeight_2);
584
585 g.setColor(currentScheme.colors[ColorScheme.COLOR_TEXT_STATUS]);
586
587 g.drawRect(
588 progressBarX, h - ((statusBarHeight + progressBarHeight) / 2),
589 progressBarWidth - 1, progressBarHeight);
590
591 final int pagesBarWidth;
592
593 if (pagesCount > 0) {
594 pagesBarWidth =
595 (int) (progressBarWidth
596 * (((float) chapterBooklet.getCurrentPageIndex() - 1)
597 / pagesCount));
598 } else {
599 /*
600 * This should never happen, how could there be 0 pages?!
601 */
602 pagesBarWidth = progressBarWidth;
603 }
604
605 final int chaptersCount = currentBook.getChaptersCount() - 1;
606 final int chaptersBarWidth;
607
608 if (chaptersCount > 0) {
609 chaptersBarWidth =
610 (int) (progressBarWidth
611 * (((float) (currentBook.getCurrentChapter().getNumber()))
612 / chaptersCount));
613 } else {
614 /*
615 * This should never happen, how could there be 0 chapters?!
616 */
617 chaptersBarWidth = progressBarWidth;
618 }
619
620

Callers 1

paintMethod · 0.95

Calls 5

setColorMethod · 0.80
getCurrentPageIndexMethod · 0.80
getChaptersCountMethod · 0.80
getNumberMethod · 0.80
getCurrentChapterMethod · 0.80

Tested by

no test coverage detected