svn commit: r19910 - trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java
[email protected] Thu, 7 Feb 2013 19:31:06 -0800 (PST)
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: closettop_nightlybuild
Date: 2013-02-07 19:31:06-0800
New Revision: 19910
Modified:
trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java
Log:
Issue 5760 - memory display always red with Java 1.6
see issue at http://argouml.tigris.org/issues/show_bug.cgi?id=5760
Change-Id: If97207b6e6ea3273f90be41ecbf840030efc55e5
Contributed-by: Laurent BRAUD
Modified: trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java?view=diff&pathrev=19910&r1=19909&r2=19910
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/HeapMonitor.java 2013-02-07 19:31:06-0800
@@ -1,6 +1,6 @@
-/* $Id$
+/* $Id: HeapMonitor.java 19743 2011-10-04 02:47:51Z tfmorris $
*****************************************************************************
- * Copyright (c) 2009,2011 Contributors - see below
+ * Copyright (c) 2009-2013 Contributors - see below
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
*
* Contributors:
* tfmorris
+ * Laurent Braud
*****************************************************************************
*
* Some portions of this file was previously release using the BSD License:
@@ -60,9 +61,15 @@
private static final int WARN_THRESHOLD = 75;
private static final int CRITICAL_THRESHOLD = 90;
- private static final Color WARN_COLOR = new Color(255, 190, 125);
+ private static final Color OK_COLOR = new Color(0, 200, 100);
+
+ private static final Color WARN_COLOR = new Color(255, 190, 125);
+
private static final Color CRITICAL_COLOR = new Color(255, 70, 70);
- private static final Color TOTAL_COLOR = new Color(255,255,0);
+
+ private static final Color CURRENT_USED_COLOR = new Color(0, 0, 0);
+
+ private static final Color CURRENT_HEAP_COLOR = new Color(255, 255, 0);
private static final long M = 1024 * 1024;
@@ -91,40 +98,39 @@
public void paint (Graphics g) {
Rectangle bounds = getBounds();
int usedX = (int) (used * bounds.width / max);
- int totalX = (int) (total * bounds.width / max);
+ int currentHeapX = (int) (total * bounds.width / max);
int warnX = WARN_THRESHOLD * bounds.width / 100;
int dangerX = CRITICAL_THRESHOLD * bounds.width / 100;
Color savedColor = g.getColor();
-
- g.setColor(getBackground().darker());
- g.fillRect(0, 0, Math.min(usedX, warnX), bounds.height);
-
+ g.setColor(OK_COLOR);
+ g.fillRect(0, 0, warnX, bounds.height);
+
g.setColor(WARN_COLOR);
- g.fillRect(warnX, 0,
- Math.min(usedX - warnX, dangerX - warnX),
- bounds.height);
-
+ g.fillRect(warnX, 0, dangerX - warnX, bounds.height);
+
g.setColor(CRITICAL_COLOR);
- g.fillRect(dangerX, 0,
- Math.min(usedX - dangerX, bounds.width - dangerX),
- bounds.height);
+ g.fillRect(dangerX, 0, bounds.width - dangerX, bounds.height);
+
+ // Thin bar to show current used
+ g.setColor(CURRENT_USED_COLOR);
+ g.fillRect(usedX - 2, 0, 2, bounds.height);
// Thin bar to show current allocated heap size
- g.setColor(TOTAL_COLOR);
- g.fillRect(totalX-2, 0,
- Math.min(2, bounds.width-totalX),
- bounds.height);
+ g.setColor(CURRENT_HEAP_COLOR);
+ g.fillRect(currentHeapX - 2, 0, 2, bounds.height);
g.setColor(getForeground());
String s = MessageFormat.format("{0}M used of {1}M max",
new Object[] {(long) (used / M), (long) (max / M) });
+
int x = (bounds.width - g.getFontMetrics().stringWidth(s)) / 2;
int y = (bounds.height + g.getFontMetrics().getHeight()) / 2;
g.drawString(s, x, y);
g.setColor(savedColor);
+
}
/*
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=3048066
To unsubscribe from this discussion, e-mail: [[email protected]].