commons.java subversion repository
sventon subversion web client - http://www.sventon.org |
[show recent changes] | |
Rev: 688 - https://secure.bioinfweb.info/Code/svn/commons.java / trunk / main / info.bioinfweb.commons.core / src / info / bioinfweb / commons / progress / AbstractProgressMonitor.java |
Show File - AbstractProgressMonitor.java [show properties] |

1 | /* |
2 | * bioinfweb.commons.java - Shared components of bioinfweb projects made available in a Java library |
3 | * Copyright (C) 2008-2011, 2013-2018 Ben Stöver, Sarah Wiechers |
4 | * <http://commons.bioinfweb.info/Java> |
5 | * |
6 | * This file is free software: you can redistribute it and/or modify |
7 | * it under the terms of the GNU Lesser General Public License as published by |
8 | * the Free Software Foundation, either version 3 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This file is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public License |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | package info.bioinfweb.commons.progress; |
20 | |
21 | |
22 | |
23 | /** |
24 | * Basic implementation of the {@link ProgressMonitor} interface. |
25 | * |
26 | * @author Ben Stöver |
27 | */ |
28 | public abstract class AbstractProgressMonitor implements ProgressMonitor { |
29 | private double progress = 0; |
30 | private String text = ""; |
31 | |
32 | |
33 | @Override |
34 | public double getProgressValue() { |
35 | return progress; |
36 | } |
37 | |
38 | |
39 | @Override |
40 | public String getProgressText() { |
41 | return text; |
42 | } |
43 | |
44 | |
45 | protected abstract void onProgress(double value, String text); |
46 | |
47 | |
48 | @Override |
49 | public void setProgressValue(double value, String text) { |
50 | progress = value; |
51 | this.text = text; |
52 | onProgress(value, text); |
53 | } |
54 | |
55 | |
56 | @Override |
57 | public void addToProgressValue(double addend) { |
58 | setProgressValue(getProgressValue() + addend); |
59 | } |
60 | |
61 | |
62 | @Override |
63 | public void setProgressValue(double value) { |
64 | setProgressValue(value, getProgressText()); |
65 | } |
66 | |
67 | |
68 | @Override |
69 | public void addToProgressValue(double addend, String text) { |
70 | setProgressValue(getProgressValue() + addend, text); |
71 | } |
72 | } |
sventon 2.5.1