Move the time-remaining display to the status area.

This could cause problems but I believe that any time we display the
time remaining we are also showing a short status string.

Hand-massaged the translations, hopefully everything still makes sense
in each language.
This commit is contained in:
Ray Greenwell
2012-03-08 18:57:54 +00:00
parent 42f14f9747
commit 4c94356981
5 changed files with 59 additions and 30 deletions
@@ -79,9 +79,21 @@ public class StatusPanel extends JComponent
*/
public void setProgress (int percent, long remaining)
{
_progress = percent;
String msg = "m.complete";
String remstr = "";
boolean needsRepaint = false;
// maybe update the progress label
if (_progress != percent) {
_progress = percent;
String msg = MessageFormat.format(get("m.complete"), percent);
_newplab = new Label(msg, _ifc.progressText, FONT);
if (_ifc.textShadow != null) {
_newplab.setAlternateColor(_ifc.textShadow);
_newplab.setStyle(LabelStyleConstants.SHADOW);
}
needsRepaint = true;
}
// maybe update the remaining label
if (remaining > 1) {
// skip this estimate if it's been less than a second since
// our last one came in
@@ -99,23 +111,26 @@ public class StatusPanel extends JComponent
remaining /= values;
// now compute our display value
msg = "m.complete_remain";
int minutes = (int)(remaining / 60);
int seconds = (int)(remaining % 60);
remstr = minutes + ":";
if (seconds < 10) {
remstr += "0";
String remstr = minutes + ":" + ((seconds < 10) ? "0" : "") + seconds;
String msg = MessageFormat.format(get("m.remain"), remstr);
_newrlab = new Label(msg, _ifc.statusText, FONT);
if (_ifc.textShadow != null) {
_newrlab.setAlternateColor(_ifc.textShadow);
_newrlab.setStyle(LabelStyleConstants.SHADOW);
}
remstr += seconds;
needsRepaint = true;
} else {
needsRepaint = needsRepaint || (_rlabel != null);
_newrlab = _rlabel = null;
}
msg = get(msg);
String label = MessageFormat.format(msg, percent, remstr);
_newplab = new Label(label, _ifc.progressText, FONT);
if (_ifc.textShadow != null) {
_newplab.setAlternateColor(_ifc.textShadow);
_newplab.setStyle(LabelStyleConstants.SHADOW);
if (needsRepaint) {
repaint();
}
repaint();
}
/**
@@ -169,6 +184,11 @@ public class StatusPanel extends JComponent
_plabel = _newplab;
_newplab = null;
}
if (_newrlab != null) {
_newrlab.layout(gfx);
_rlabel = _newrlab;
_newrlab = null;
}
if (_barimg != null) {
gfx.setClip(_ifc.progress.x, _ifc.progress.y,
@@ -191,17 +211,14 @@ public class StatusPanel extends JComponent
}
if (_label != null) {
// if the status region is higher than the progress region, we
// want to align the label with the bottom of its region
// rather than the top
int ly;
if (_ifc.status.y > _ifc.progress.y) {
ly = _ifc.status.y;
} else {
ly = _ifc.status.y + (_ifc.status.height -
_label.getSize().height);
}
_label.render(gfx, _ifc.status.x, ly);
_label.render(gfx, _ifc.status.x, getStatusY(_label));
}
if (_rlabel != null) {
// put the remaining label at the end of the status area. This could be dangerous
// but I think the only time we would display it is with small statuses.
int x = _ifc.status.x + _ifc.status.width - _rlabel.getSize().width;
_rlabel.render(gfx, x, getStatusY(_rlabel));
}
SwingUtil.restoreAntiAliasing(gfx, oalias);
@@ -214,6 +231,17 @@ public class StatusPanel extends JComponent
return _psize;
}
protected int getStatusY (Label label)
{
// if the status region is higher than the progress region, we
// want to align the label with the bottom of its region
// rather than the top
if (_ifc.status.y > _ifc.progress.y) {
return _ifc.status.y;
}
return _ifc.status.y + (_ifc.status.height - label.getSize().height);
}
/** Used by {@link #setStatus}. */
protected String xlate (String compoundKey)
{
@@ -284,6 +312,7 @@ public class StatusPanel extends JComponent
protected boolean _displayError;
protected Label _label, _newlab;
protected Label _plabel, _newplab;
protected Label _rlabel, _newrlab;
protected UpdateInterface _ifc;
@@ -47,7 +47,7 @@ m.launching = Launching...
m.patch_notes = Patch Notes...
m.complete = {0}% complete
m.complete_remain = {0}% complete {1} remaining
m.remain = {0} remaining
m.updating_metadata = Downloading control files...
@@ -47,7 +47,7 @@ m.launching = Starte...
m.patch_notes = Patchnotes
m.complete = {0}% abgeschlossen
m.complete_remain = {0}% abgeschlossen {1} \u00fcbrig
m.remain = {0} \u00fcbrig
m.updating_metadata = Lade Steuerungsdateien herunter...
@@ -45,7 +45,7 @@ m.patching = \u4fee\u6b63\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u4e2d\
m.launching = \u5b9f\u884c\u4e2d\u2026
m.complete = {0}\uff05\u5b8c\u4e86
m.complete_remain = {0}\uff05\u5b8c\u4e86\u3000\u6b8b\u308a{1}
m.remain = \u3000\u6b8b\u308a{0}
m.updating_metadata = \u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u30d5\u30a1\u30a4\u30eb\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u4e2d\u2026
@@ -29,7 +29,7 @@ m.patching = \u5347\u7ea7...
m.launching = \u542f\u52a8...
m.complete = {0}% \u5b8c\u6210
m.complete_remain = {0}% \u5b8c\u6210 {1} \u5269\u4f59\u65f6\u95f4
m.remain = {0} \u5269\u4f59\u65f6\u95f4
m.updating_metadata = \u4e0b\u8f7d\u63a7\u5236\u6587\u4ef6...