Issue #704 introduce canvas based rendering for making KML screen overlays

Change-Id: I6fc7873d98fe140ebea84899b7e4732719866def

Former-commit-id: 02e2c7b579 [formerly bb83a95f5f00cce75b47e7fab084cf3258f65aba]
Former-commit-id: 881896c21b
This commit is contained in:
Ben Steffensmeier 2012-06-27 16:26:26 -05:00
parent 7d807fad71
commit b0f5013c7c
22 changed files with 1260 additions and 1052 deletions

View file

@ -56,4 +56,20 @@ public abstract class AbstractAdvisoryDataAdapter implements
public abstract LineStyle getLineStyle(); public abstract LineStyle getLineStyle();
@Override
public int hashCode() {
return getClass().hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return true;
}
} }

View file

@ -173,4 +173,30 @@ public class AirmetDataAdapter extends AbstractAdvisoryDataAdapter {
return LINE_STYLE; return LINE_STYLE;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((hazardType == null) ? 0 : hazardType.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;
AirmetDataAdapter other = (AirmetDataAdapter) obj;
if (hazardType == null) {
if (other.hazardType != null)
return false;
} else if (!hazardType.equals(other.hazardType))
return false;
return true;
}
} }

View file

@ -238,4 +238,26 @@ public class ConvSigmetCastDataAdapter extends AbstractAdvisoryDataAdapter {
return forecast; return forecast;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (forecast ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConvSigmetCastDataAdapter other = (ConvSigmetCastDataAdapter) obj;
if (forecast != other.forecast)
return false;
return true;
}
} }

View file

@ -84,12 +84,12 @@ public class ConvSigmetOutlookDataAdapter extends AbstractAdvisoryDataAdapter {
} }
Coordinate[] coords = new Coordinate[locations.size()]; Coordinate[] coords = new Coordinate[locations.size()];
for (ConvSigmetLocation loc : locations) { for (ConvSigmetLocation loc : locations) {
coords[loc.getIndex() - 1] = new Coordinate(loc.getLongitude(), loc coords[loc.getIndex() - 1] = new Coordinate(loc.getLongitude(),
.getLatitude()); loc.getLatitude());
} }
String label = String.format(LABEL_FORMAT, section.getSequenceID()); String label = String.format(LABEL_FORMAT, section.getSequenceID());
AdvisoryRecord aRecord = new AdvisoryRecord(coords, label, section AdvisoryRecord aRecord = new AdvisoryRecord(coords, label,
.getSegment()); section.getSegment());
return aRecord; return aRecord;
} }

View file

@ -95,13 +95,13 @@ public class IntlSigmetDataAdapter extends AbstractAdvisoryDataAdapter {
if (sigmetRecord.getDistance() != -9999 && coords.length <= 2) { if (sigmetRecord.getDistance() != -9999 && coords.length <= 2) {
if (coords.length == 1) { if (coords.length == 1) {
AdvisoryRecord aRecord = new AdvisoryRecord(coords[0], AdvisoryRecord aRecord = new AdvisoryRecord(coords[0],
sigmetRecord.getDistance(), label, sigmetRecord sigmetRecord.getDistance(), label,
.getBullMessage()); sigmetRecord.getBullMessage());
result.add(aRecord); result.add(aRecord);
} else { } else {
AdvisoryRecord aRecord = new AdvisoryRecord(coords, AdvisoryRecord aRecord = new AdvisoryRecord(coords,
sigmetRecord.getDistance(), label, sigmetRecord sigmetRecord.getDistance(), label,
.getBullMessage()); sigmetRecord.getBullMessage());
result.add(aRecord); result.add(aRecord);
} }
} else { } else {
@ -137,4 +137,30 @@ public class IntlSigmetDataAdapter extends AbstractAdvisoryDataAdapter {
return LINE_STYLE; return LINE_STYLE;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((hazardType == null) ? 0 : hazardType.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
IntlSigmetDataAdapter other = (IntlSigmetDataAdapter) obj;
if (hazardType == null) {
if (other.hazardType != null)
return false;
} else if (!hazardType.equals(other.hazardType))
return false;
return true;
}
} }

View file

@ -146,4 +146,30 @@ public class NonConvSigmetDataAdapter extends AbstractAdvisoryDataAdapter {
return LINE_STYLE; return LINE_STYLE;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((hazardType == null) ? 0 : hazardType.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
NonConvSigmetDataAdapter other = (NonConvSigmetDataAdapter) obj;
if (hazardType == null) {
if (other.hazardType != null)
return false;
} else if (!hazardType.equals(other.hazardType))
return false;
return true;
}
} }

View file

@ -49,8 +49,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
* @version 1.0 * @version 1.0
*/ */
@XmlAccessorType(XmlAccessType.NONE) @XmlAccessorType(XmlAccessType.NONE)
public class AdvisoryResourceData extends public class AdvisoryResourceData extends AbstractRequestableResourceData {
AbstractRequestableResourceData {
@XmlElement @XmlElement
private AbstractAdvisoryDataAdapter dataAdapter; private AbstractAdvisoryDataAdapter dataAdapter;
@ -64,48 +63,11 @@ public class AdvisoryResourceData extends
@XmlAttribute @XmlAttribute
private boolean enableNonstandardInspect = false; private boolean enableNonstandardInspect = false;
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj instanceof AdvisoryResourceData == false) {
return false;
}
AdvisoryResourceData other = (AdvisoryResourceData) obj;
if (other.dataAdapter != dataAdapter
&& (other.dataAdapter == null || !other.dataAdapter
.equals(dataAdapter))) {
return false;
}
if (other.name != name
&& (other.name == null || !other.name.equals(name))) {
return false;
}
if (other.colorString != colorString
&& (other.colorString == null || !other.colorString
.equalsIgnoreCase(colorString))) {
return false;
}
if (other.enableNonstandardInspect != this.enableNonstandardInspect) {
return false;
}
return true;
}
@Override @Override
protected AbstractVizResource<?, ?> constructResource( protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects) LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException { throws VizException {
AdvisoryResource nr = new AdvisoryResource(this, AdvisoryResource nr = new AdvisoryResource(this, loadProperties);
loadProperties);
if (colorString != null) { if (colorString != null) {
nr.getCapability(ColorableCapability.class).setColorAsString( nr.getCapability(ColorableCapability.class).setColorAsString(
colorString); colorString);
@ -116,7 +78,6 @@ public class AdvisoryResourceData extends
return nr; return nr;
} }
public AbstractAdvisoryDataAdapter getDataAdapter() { public AbstractAdvisoryDataAdapter getDataAdapter() {
return dataAdapter; return dataAdapter;
} }
@ -149,4 +110,46 @@ public class AdvisoryResourceData extends
return colorString; return colorString;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ ((colorString == null) ? 0 : colorString.hashCode());
result = prime * result
+ ((dataAdapter == null) ? 0 : dataAdapter.hashCode());
result = prime * result + (enableNonstandardInspect ? 1231 : 1237);
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
AdvisoryResourceData other = (AdvisoryResourceData) obj;
if (colorString == null) {
if (other.colorString != null)
return false;
} else if (!colorString.equals(other.colorString))
return false;
if (dataAdapter == null) {
if (other.dataAdapter != null)
return false;
} else if (!dataAdapter.equals(other.dataAdapter))
return false;
if (enableNonstandardInspect != other.enableNonstandardInspect)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
} }

View file

@ -32,6 +32,7 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.legend.ILegendDecorator; import com.raytheon.uf.viz.core.legend.ILegendDecorator;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
@ -101,15 +102,8 @@ public abstract class AbstractLegendResource<T extends AbstractResourceData>
LegendEntry[] legendData = getLegendData(descriptor); LegendEntry[] legendData = getLegendData(descriptor);
List<DrawableString> legendStrings = new ArrayList<DrawableString>(); List<DrawableString> legendStrings = new ArrayList<DrawableString>();
// Disable the clipping pane double yStart = paintProps.getCanvasBounds().height
target.clearClippingPlane(); - (BOTTOM_OFFSET_IN_PIXELS);
// Get the ratio for pixel to gl pixel conversion
double ratio = paintProps.getView().getExtent().getWidth()
/ paintProps.getCanvasBounds().width;
double yStart = paintProps.getView().getExtent().getMaxY()
- (BOTTOM_OFFSET_IN_PIXELS * ratio);
for (LegendEntry le : legendData) { for (LegendEntry le : legendData) {
String allText = ""; String allText = "";
for (LegendData ld : le.legendParts) { for (LegendData ld : le.legendParts) {
@ -119,8 +113,8 @@ public abstract class AbstractLegendResource<T extends AbstractResourceData>
Rectangle2D allTextBounds = target Rectangle2D allTextBounds = target
.getStringBounds(le.font, allText); .getStringBounds(le.font, allText);
double xStart = paintProps.getView().getExtent().getMaxX() double xStart = paintProps.getCanvasBounds().width
- ((RIGHT_OFFSET_IN_PIXELS + allTextBounds.getWidth()) * ratio); - ((RIGHT_OFFSET_IN_PIXELS + allTextBounds.getWidth()));
double maxHeight = 0.0; double maxHeight = 0.0;
for (LegendData ld : le.legendParts) { for (LegendData ld : le.legendParts) {
@ -132,18 +126,17 @@ public abstract class AbstractLegendResource<T extends AbstractResourceData>
legendStrings.add(string); legendStrings.add(string);
Rectangle2D textBounds = target.getStringsBounds(string); Rectangle2D textBounds = target.getStringsBounds(string);
xStart += (textBounds.getWidth() * ratio); xStart += textBounds.getWidth();
if (textBounds.getHeight() > maxHeight) { if (textBounds.getHeight() > maxHeight) {
maxHeight = textBounds.getHeight(); maxHeight = textBounds.getHeight();
} }
} }
yStart -= (maxHeight * ratio); yStart -= maxHeight;
} }
target.drawStrings(legendStrings); target.getExtension(ICanvasRenderingExtension.class).drawStrings(
paintProps, legendStrings.toArray(new DrawableString[0]));
target.setupClippingPlane(paintProps.getClippingPane());
} }
/* /*

View file

@ -112,5 +112,8 @@
<graphicsExtension <graphicsExtension
class="com.raytheon.uf.viz.core.drawables.ext.colormap.GeneralColormappedImageExtension"> class="com.raytheon.uf.viz.core.drawables.ext.colormap.GeneralColormappedImageExtension">
</graphicsExtension> </graphicsExtension>
<graphicsExtension
class="com.raytheon.uf.viz.core.drawables.ext.GeneralCanvasRenderingExtension">
</graphicsExtension>
</extension> </extension>
</plugin> </plugin>

View file

@ -0,0 +1,540 @@
/**
* 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.core;
import java.awt.geom.Rectangle2D;
import java.awt.image.RenderedImage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.data.IColormappedDataPreparer;
import com.raytheon.uf.viz.core.data.IDataPreparer;
import com.raytheon.uf.viz.core.data.IImageDataPreparer;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.data.resp.NumericImageData;
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtensionManager;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* A base target that handles many of the generic things a target needs to do,
* such as calling alternative forms of overloaded functions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 25, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public abstract class AbstractGraphicsTarget implements IGraphicsTarget {
/** Does a refresh need to be performed? */
protected boolean needsRefresh = true;
protected GraphicsExtensionManager extensionManager;
protected RGB backgroundColor = new RGB(0, 0, 0);
public AbstractGraphicsTarget() {
extensionManager = new GraphicsExtensionManager(this);
}
@Override
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException {
return ImagingSupport.drawRasters(this, paintProps, images);
}
@Override
@Deprecated
public IImage initializeRaster(IDataPreparer preparer,
ColorMapParameters optionalParams) {
IImage rval = null;
if (optionalParams == null) {
// Assume IImageDataPreparer
final IImageDataPreparer imagePreparer = (IImageDataPreparer) preparer;
rval = initializeRaster(new IRenderedImageCallback() {
@Override
public RenderedImage getImage() throws VizException {
return imagePreparer.prepareData().getImage();
}
});
} else if (preparer instanceof IColormappedDataPreparer) {
try {
IColormappedImageExtension cmapExt = getExtension(IColormappedImageExtension.class);
final IColormappedDataPreparer cmapPreparer = (IColormappedDataPreparer) preparer;
rval = cmapExt.initializeRaster(
new IColorMapDataRetrievalCallback() {
@Override
public ColorMapData getColorMapData()
throws VizException {
NumericImageData oldData = cmapPreparer
.prepareData();
return new ColorMapData(
oldData.getData(),
new int[] {
oldData.getDatasetBounds().width,
oldData.getDatasetBounds().height });
}
}, optionalParams);
} catch (VizException e) {
throw new IllegalStateException(e);
}
}
return rval;
}
@Override
public boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps) throws VizException {
return this.drawRaster(image, extent, paintProps,
RasterMode.SYNCHRONOUS);
}
@Override
public boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps, RasterMode mode) throws VizException {
DrawableImage di = new DrawableImage(image, extent);
di.setMode(mode);
return drawRasters(paintProps, di);
}
@Override
public void drawStrings(DrawableString... parameters) throws VizException {
drawStrings(Arrays.asList(parameters));
}
@Override
public Rectangle2D getStringsBounds(DrawableString parameters) {
// TODO: Handle box already set? and OUTLINE style
String[] text = parameters.getText();
double maxWidth = 0;
double totalHeight = 0;
Rectangle2D bounds = null;
for (String string : text) {
Rectangle2D txtBounds = getStringsBounds(parameters, string);
if (txtBounds.getWidth() > maxWidth) {
maxWidth = txtBounds.getWidth();
}
totalHeight += txtBounds.getHeight();
if (bounds == null) {
bounds = txtBounds;
}
}
if (bounds != null) {
if (parameters.textStyle == TextStyle.BLANKED
|| parameters.textStyle == TextStyle.BOXED) {
maxWidth += 1.0f;
}
bounds.setRect(0, 0, maxWidth, totalHeight);
}
return bounds;
}
@Override
public void drawShadedShape(IShadedShape shape, float alpha)
throws VizException {
drawShadedShape(shape, alpha, 1.0f);
}
@Override
public void drawShadedShape(IShadedShape shape, float alpha,
float brightness) throws VizException {
drawShadedShapes(alpha, brightness, shape);
}
@Override
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth) throws VizException {
drawWireframeShape(shape, color, lineWidth, LineStyle.SOLID);
}
@Override
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle) throws VizException {
drawWireframeShape(shape, color, lineWidth, lineStyle, 1.0f);
}
@Override
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle, IFont font)
throws VizException {
drawWireframeShape(shape, color, lineWidth, lineStyle, font, 1.0f);
}
@Override
@Deprecated
public void drawArc(double x1, double y1, double z1, double radius,
RGB color, float width, int startAzimuth, int endAzimuth,
LineStyle lineStyle, boolean includeSides) throws VizException {
DrawableCircle dc = new DrawableCircle();
dc.setCoordinates(x1, y1, z1);
dc.basics.color = color;
dc.lineStyle = lineStyle;
dc.startAzimuth = startAzimuth;
dc.endAzimuth = endAzimuth;
if (startAzimuth > endAzimuth) {
dc.numberOfPoints = (endAzimuth + 360) - startAzimuth;
} else {
dc.numberOfPoints = endAzimuth - startAzimuth;
}
dc.includeSides = includeSides;
dc.lineWidth = width;
dc.radius = radius;
drawCircle(dc);
}
@Override
public double[] getPointOnCircle(double x1, double y1, double z1,
double radius, double angle) throws VizException {
double pointOnCircle[] = new double[3];
pointOnCircle[0] = x1 + radius * Math.cos(Math.toRadians(angle));
pointOnCircle[1] = y1 + radius * Math.sin(Math.toRadians(angle));
// on plane z1
pointOnCircle[2] = z1;
return pointOnCircle;
}
@Override
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor) {
return createWireframeShape(mutable, descriptor, 0.0f);
}
@Override
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor, float simplificationLevel) {
return createWireframeShape(mutable, descriptor, simplificationLevel,
false, null);
}
@Override
public IWireframeShape createWireframeShape(boolean mutable,
GeneralGridGeometry geom, float simplificationLevel) {
return createWireframeShape(mutable, geom, simplificationLevel, false,
null);
}
@Override
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor, float simplificationLevel,
boolean spatialChopFlag, IExtent extent) {
return createWireframeShape(mutable, descriptor.getGridGeometry(),
simplificationLevel, spatialChopFlag, extent);
}
@Override
public IWireframeShape createWireframeShape(boolean mutableFlag,
GeneralGridGeometry geom) {
return createWireframeShape(mutableFlag, geom, 0.0f);
}
@Override
public IShadedShape createShadedShape(boolean mutable,
IDescriptor descriptor, boolean tesselate) {
return createShadedShape(mutable, descriptor.getGridGeometry(),
tesselate);
}
@Override
public void setNeedsRefresh(boolean needsRefresh) {
this.needsRefresh = needsRefresh;
}
@Override
public boolean isNeedsRefresh() {
return needsRefresh;
}
@Override
public void setBackgroundColor(RGB backgroundColor) {
this.backgroundColor = backgroundColor;
}
@Override
@Deprecated
public void setUseBuiltinColorbar(boolean isColorbarDisplayed) {
// Most targets do not support a BuiltinColorbar and this functionality
// is deprecated, so the default behavior is to completely ignore this.
}
@Override
@Deprecated
public String getViewType() {
return VizConstants.VIEW_2D;
}
@Override
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle) throws VizException {
drawPoint(x, y, z, color, pointStyle, 1.0f);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawPoints(java.util.Collection,
* org.eclipse.swt.graphics.RGB,
* com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle, float)
*/
@Override
public void drawPoints(Collection<double[]> locations, RGB color,
PointStyle pointStyle, float magnification) throws VizException {
List<DrawableString> dstrings = new ArrayList<DrawableString>();
for (double[] location : locations) {
String text = null;
switch (pointStyle) {
case SQUARE:
text = "";
break;
case CIRCLE:
text = "";
break;
case CROSS:
text = "+";
break;
case DASH:
text = "-";
break;
case DISC:
text = "";
break;
case POINT:
text = "";
break;
case BOX:
text = "";
break;
case STAR:
text = "*";
break;
case X:
text = "x";
break;
case NONE:
default:
return;
}
DrawableString dstring = new DrawableString(text, color);
dstring.setCoordinates(location[0], location[1]);
dstring.magnification = magnification;
dstrings.add(dstring);
}
drawStrings(dstrings);
}
@Override
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle, float magnification) throws VizException {
drawPoints(Arrays.asList(new double[] { x, y, z }), color, pointStyle,
magnification);
}
@Override
public void renderOffscreen(IImage offscreenImage) throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOffscreen(
offscreenImage);
}
@Override
public void renderOnscreen() throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOnscreen();
}
@Override
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation)
throws VizException {
drawString(font, text, x, y, z, textStyle, color, horizontalAlignment,
verticalAlignment, rotation, 1.0f, 1.0f);
}
@Override
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment, Double rotation)
throws VizException {
drawString(font, text, x, y, z, textStyle, color, horizontalAlignment,
VerticalAlignment.BOTTOM, rotation);
}
@Override
public void drawStrings(IFont font, String[] text, double x, double y,
double z, TextStyle textStyle, RGB[] colors,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) throws VizException {
DrawableString params = new DrawableString(text, colors);
params.font = font;
params.setCoordinates(x, y, z);
params.textStyle = textStyle;
params.horizontalAlignment = horizontalAlignment;
params.verticallAlignment = verticalAlignment;
drawStrings(params);
}
@Override
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation, float alpha,
double magnification) throws VizException {
DrawableString params = new DrawableString(string, color);
params.font = font;
params.setCoordinates(xPos, yPos, zPos);
params.textStyle = textStyle;
params.horizontalAlignment = horizontalAlignment;
params.verticallAlignment = verticalAlignment;
params.rotation = rotation != null ? rotation : 0.0;
params.basics.alpha = alpha;
params.magnification = magnification;
drawStrings(params);
}
@Override
public Rectangle2D getStringBounds(IFont font, String text) {
if (font == null) {
font = getDefaultFont();
}
DrawableString params = new DrawableString(text, null);
params.font = font;
return getStringsBounds(params, text);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringBounds(com.raytheon
* .uf.viz.core.drawables.IFont, java.lang.String[],
* com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle)
*/
@Override
public Rectangle2D getStringBounds(IFont font, String[] text,
TextStyle style) {
DrawableString params = new DrawableString(text, (RGB[]) null);
params.font = font;
params.textStyle = style;
return getStringsBounds(params);
}
@Override
public void drawCircle(double x1, double y1, double z1, double radius,
RGB color, float width) throws VizException {
DrawableCircle circle = new DrawableCircle();
circle.setCoordinates(x1, y1, z1);
circle.lineWidth = width;
circle.basics.color = color;
circle.radius = new Double(radius);
drawCircle(circle);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawFilledCircle(double,
* double, double, double, org.eclipse.swt.graphics.RGB)
*/
@Override
public void drawFilledCircle(double x, double y, double z, double radius,
RGB color) throws VizException {
DrawableCircle circle = new DrawableCircle();
circle.setCoordinates(x, y, z);
circle.basics.color = color;
circle.radius = new Double(radius);
circle.filled = true;
drawCircle(circle);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#buildColorMap(java.lang.String)
*/
@Override
public IColorMap buildColorMap(String name) throws VizException {
return ColorMapLoader.loadColorMap(name);
}
@Override
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width, LineStyle lineStyle)
throws VizException {
DrawableLine line = new DrawableLine();
line.addPoint(x1, y1, z1);
line.addPoint(x2, y2, z2);
line.width = width;
line.lineStyle = lineStyle;
line.basics.color = color;
drawLine(line);
}
@Override
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width) throws VizException {
drawLine(x1, y1, z1, x2, y2, z2, color, width, LineStyle.SOLID);
}
@Override
public <T extends IGraphicsExtensionInterface> T getExtension(
Class<T> extensionClass) throws VizException {
return extensionManager.getExtension(extensionClass);
}
}

View file

@ -0,0 +1,213 @@
/**
* 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.core;
import javax.vecmath.Vector3d;
import org.eclipse.swt.graphics.Rectangle;
import com.raytheon.uf.viz.core.geom.Plane;
import com.raytheon.uf.viz.core.geom.Ray;
/**
*
* Provides basic view functionality that may be useful to any view object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 25, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public abstract class AbstractView implements IView {
private static final Plane mapPlane = new Plane(0.0, 0.0, 1.0, 0.0, false);
protected IExtent extent;
public AbstractView(IExtent pe) {
this.extent = pe;
}
@Override
public void scaleAndBias(double factor, double screenX, double screenY,
IGraphicsTarget target) {
double[] grid = screenToGrid(screenX, screenY, 0, target);
this.extent.scaleAndBias(factor, grid[0], grid[1]);
}
@Override
public double getZoom() {
return extent.getScale();
}
@Override
public double recalcZoomLevel(int[] dimensions) {
int worldWidth = dimensions[0];
int worldHeight = dimensions[1];
return Math.min((extent.getMaxX() - extent.getMinX()) / worldWidth,
(extent.getMaxY() - extent.getMinY()) / worldHeight);
}
@Override
public void zoom(double zoomLevel) {
this.extent.scale(zoomLevel);
}
@Override
public boolean isVisible(double[] pixel) {
return extent.contains(pixel);
}
@Override
public boolean isVisible(IExtent pe) {
return extent.intersects(pe);
}
@Override
public IExtent getExtent() {
return extent;
}
@Override
public void setExtent(IExtent e) {
this.extent = e;
}
@Override
public double[] getDisplayCoords(double[] screenCoordinate,
IGraphicsTarget target) {
Ray r = computeRay(screenCoordinate, target);
if (r == null) {
return null;
}
Vector3d i = mapPlane.intersection(r);
if (i == null) {
return null;
}
return new double[] { i.x, i.y, i.z };
}
/**
* Create a Ray starting a the near plane with direction towards the far
*
* @param mouse
* mouse x,y
* @return Ray
*/
public Ray computeRay(double[] mouse, IGraphicsTarget target) {
Vector3d far = new Vector3d(screenToGrid(mouse[0], mouse[1], 1, target));
Vector3d near = new Vector3d(
screenToGrid(mouse[0], mouse[1], 0, target));
if (near == null || far == null) {
return null;
}
far.sub(near);
far.normalize();
return new Ray(near, far);
}
@Override
public IExtent createExtent(PixelCoverage pc) {
return new PixelExtent(pc.getMinX(), pc.getMaxX(), pc.getMinY(),
pc.getMaxY());
}
@Override
public void shiftExtent(double[] startScreen, double[] endScreen,
IGraphicsTarget target) {
double[] start = screenToGrid(startScreen[0], startScreen[1], 0, target);
double[] end = screenToGrid(endScreen[0], endScreen[1], 0, target);
this.extent.shift(end[0] - start[0], end[1] - start[1]);
}
@Override
public void scaleToClientArea(Rectangle clientArea, int[] dims) {
double screenRatio;
if ((clientArea.width == 0) || (clientArea.height == 0)) {
screenRatio = 1.0;
} else {
screenRatio = (double) clientArea.width
/ (double) clientArea.height;
}
int f_worldWidth = dims[0];
int f_worldHeight = dims[1];
double worldRatio = (double) f_worldWidth / (double) f_worldHeight;
// set pixel extent to show entire map
if (screenRatio > worldRatio) {
this.extent = new PixelExtent(0, f_worldHeight * screenRatio, 0,
f_worldHeight);
} else {
this.extent = new PixelExtent(0, f_worldWidth, 0, f_worldWidth
/ screenRatio);
}
this.extent.shift((f_worldWidth - extent.getWidth()) / 2,
(f_worldHeight - extent.getHeight()) / 2);
}
@Override
public double[] screenToGrid(double x, double y, double depth,
IGraphicsTarget target) {
double correctedX = (x * (extent.getMaxX() - extent.getMinX()) / getCanvasBounds(target).width)
+ extent.getMinX();
double correctedY = (y * (extent.getMaxY() - extent.getMinY()) / getCanvasBounds(target).height)
+ extent.getMinY();
// z bounds are 0 to 1
double correctedZ = (depth * (extent.getMax().z - extent.getMin().z))
+ extent.getMin().z;
return new double[] { correctedX, correctedY, correctedZ };
}
@Override
public double[] gridToScreen(double[] grid, IGraphicsTarget target) {
double x = ((grid[0] - extent.getMinX()) * getCanvasBounds(target).width)
/ (extent.getMaxX() - extent.getMinX());
double y = ((grid[1] - extent.getMinY()) * getCanvasBounds(target).height)
/ (extent.getMaxY() - extent.getMinY());
// z bounds are 0 to 1
double z = (grid[2] - extent.getMin().z)
/ (extent.getMax().z - extent.getMin().z);
return new double[] { x, y, z };
}
public abstract Rectangle getCanvasBounds(IGraphicsTarget target);
public abstract void setupView(IGraphicsTarget target);
public abstract AbstractView clone();
}

View file

@ -166,6 +166,6 @@ public interface IView {
public abstract void scaleToClientArea(Rectangle clientArea, public abstract void scaleToClientArea(Rectangle clientArea,
int[] dimensions); int[] dimensions);
public Object clone(); public IView clone();
} }

View file

@ -0,0 +1,152 @@
/**
* 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.core.drawables.ext;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* A general implementation of the canvas rendering extension which converts
* canvas relative coordinates into display coordinates.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 26, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GeneralCanvasRenderingExtension extends
GraphicsExtension<IGraphicsTarget> implements ICanvasRenderingExtension {
@Override
public void drawStrings(PaintProperties paintProps,
DrawableString... parameters) throws VizException {
IExtent extent = paintProps.getView().getExtent();
double xRatio = extent.getWidth() / paintProps.getCanvasBounds().width;
double yRatio = extent.getHeight()
/ paintProps.getCanvasBounds().height;
List<DrawableString> mapStrings = new ArrayList<DrawableString>(
parameters.length);
for (DrawableString screenString : parameters) {
DrawableString mapString = new DrawableString(
screenString.getText(), screenString.getColors());
mapString.boxColor = screenString.boxColor;
mapString.font = screenString.font;
mapString.horizontalAlignment = screenString.horizontalAlignment;
mapString.magnification = screenString.magnification;
mapString.rotation = screenString.rotation;
mapString.shadowColor = screenString.shadowColor;
mapString.textStyle = screenString.textStyle;
mapString.verticallAlignment = screenString.verticallAlignment;
mapString.basics.alpha = screenString.basics.alpha;
mapString.basics.xOrColors = screenString.basics.xOrColors;
mapString.basics.color = screenString.basics.color;
mapString.basics.x = extent.getMinX() + screenString.basics.x
* xRatio;
mapString.basics.y = extent.getMinY() + screenString.basics.y
* yRatio;
mapString.basics.z = screenString.basics.z;
mapStrings.add(mapString);
}
target.clearClippingPlane();
target.drawStrings(mapStrings);
target.setupClippingPlane(paintProps.getClippingPane());
}
@Override
public void drawLines(PaintProperties paintProps,
DrawableLine... parameters) throws VizException {
IExtent extent = paintProps.getView().getExtent();
double xRatio = extent.getWidth() / paintProps.getCanvasBounds().width;
double yRatio = extent.getHeight()
/ paintProps.getCanvasBounds().height;
List<DrawableLine> mapLines = new ArrayList<DrawableLine>(
parameters.length);
for (DrawableLine screenLine : parameters) {
DrawableLine mapLine = new DrawableLine();
mapLine.lineStyle = screenLine.lineStyle;
mapLine.width = screenLine.width;
mapLine.basics.alpha = screenLine.basics.alpha;
mapLine.basics.color = screenLine.basics.color;
mapLine.basics.xOrColors = screenLine.basics.xOrColors;
for (double[] point : screenLine.points) {
double x = extent.getMinX() + point[0] * xRatio;
double y = extent.getMinY() + point[1] * yRatio;
mapLine.addPoint(x, y);
}
mapLines.add(mapLine);
}
target.clearClippingPlane();
target.drawLine(mapLines.toArray(new DrawableLine[0]));
target.setupClippingPlane(paintProps.getClippingPane());
}
@Override
public void drawColorRamp(PaintProperties paintProps,
DrawableColorMap colorMap) throws VizException {
IExtent extent = paintProps.getView().getExtent();
double xRatio = extent.getWidth() / paintProps.getCanvasBounds().width;
double yRatio = extent.getHeight()
/ paintProps.getCanvasBounds().height;
DrawableColorMap newColorMap = new DrawableColorMap(
colorMap.getColorMapParams());
newColorMap.alpha = colorMap.alpha;
newColorMap.brightness = colorMap.brightness;
newColorMap.contrast = colorMap.contrast;
newColorMap.interpolate = colorMap.interpolate;
double x1 = colorMap.extent.getMinX();
double y1 = colorMap.extent.getMinY();
double x2 = colorMap.extent.getMaxX();
double y2 = colorMap.extent.getMaxY();
x1 = extent.getMinX() + x1 * xRatio;
y1 = extent.getMinY() + y1 * yRatio;
x2 = extent.getMinX() + x2 * xRatio;
y2 = extent.getMinY() + y2 * yRatio;
newColorMap.extent = new PixelExtent(x1, x2, y1, y2);
target.clearClippingPlane();
target.drawColorRamp(newColorMap);
target.setupClippingPlane(paintProps.getClippingPane());
}
@Override
public int getCompatibilityValue(IGraphicsTarget target) {
return Compatibilty.GENERIC;
}
}

View file

@ -0,0 +1,80 @@
/**
* 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.core.drawables.ext;
import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Contains methods for drawing on a target using canvas relative postions.
* Useful for extra descriptions or information that are not drawn on a point of
* the map but rather are on a specific portion of the display.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 26, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public interface ICanvasRenderingExtension extends IGraphicsExtensionInterface {
/**
* Draw the DrawableString object to the screen, the location of the
* draqwable strings should be in canvas pixels which start at 0,0 in the
* upper left.
*
* @param parameters
* @throws VizException
*/
public abstract void drawStrings(PaintProperties paintProps,
DrawableString... parameters) throws VizException;
/**
* Draw the DrawableLine object to the screen. The points in the line should
* be in canvas pixels which start at 0,0 in the upper left.
*
* @param parameters
* @throws VizException
*/
public abstract void drawLines(PaintProperties paintProps,
DrawableLine... parameters) throws VizException;
/**
* Draw the drawable colormap to the screen, the extent of the colormap
* should be in canvas pixels.
*
* @param colorMap
* the colorMap to draw
*/
public abstract void drawColorRamp(PaintProperties paintProps,
DrawableColorMap colorMap) throws VizException;
}

View file

@ -29,7 +29,6 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.DrawableColorMap; import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
@ -39,6 +38,7 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.preferences.ColorFactory; import com.raytheon.uf.viz.core.preferences.ColorFactory;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@ -169,28 +169,25 @@ public class D2DColorBarResource extends
private void paintLeftColorBar(IGraphicsTarget target, private void paintLeftColorBar(IGraphicsTarget target,
PaintProperties paintProps, AbstractVizResource<?, ?> rsc, PaintProperties paintProps, AbstractVizResource<?, ?> rsc,
ColorMapParameters colorMapParameters) throws VizException { ColorMapParameters colorMapParameters) throws VizException {
IExtent viewExtent = paintProps.getView().getExtent();
double ratio = (viewExtent.getWidth() / paintProps.getCanvasBounds().width);
ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc
.getCapability(ImagingCapability.class) : null; .getCapability(ImagingCapability.class) : null;
float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha(); float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha();
float brightness = cap != null ? cap.getBrightness() : 1.0f; float brightness = cap != null ? cap.getBrightness() : 1.0f;
float contrast = cap != null ? cap.getContrast() : 1.0f; float contrast = cap != null ? cap.getContrast() : 1.0f;
double x1 = viewExtent.getMinX() + (3 * ratio); double x1 = 3;
double drawnWidth = ((viewExtent.getMaxX() - x1) * (((paintProps double drawnWidth = (paintProps.getCanvasBounds().width / 2.0) - 7.0;
.getCanvasBounds().width / 2.0) - 7.0) / paintProps
.getCanvasBounds().width));
double x2 = x1 + drawnWidth; double x2 = x1 + drawnWidth;
double y1 = viewExtent.getMinY(); double y1 = 0;
int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25; int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25;
double y2 = y1 + (pixels * ratio); double y2 = y1 + (pixels);
DrawableColorMap cmap = new DrawableColorMap(colorMapParameters); DrawableColorMap cmap = new DrawableColorMap(colorMapParameters);
cmap.extent = new PixelExtent(x1, x2, y1, y2); cmap.extent = new PixelExtent(x1, x2, y1, y2);
cmap.alpha = alpha; cmap.alpha = alpha;
cmap.brightness = brightness; cmap.brightness = brightness;
cmap.contrast = contrast; cmap.contrast = contrast;
target.drawColorRamp(cmap); target.getExtension(ICanvasRenderingExtension.class).drawColorRamp(
paintProps, cmap);
if (rsc.hasCapability(BlendedCapability.class)) { if (rsc.hasCapability(BlendedCapability.class)) {
alpha *= 2.0; alpha *= 2.0;
@ -208,29 +205,26 @@ public class D2DColorBarResource extends
private void paintRightColorBar(IGraphicsTarget target, private void paintRightColorBar(IGraphicsTarget target,
PaintProperties paintProps, AbstractVizResource<?, ?> rsc, PaintProperties paintProps, AbstractVizResource<?, ?> rsc,
ColorMapParameters colorMapParameters) throws VizException { ColorMapParameters colorMapParameters) throws VizException {
IExtent viewExtent = paintProps.getView().getExtent();
double ratio = (viewExtent.getWidth() / paintProps.getCanvasBounds().width);
ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc
.getCapability(ImagingCapability.class) : null; .getCapability(ImagingCapability.class) : null;
float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha(); float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha();
float brightness = cap != null ? cap.getBrightness() : 1.0f; float brightness = cap != null ? cap.getBrightness() : 1.0f;
float contrast = cap != null ? cap.getContrast() : 1.0f; float contrast = cap != null ? cap.getContrast() : 1.0f;
double x1 = viewExtent.getMinX(); double x1 = 0;
double drawnWidth = ((viewExtent.getMaxX() - x1) * (((paintProps double drawnWidth = ((paintProps.getCanvasBounds().width / 2.0) - 7.0);
.getCanvasBounds().width / 2.0) - 7.0) / paintProps double x2 = paintProps.getCanvasBounds().width - 3;
.getCanvasBounds().width));
double x2 = viewExtent.getMaxX() - (3 * ratio);
x1 = x2 - drawnWidth; x1 = x2 - drawnWidth;
double y1 = viewExtent.getMinY(); double y1 = 0;
int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25; int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25;
double y2 = y1 + (pixels * ratio); double y2 = y1 + pixels;
DrawableColorMap cmap = new DrawableColorMap(colorMapParameters); DrawableColorMap cmap = new DrawableColorMap(colorMapParameters);
cmap.extent = new PixelExtent(x1, x2, y1, y2); cmap.extent = new PixelExtent(x1, x2, y1, y2);
cmap.alpha = alpha; cmap.alpha = alpha;
cmap.brightness = brightness; cmap.brightness = brightness;
cmap.contrast = contrast; cmap.contrast = contrast;
target.drawColorRamp(cmap); target.getExtension(ICanvasRenderingExtension.class).drawColorRamp(
paintProps, cmap);
alpha *= 2.0; alpha *= 2.0;
double yPos = y1 + ((y2 - y1) * .4); double yPos = y1 + ((y2 - y1) * .4);
@ -470,11 +464,8 @@ public class D2DColorBarResource extends
} }
} }
double ratio = paintProps.getView().getExtent().getWidth()
/ paintProps.getCanvasBounds().width;
double lastXPos = Double.NEGATIVE_INFINITY; double lastXPos = Double.NEGATIVE_INFINITY;
double padding = 3 * ratio; double padding = 3;
if (paintProps.getCanvasBounds().width < 500) { if (paintProps.getCanvasBounds().width < 500) {
colorBarFont.setMagnification(0.9f); colorBarFont.setMagnification(0.9f);
} }
@ -516,13 +507,14 @@ public class D2DColorBarResource extends
drawable.basics.alpha = paintProps.getAlpha(); drawable.basics.alpha = paintProps.getAlpha();
Rectangle2D rect = target.getStringsBounds(drawable); Rectangle2D rect = target.getStringsBounds(drawable);
double widthDiv2 = (rect.getWidth() / 2) * ratio; double widthDiv2 = (rect.getWidth() / 2);
if (xPos - widthDiv2 > lastXPos) { if (xPos - widthDiv2 > lastXPos) {
drawables.add(drawable); drawables.add(drawable);
lastXPos = xPos + widthDiv2 + padding; lastXPos = xPos + widthDiv2 + padding;
} }
} }
target.drawStrings(drawables); target.getExtension(ICanvasRenderingExtension.class).drawStrings(
paintProps, drawables.toArray(new DrawableString[0]));
} }
} }
} }

View file

@ -22,7 +22,6 @@ package com.raytheon.viz.core.gl.internal;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File; import java.io.File;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -30,7 +29,6 @@ import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -58,24 +56,17 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.application.ProgramArguments; import com.raytheon.uf.viz.application.ProgramArguments;
import com.raytheon.uf.viz.core.AbstractGraphicsTarget;
import com.raytheon.uf.viz.core.Activator; import com.raytheon.uf.viz.core.Activator;
import com.raytheon.uf.viz.core.DrawableCircle; import com.raytheon.uf.viz.core.DrawableCircle;
import com.raytheon.uf.viz.core.DrawableColorMap; import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IView; import com.raytheon.uf.viz.core.IView;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.VizConstants;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.data.IColormappedDataPreparer;
import com.raytheon.uf.viz.core.data.IDataPreparer;
import com.raytheon.uf.viz.core.data.IImageDataPreparer;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback; import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.data.resp.NumericImageData;
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters; import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
@ -83,13 +74,9 @@ import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IShadedShape; import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface; import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtensionManager; import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtensionManager;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.preferences.PreferenceConstants; import com.raytheon.uf.viz.core.preferences.PreferenceConstants;
import com.raytheon.viz.core.gl.GLContextBridge; import com.raytheon.viz.core.gl.GLContextBridge;
@ -105,7 +92,6 @@ import com.raytheon.viz.core.gl.internal.ext.GLDefaultImagingExtension;
import com.raytheon.viz.core.gl.objects.GLTextureObject; import com.raytheon.viz.core.gl.objects.GLTextureObject;
import com.sun.opengl.util.Screenshot; import com.sun.opengl.util.Screenshot;
import com.sun.opengl.util.j2d.TextRenderer; import com.sun.opengl.util.j2d.TextRenderer;
import com.vividsolutions.jts.geom.Coordinate;
/** /**
* *
@ -145,7 +131,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1 * @version 1
* *
*/ */
public class GLTarget implements IGLTarget { public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GLTarget.class); .getHandler(GLTarget.class);
@ -171,9 +157,6 @@ public class GLTarget implements IGLTarget {
/** Has a texure load occurred during a draw operation */ /** Has a texure load occurred during a draw operation */
protected boolean hasLoadedTextureOnLoop = false; protected boolean hasLoadedTextureOnLoop = false;
/** Does a refresh need to be performed? */
protected boolean needsRefresh = false;
/** A refresh count used to handle refresh requests that occur during draws */ /** A refresh count used to handle refresh requests that occur during draws */
protected int refreshCount = 0; protected int refreshCount = 0;
@ -251,17 +234,10 @@ public class GLTarget implements IGLTarget {
*/ */
protected Rectangle canvasSize; protected Rectangle canvasSize;
/**
*
*/
protected RGB backgroundColor = new RGB(0, 0, 0);
protected FontFactory fontFactory; protected FontFactory fontFactory;
protected Rectangle monitorBounds; protected Rectangle monitorBounds;
private GraphicsExtensionManager extensionManager;
/** /**
* Construct a GL target using a canvas (inherited from IGraphicsTarget) * Construct a GL target using a canvas (inherited from IGraphicsTarget)
* *
@ -407,17 +383,6 @@ public class GLTarget implements IGLTarget {
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#buildColorMap(java.lang.String)
*/
@Override
public IColorMap buildColorMap(String name) throws VizException {
return ColorMapLoader.loadColorMap(name);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -443,32 +408,6 @@ public class GLTarget implements IGLTarget {
return new GLShadedShape(targetGeometry, mutable, tesselate); return new GLShadedShape(targetGeometry, mutable, tesselate);
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#createShadedShape(boolean,
* com.raytheon.viz.core.map.IMapDescriptor, boolean)
*/
@Override
@Deprecated
public IShadedShape createShadedShape(boolean mutable,
IDescriptor descriptor, boolean tesselate) {
return createShadedShape(mutable, descriptor.getGridGeometry(),
tesselate);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#createWireframeShape(boolean,
* org.geotools.coverage.grid.GeneralGridGeometry)
*/
@Override
public IWireframeShape createWireframeShape(boolean mutableFlag,
GeneralGridGeometry geom) {
return new GLWireframeShape2D(geom, mutableFlag);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -488,52 +427,6 @@ public class GLTarget implements IGLTarget {
} }
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#createWireframeShape(boolean,
* com.raytheon.viz.core.map.IMapDescriptor)
*/
@Override
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor) {
return new GLWireframeShape2D(descriptor.getGridGeometry(), mutable);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#createWireframeShape(boolean,
* com.raytheon.viz.core.map.IMapDescriptor, float)
*/
@Override
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor, float simplificationLevel) {
if (simplificationLevel > 0.0) {
return new GLWireframeShape(descriptor, mutable,
simplificationLevel);
} else {
return new GLWireframeShape2D(descriptor.getGridGeometry(), mutable);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#createWireframeShape(boolean,
* org.geotools.coverage.grid.GeneralGridGeometry, float)
*/
@Override
public IWireframeShape createWireframeShape(boolean mutable,
GeneralGridGeometry geom, float simplificationLevel) {
if (simplificationLevel > 0.0) {
return new GLWireframeShape(geom, mutable, simplificationLevel);
} else {
return new GLWireframeShape2D(geom, mutable);
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -586,53 +479,6 @@ public class GLTarget implements IGLTarget {
gl.glDeleteBuffers(1, IntBuffer.wrap(new int[] { id })); gl.glDeleteBuffers(1, IntBuffer.wrap(new int[] { id }));
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#drawArc(double, double,
* double, double, org.eclipse.swt.graphics.RGB, float, int, int,
* com.raytheon.viz.core.IGraphicsTarget.LineStyle, boolean)
*/
@Override
@Deprecated
public void drawArc(double x1, double y1, double z1, double radius,
RGB color, float width, int startAzimuth, int endAzimuth,
LineStyle lineStyle, boolean includeSides) throws VizException {
DrawableCircle dc = new DrawableCircle();
dc.setCoordinates(x1, y1, z1);
dc.basics.color = color;
dc.lineStyle = lineStyle;
dc.startAzimuth = startAzimuth;
dc.endAzimuth = endAzimuth;
if (startAzimuth > endAzimuth) {
dc.numberOfPoints = (endAzimuth + 360) - startAzimuth;
} else {
dc.numberOfPoints = endAzimuth - startAzimuth;
}
dc.includeSides = includeSides;
dc.lineWidth = width;
dc.radius = radius;
drawCircle(dc);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#drawCircle(double, double,
* double, double, org.eclipse.swt.graphics.RGB, float)
*/
@Override
@Deprecated
public void drawCircle(double x1, double y1, double z1, double radius,
RGB color, float width) throws VizException {
DrawableCircle circle = new DrawableCircle();
circle.setCoordinates(x1, y1, z1);
circle.lineWidth = width;
circle.basics.color = color;
circle.radius = new Double(radius);
drawCircle(circle);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -834,60 +680,6 @@ public class GLTarget implements IGLTarget {
} }
} }
/*
* (non-Javadoc)
*
* Draw on the plane where Z is the z parameter.
*
* @see com.raytheon.viz.core.IGraphicsTarget#drawFilledCircle(double,
* double, double, double, org.eclipse.swt.graphics.RGB)
*/
@Override
@Deprecated
public void drawFilledCircle(double x, double y, double z, double radius,
RGB color) throws VizException {
DrawableCircle circle = new DrawableCircle();
circle.setCoordinates(x, y, z);
circle.basics.color = color;
circle.radius = new Double(radius);
circle.filled = true;
drawCircle(circle);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#drawLine3d(double, double,
* double, double, double, double, org.eclipse.swt.graphics.RGB, float)
*/
@Override
@Deprecated
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width) throws VizException {
drawLine(x1, y1, z1, x2, y2, z2, color, width, LineStyle.SOLID);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#drawLine3d(double, double,
* double, double, double, double, org.eclipse.swt.graphics.RGB, float,
* LineStyle)
*/
@Override
@Deprecated
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width, LineStyle lineStyle)
throws VizException {
DrawableLine line = new DrawableLine();
line.addPoint(x1, y1, z1);
line.addPoint(x2, y2, z2);
line.width = width;
line.lineStyle = lineStyle;
line.basics.color = color;
drawLine(line);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -943,67 +735,6 @@ public class GLTarget implements IGLTarget {
} }
} }
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle) throws VizException {
drawPoint(x, y, z, color, pointStyle, 1.0f);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawPoint(double, double,
* double, org.eclipse.swt.graphics.RGB,
* com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle, float)
*/
@Override
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle, float magnification) throws VizException {
drawPoints(Arrays.asList(new double[] { x, y, z }), color, pointStyle,
magnification);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawRaster(com.raytheon.viz.core
* .drawables.IImage, com.raytheon.viz.core.PixelCoverage, PaintProperties)
*/
@Override
public boolean drawRaster(final IImage image, final PixelCoverage coverage,
PaintProperties paintProps) throws VizException {
return this.drawRaster(image, coverage, paintProps,
RasterMode.SYNCHRONOUS);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.IGraphicsTarget#drawRaster(com.raytheon.core.Image,
* com.raytheon.core.rsc.Extent, float)
*/
@Override
public boolean drawRaster(final IImage image, final PixelCoverage pc,
PaintProperties paintProps, RasterMode mode) throws VizException {
DrawableImage di = new DrawableImage(image, pc);
di.setMode(mode);
return drawRasters(paintProps, di);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.ext.IImagingExtension#drawRasters(
* com.raytheon.uf.viz.core.drawables.PaintProperties,
* com.raytheon.uf.viz.core.DrawableImage[])
*/
@Override
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException {
return ImagingSupport.drawRasters(this, paintProps, images);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -1074,65 +805,6 @@ public class GLTarget implements IGLTarget {
} }
} }
/**
* Draw the outline for the coverage
*
* @param coverage
* @param color
* @param lineWidth
* @param alpha
*/
public void drawRect(PixelCoverage coverage, RGB color, float lineWidth,
double alpha) {
this.pushGLState();
try {
gl.glPolygonMode(GL.GL_FRONT, GL.GL_LINE);
gl.glColor3d(color.red / 255.0, color.green / 255.0,
color.blue / 255.0);
gl.glLineWidth(lineWidth);
gl.glBegin(GL.GL_QUADS);
Coordinate c = coverage.getUl();
gl.glVertex3d(c.x, c.y, c.z);
c = coverage.getLl();
gl.glVertex3d(c.x, c.y, c.z);
c = coverage.getLr();
gl.glVertex3d(c.x, c.y, c.z);
c = coverage.getUr();
gl.glEnd();
} finally {
this.popGLState();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawShadedShape(com.raytheon.viz
* .core.drawables.IShadedShape, float)
*/
@Override
public void drawShadedShape(IShadedShape shape, float alpha)
throws VizException {
drawShadedShape(shape, alpha, 1.0f);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawShadedShape(com.raytheon.viz
* .core.drawables.IShadedShape, float)
*/
@Override
public void drawShadedShape(IShadedShape shape, float alpha,
float brightness) throws VizException {
drawShadedShapes(alpha, brightness, shape);
}
@Override @Override
public void drawShadedShapes(float alpha, float brightness, public void drawShadedShapes(float alpha, float brightness,
IShadedShape... shapes) throws VizException { IShadedShape... shapes) throws VizException {
@ -1186,89 +858,6 @@ public class GLTarget implements IGLTarget {
} }
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawString(com.raytheon.viz.core
* .drawables.IFont, java.lang.String, double, double,
* com.raytheon.viz.core.IGraphicsTarget.TextStyle,
* org.eclipse.swt.graphics.RGB,
* com.raytheon.viz.core.IGraphicsTarget.Alignment, Double)
*/
@Override
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
HorizontalAlignment alignment, Double rotation) throws VizException {
drawString(font, string, xPos, yPos, zPos, textStyle, color, alignment,
IGraphicsTarget.VerticalAlignment.BOTTOM, rotation);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawString(com.raytheon.viz.core
* .drawables.IFont, java.lang.String, double, double,
* com.raytheon.viz.core.IGraphicsTarget.TextStyle,
* org.eclipse.swt.graphics.RGB,
* com.raytheon.viz.core.IGraphicsTarget.Alignment,
* com.raytheon.viz.core.IGraphicsTarget.VertAlignment, java.lang.Double)
*/
@Override
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation)
throws VizException {
// default the alpha to 1
drawString(font, string, xPos, yPos, zPos, textStyle, color,
horizontalAlignment, verticalAlignment, rotation, 1.0f, 1.0);
}
@Override
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation, float alpha,
double magnification) throws VizException {
DrawableString params = new DrawableString(string, color);
params.font = font;
params.setCoordinates(xPos, yPos, zPos);
params.textStyle = textStyle;
params.horizontalAlignment = horizontalAlignment;
params.verticallAlignment = verticalAlignment;
params.rotation = rotation != null ? rotation : 0.0;
params.basics.alpha = alpha;
params.magnification = magnification;
drawStrings(params);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawStrings(com.raytheon.viz.core
* .drawables.IFont, java.lang.String[], double, double, double,
* com.raytheon.viz.core.IGraphicsTarget.TextStyle,
* org.eclipse.swt.graphics.RGB[],
* com.raytheon.viz.core.IGraphicsTarget.Alignment, java.lang.Double)
*/
@Override
public void drawStrings(IFont font, String[] text, double x, double y,
double z, TextStyle textStyle, RGB[] colors,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) throws VizException {
DrawableString params = new DrawableString(text, colors);
params.font = font;
params.setCoordinates(x, y, z);
params.textStyle = textStyle;
params.horizontalAlignment = horizontalAlignment;
params.verticallAlignment = verticalAlignment;
drawStrings(params);
}
private double calculateFontResizePercentage(IFont font) { private double calculateFontResizePercentage(IFont font) {
double paneWidth = this.canvasSize.width; double paneWidth = this.canvasSize.width;
if (this.theCanvas == null) { if (this.theCanvas == null) {
@ -1300,33 +889,6 @@ public class GLTarget implements IGLTarget {
* font.getMagnification(); * font.getMagnification();
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawWireframeShape(com.raytheon
* .viz.core.drawables.IWireframeShape, org.eclipse.swt.graphics.RGB, float)
*/
@Override
public void drawWireframeShape(IWireframeShape shape, RGB aColor,
float lineWidth) throws VizException {
drawWireframeShape(shape, aColor, lineWidth, LineStyle.SOLID);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawWireframeShape(com.raytheon
* .viz.core.drawables.IWireframeShape, org.eclipse.swt.graphics.RGB, float)
*/
@Override
public void drawWireframeShape(IWireframeShape shape, RGB aColor,
float lineWidth, IGraphicsTarget.LineStyle lineStyle)
throws VizException {
drawWireframeShape(shape, aColor, lineWidth, lineStyle, 1.0f);
}
@Override @Override
public void drawWireframeShape(IWireframeShape shape, RGB aColor, public void drawWireframeShape(IWireframeShape shape, RGB aColor,
float lineWidth, IGraphicsTarget.LineStyle lineStyle, float alpha) float lineWidth, IGraphicsTarget.LineStyle lineStyle, float alpha)
@ -1335,20 +897,6 @@ public class GLTarget implements IGLTarget {
alpha); alpha);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#drawWireframeShape(com.raytheon
* .viz.core.drawables.IWireframeShape, org.eclipse.swt.graphics.RGB, float)
*/
@Override
public void drawWireframeShape(IWireframeShape shape, RGB aColor,
float lineWidth, IGraphicsTarget.LineStyle lineStyle, IFont font)
throws VizException {
drawWireframeShape(shape, aColor, lineWidth, lineStyle, font, 1.0f);
}
@Override @Override
public void drawWireframeShape(IWireframeShape shape, RGB aColor, public void drawWireframeShape(IWireframeShape shape, RGB aColor,
float lineWidth, IGraphicsTarget.LineStyle lineStyle, IFont font, float lineWidth, IGraphicsTarget.LineStyle lineStyle, IFont font,
@ -1552,25 +1100,6 @@ public class GLTarget implements IGLTarget {
return theHeight; return theHeight;
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#getPointOnCircle(double,
* double, double, double)
*/
@Override
public double[] getPointOnCircle(double x1, double y1, double z1,
double radius, double angle) throws VizException {
double pointOnCircle[] = new double[3];
pointOnCircle[0] = x1 + radius * Math.cos(Math.toRadians(angle));
pointOnCircle[1] = y1 + radius * Math.sin(Math.toRadians(angle));
// on plane z1
pointOnCircle[2] = z1;
return pointOnCircle;
}
private double getScaleX() { private double getScaleX() {
return targetView.getExtent().getWidth() / this.canvasSize.width; return targetView.getExtent().getWidth() / this.canvasSize.width;
@ -1581,40 +1110,6 @@ public class GLTarget implements IGLTarget {
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IGraphicsTarget#getStringBounds(com.raytheon.viz
* .core.drawables.IFont, java.lang.String)
*/
@Override
public Rectangle2D getStringBounds(IFont font, String string) {
if (font == null) {
font = getDefaultFont();
}
DrawableString params = new DrawableString(string, null);
params.font = font;
return getStringsBounds(params, string);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringBounds(com.raytheon
* .uf.viz.core.drawables.IFont, java.lang.String[],
* com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle)
*/
@Override
public Rectangle2D getStringBounds(IFont font, String[] text,
TextStyle textStyle) {
DrawableString params = new DrawableString(text, (RGB[]) null);
params.font = font;
params.textStyle = textStyle;
return getStringsBounds(params);
}
/** /**
* @return the Width * @return the Width
*/ */
@ -1748,55 +1243,6 @@ public class GLTarget implements IGLTarget {
return new GLImage(imageCallback, GLDefaultImagingExtension.class); return new GLImage(imageCallback, GLDefaultImagingExtension.class);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#initializeRaster(com.raytheon
* .uf.viz.core.data.interfaces.IDataRequester,
* com.raytheon.uf.viz.core.drawables.ColorMapParameters)
*/
@Override
@Deprecated
public IImage initializeRaster(IDataPreparer preparer,
ColorMapParameters optionalParams) {
IImage rval = null;
if (optionalParams == null) {
// Assume IImageDataPreparer
final IImageDataPreparer imagePreparer = (IImageDataPreparer) preparer;
rval = initializeRaster(new IRenderedImageCallback() {
@Override
public RenderedImage getImage() throws VizException {
return imagePreparer.prepareData().getImage();
}
});
} else if (preparer instanceof IColormappedDataPreparer) {
try {
IColormappedImageExtension cmapExt = getExtension(IColormappedImageExtension.class);
final IColormappedDataPreparer cmapPreparer = (IColormappedDataPreparer) preparer;
rval = cmapExt.initializeRaster(
new IColorMapDataRetrievalCallback() {
@Override
public ColorMapData getColorMapData()
throws VizException {
NumericImageData oldData = cmapPreparer
.prepareData();
return new ColorMapData(
oldData.getData(),
new int[] {
oldData.getDatasetBounds().width,
oldData.getDatasetBounds().height });
}
}, optionalParams);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error constructing creating image", e);
}
}
return rval;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -1834,16 +1280,6 @@ public class GLTarget implements IGLTarget {
return defaultFont.deriveWithSize(defaultFont.getFontSize()); return defaultFont.deriveWithSize(defaultFont.getFontSize());
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IGraphicsTarget#isNeedsRefresh()
*/
@Override
public boolean isNeedsRefresh() {
return needsRefresh;
}
protected GLTextureObject loadColormapIntoTexture(ColorMap glColorMap) { protected GLTextureObject loadColormapIntoTexture(ColorMap glColorMap) {
Buffer bb = glColorMap.getColorMap(); Buffer bb = glColorMap.getColorMap();
GLContextBridge.makeMasterContextCurrent(); GLContextBridge.makeMasterContextCurrent();
@ -1960,7 +1396,7 @@ public class GLTarget implements IGLTarget {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Background color cannot be null"); "Background color cannot be null");
} }
this.backgroundColor = backgroundColor; super.setBackgroundColor(backgroundColor);
gl.glClearColor(backgroundColor.red / 255f, gl.glClearColor(backgroundColor.red / 255f,
backgroundColor.green / 255f, backgroundColor.blue / 255f, 1.0f); backgroundColor.green / 255f, backgroundColor.blue / 255f, 1.0f);
@ -2138,12 +1574,6 @@ public class GLTarget implements IGLTarget {
return this.canvasSize; return this.canvasSize;
} }
@Override
@Deprecated
public String getViewType() {
return VizConstants.VIEW_2D;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -2217,69 +1647,6 @@ public class GLTarget implements IGLTarget {
return i; return i;
} }
@Override
public void renderOffscreen(IImage offscreenImage) throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOffscreen(
offscreenImage);
}
@Override
public void renderOnscreen() throws VizException {
getExtension(IOffscreenRenderingExtension.class).renderOnscreen();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawStrings(com.raytheon.uf.
* viz.core.DrawStringsParameters)
*/
@Override
public void drawStrings(DrawableString... parameters) throws VizException {
// TODO: Handle rotation on start of text and drawing within box and
// OUTLINE style
drawStrings(Arrays.asList(parameters));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon
* .uf.viz.core.DrawStringsParameters)
*/
@Override
public Rectangle2D getStringsBounds(DrawableString parameters) {
// TODO: Handle box already set? and OUTLINE style
String[] text = parameters.getText();
double maxWidth = 0;
double totalHeight = 0;
Rectangle2D bounds = null;
for (String string : text) {
Rectangle2D txtBounds = getStringsBounds(parameters, string);
if (txtBounds.getWidth() > maxWidth) {
maxWidth = txtBounds.getWidth();
}
totalHeight += txtBounds.getHeight();
if (bounds == null) {
bounds = txtBounds;
}
}
if (bounds != null) {
if (parameters.textStyle == TextStyle.BLANKED
|| parameters.textStyle == TextStyle.BOXED) {
maxWidth += 1.0f;
}
bounds.setRect(0, 0, maxWidth, totalHeight);
}
return bounds;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -3033,23 +2400,12 @@ public class GLTarget implements IGLTarget {
@Override @Override
public final <T extends IGraphicsExtensionInterface> T getExtension( public final <T extends IGraphicsExtensionInterface> T getExtension(
Class<T> extensionClass) throws VizException { Class<T> extensionClass) throws VizException {
Class<? extends IGraphicsExtensionInterface> toUse = extensionClass;
if (extensionClass == IImagingExtension.class) { if (extensionClass == IImagingExtension.class) {
toUse = GLDefaultImagingExtension.class; return extensionClass.cast(super
.getExtension(GLDefaultImagingExtension.class));
} else {
return super.getExtension(extensionClass);
} }
return extensionClass.cast(extensionManager.getExtension(toUse));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#setUseBuiltinColorbar(boolean)
*/
@Override
@Deprecated
public void setUseBuiltinColorbar(boolean isColorbarDisplayed) {
// No effect
} }
} }

View file

@ -21,17 +21,13 @@ package com.raytheon.viz.core.gl.internal;
import javax.media.opengl.GL; import javax.media.opengl.GL;
import javax.media.opengl.glu.GLU; import javax.media.opengl.glu.GLU;
import javax.vecmath.Vector3d;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import com.raytheon.uf.viz.core.AbstractView;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IView;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.geom.Plane;
import com.raytheon.uf.viz.core.geom.Ray;
import com.raytheon.viz.core.gl.IGLTarget; import com.raytheon.viz.core.gl.IGLTarget;
/** /**
@ -48,11 +44,7 @@ import com.raytheon.viz.core.gl.IGLTarget;
* @author estrabal * @author estrabal
* @version 1.0 * @version 1.0
*/ */
public class GLView2D implements IView { public class GLView2D extends AbstractView {
private static final Plane mapPlane = new Plane(0.0, 0.0, 1.0, 0.0, false);
private IExtent extent;
public GLView2D() { public GLView2D() {
this(0, 0, 0, 0); this(0, 0, 0, 0);
@ -65,7 +57,7 @@ public class GLView2D implements IView {
* @param maxY * @param maxY
*/ */
public GLView2D(double minX, double maxX, double minY, double maxY) { public GLView2D(double minX, double maxX, double minY, double maxY) {
this.extent = new PixelExtent(minX, maxX, minY, maxY); this(new PixelExtent(minX, maxX, minY, maxY));
} }
/** /**
@ -76,7 +68,7 @@ public class GLView2D implements IView {
} }
public GLView2D(IExtent pe) { public GLView2D(IExtent pe) {
this.extent = pe; super(pe);
} }
protected IGLTarget asIGLTarget(IGraphicsTarget target) { protected IGLTarget asIGLTarget(IGraphicsTarget target) {
@ -88,58 +80,6 @@ public class GLView2D implements IView {
} }
} }
/**
*
*/
public void scale(double factor) {
this.extent.scale(factor);
}
/**
*
* @param factor
* @param xCenter
* @param yCenter
*/
public void scaleAndBias(double factor, double screenX, double screenY,
IGraphicsTarget target) {
double[] grid = screenToGrid(screenX, screenY, 0, target);
this.extent.scaleAndBias(factor, grid[0], grid[1]);
}
public double recalcZoomLevel(int[] dimensions) {
int worldWidth = dimensions[0];
int worldHeight = dimensions[1];
return Math.min((extent.getMaxX() - extent.getMinX()) / worldWidth,
(extent.getMaxY() - extent.getMinY()) / worldHeight);
}
public boolean isVisible(double[] pixel) {
return getExtent().contains(pixel);
}
/**
* Determine if the getExtent() is in view
*
* @param pe
* @return
*/
public boolean isVisible(IExtent pe) {
return this.getExtent().intersects(pe);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
// @Override
// public Object clone() {
// return new GLView2D(this.getExtent().clone());
// }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -150,170 +90,6 @@ public class GLView2D implements IView {
return "GLView2D { " + this.getExtent().toString() + " }"; return "GLView2D { " + this.getExtent().toString() + " }";
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IView#screenToGrid(double, double, double)
*/
@Override
public double[] screenToGrid(double x, double y, double depth,
IGraphicsTarget target) {
Rectangle bounds = asIGLTarget(target).getBounds();
double correctedX = (x * (extent.getMaxX() - extent.getMinX()) / bounds.width)
+ extent.getMinX();
double correctedY = (y * (extent.getMaxY() - extent.getMinY()) / bounds.height)
+ extent.getMinY();
// z bounds are 0 to 1
double correctedZ = (depth * (extent.getMax().z - extent.getMin().z))
+ extent.getMin().z;
return new double[] { correctedX, correctedY, correctedZ };
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IView#gridToScreen(double[])
*/
@Override
public double[] gridToScreen(double[] grid, IGraphicsTarget target) {
Rectangle bounds = asIGLTarget(target).getBounds();
double x = ((grid[0] - extent.getMinX()) * bounds.width)
/ (extent.getMaxX() - extent.getMinX());
double y = ((grid[1] - extent.getMinY()) * bounds.height)
/ (extent.getMaxY() - extent.getMinY());
// z bounds are 0 to 1
double z = (grid[2] - extent.getMin().z)
/ (extent.getMax().z - extent.getMin().z);
return new double[] { x, y, z };
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.gl.internal.GLAbstractView#getMapCoords(com.raytheon
* .viz.core.Ray)
*/
@Override
public double[] getDisplayCoords(double[] screenCoordinate,
IGraphicsTarget target) {
Ray r = computeRay(screenCoordinate, target);
if (r == null) {
return null;
}
Vector3d i = mapPlane.intersection(r);
if (i == null) {
return null;
}
return new double[] { i.x, i.y, i.z };
}
/**
* Create a Ray starting a the near plane with direction towards the far
*
* @param mouse
* mouse x,y
* @return Ray
*/
public Ray computeRay(double[] mouse, IGraphicsTarget target) {
Vector3d far = new Vector3d(screenToGrid(mouse[0], mouse[1], 1, target));
Vector3d near = new Vector3d(
screenToGrid(mouse[0], mouse[1], 0, target));
if (near == null || far == null) {
return null;
}
far.sub(near);
far.normalize();
return new Ray(near, far);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IView#getExtent()
*/
@Override
public IExtent getExtent() {
return extent;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IView#setExtent(com.raytheon.viz.core.IExtent)
*/
@Override
public void setExtent(IExtent e) {
this.extent = e;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IView#createExtent(com.raytheon.viz.core.PixelCoverage
* )
*/
@Override
public IExtent createExtent(PixelCoverage pc) {
return new PixelExtent(pc.getMinX(), pc.getMaxX(), pc.getMinY(),
pc.getMaxY());
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.IView#shiftExtent(double[])
*/
@Override
public void shiftExtent(double[] startScreen, double[] endScreen,
IGraphicsTarget target) {
double[] start = screenToGrid(startScreen[0], startScreen[1], 0, target);
double[] end = screenToGrid(endScreen[0], endScreen[1], 0, target);
this.extent.shift(end[0] - start[0], end[1] - start[1]);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IView#scaleToClientArea(org.eclipse.swt.graphics
* .Rectangle, int[])
*/
@Override
public void scaleToClientArea(Rectangle clientArea, int[] dims) {
double screenRatio;
if ((clientArea.width == 0) || (clientArea.height == 0)) {
screenRatio = 1.0;
} else {
screenRatio = (double) clientArea.width
/ (double) clientArea.height;
}
int f_worldWidth = dims[0];
int f_worldHeight = dims[1];
double worldRatio = (double) f_worldWidth / (double) f_worldHeight;
// set pixel extent to show entire map
if (screenRatio > worldRatio) {
this.extent = new PixelExtent(0, f_worldHeight * screenRatio, 0,
f_worldHeight);
} else {
this.extent = new PixelExtent(0, f_worldWidth, 0, f_worldWidth
/ screenRatio);
}
this.extent.shift((f_worldWidth - extent.getWidth()) / 2,
(f_worldHeight - extent.getHeight()) / 2);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -342,26 +118,6 @@ public class GLView2D implements IView {
} }
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IView#getZoom()
*/
@Override
public double getZoom() {
return extent.getScale();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IView#zoom(double)
*/
@Override
public void zoom(double zoomLevel) {
this.extent.scale(zoomLevel);
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -382,8 +138,13 @@ public class GLView2D implements IView {
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override @Override
public Object clone() { public GLView2D clone() {
return new GLView2D((PixelExtent) this.extent.clone()); return new GLView2D((PixelExtent) this.extent.clone());
} }
@Override
public Rectangle getCanvasBounds(IGraphicsTarget target) {
return asIGLTarget(target).getBounds();
}
} }

View file

@ -61,6 +61,7 @@ import com.raytheon.uf.viz.core.cache.CacheObject.IObjectRetrieverAndDisposer;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style; import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@ -412,19 +413,15 @@ public class LightningResource extends
} }
} }
target.clearClippingPlane();
font.setMagnification(magnification); font.setMagnification(magnification);
List<DrawableString> strings = new ArrayList<DrawableString>(); List<DrawableString> strings = new ArrayList<DrawableString>();
double ratio = extent.getWidth() / paintProps.getCanvasBounds().width;
double height = target.getStringsBounds(new DrawableString("Hy", null)) double height = target.getStringsBounds(new DrawableString("Hy", null))
.getHeight(); .getHeight();
if (this.resourceData.isHandlingPositiveStrikes()) { if (this.resourceData.isHandlingPositiveStrikes()) {
DrawableString pos = new DrawableString(posCount + " + Strikes", DrawableString pos = new DrawableString(posCount + " + Strikes",
color); color);
pos.setCoordinates(extent.getMinX() + 225 * ratio, extent.getMinY() pos.setCoordinates(225, height * 2);
+ height * 2 * ratio);
pos.font = font; pos.font = font;
pos.verticallAlignment = VerticalAlignment.TOP; pos.verticallAlignment = VerticalAlignment.TOP;
pos.horizontalAlignment = HorizontalAlignment.RIGHT; pos.horizontalAlignment = HorizontalAlignment.RIGHT;
@ -434,16 +431,16 @@ public class LightningResource extends
if (this.resourceData.isHandlingNegativeStrikes()) { if (this.resourceData.isHandlingNegativeStrikes()) {
DrawableString neg = new DrawableString(negCount + " - Strikes", DrawableString neg = new DrawableString(negCount + " - Strikes",
color); color);
neg.setCoordinates(extent.getMinX() + 225 * ratio, extent.getMinY() neg.setCoordinates(225, height * 3);
+ height * 3 * ratio);
neg.font = font; neg.font = font;
neg.verticallAlignment = VerticalAlignment.TOP; neg.verticallAlignment = VerticalAlignment.TOP;
neg.horizontalAlignment = HorizontalAlignment.RIGHT; neg.horizontalAlignment = HorizontalAlignment.RIGHT;
strings.add(neg); strings.add(neg);
} }
target.drawStrings(strings); target.getExtension(ICanvasRenderingExtension.class).drawStrings(
target.setupClippingPlane(paintProps.getClippingPane()); paintProps, strings.toArray(new DrawableString[0]));
} }
/* /*

View file

@ -26,7 +26,6 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
@ -35,6 +34,7 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceGroup; import com.raytheon.uf.viz.core.rsc.IResourceGroup;
@ -212,9 +212,8 @@ public class RadarTextResource extends
} }
} }
target.clearClippingPlane(); target.getExtension(ICanvasRenderingExtension.class).drawStrings(
target.drawStrings(stringsToRender); paintProps, stringsToRender.toArray(new DrawableString[0]));
target.setupClippingPlane(paintProps.getClippingPane());
} }
/** /**
@ -235,11 +234,8 @@ public class RadarTextResource extends
PaintProperties paintProps, TextPair pair, PaintProperties paintProps, TextPair pair,
HorizontalAlignment hAlign, int yOffset, int xOffset, HorizontalAlignment hAlign, int yOffset, int xOffset,
List<DrawableString> stringsToRender) throws VizException { List<DrawableString> stringsToRender) throws VizException {
IExtent extent = paintProps.getView().getExtent();
if (pair.text != null && xOffset > 0 && yOffset > 0 if (pair.text != null && xOffset > 0 && yOffset > 0
&& pair.text.length > 0) { && pair.text.length > 0) {
double ratio = extent.getWidth()
/ paintProps.getCanvasBounds().width;
RGB[] colors = new RGB[pair.text.length]; RGB[] colors = new RGB[pair.text.length];
for (int i = 0; i < pair.text.length; ++i) { for (int i = 0; i < pair.text.length; ++i) {
colors[i] = pair.color; colors[i] = pair.color;
@ -247,8 +243,7 @@ public class RadarTextResource extends
textFont.setMagnification(pair.magnification); textFont.setMagnification(pair.magnification);
DrawableString dString = new DrawableString(pair.text, colors); DrawableString dString = new DrawableString(pair.text, colors);
dString.font = textFont; dString.font = textFont;
dString.setCoordinates(extent.getMinX() + xOffset * ratio, dString.setCoordinates(xOffset, yOffset, 0);
extent.getMinY() + yOffset * ratio, 0);
dString.textStyle = TextStyle.BLANKED; dString.textStyle = TextStyle.BLANKED;
dString.horizontalAlignment = hAlign; dString.horizontalAlignment = hAlign;
dString.verticallAlignment = VerticalAlignment.TOP; dString.verticallAlignment = VerticalAlignment.TOP;

View file

@ -81,6 +81,7 @@ import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IRenderable; import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.rsc.jts.JTSCompiler; import com.raytheon.viz.core.rsc.jts.JTSCompiler;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension; import com.raytheon.viz.pointdata.drawables.IPointImageExtension;
@ -1095,7 +1096,7 @@ public class RadarGraphicsPage implements IRenderable {
width = (maxx - minx) * magnification; width = (maxx - minx) * magnification;
} }
xOffset = (paintProps.getCanvasBounds().width - width) / 2; xOffset = (paintProps.getCanvasBounds().width - width) / 2;
List<DrawableLine> lines = new ArrayList<DrawableLine>();
for (Geometry g : this.screenGeometries) { for (Geometry g : this.screenGeometries) {
Coordinate[] coords = g.getCoordinates(); Coordinate[] coords = g.getCoordinates();
@ -1106,16 +1107,14 @@ public class RadarGraphicsPage implements IRenderable {
double x2 = coords[1].x * magnification + xOffset; double x2 = coords[1].x * magnification + xOffset;
double y2 = (coords[1].y + 0.25) * magnification * 1.3 double y2 = (coords[1].y + 0.25) * magnification * 1.3
+ yOffset; + yOffset;
double[] pts1 = paintProps.getView().getDisplayCoords(
new double[] { x1, y1 }, target);
double[] pts2 = paintProps.getView().getDisplayCoords(
new double[] { x2, y2 }, target);
DrawableLine line = new DrawableLine(); DrawableLine line = new DrawableLine();
line.addPoint(pts1[0], pts1[1]); line.addPoint(x1, y1);
line.addPoint(pts2[0], pts2[1]); line.addPoint(x2, y2);
line.basics.color = this.color; line.basics.color = this.color;
target.drawLine(line); lines.add(line);
} }
target.getExtension(ICanvasRenderingExtension.class).drawLines(
paintProps, lines.toArray(new DrawableLine[0]));
} }
// Only paint data table text if no configuration is specified or // Only paint data table text if no configuration is specified or
@ -1132,13 +1131,12 @@ public class RadarGraphicsPage implements IRenderable {
// if (x < 0.1) { // if (x < 0.1) {
// x = 0; // x = 0;
// } // }
double[] pts = paintProps.getView().getDisplayCoords(
new double[] { x, y }, target);
DrawableString string = new DrawableString(str, this.color); DrawableString string = new DrawableString(str, this.color);
string.font = this.font; string.font = this.font;
string.setCoordinates(pts[0], pts[1]); string.setCoordinates(x, y);
string.verticallAlignment = VerticalAlignment.TOP; string.verticallAlignment = VerticalAlignment.TOP;
target.drawStrings(string); target.getExtension(ICanvasRenderingExtension.class)
.drawStrings(paintProps, string);
} }
} }

View file

@ -29,12 +29,13 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.dataplugin.radar.RadarDataKey; import com.raytheon.uf.common.dataplugin.radar.RadarDataKey;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord; import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -217,9 +218,6 @@ public class RadarGraphicsResource extends AbstractRadarResource<MapDescriptor>
xPos = paintProps.getCanvasBounds().x xPos = paintProps.getCanvasBounds().x
+ paintProps.getCanvasBounds().width - xPos; + paintProps.getCanvasBounds().width - xPos;
double[] pts = paintProps.getView().getDisplayCoords(
new double[] { xPos, yPos }, target);
// Get the Lat/Lon of the screen Extent // Get the Lat/Lon of the screen Extent
Envelope screenLatLon = descriptor.pixelToWorld(paintProps Envelope screenLatLon = descriptor.pixelToWorld(paintProps
.getView().getExtent()); .getView().getExtent());
@ -241,18 +239,22 @@ public class RadarGraphicsResource extends AbstractRadarResource<MapDescriptor>
} }
} }
target.drawString(null, offScreenCount + " FEATURES OFF SCREEN", DrawableString offscreen = new DrawableString(offScreenCount
pts[0], pts[1], 0, TextStyle.NORMAL, + " FEATURES OFF SCREEN", this.getCapability(
this.getCapability(ColorableCapability.class).getColor(), ColorableCapability.class).getColor());
HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE, 0.0); offscreen.setCoordinates(xPos, yPos);
offscreen.horizontalAlignment = HorizontalAlignment.CENTER;
offscreen.verticallAlignment = VerticalAlignment.MIDDLE;
pts = paintProps.getView().getDisplayCoords( DrawableString notShown = new DrawableString(filteredCount
new double[] { xPos, yPos + 20 }, target); + " FEATURES NOT SHOWN", this.getCapability(
ColorableCapability.class).getColor());
notShown.setCoordinates(xPos, yPos + 20);
notShown.horizontalAlignment = HorizontalAlignment.CENTER;
notShown.verticallAlignment = VerticalAlignment.MIDDLE;
target.getExtension(ICanvasRenderingExtension.class).drawStrings(
paintProps, offscreen, notShown);
target.drawString(null, filteredCount + " FEATURES NOT SHOWN",
pts[0], pts[1], 0, TextStyle.NORMAL,
this.getCapability(ColorableCapability.class).getColor(),
HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE, 0.0);
} }
} }

View file

@ -57,6 +57,7 @@ import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderable; import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.ICanvasRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
@ -367,9 +368,9 @@ public class RedbookFrame implements IRenderable {
if (tb.isLegend) { if (tb.isLegend) {
// Left edge with some padding // Left edge with some padding
xOrigin = pe.getMinX() + 2 * xRatio; xOrigin = 2;
// n lines down from top edge // n lines down from top edge
yOrigin = pe.getMinY() + yCellSize * legendLine; yOrigin = yCellSize * legendLine / yRatio;
++legendLine; ++legendLine;
vAlign = IGraphicsTarget.VerticalAlignment.TOP; vAlign = IGraphicsTarget.VerticalAlignment.TOP;
@ -458,7 +459,7 @@ public class RedbookFrame implements IRenderable {
// The value of 50 is taken from AWIPS-1 // The value of 50 is taken from AWIPS-1
if ((nCharsOnLine + seg.length()) > 50) { if ((nCharsOnLine + seg.length()) > 50) {
x = xOrigin; x = xOrigin;
y += yCellSize; y += yCellSize / yRatio;
nCharsOnLine = 0; nCharsOnLine = 0;
++legendLine; ++legendLine;
} }
@ -467,7 +468,7 @@ public class RedbookFrame implements IRenderable {
x += drawString(target, seg, x, y, symbolFont, x += drawString(target, seg, x, y, symbolFont,
true, vAlign == VerticalAlignment.TOP, true, vAlign == VerticalAlignment.TOP,
xRatio, yRatio, paintProps); xRatio, yRatio, paintProps, tb.isLegend);
iStart = -1; iStart = -1;
} }
@ -526,7 +527,7 @@ public class RedbookFrame implements IRenderable {
// The value of 50 is taken from AWIPS-1 // The value of 50 is taken from AWIPS-1
if ((nCharsOnLine + seg.length()) > 50) { if ((nCharsOnLine + seg.length()) > 50) {
x = xOrigin; x = xOrigin;
y += yCellSize; y += yCellSize / yRatio;
nCharsOnLine = 0; nCharsOnLine = 0;
++legendLine; ++legendLine;
} }
@ -535,7 +536,7 @@ public class RedbookFrame implements IRenderable {
drawString(target, seg, x, y, symbolFont, true, drawString(target, seg, x, y, symbolFont, true,
vAlign == VerticalAlignment.TOP, xRatio, yRatio, vAlign == VerticalAlignment.TOP, xRatio, yRatio,
paintProps); paintProps, tb.isLegend);
} }
} }
@ -550,8 +551,8 @@ public class RedbookFrame implements IRenderable {
private double drawString(IGraphicsTarget target, String s, double x, private double drawString(IGraphicsTarget target, String s, double x,
double y, boolean symbols, boolean blanked, boolean top, double y, boolean symbols, boolean blanked, boolean top,
double xRatio, double yRatio, PaintProperties paintProps) double xRatio, double yRatio, PaintProperties paintProps,
throws VizException { boolean isLegend) throws VizException {
double magnification = redbookResource.getMagnification(); double magnification = redbookResource.getMagnification();
@ -568,7 +569,13 @@ public class RedbookFrame implements IRenderable {
if (blanked) { if (blanked) {
dstring.textStyle = TextStyle.BLANKED; dstring.textStyle = TextStyle.BLANKED;
} }
target.drawStrings(dstring); if (isLegend) {
target.getExtension(ICanvasRenderingExtension.class).drawStrings(
paintProps, dstring);
} else {
target.drawStrings(dstring);
}
return bounds.getWidth() * xRatio; return bounds.getWidth() * xRatio;
} else { } else {
double width = s.length() * 12 * xRatio * magnification; double width = s.length() * 12 * xRatio * magnification;