Mercurial > hg > release > thermostat-0.5
changeset 592:136dfbad25fb
Use larger units in host memory chart
Use larger units (MiB instead of bytes) for the range axis in the host
memory chart. Ideally this range should be completely dynamic, but MiB
seems good enough for now.
Reviewed-by: vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-August/003035.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 07 Sep 2012 16:35:21 -0400 |
parents | 918b58ad8bbb |
children | 8b76cd6f56b6 |
files | client/core/src/main/java/com/redhat/thermostat/client/ui/HostMemoryPanel.java client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties |
diffstat | 2 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/HostMemoryPanel.java Fri Sep 07 16:14:49 2012 -0400 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/HostMemoryPanel.java Fri Sep 07 16:35:21 2012 -0400 @@ -58,6 +58,7 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.time.FixedMillisecond; import org.jfree.data.time.RegularTimePeriod; @@ -66,11 +67,12 @@ import com.redhat.thermostat.client.internal.ui.swing.WrapLayout; import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.osgi.service.BasicView; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.model.DiscreteTimeData; +import com.redhat.thermostat.common.utils.DisplayableValues; +import com.redhat.thermostat.common.utils.DisplayableValues.Scale; -public class HostMemoryPanel extends HostMemoryView implements SwingComponent { +public class HostMemoryPanel extends HostMemoryView implements SwingComponent { private JPanel visiblePanel; @@ -196,7 +198,9 @@ for (DiscreteTimeData<? extends Number> timeData: copy) { RegularTimePeriod period = new FixedMillisecond(timeData.getTimeInMillis()); if (series.getDataItem(period) == null) { - series.add(new FixedMillisecond(timeData.getTimeInMillis()), timeData.getData(), false); + Long sizeInBytes = (Long) timeData.getData(); + Double sizeInMegaBytes = DisplayableValues.Scale.convertTo(Scale.MiB, sizeInBytes); + series.add(new FixedMillisecond(timeData.getTimeInMillis()), sizeInMegaBytes, false); } } series.fireSeriesChanged(); @@ -286,7 +290,7 @@ JFreeChart chart = ChartFactory.createTimeSeriesChart( localize(LocaleResources.HOST_MEMORY_CHART_TITLE), // Title localize(LocaleResources.HOST_MEMORY_CHART_TIME_LABEL), // x-axis Label - localize(LocaleResources.HOST_MEMORY_CHART_SIZE_LABEL), // y-axis Label + localize(LocaleResources.HOST_MEMORY_CHART_SIZE_LABEL, Scale.MiB.name()), // y-axis Label memoryCollection, // Dataset false, // Show Legend false, // Use tooltips @@ -297,10 +301,12 @@ chart.getPlot().setBackgroundImageAlpha(0.0f); chart.getPlot().setOutlinePaint(new Color(0,0,0,0)); + NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); + rangeAxis.setAutoRangeMinimumSize(100); + return chart; } - private void fireShowHideHandlers(boolean show, String tag) { for (GraphVisibilityChangeListener listener: listeners) { if (show) {
--- a/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Fri Sep 07 16:14:49 2012 -0400 +++ b/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Fri Sep 07 16:35:21 2012 -0400 @@ -93,7 +93,7 @@ HOST_MEMORY_SECTION_OVERVIEW = Memory HOST_MEMORY_CHART_TITLE = Memory HOST_MEMORY_CHART_TIME_LABEL = Time -HOST_MEMORY_CHART_SIZE_LABEL = Size (bytes) +HOST_MEMORY_CHART_SIZE_LABEL = Size ({0}) HOST_MEMORY_TOTAL = Total Memory HOST_MEMORY_FREE = Free Memory