@@ -0,0 +1,2306 @@
+package com.ibm.nmon.util;%0A%0Aimport com.ibm.nmon.NMONVisualizerApp;%0A%0Aimport com.ibm.nmon.interval.Interval;%0A%0Apublic class GranularityHelper %7B%0A    public static int DEFAULT_GRANULARITY = 60000;%0A%0A    private final NMONVisualizerApp app;%0A%0A    private int granularity = DEFAULT_GRANULARITY;%0A    private boolean automatic = false;%0A%0A    public GranularityHelper(NMONVisualizerApp app) %7B%0A        this.app = app;%0A    %7D%0A%0A    public int getGranularity() %7B%0A        return granularity;%0A    %7D%0A%0A    public boolean isAutomatic() %7B%0A        return automatic;%0A    %7D%0A%0A    public void setAutomatic(boolean automatic) %7B%0A        if (this.automatic != automatic) %7B%0A            this.automatic = automatic;%0A%0A            if (this.automatic) %7B%0A                recalculate();%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void setGranularity(int granularity) %7B%0A        if (granularity %3C 0) %7B%0A            throw new IllegalArgumentException(%22granularity must be positive%22);%0A        %7D%0A        else %7B%0A            this.granularity = granularity;%0A            this.automatic = false;%0A        %7D%0A    %7D%0A%0A    // attempt to get about 100 data points on each chart, based on the interval duration rounded to%0A    // the nearest 15 seconds%0A    // default to 60s%0A    public void recalculate() %7B%0A        if (!automatic) %7B%0A            throw new IllegalStateException(%22cannot automatically set granularity; call setAutomatic(true) first%22);%0A        %7D%0A%0A        long duration = 0;%0A%0A        Interval interval = app.getIntervalManager().getCurrentInterval();%0A%0A        if (Interval.DEFAULT.equals(interval)) %7B%0A            duration = app.getMaxSystemTime() - app.getMinSystemTime();%0A%0A            // no files parsed yet =%3E default back to 60s%0A            if (duration == Long.MAX_VALUE) %7B%0A                granularity = 60000;%0A                return;%0A            %7D%0A        %7D%0A        else %7B%0A            duration = interval.getDuration();%0A        %7D%0A%0A        long granularity = duration / 100;%0A%0A        if (granularity %3E= Integer.MAX_VALUE) %7B%0A            granularity = 2147475000; // MAX_VALUE rounded down to nearest 15000%0A        %7D%0A%0A        // round to nearest 15 seconds%0A        granularity = Math.round(granularity / 15000d) * 15000;%0A%0A        if (granularity %3C 1000) %7B%0A            granularity = 1000;%0A        %7D%0A%0A        this.granularity = (int) granularity;%0A    %7D%0A%7D%0A

Create GranularityHelper.java