MCPcopy Index your code
hub / github.com/ArtifexSoftware/mupdf / RenderProgressmeter

Class RenderProgressmeter

platform/java/example/Viewer.java:1815–1881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1813 }
1814
1815 class RenderProgressmeter extends Progressmeter {
1816 Cookie cookie;
1817
1818 public RenderProgressmeter(Frame parent, String title, Cookie cookie, final int update) {
1819 super(parent, title, false, "Progress: 100%");
1820 this.cookie = cookie;
1821
1822 (new Thread() {
1823 public void run() {
1824 try {
1825 int slept = 0;
1826 while (!progress(slept))
1827 {
1828 sleep(update);
1829 slept += update;
1830 }
1831 } catch (InterruptedException e) {
1832 }
1833 }
1834 }).start();
1835 }
1836
1837 public void cancel() {
1838 super.cancel();
1839 cookie.abort();
1840 }
1841
1842 public boolean progress(int slept) {
1843 int progress = cookie.getProgress();
1844 int max = cookie.getProgressMax();
1845
1846 if (max <= 0 && progress < 100)
1847 max = 100;
1848 else if (max <= 0 && progress > 100)
1849 {
1850 int v = progress;
1851 max = 10;
1852 while (v > 10)
1853 {
1854 v /= 10;
1855 max *= 10;
1856 }
1857 }
1858
1859 if (progress >= max)
1860 done = true;
1861
1862 int percent = (int) ((float) progress / max * 100.0f);
1863
1864 StringBuilder text = new StringBuilder();
1865 text.append("Progress: ");
1866 text.append(percent);
1867 text.append("%");
1868
1869 if (slept > 0)
1870 setVisible(true);
1871
1872 if (progress(text.toString()))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…