diff --git a/cave/com.raytheon.uf.viz.core.feature/feature.xml b/cave/com.raytheon.uf.viz.core.feature/feature.xml index 12c61a296b..05f7c21fef 100644 --- a/cave/com.raytheon.uf.viz.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.core.feature/feature.xml @@ -231,4 +231,18 @@ install-size="0" version="0.0.0"/> + + + + diff --git a/cave/com.raytheon.uf.viz.stats/.classpath b/cave/com.raytheon.uf.viz.stats/.classpath new file mode 100644 index 0000000000..1fa3e6803d --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/cave/com.raytheon.uf.viz.stats/.project b/cave/com.raytheon.uf.viz.stats/.project new file mode 100644 index 0000000000..9efc849520 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.viz.stats + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/cave/com.raytheon.uf.viz.stats/.settings/org.eclipse.jdt.core.prefs b/cave/com.raytheon.uf.viz.stats/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..bb7cad9231 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Nov 05 11:14:57 CST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..bbc9e9368e --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Stats +Bundle-SymbolicName: com.raytheon.uf.viz.stats;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: com.raytheon.uf.viz.stats.Activator +Bundle-Vendor: RAYTHEON +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.raytheon.uf.viz.core;bundle-version="1.12.1174", + com.raytheon.viz.ui;bundle-version="1.12.1174", + com.raytheon.uf.common.stats;bundle-version="1.0.0", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.util;bundle-version="1.12.1174", + com.google.guava;bundle-version="1.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: com.raytheon.uf.viz.stats, + com.raytheon.uf.viz.stats.ui diff --git a/cave/com.raytheon.uf.viz.stats/build.properties b/cave/com.raytheon.uf.viz.stats/build.properties new file mode 100644 index 0000000000..b5c529a3c3 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + build.properties diff --git a/cave/com.raytheon.uf.viz.stats/plugin.xml b/cave/com.raytheon.uf.viz.stats/plugin.xml new file mode 100644 index 0000000000..0c3c85699f --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/plugin.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/Activator.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/Activator.java new file mode 100644 index 0000000000..5ef0faed54 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/Activator.java @@ -0,0 +1,50 @@ +package com.raytheon.uf.viz.stats; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.raytheon.uf.viz.stats"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/action/StatsAction.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/action/StatsAction.java new file mode 100644 index 0000000000..55e91bb15a --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/action/StatsAction.java @@ -0,0 +1,99 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.action; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +import com.raytheon.uf.common.stats.GraphDataRequest; +import com.raytheon.uf.common.stats.GraphDataResponse; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.requests.ThriftClient; +import com.raytheon.uf.viz.stats.ui.StatsControlDlg; + +/** + * Stats Action Handler. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 11, 2012    728     mpduff      Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class StatsAction extends AbstractHandler { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(StatsAction.class); + + /** Dialog instance */ + private StatsControlDlg statsControlDlg = null; + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + if ((statsControlDlg == null) || (statsControlDlg.isDisposed() == true)) { + GraphDataRequest request = new GraphDataRequest(); + request.setMetaDataRequest(true); + + GraphDataResponse response = sendRequest(request); + + if (response != null) { + Shell shell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); + statsControlDlg = new StatsControlDlg(shell); + statsControlDlg.setConfigList(response.getConfigList()); + statsControlDlg.open(); + } + } else { + statsControlDlg.bringToTop(); + } + + return null; + } + + /** + * Send GraphDataRequest. + * + * @param req + * The request to send + * @return The GraphDataResponse + */ + private GraphDataResponse sendRequest(GraphDataRequest req) { + try { + return (GraphDataResponse) ThriftClient.sendRequest(req); + } catch (VizException e) { + statusHandler.handle(Priority.ERROR, "Error Requesting Data", e); + } + + return null; + } +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/display/ScaleManager.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/display/ScaleManager.java new file mode 100644 index 0000000000..cda6e8e74a --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/display/ScaleManager.java @@ -0,0 +1,190 @@ +package com.raytheon.uf.viz.stats.display; + + +public class ScaleManager { + /** + * Max number of major ticks, including first and last + */ + private final int MAX_MAJOR_TICK = 6; + + private final double ZOOMED_FACTOR = 0.01; + + private final double UNZOOMED_FACTOR = 5.0; + + private double[] niceMajorIncrementArray = { 0.01, 0.02, 0.05, 0.1, 0.2, + 0.5, 1.0, 2.0, 5.0 }; + + private double baseFactorStartingPoint = .01; + + private double minDataValue; + + private double maxDataValue; + + private double minScaleValue; + + private double maxScaleValue; + + private int majorTickCount; + + private double majorTickIncrement; + + private boolean zoomFlag; + + public ScaleManager(double minDataValue, double maxDataValue) { + this.minDataValue = minDataValue; + this.maxDataValue = maxDataValue; + + rescale(); + } + + private synchronized void rescale() { + int multipleCount = 0; + + // if zooming, use the ZOOMED_FACTOR value + if (zoomFlag) { + multipleCount = (int) Math.floor(minDataValue / ZOOMED_FACTOR); + minScaleValue = multipleCount * ZOOMED_FACTOR; + } + // if NOT zooming, use the UNZOOMED_FACTOR value + else { + multipleCount = (int) Math.floor(minDataValue / UNZOOMED_FACTOR); + minScaleValue = multipleCount * UNZOOMED_FACTOR; + + if ((maxDataValue - minDataValue < 10) && (minDataValue > .5)) { + minScaleValue = minDataValue - .5; + } + } + + double baseFactor = baseFactorStartingPoint; + + boolean done = false; + int i = 0; + + // set the range the values fit into + double range = maxDataValue - minScaleValue; + if (range < 1 && !zoomFlag) { + range = 1; + } + + while (!done) { + double testIncrement = niceMajorIncrementArray[i] * (baseFactor); + + int testTickCount = (int) Math.ceil(range / testIncrement + 1); + + // if there are a reasonable number of tickCounts, then stop + if (testTickCount <= MAX_MAJOR_TICK) { + + majorTickCount = testTickCount; + + majorTickIncrement = testIncrement; + + // first tick counts as a tick, so subtract 1 + maxScaleValue = minScaleValue + + ((majorTickCount - 1) * majorTickIncrement); + + return; + } + + i++; + + if (i >= niceMajorIncrementArray.length) { + i = 0; + baseFactor *= 10.0; + } + + } // end while !done + + return; + } + + public void setMaxDataValue(double maxDataValue) { + this.maxDataValue = maxDataValue; + + rescale(); + } + + public double getMaxDataValue() { + return maxDataValue; + + } + + public void setMinDataValue(double minDataValue) { + this.minDataValue = minDataValue; + rescale(); + } + + public double getMinDataValue() { + return minDataValue; + } + + public int getMajorTickCount() { + return majorTickCount; + } + + public double getMajorTickIncrement() { + return majorTickIncrement; + } + + public double getMaxScaleValue() { + return maxScaleValue; + } + + public double getMinScaleValue() { + return minScaleValue; + } + + public void setNiceMajorIncrementArray(double[] niceMajorIncrementArray) { + this.niceMajorIncrementArray = niceMajorIncrementArray; + rescale(); + } + + public double[] getNiceMajorIncrementArray() { + return niceMajorIncrementArray; + } + + public boolean isZoomFlag() { + return zoomFlag; + } + + public void setZoomFlag(boolean zoomFlag) { + this.zoomFlag = zoomFlag; + rescale(); + + } + + /** + * @param baseFactorStartingPoint + * The baseFactorStartingPoint to set. + */ + public void setBaseFactorStartingPoint(double baseFactorStartingPoint) { + this.baseFactorStartingPoint = baseFactorStartingPoint; + } + + /** + * @return Returns the baseFactorStartingPoint. + */ + public double getBaseFactorStartingPoint() { + return baseFactorStartingPoint; + } + + @Override + public String toString() { + String outString = " minDataValue = " + getMinDataValue() + + " maxDataValue = " + getMaxDataValue() + "\n" + + " minScaleValue = " + getMinScaleValue() + + " maxScaleValue = " + getMaxScaleValue() + "\n" + + " majorTickCount = " + getMajorTickCount() + + " majorTickIncrement = " + getMajorTickIncrement(); + + return outString; + } + + // For testing + public static void main(String[] argArray) { + double minValue = 5.1; + double maxValue = 5.3; + ScaleManager scaler = new ScaleManager(minValue, maxValue); + + System.out.println(scaler.toString()); + } +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManager.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManager.java new file mode 100644 index 0000000000..68b55924a1 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManager.java @@ -0,0 +1,142 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.ui; + +/** + * Color Manager + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 16, 2012            mpduff      Initial creation.
+ *
+ * 
+ * + * @version 1.0 + */ +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.swt.graphics.RGB; + +public class ColorManager { + + /** Color list */ + private List colorRGBs; + + /** + * Constructor. + */ + public ColorManager() { + setupColors(); + } + + /** + * Initialize the colors + */ + private void setupColors() { + List tempColorRGBs = new ArrayList(); + + tempColorRGBs.add(new RGB(255, 0, 0)); // RED + tempColorRGBs.add(new RGB(255, 165, 0)); // ORANGE + tempColorRGBs.add(new RGB(0, 255, 0)); // GREEN + tempColorRGBs.add(new RGB(255, 255, 0)); // YELLOW + tempColorRGBs.add(new RGB(165, 42, 42)); // BROWN + tempColorRGBs.add(new RGB(0, 255, 255)); // CYAN + tempColorRGBs.add(new RGB(255, 0, 255)); // MAGENTA + tempColorRGBs.add(new RGB(0, 0, 255)); // BLUE + tempColorRGBs.add(new RGB(138, 43, 226)); // BLUEVIOLET + tempColorRGBs.add(new RGB(238, 130, 238)); // VIOLET + tempColorRGBs.add(new RGB(102, 205, 170)); // AQUAMARINE3 + tempColorRGBs.add(new RGB(139, 125, 107)); // BISQUE4 + tempColorRGBs.add(new RGB(238, 197, 145)); // BURLYWOOD2 + tempColorRGBs.add(new RGB(205, 205, 0)); // YELLOW3 + tempColorRGBs.add(new RGB(69, 139, 0)); // CHARTREUSE4 + tempColorRGBs.add(new RGB(255, 127, 80)); // CORAL + tempColorRGBs.add(new RGB(100, 149, 237)); // CORNFLOWERBLUE + tempColorRGBs.add(new RGB(0, 139, 139)); // CYAN4 + tempColorRGBs.add(new RGB(169, 169, 169)); // DARKGRAY + tempColorRGBs.add(new RGB(139, 0, 139)); // DARKMAGENTA + tempColorRGBs.add(new RGB(238, 118, 0)); // DARKORANGE2 + tempColorRGBs.add(new RGB(139, 0, 0)); // DARKRED + tempColorRGBs.add(new RGB(233, 150, 122)); // DARKSALMON + tempColorRGBs.add(new RGB(255, 20, 147)); // DEEPPINK + tempColorRGBs.add(new RGB(0, 191, 255)); // DEEPSKYBLUE + tempColorRGBs.add(new RGB(255, 255, 255)); // WHITE + tempColorRGBs.add(new RGB(193, 205, 193)); // HONEYDEW3 + tempColorRGBs.add(new RGB(139, 58, 98)); // HOTPINK4 + tempColorRGBs.add(new RGB(144, 238, 144)); // LIGHTGREEN + tempColorRGBs.add(new RGB(255, 182, 193)); // LIGHTPINK + tempColorRGBs.add(new RGB(176, 196, 222)); // LIGHTSTEELBLUE + tempColorRGBs.add(new RGB(205, 133, 0)); // ORANGE3 + tempColorRGBs.add(new RGB(139, 105, 105)); // ROSYBROWN4 + tempColorRGBs.add(new RGB(210, 180, 140)); // TAN + tempColorRGBs.add(new RGB(0, 0, 0)); // BLACK + + colorRGBs = Collections.unmodifiableList(tempColorRGBs); + + } + + /** + * Get the list of colors. + * + * @return the list of colors + */ + public List getColorRGBs() { + return colorRGBs; + } + + /** + * Get the color at the provided index. + * + * @param index + * The index + * @return the color for the index + */ + public RGB getColorAtIndex(int index) { + int indexRV = index % colorRGBs.size(); + + RGB returnColor = colorRGBs.get(indexRV); + + if (returnColor == null) { + return new RGB(0, 0, 0); + } + + return returnColor; + } + + // for testing + public static void main(String[] args) { + ColorManager cm = new ColorManager(); + + List colorRGBArray = cm.getColorRGBs(); + + for (RGB rgb : colorRGBArray) { + // String s = RGBColors.getColorName(rgb); + // System.out.println(String.format("%20S", s) + "\t" + + // rgb.toString()); + System.out.println(rgb.toString()); + } + } +} diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java new file mode 100644 index 0000000000..f26367d842 --- /dev/null +++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/ColorManagerDlg.java @@ -0,0 +1,356 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.stats.ui; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.ScrolledComposite; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; + +import com.raytheon.uf.common.stats.data.GraphData; +import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase; + +/** + * TODO Add Description + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 18, 2012            mpduff     Initial creation
+ *
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class ColorManagerDlg extends CaveSWTDialogBase { + private Composite mainComp; + + private final IColorSelection callback; + + private Button individualRdo; + + private Tree selectionTree; + + private final GraphData graphData; + + private final List