Issue #1395 Updated SetOpacityDialog. Added source jars for geoapi. Removed legacy shapefile import menu item.

Change-Id: I495db377f77485fd9bd896f02dba9c640b9ad3b1

Former-commit-id: 753fa0487b [formerly 753fa0487b [formerly a7657cf6b42a3d7a0f5fd64468820d1547ad1e9d]]
Former-commit-id: 639b5abbd9
Former-commit-id: 995f28220a
This commit is contained in:
Ron Anderson 2012-12-13 15:23:43 -06:00
parent a41d5a1ad0
commit 676819adfa
4 changed files with 82 additions and 32 deletions

View file

@ -45,6 +45,7 @@
commandId="com.raytheon.viz.shapefile.shapefileImport">
</handler>
</extension>
<!--
<extension
point="org.eclipse.ui.menus">
<menuContribution
@ -56,5 +57,6 @@
</command>
</menuContribution>
</extension>
-->
</plugin>

View file

@ -24,14 +24,17 @@ import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability;
import com.raytheon.viz.ui.dialogs.SetOpacityDialog;
import com.raytheon.viz.ui.dialogs.SetOpacityDialog.IOpacityChangedListener;
/**
* Action to set the shading field for a resource
@ -217,10 +220,25 @@ public class ShadedAction extends AbstractRightClickAction implements
*/
@Override
public void run() {
AbstractVizResource<?, ?> rsc = getTopMostSelectedResource();
final AbstractVizResource<?, ?> rsc = getTopMostSelectedResource();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
SetOpacityDialog dlg = new SetOpacityDialog(shell, rsc);
float opacity = rsc.getCapability(ShadeableCapability.class)
.getOpacity();
RGB rgb;
if (rsc.hasCapability(ColorableCapability.class)) {
rgb = rsc.getCapability(ColorableCapability.class).getColor();
} else {
rgb = new RGB(0, 255, 255);
}
SetOpacityDialog dlg = new SetOpacityDialog(shell, opacity, rgb);
dlg.addOpacityChangedListener(new IOpacityChangedListener() {
@Override
public void opacityChanged(float opacity) {
rsc.getCapability(ShadeableCapability.class).setOpacity(
opacity);
}
});
dlg.open();
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.viz.ui.dialogs;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
@ -37,10 +38,6 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability;
/**
* TODO Add Description
*
@ -60,15 +57,23 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability;
public class SetOpacityDialog extends CaveJFACEDialog {
private AbstractVizResource<?, ?> resource;
public static interface IOpacityChangedListener {
public void opacityChanged(float opacity);
}
private ListenerList listenerList;
private float originalOpacity;
private float opacity;
public SetOpacityDialog(Shell parentShell, AbstractVizResource<?, ?> rsc) {
private RGB color;
public SetOpacityDialog(Shell parentShell, float originalOpacity, RGB color) {
super(parentShell);
this.resource = rsc;
this.opacity = this.originalOpacity = originalOpacity;
this.color = color;
this.listenerList = new ListenerList();
}
@Override
@ -103,8 +108,6 @@ public class SetOpacityDialog extends CaveJFACEDialog {
scale.setLayoutData(layoutData);
scale.setMinimum(0);
scale.setMaximum(100);
opacity = originalOpacity = resource.getCapability(
ShadeableCapability.class).getOpacity();
scale.setSelection((int) (originalOpacity * 100));
@ -124,10 +127,9 @@ public class SetOpacityDialog extends CaveJFACEDialog {
Scale scale = (Scale) e.widget;
label.setText(scale.getSelection() + "%");
opacity = scale.getSelection() / 100.0f;
resource.getCapability(ShadeableCapability.class).setOpacity(
opacity);
resource.issueRefresh();
canvas.redraw();
fireListeners(opacity);
}
});
@ -141,19 +143,15 @@ public class SetOpacityDialog extends CaveJFACEDialog {
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(rect1);
Rectangle rect2 = new Rectangle(rect1.x + rect1.width / 2, rect1.y,
rect1.width / 2, rect1.height);
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(rect2);
int dx = rect1.width / 5;
int dy = rect1.height / 5;
RGB rgb;
if (resource.hasCapability(ColorableCapability.class)) {
rgb = resource.getCapability(ColorableCapability.class).getColor();
} else {
rgb = new RGB(0, 255, 255);
}
Rectangle rect2 = new Rectangle(rect1.x + dx, rect1.y + dy, rect1.width
- 2 * dx, rect1.height - 2 * dy);
gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
gc.drawRectangle(rect2);
Color color = new Color(gc.getDevice(), rgb);
Color color = new Color(gc.getDevice(), this.color);
gc.setBackground(color);
gc.setAlpha((int) (opacity * 255));
gc.fillRectangle(rect1);
@ -162,9 +160,41 @@ public class SetOpacityDialog extends CaveJFACEDialog {
@Override
protected void cancelPressed() {
resource.getCapability(ShadeableCapability.class).setOpacity(
originalOpacity);
resource.issueRefresh();
opacity = originalOpacity;
fireListeners(opacity);
super.cancelPressed();
}
/**
* Add listener to be notified when opacity is changed
*
* @param listener
*/
public void addOpacityChangedListener(IOpacityChangedListener listener) {
this.listenerList.add(listener);
}
/**
* Remove opacity changed listener
*
* @param listener
*/
public void removeOpacityChangedListener(IOpacityChangedListener listener) {
this.listenerList.remove(listener);
}
private void fireListeners(float opacity) {
for (Object listener : listenerList.getListeners()) {
((IOpacityChangedListener) listener).opacityChanged(opacity);
}
}
/**
* Get selected opacity
*
* @return the opacity
*/
public float getOpacity() {
return opacity;
}
}

View file

@ -9,13 +9,13 @@
<classpathentry kind="lib" path="commons-lang-2.3.jar"/>
<classpathentry kind="lib" path="commons-pool-1.5.3.jar"/>
<classpathentry exported="true" kind="lib" path="ecore-2.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="geoapi-2.3-M1.jar"/>
<classpathentry exported="true" kind="lib" path="geoapi-pending-2.3-M1.jar"/>
<classpathentry exported="true" kind="lib" path="geoapi-2.3-M1.jar" sourcepath="geoapi-2.3-M1-sources.jar"/>
<classpathentry exported="true" kind="lib" path="geoapi-pending-2.3-M1.jar" sourcepath="geoapi-pending-2.3-M1-sources.jar"/>
<classpathentry exported="true" kind="lib" path="gt-api-2.6.4.jar" sourcepath="gt-api-2.6.4-sources.jar"/>
<classpathentry exported="true" kind="lib" path="gt-coverage-2.6.4.jar" sourcepath="gt-coverage-2.6.4-sources.jar"/>
<classpathentry exported="true" kind="lib" path="gt-cql-2.6.4.jar"/>
<classpathentry exported="true" kind="lib" path="gt-data-2.6.4.jar" sourcepath="gt-data-2.6.4-sources.zip"/>
<classpathentry exported="true" kind="lib" path="gt-directory-2.6.4.jar" sourcepath="gt-directory-2.6.4-sources.zip"/>
<classpathentry exported="true" kind="lib" path="gt-data-2.6.4.jar" sourcepath="gt-data-2.6.4-sources.zip"/>
<classpathentry exported="true" kind="lib" path="gt-directory-2.6.4.jar" sourcepath="gt-directory-2.6.4-sources.zip"/>
<classpathentry exported="true" kind="lib" path="gt-epsg-wkt-2.6.4.jar" sourcepath="gt-epsg-wkt-2.6.4-sources.jar"/>
<classpathentry exported="true" kind="lib" path="gt-geotiff-2.6.4.jar" sourcepath="gt-geotiff-2.6.4-sources.jar"/>
<classpathentry exported="true" kind="lib" path="gt-graph-2.6.4.jar" sourcepath="gt-graph-2.6.4-sources.jar"/>