Omaha #4633 Initial implementation of auto transition.
Former-commit-id: d9aea4ace2a767d70dff81d44b371949e2f4a7cb
This commit is contained in:
parent
1c345d7dad
commit
72c9fb05d9
12 changed files with 1009 additions and 0 deletions
7
cave/com.raytheon.uf.viz.auto.transition/.classpath
Normal file
7
cave/com.raytheon.uf.viz.auto.transition/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
cave/com.raytheon.uf.viz.auto.transition/.project
Normal file
28
cave/com.raytheon.uf.viz.auto.transition/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.viz.auto.transition</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,16 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Automatic Transition
|
||||
Bundle-SymbolicName: com.raytheon.uf.viz.auto.transition;singleton:=true
|
||||
Bundle-Version: 1.15.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: com.raytheon.viz.ui;bundle-version="1.15.1",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.15.1",
|
||||
com.raytheon.uf.common.time;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.14.2",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||
com.raytheon.uf.viz.core.rsc;bundle-version="1.14.1",
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.15.0"
|
||||
Import-Package: com.raytheon.viz.core.rsc
|
|
@ -0,0 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
22
cave/com.raytheon.uf.viz.auto.transition/plugin.xml
Normal file
22
cave/com.raytheon.uf.viz.auto.transition/plugin.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="com.raytheon.viz.ui.contextualMenu">
|
||||
<contextualMenu
|
||||
actionClass="com.raytheon.uf.viz.auto.transition.AutoTransitionAction"
|
||||
capabilityClass="com.raytheon.viz.core.rsc.BlendedResource"
|
||||
name="com.raytheon.uf.viz.auto.transition.AutoTransitionAction"
|
||||
sortID="50">
|
||||
</contextualMenu>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.viz.ui.contextualMenu">
|
||||
<contextualMenu
|
||||
actionClass="com.raytheon.uf.viz.auto.transition.ConfigureAutoTransitionAction"
|
||||
capabilityClass="com.raytheon.uf.viz.auto.transition.AutoTransitionResource"
|
||||
name="com.raytheon.uf.viz.auto.transition.ConfigureAutoTransitionAction"
|
||||
sortID="51">
|
||||
</contextualMenu>
|
||||
</extension>
|
||||
</plugin>
|
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceGroup;
|
||||
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogatable;
|
||||
import com.raytheon.uf.viz.core.time.TimeMatchingJob;
|
||||
import com.raytheon.viz.core.rsc.BlendedResource;
|
||||
import com.raytheon.viz.core.rsc.BlendedResourceData;
|
||||
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action which converts a {@link BlendedResource} into a
|
||||
* {@link AutoTransitionResource}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 09, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AutoTransitionAction extends AbstractRightClickAction {
|
||||
|
||||
private static final transient IUFStatusHandler logger = UFStatus
|
||||
.getHandler(AutoTransitionAction.class);
|
||||
|
||||
public AutoTransitionAction() {
|
||||
super(AS_CHECK_BOX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
BlendedResource resource = (BlendedResource) selectedRsc.getResource();
|
||||
for (ResourcePair pair : resource.getResourceList()) {
|
||||
if (pair.getResource() instanceof Interrogatable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private AutoTransitionResourceData getResourceData() {
|
||||
if (selectedRsc.getResource() instanceof AutoTransitionResource) {
|
||||
return ((AutoTransitionResource) selectedRsc.getResource())
|
||||
.getResourceData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
AutoTransitionResourceData data = getResourceData();
|
||||
if (data != null) {
|
||||
return data.isAutomaticSelection();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Automatic Transition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AutoTransitionResourceData data = getResourceData();
|
||||
if (data != null) {
|
||||
data.setAutomaticSelection(!data.isAutomaticSelection());
|
||||
return;
|
||||
}
|
||||
ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance();
|
||||
// Put the base resource in a group so it can be serialized
|
||||
ResourceGroup group = new ResourceGroup();
|
||||
group.getResourceList().add(selectedRsc);
|
||||
try {
|
||||
String baseXml = jaxb.marshal(group);
|
||||
group = jaxb.unmarshal(ResourceGroup.class, baseXml);
|
||||
} catch (SerializationException e) {
|
||||
logger.error("Unable to initialize Automatic Transition.", e);
|
||||
}
|
||||
ResourcePair pair = group.getResourceList().get(0);
|
||||
|
||||
AbstractVizResource<?, ?> oldResource = selectedRsc.getResource();
|
||||
AutoTransitionResourceData resourceData = new AutoTransitionResourceData(
|
||||
(BlendedResourceData) pair.getResourceData());
|
||||
|
||||
selectedRsc.setResourceData(resourceData);
|
||||
selectedRsc.setLoadProperties(pair.getLoadProperties());
|
||||
selectedRsc.setResource(null);
|
||||
try {
|
||||
selectedRsc.instantiateResource(oldResource.getDescriptor());
|
||||
} catch (VizException e) {
|
||||
logger.error("Unable to initialize Automatic Transition.", e);
|
||||
selectedRsc.setResource(oldResource);
|
||||
return;
|
||||
}
|
||||
oldResource.dispose();
|
||||
TimeMatchingJob.scheduleTimeMatch(oldResource.getDescriptor());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.layout.RowData;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Scale;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.auto.transition.AverageValueCalculator.CalculatorListener;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* Dialog for configuring a {@link AutoTransitionResource}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 09, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AutoTransitionDialog extends CaveSWTDialog implements
|
||||
CalculatorListener {
|
||||
|
||||
private final AutoTransitionResource resource;
|
||||
|
||||
private int originalControlIndex;
|
||||
|
||||
private double originalThreshold;
|
||||
|
||||
private Combo resourceCombo;
|
||||
|
||||
private Scale thresholdSlider;
|
||||
|
||||
private Text thresholdText;
|
||||
|
||||
private Text currentValueText;
|
||||
|
||||
public AutoTransitionDialog(Shell parentShell,AutoTransitionResource resource) {
|
||||
super(parentShell);
|
||||
this.resource = resource;
|
||||
setText("Configure Automatic Transition");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
resource.getCalculator().addListener(this);
|
||||
new Label(shell, SWT.NONE).setText("Control Resource: ");
|
||||
resourceCombo = new Combo(shell, SWT.READ_ONLY);
|
||||
for (ResourcePair pair : resource.getResourceList()) {
|
||||
resourceCombo.add(pair.getResource().getName());
|
||||
}
|
||||
resourceCombo.select(resource.getResourceData().getControlIndex());
|
||||
GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
layoutData.horizontalSpan = 2;
|
||||
resourceCombo.setLayoutData(layoutData);
|
||||
|
||||
resourceCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
resourceComboSelected();
|
||||
}
|
||||
});
|
||||
|
||||
new Label(shell, SWT.NONE).setText("Threshold Value: ");
|
||||
thresholdSlider = new Scale(shell, SWT.HORIZONTAL);
|
||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
layoutData.minimumWidth = 100;
|
||||
thresholdSlider.setLayoutData(layoutData);
|
||||
|
||||
originalThreshold = resource.getResourceData()
|
||||
.getThresholdValue();
|
||||
originalControlIndex = resource.getResourceData().getControlIndex();
|
||||
|
||||
ResourcePair controlPair = resource.getResourceList().get(resource.getResourceData().getControlIndex());
|
||||
final ColorMapParameters params = controlPair.getResource().getCapability(ColorMapCapability.class).getColorMapParameters();
|
||||
|
||||
int sliderSpan = thresholdSlider.getMaximum()
|
||||
- thresholdSlider.getMinimum();
|
||||
double paramSpan = params.getColorMapMax() - params.getColorMapMin();
|
||||
|
||||
thresholdSlider
|
||||
.setSelection((int) (thresholdSlider.getMinimum() + sliderSpan
|
||||
* (originalThreshold - params.getColorMapMin())
|
||||
/ paramSpan));
|
||||
|
||||
|
||||
thresholdText = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
|
||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||
layoutData.widthHint = 50;
|
||||
thresholdText.setLayoutData(layoutData);
|
||||
thresholdText.setText(Double.toString(originalThreshold));
|
||||
|
||||
thresholdSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
sliderSelected();
|
||||
}
|
||||
});
|
||||
new Label(shell, SWT.NONE).setText("Current Value: ");
|
||||
currentValueText = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
|
||||
currentValueText
|
||||
.setText(Double.toString(resource.getCalculator().getValue()));
|
||||
layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
|
||||
layoutData.widthHint = 50;
|
||||
currentValueText.setLayoutData(layoutData);
|
||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||
layoutData = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
|
||||
layoutData.horizontalSpan = 3;
|
||||
buttonComp.setLayoutData(layoutData);
|
||||
|
||||
buttonComp.setLayout(new RowLayout(SWT.HORIZONTAL));
|
||||
Button okButton = new Button(buttonComp, SWT.PUSH);
|
||||
okButton.setText("OK");
|
||||
okButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
okButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
okPressed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Button cancelButton = new Button(buttonComp, SWT.PUSH);
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
cancelPressed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void resourceComboSelected() {
|
||||
resource.getResourceData().setControlIndex(
|
||||
resourceCombo.getSelectionIndex());
|
||||
sliderSelected();
|
||||
}
|
||||
|
||||
protected void sliderSelected() {
|
||||
ResourcePair controlPair = resource.getResourceList().get(
|
||||
resource.getResourceData().getControlIndex());
|
||||
final ColorMapParameters params = controlPair.getResource()
|
||||
.getCapability(ColorMapCapability.class)
|
||||
.getColorMapParameters();
|
||||
|
||||
int sliderSpan = thresholdSlider.getMaximum()
|
||||
- thresholdSlider.getMinimum();
|
||||
double paramSpan = params.getColorMapMax() - params.getColorMapMin();
|
||||
|
||||
double value = params.getColorMapMin()
|
||||
+ paramSpan
|
||||
* (thresholdSlider.getSelection() - thresholdSlider
|
||||
.getMinimum()) / sliderSpan;
|
||||
resource.getResourceData().setThresholdValue(value);
|
||||
resource.issueRefresh();
|
||||
thresholdText.setText(Double.toString(value));
|
||||
}
|
||||
|
||||
protected void okPressed() {
|
||||
close();
|
||||
}
|
||||
|
||||
protected void cancelPressed() {
|
||||
resource.getResourceData().setThresholdValue(originalThreshold);
|
||||
resource.getResourceData().setControlIndex(originalControlIndex);
|
||||
resource.issueRefresh();
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(3, false);
|
||||
mainLayout.marginHeight = 3;
|
||||
mainLayout.marginWidth = 3;
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposed() {
|
||||
super.disposed();
|
||||
resource.getCalculator().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculationComplete() {
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (currentValueText.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
currentValueText
|
||||
.setText(Double.toString(resource.getCalculator().getValue()));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.auto.transition.AverageValueCalculator.CalculatorListener;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintStatus;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.BlendableCapability;
|
||||
import com.raytheon.viz.core.rsc.BlendedResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides the ability to automatically select which resource to render based
|
||||
* off the average value of a control resource.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 09, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AutoTransitionResource extends BlendedResource implements
|
||||
CalculatorListener {
|
||||
|
||||
private AverageValueCalculator calc = new AverageValueCalculator();
|
||||
|
||||
private AutoTransitionResourceData resourceData;
|
||||
|
||||
public AutoTransitionResource(AutoTransitionResourceData data,
|
||||
LoadProperties props) {
|
||||
super(data, props);
|
||||
this.resourceData = data;
|
||||
}
|
||||
|
||||
public AverageValueCalculator getCalculator() {
|
||||
return calc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculationComplete() {
|
||||
issueRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposeInternal() {
|
||||
super.disposeInternal();
|
||||
calc.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initInternal(IGraphicsTarget target) throws VizException {
|
||||
super.initInternal(target);
|
||||
calc.addListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
if (resourceData.isAutomaticSelection()) {
|
||||
int controlIndex = resourceData.getControlIndex();
|
||||
AbstractVizResource<?, ?> controller = getResourceList().get(
|
||||
controlIndex).getResource();
|
||||
|
||||
DataTime time = paintProps.getFramesInfo().getTimeForResource(
|
||||
controller);
|
||||
|
||||
if (calc.calculate(controller, time, paintProps.getView()
|
||||
.getExtent().clone()) == false) {
|
||||
updatePaintStatus(PaintStatus.INCOMPLETE);
|
||||
}
|
||||
double avg = calc.getValue();
|
||||
if (!Double.isNaN(avg) && avg >= resourceData.getThresholdValue()) {
|
||||
getCapability(BlendableCapability.class).toggle(
|
||||
(controlIndex + 1) % 2);
|
||||
} else {
|
||||
getCapability(BlendableCapability.class).toggle(controlIndex);
|
||||
}
|
||||
}
|
||||
super.paintInternal(target, paintProps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoTransitionResourceData getResourceData() {
|
||||
return resourceData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resourceDataChanged(ChangeType type, Object updateObject) {
|
||||
super.resourceDataChanged(type, updateObject);
|
||||
if (updateObject instanceof BlendableCapability) {
|
||||
int alphaStep = getCapability(BlendableCapability.class)
|
||||
.getAlphaStep();
|
||||
if (alphaStep > 0 && alphaStep < BlendableCapability.BLEND_MAX) {
|
||||
resourceData.setAutomaticSelection(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
||||
import com.raytheon.viz.core.rsc.BlendedResourceData;
|
||||
|
||||
/**
|
||||
*
|
||||
* Serializable data for {@link AutoTransitionResource}
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 09, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class AutoTransitionResourceData extends BlendedResourceData {
|
||||
|
||||
@XmlElement
|
||||
private int controlIndex = 1;
|
||||
|
||||
@XmlElement
|
||||
private double thresholdValue = 30;
|
||||
|
||||
@XmlElement
|
||||
private boolean automaticSelection = true;
|
||||
|
||||
public AutoTransitionResourceData() {
|
||||
|
||||
}
|
||||
|
||||
public AutoTransitionResourceData(BlendedResourceData blended) {
|
||||
this.resourceList = new ResourceList();
|
||||
for (ResourcePair pair : blended.getResourceList()) {
|
||||
ResourcePair newPair = new ResourcePair();
|
||||
newPair.setResourceData(pair.getResourceData());
|
||||
newPair.setLoadProperties(pair.getLoadProperties());
|
||||
newPair.setProperties(pair.getProperties());
|
||||
this.resourceList.add(pair);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoTransitionResource construct(LoadProperties loadProperties,
|
||||
IDescriptor descriptor) throws VizException {
|
||||
return new AutoTransitionResource(this, loadProperties);
|
||||
}
|
||||
|
||||
public int getControlIndex() {
|
||||
return controlIndex;
|
||||
}
|
||||
|
||||
public void setControlIndex(int controlIndex) {
|
||||
this.controlIndex = controlIndex;
|
||||
}
|
||||
|
||||
public double getThresholdValue() {
|
||||
return thresholdValue;
|
||||
}
|
||||
|
||||
public void setThresholdValue(double thresholdValue) {
|
||||
this.thresholdValue = thresholdValue;
|
||||
}
|
||||
|
||||
public boolean isAutomaticSelection() {
|
||||
return automaticSelection;
|
||||
}
|
||||
|
||||
public void setAutomaticSelection(boolean automaticSelection) {
|
||||
this.automaticSelection = automaticSelection;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import javax.measure.Measure;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogatable;
|
||||
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogator;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Async calculation of the average value of a resource.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 10, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AverageValueCalculator extends Job {
|
||||
|
||||
private static final int NUM_POINTS = 5;
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
private final Set<CalculatorListener> listeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
private Task nextTask;
|
||||
|
||||
private Task lastTask;
|
||||
|
||||
private double value = Double.NaN;
|
||||
|
||||
public AverageValueCalculator() {
|
||||
super("Calculating Resource Average Value");
|
||||
}
|
||||
|
||||
public boolean calculate(AbstractVizResource<?, ?> resource, DataTime time,
|
||||
IExtent extent) {
|
||||
Task newTask = new Task(resource, time, extent);
|
||||
synchronized (lock) {
|
||||
if (newTask.equals(lastTask)) {
|
||||
nextTask = null;
|
||||
return true;
|
||||
} else {
|
||||
nextTask = newTask;
|
||||
schedule();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
Task task = null;
|
||||
synchronized (lock) {
|
||||
task = nextTask;
|
||||
}
|
||||
if (task == null) {
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
double value = calculateAverage(task.resource, task.time, task.extent);
|
||||
synchronized (lock) {
|
||||
if (task.equals(nextTask)) {
|
||||
this.value = value;
|
||||
lastTask = task;
|
||||
nextTask = null;
|
||||
}
|
||||
}
|
||||
for (CalculatorListener listener : listeners) {
|
||||
listener.calculationComplete();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
public void addListener(CalculatorListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(CalculatorListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the average value of a resource at a particular time for the
|
||||
* specified area. Currently this just samples 25 points evenly spaced
|
||||
* throughout the visible area as proposed by Jordan Gerth.
|
||||
*/
|
||||
public static double calculateAverage(AbstractVizResource<?, ?> resource,
|
||||
DataTime time, IExtent extent) {
|
||||
if (!(resource instanceof Interrogatable)) {
|
||||
return Double.NaN;
|
||||
}
|
||||
Interrogatable interrogatable = (Interrogatable) resource;
|
||||
IDescriptor descriptor = resource.getDescriptor();
|
||||
double sum = 0.0;
|
||||
int k = 0;
|
||||
for (int i = 1; i < NUM_POINTS; i++) {
|
||||
for (int j = 1; j < NUM_POINTS; j++) {
|
||||
double mx = extent.getMinX()
|
||||
+ (extent.getMaxX() - extent.getMinX()) / NUM_POINTS
|
||||
* i;
|
||||
double my = extent.getMinY()
|
||||
+ (extent.getMaxY() - extent.getMinY()) / NUM_POINTS
|
||||
* j;
|
||||
double[] p2w = descriptor.pixelToWorld(new double[] { mx, my });
|
||||
ReferencedCoordinate coord = new ReferencedCoordinate(
|
||||
new Coordinate(p2w[0], p2w[1]));
|
||||
Measure<?, ?> value = Interrogator.interrogateSingle(
|
||||
interrogatable, coord, time, Interrogator.VALUE);
|
||||
if (value != null && value.getValue() instanceof Number) {
|
||||
double measuredValue = ((Number) value.getValue())
|
||||
.doubleValue();
|
||||
if (!Double.isNaN(measuredValue)) {
|
||||
sum += measuredValue;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k > NUM_POINTS) {
|
||||
return sum / k;
|
||||
} else {
|
||||
return Double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Task {
|
||||
|
||||
public final AbstractVizResource<?, ?> resource;
|
||||
|
||||
public final DataTime time;
|
||||
|
||||
public final IExtent extent;
|
||||
|
||||
public Task(AbstractVizResource<?, ?> resource, DataTime time,
|
||||
IExtent extent) {
|
||||
this.resource = resource;
|
||||
this.time = time;
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((extent == null) ? 0 : extent.hashCode());
|
||||
result = prime * result
|
||||
+ ((resource == null) ? 0 : resource.hashCode());
|
||||
result = prime * result + ((time == null) ? 0 : time.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Task other = (Task) obj;
|
||||
if (extent == null) {
|
||||
if (other.extent != null)
|
||||
return false;
|
||||
} else if (!extent.equals(other.extent))
|
||||
return false;
|
||||
if (resource == null) {
|
||||
if (other.resource != null)
|
||||
return false;
|
||||
} else if (!resource.equals(other.resource))
|
||||
return false;
|
||||
if (time == null) {
|
||||
if (other.time != null)
|
||||
return false;
|
||||
} else if (!time.equals(other.time))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static interface CalculatorListener{
|
||||
|
||||
public void calculationComplete();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* 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.auto.transition;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action which opens the {@link AutoTransitionDialog}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 09, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ConfigureAutoTransitionAction extends AbstractRightClickAction {
|
||||
|
||||
private AutoTransitionResourceData getResourceData() {
|
||||
if (selectedRsc.getResource() instanceof AutoTransitionResource) {
|
||||
return ((AutoTransitionResource) selectedRsc.getResource())
|
||||
.getResourceData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return !getResourceData().isAutomaticSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Configure Automatic Transition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AutoTransitionResource resource = (AutoTransitionResource) selectedRsc
|
||||
.getResource();
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
new AutoTransitionDialog(shell, resource).open();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,4 +35,10 @@
|
|||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.viz.auto.transition"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
</feature>
|
||||
|
|
Loading…
Add table
Reference in a new issue