Issue #1638 Made string rendering always look right despite extent proportions so it is never warped. Moved dataURI map creation to DataURIUtil. Fixed double dispose of controls in VizDisplayPane, also made resize non interface method.

Amend: Fixed menu mix up and making sure perspective bar is on by default

Change-Id: I0c19e5fbf0f0d29cdca0f63afb33ca964a145b94

Former-commit-id: c8fcaf06d1 [formerly b91b706701] [formerly 1d3c378dde [formerly 53e42aa3925399271cc3ad4ee964476ddffc8eb6]]
Former-commit-id: 1d3c378dde
Former-commit-id: e05c12e246
This commit is contained in:
Max Schenkelberg 2013-04-18 17:52:22 -05:00
parent 9423b26507
commit 69abb31ee6
14 changed files with 171 additions and 115 deletions

View file

@ -83,6 +83,23 @@ public class DrawableString extends AbstractDrawableObject {
*/
public RGB boxColor;
public DrawableString(DrawableString that) {
this.basics.alpha = that.basics.alpha;
this.basics.color = that.basics.color;
this.basics.xOrColors = that.basics.xOrColors;
this.setCoordinates(that.basics.x, that.basics.y, that.basics.z);
this.text = that.text;
this.colors = that.colors;
this.font = that.font;
this.horizontalAlignment = that.horizontalAlignment;
this.verticallAlignment = that.verticallAlignment;
this.magnification = that.magnification;
this.rotation = that.rotation;
this.textStyle = that.textStyle;
this.shadowColor = that.shadowColor;
this.boxColor = that.boxColor;
}
/**
* Construct parameters with text, splits by newline, all text will be drawn
* with color "color"

View file

@ -90,12 +90,6 @@ public interface IDisplayPane {
*/
public abstract void refresh();
/**
* Perform the resize computations
*
*/
public abstract void resize();
/**
* Get bounds of pane
*

View file

@ -41,7 +41,7 @@
id="com.raytheon.uf.viz.personalities.cave.openPerspective">
</dynamic>
</menu>
<menu id="cave.browsers"
<menu id="browsers"
label="Data Browsers">
<!-- Place holder for data browsers -->
</menu>

View file

@ -237,12 +237,23 @@ public class VizWorkbenchAdvisor extends WorkbenchAdvisor {
* (org.eclipse.ui.application.IWorkbenchWindowConfigurer)
*/
@Override
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
public final WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
if (createdMenus == false) {
createdMenus = true;
createDynamicMenus();
}
return createNewWindowAdvisor(configurer);
}
/**
* Create a new {@link WorkbenchWindowAdvisor}
*
* @param configurer
* @return
*/
protected WorkbenchWindowAdvisor createNewWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
return new VizWorkbenchWindowAdvisor(configurer);
}

View file

@ -78,7 +78,7 @@ public class VizWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowProgressIndicator(true);
configurer.setInitialSize(new Point(1024, 768));
// Don't show perspective bar if running a specific perspective?
configurer.setShowPerspectiveBar(true);
configurer.setShowCoolBar(true);
configurer.setShowStatusLine(true);

View file

@ -57,4 +57,15 @@
commandId="com.raytheon.uf.viz.productbrowser.productBrowser">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:browsers">
<command
commandId="com.raytheon.uf.viz.productbrowser.productBrowser"
label="Product Browser"
style="push">
</command>
</menuContribution>
</extension>
</plugin>

View file

@ -123,7 +123,8 @@ import com.sun.opengl.util.j2d.TextRenderer;
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap
* interpolation by default.
*
* Apr 18, 2013 1638 mschenke Made string rendering always occur in canvas space so
* strings are always readable despite extent
*
* </pre>
*
@ -1200,6 +1201,12 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
new GLFont(java.awt.Font.MONOSPACED, 14.0f,
new Style[] { Style.BOLD }));
}
// Set swap interval to 1 refresh
gl.setSwapInterval(1);
// Set swap interval to 0 refresh (disables vsync)
gl.setSwapInterval(0);
releaseContext();
}
@ -1811,6 +1818,24 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
return;
}
double glScaleX = getScaleX();
double glScaleY = getScaleY();
double stringScaleX = 1.0;
double stringScaleY = 1.0;
Rectangle bounds = getBounds();
List<DrawableString> copy = new ArrayList<DrawableString>(
parameters.size());
for (DrawableString dString : parameters) {
// Convert strings into canvas location
dString = new DrawableString(dString);
double[] screen = targetView.gridToScreen(new double[] {
dString.basics.x, dString.basics.y, dString.basics.z },
this);
dString.setCoordinates(bounds.x + screen[0], bounds.y + screen[1]);
copy.add(dString);
}
parameters = copy;
// TODO if parameters has different fonts we should ensure that all
// strings with the same font are rendered in a group, otherwise this
// function ends up calling begin/end rendering lots which slows it down
@ -1822,10 +1847,12 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
try {
IExtent extent = targetView.getExtent();
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glScaled(1.0, -1.0, 1.0);
gl.glTranslated(extent.getMinX(), extent.getMinY(), 0);
gl.glScaled(glScaleX, -glScaleY, 1.0);
// This loop just draws the box or a blank rectangle.
for (DrawableString dString : parameters) {
@ -1841,14 +1868,13 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
if (verticalAlignment == VerticalAlignment.MIDDLE
&& dString.getText().length > 1) {
Rectangle2D totalBounds = getStringsBounds(dString);
double totalHeight = totalBounds.getHeight()
* getScaleY();
double totalHeight = totalBounds.getHeight();
yPos -= totalHeight * .5;
verticalAlignment = VerticalAlignment.TOP;
}
double scaleX = getScaleX();
double scaleY = getScaleY();
double scaleX = stringScaleX;
double scaleY = stringScaleY;
if (dString.rotation != 0.0) {
rotatedPoint = getUpdatedCoordinates(
@ -1885,14 +1911,14 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
backgroundColor.blue / 255.0, alpha);
}
double width = textBounds.getWidth() * scaleX;
double height = textBounds.getHeight() * scaleY;
double diff = height + textBounds.getY() * scaleY;
double width = textBounds.getWidth();
double height = textBounds.getHeight();
double diff = height + textBounds.getY();
double x1 = xy[0] - scaleX;
double y1 = xy[1] - scaleY - diff;
double x2 = xy[0] + width + scaleX;
double y2 = xy[1] + height - diff + scaleY;
double x2 = xy[0] + width;
double y2 = xy[1] + height - diff;
gl.glRectd(x1, y2, x2, y1);
@ -1912,9 +1938,9 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
gl.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
if (verticalAlignment == VerticalAlignment.TOP) {
yPos += textBounds.getHeight() * getScaleY();
yPos += textBounds.getHeight();
} else {
yPos -= textBounds.getHeight() * getScaleY();
yPos -= textBounds.getHeight();
}
}
@ -1978,15 +2004,15 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
* magnification;
}
float scaleX = (float) (getScaleX() * fontPercentage);
float scaleY = (float) (getScaleY() * fontPercentage);
float scaleX = (float) (stringScaleX * fontPercentage);
float scaleY = (float) (stringScaleY * fontPercentage);
double yPos = dString.basics.y;
VerticalAlignment verticalAlignment = dString.verticallAlignment;
if (verticalAlignment == VerticalAlignment.MIDDLE
&& dString.getText().length > 1) {
Rectangle2D totalBounds = getStringsBounds(dString);
double totalHeight = totalBounds.getHeight() * getScaleY();
double totalHeight = totalBounds.getHeight();
yPos -= totalHeight * .5;
verticalAlignment = VerticalAlignment.TOP;
}
@ -2068,9 +2094,9 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
textRenderer.draw3D(string, xy[0], xy[1], 0.0f, scaleY);
}
if (verticalAlignment == VerticalAlignment.TOP) {
yPos += textBounds.getHeight() * getScaleY();
yPos += textBounds.getHeight();
} else {
yPos -= textBounds.getHeight() * getScaleY();
yPos -= textBounds.getHeight();
}
}
@ -2120,10 +2146,8 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
double width = textBounds.getWidth();
double height = textBounds.getHeight();
double adjustedWidth = width * getScaleX();
double adjustedHeight = height * getScaleY();
double adjustedOffset = (height + textBounds.getY()) * getScaleY();
double offset = (height + textBounds.getY());
// double adjustedOffset = (height + textBounds.getY()) * getScaleY();
double canvasX1 = 0.0;
double canvasY1 = 0.0;
@ -2133,22 +2157,22 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
canvasX1 = xPos;
} else if (horizontalAlignment == HorizontalAlignment.CENTER) {
canvasX1 = xPos - adjustedWidth / 2;
canvasX1 = xPos - width / 2;
} else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
canvasX1 = xPos - adjustedWidth;
canvasX1 = xPos - width;
}
// Calculate the vertical point based on alignment
if (verticalAlignment == VerticalAlignment.BOTTOM) { // normal
canvasY1 = yPos;
} else if (verticalAlignment == VerticalAlignment.MIDDLE) {
canvasY1 = yPos + adjustedHeight / 2;
canvasY1 = yPos + height / 2;
} else if (verticalAlignment == VerticalAlignment.TOP) {
canvasY1 = yPos + adjustedHeight;
canvasY1 = yPos + height;
}
canvasY1 -= (adjustedOffset);
canvasY1 -= (offset);
return new float[] { (float) canvasX1, (float) -canvasY1 };
}

View file

@ -1,5 +1,5 @@
org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = true
org.eclipse.ui/presentationFactoryId=com.raytheon.viz.ui.personalities.awips.VizPresentationFactory
org.eclipse.ui/presentationFactoryId=com.raytheon.uf.viz.personalities.cave.presentation.VizPresentationFactory
org.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme
org.eclipse.ui.editors/lineNumberRuler=true
org.eclipse.core.resources/snapshots.operations=2147483647

View file

@ -27,6 +27,8 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.contexts.IContextService;
@ -91,6 +93,12 @@ public class AWIPSWorkbenchAdvisor extends VizWorkbenchAdvisor {
"-perspective") != null;
}
@Override
protected WorkbenchWindowAdvisor createNewWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
return new AWIPSWorkbenchWindowAdvisor(configurer, singlePerspective);
}
@Override
public String getInitialWindowPerspectiveId() {
if (singlePerspective) {

View file

@ -198,17 +198,17 @@ public class VizDisplayPane implements IDisplayPane {
boolean enableContextualMenus) throws VizException {
this.container = container;
this.canvasComp = canvasComp;
this.canvasComp.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
VizDisplayPane.this.dispose();
}
});
// create the graphics adapter
graphicsAdapter = display.getGraphicsAdapter();
// create the canvas
this.canvas = graphicsAdapter.constrcutCanvas(canvasComp);
this.canvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
VizDisplayPane.this.dispose();
}
});
// set the renderable display
setRenderableDisplay(display);
@ -400,10 +400,6 @@ public class VizDisplayPane implements IDisplayPane {
container.notifyRenderableDisplayChangedListeners(this,
renderableDisplay, DisplayChangeType.REMOVE);
}
if (canvas.isDisposed() == false) {
canvasComp.dispose();
}
}
}
@ -812,13 +808,7 @@ public class VizDisplayPane implements IDisplayPane {
/**
* Resize the pane
*/
public void resize() {
synchronized (this) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
protected void resize() {
if (canvas == null || canvas.isDisposed()) {
return;
}
@ -827,27 +817,13 @@ public class VizDisplayPane implements IDisplayPane {
Rectangle clientArea = canvas.getClientArea();
if (renderableDisplay != null
&& renderableDisplay.getExtent() == null) {
scaleToClientArea();
zoomLevel = renderableDisplay
.recalcZoomLevel(renderableDisplay
.getDimensions());
refresh();
} else if (renderableDisplay != null) {
if (renderableDisplay != null) {
renderableDisplay.calcPixelExtent(clientArea);
zoomLevel = renderableDisplay
.recalcZoomLevel(renderableDisplay
zoomLevel = renderableDisplay.recalcZoomLevel(renderableDisplay
.getDimensions());
}
refresh();
}
}
});
}
}
/*
* (non-Javadoc)
@ -914,6 +890,13 @@ public class VizDisplayPane implements IDisplayPane {
return canvas;
}
/**
* @return the pane composite
*/
public Composite getComposite() {
return canvasComp;
}
/*
* (non-Javadoc)
*

View file

@ -22,7 +22,6 @@ package com.raytheon.uf.common.dataplugin;
import java.lang.reflect.Field;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.Column;
@ -75,6 +74,7 @@ import com.raytheon.uf.common.util.ConvertUtil;
* Removed unused getIdentfier().
* Mar 29, 2013 1638 mschenke Added methods for loading from data map and creating data map from
* dataURI fields
* Apr 18, 2013 1638 mschenke Moved dataURI map generation into DataURIUtil
*
* </pre>
*
@ -227,27 +227,9 @@ public abstract class PluginDataObject extends PersistableDataObject implements
* @throws PluginException
*/
public Map<String, Object> createDataURIMap() throws PluginException {
try {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = DataURIUtil.createDataURIMap(this);
map.put("pluginName", getPluginName());
Field[] fields = DataURIUtil.getInstance().getAllDataURIFields(
getClass());
for (int i = 0; i < fields.length; ++i) {
String fieldName = PluginDataObject.getDataURIFieldName(
getClass(), i);
String[] nested = fieldName.split("[.]");
Object source = this;
if (nested.length > 0) {
for (int j = 0; j < nested.length; ++j) {
source = PropertyUtils.getProperty(source, nested[j]);
}
map.put(fieldName, source);
}
}
return map;
} catch (Exception e) {
throw new PluginException("Error constructing dataURI mapping", e);
}
}
/**

View file

@ -27,6 +27,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.PropertyUtils;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
/**
* Utility class for working with dataURIs
*
@ -37,6 +42,7 @@ import java.util.Map;
* 10/07/2008 1533 bphillip Initial Checkin
* Mar 29, 2013 1638 mschenke Added method for recursively getting all
* dataURI fields for an object
* Apr 18, 2013 1638 mschenke Moved dataURI map generation into here from PluginDataObject
*
* </pre>
*
@ -70,6 +76,38 @@ public class DataURIUtil {
return instance;
}
/**
* Creates a DataURI map for the specified object based on {@link DataURI}
* annotations
*
* @param object
* @return
* @throws PluginException
*/
public static Map<String, Object> createDataURIMap(Object object)
throws PluginException {
try {
Map<String, Object> map = new HashMap<String, Object>();
Field[] fields = DataURIUtil.getInstance().getAllDataURIFields(
object.getClass());
for (int i = 0; i < fields.length; ++i) {
String fieldName = PluginDataObject.getDataURIFieldName(
object.getClass(), i);
String[] nested = fieldName.split("[.]");
Object source = object;
if (nested.length > 0) {
for (int j = 0; j < nested.length && source != null; ++j) {
source = PropertyUtils.getProperty(source, nested[j]);
}
map.put(fieldName, source);
}
}
return map;
} catch (Exception e) {
throw new PluginException("Error constructing dataURI mapping", e);
}
}
public Field[] getAllDataURIFields(Class<?> obj) {
List<Field> fields = new ArrayList<Field>();
getAllDataURIFields(obj, fields);

View file

@ -347,7 +347,6 @@ public class ResourceBndlLoader implements Runnable { // extends Job {
}
pane.setZoomLevel( mapDisplay.getZoomLevel() );
pane.resize();
pane.refresh();
return true;

View file

@ -64,17 +64,6 @@ public class NCDisplayPane extends VizDisplayPane {
}
// if the user has locked the zoom due to a size-of-image reprojection, we
// don't want to change the zoomLevel which is a done in VizPaneDisplay
// TODO : this seems to work except that resize() is called just after an rbd is
// loaded which, when size of image is selected, causes the image not to display.
//
public void resize() {
// if( !((NCMapDescriptor)getDescriptor()).getSuspendZoom() ) {
super.resize();
// }
}
// if we need to get rid of NCDisplayPane we can either go back
// to having a separate 'no-op' SuspendZoomHandler or add a check
// for the descriptor's suspend zoom flag in our NcPanHandler class