diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AbstractAdvisoryDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AbstractAdvisoryDataAdapter.java index 93aac662ba..20afc416dc 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AbstractAdvisoryDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AbstractAdvisoryDataAdapter.java @@ -53,7 +53,23 @@ public abstract class AbstractAdvisoryDataAdapter implements PluginDataObject record); public abstract float getLineWidth(); - + 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; + } + } diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AirmetDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AirmetDataAdapter.java index bc1f6010f0..ad7a0c84d7 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AirmetDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/AirmetDataAdapter.java @@ -173,4 +173,30 @@ public class AirmetDataAdapter extends AbstractAdvisoryDataAdapter { 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; + } + } diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetCastDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetCastDataAdapter.java index 29c7cd98e1..e2317e31cc 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetCastDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetCastDataAdapter.java @@ -238,4 +238,26 @@ public class ConvSigmetCastDataAdapter extends AbstractAdvisoryDataAdapter { 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; + } + } diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetOutlookDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetOutlookDataAdapter.java index c97b54203a..dd9221b0cd 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetOutlookDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/ConvSigmetOutlookDataAdapter.java @@ -37,13 +37,13 @@ import com.vividsolutions.jts.geom.Coordinate; @XmlAccessorType(XmlAccessType.NONE) public class ConvSigmetOutlookDataAdapter extends AbstractAdvisoryDataAdapter { - + private static final String LABEL_FORMAT = "%s Outlook"; private static final String CLASS_TYPE = "OUTLOOK"; private static final float LINE_WIDTH = 1.0f; - + private static final LineStyle LINE_STYLE = LineStyle.SOLID; @Override @@ -84,12 +84,12 @@ public class ConvSigmetOutlookDataAdapter extends AbstractAdvisoryDataAdapter { } Coordinate[] coords = new Coordinate[locations.size()]; for (ConvSigmetLocation loc : locations) { - coords[loc.getIndex() - 1] = new Coordinate(loc.getLongitude(), loc - .getLatitude()); + coords[loc.getIndex() - 1] = new Coordinate(loc.getLongitude(), + loc.getLatitude()); } String label = String.format(LABEL_FORMAT, section.getSequenceID()); - AdvisoryRecord aRecord = new AdvisoryRecord(coords, label, section - .getSegment()); + AdvisoryRecord aRecord = new AdvisoryRecord(coords, label, + section.getSegment()); return aRecord; } @@ -98,7 +98,7 @@ public class ConvSigmetOutlookDataAdapter extends AbstractAdvisoryDataAdapter { public float getLineWidth() { return LINE_WIDTH; } - + @Override public LineStyle getLineStyle() { return LINE_STYLE; diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/IntlSigmetDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/IntlSigmetDataAdapter.java index 3fc6abf098..ba057241b5 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/IntlSigmetDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/IntlSigmetDataAdapter.java @@ -95,13 +95,13 @@ public class IntlSigmetDataAdapter extends AbstractAdvisoryDataAdapter { if (sigmetRecord.getDistance() != -9999 && coords.length <= 2) { if (coords.length == 1) { AdvisoryRecord aRecord = new AdvisoryRecord(coords[0], - sigmetRecord.getDistance(), label, sigmetRecord - .getBullMessage()); + sigmetRecord.getDistance(), label, + sigmetRecord.getBullMessage()); result.add(aRecord); } else { AdvisoryRecord aRecord = new AdvisoryRecord(coords, - sigmetRecord.getDistance(), label, sigmetRecord - .getBullMessage()); + sigmetRecord.getDistance(), label, + sigmetRecord.getBullMessage()); result.add(aRecord); } } else { @@ -137,4 +137,30 @@ public class IntlSigmetDataAdapter extends AbstractAdvisoryDataAdapter { 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; + } + } diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/NonConvSigmetDataAdapter.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/NonConvSigmetDataAdapter.java index 724d3f19c5..37b080510a 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/NonConvSigmetDataAdapter.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/adapter/NonConvSigmetDataAdapter.java @@ -56,9 +56,9 @@ import com.vividsolutions.jts.geom.Coordinate; public class NonConvSigmetDataAdapter extends AbstractAdvisoryDataAdapter { private static final String INSPECT_FORMAT = "Valid UNTIL %02d%02d%02d\n%s"; - + private static final float LINE_WIDTH = 1.5f; - + private static final LineStyle LINE_STYLE = LineStyle.SOLID; @XmlAttribute @@ -146,4 +146,30 @@ public class NonConvSigmetDataAdapter extends AbstractAdvisoryDataAdapter { 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; + } + } diff --git a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResourceData.java b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResourceData.java index cb49282553..0bf5a4ddef 100644 --- a/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResourceData.java +++ b/cave/com.raytheon.uf.viz.aviation.advisory/src/com/raytheon/uf/viz/aviation/advisory/rsc/AdvisoryResourceData.java @@ -49,8 +49,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; * @version 1.0 */ @XmlAccessorType(XmlAccessType.NONE) -public class AdvisoryResourceData extends - AbstractRequestableResourceData { +public class AdvisoryResourceData extends AbstractRequestableResourceData { @XmlElement private AbstractAdvisoryDataAdapter dataAdapter; @@ -60,52 +59,15 @@ public class AdvisoryResourceData extends @XmlAttribute private String colorString; - + @XmlAttribute 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 protected AbstractVizResource constructResource( LoadProperties loadProperties, PluginDataObject[] objects) throws VizException { - AdvisoryResource nr = new AdvisoryResource(this, - loadProperties); + AdvisoryResource nr = new AdvisoryResource(this, loadProperties); if (colorString != null) { nr.getCapability(ColorableCapability.class).setColorAsString( colorString); @@ -116,7 +78,6 @@ public class AdvisoryResourceData extends return nr; } - public AbstractAdvisoryDataAdapter getDataAdapter() { return dataAdapter; } @@ -149,4 +110,46 @@ public class AdvisoryResourceData extends 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; + } + } diff --git a/cave/com.raytheon.uf.viz.core.rsc/src/com/raytheon/uf/viz/core/rsc/legend/AbstractLegendResource.java b/cave/com.raytheon.uf.viz.core.rsc/src/com/raytheon/uf/viz/core/rsc/legend/AbstractLegendResource.java index 8064d0143f..28c06fd0b6 100644 --- a/cave/com.raytheon.uf.viz.core.rsc/src/com/raytheon/uf/viz/core/rsc/legend/AbstractLegendResource.java +++ b/cave/com.raytheon.uf.viz.core.rsc/src/com/raytheon/uf/viz/core/rsc/legend/AbstractLegendResource.java @@ -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.PaintProperties; 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.legend.ILegendDecorator; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; @@ -101,15 +102,8 @@ public abstract class AbstractLegendResource LegendEntry[] legendData = getLegendData(descriptor); List legendStrings = new ArrayList(); - // Disable the clipping pane - target.clearClippingPlane(); - - // 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); + double yStart = paintProps.getCanvasBounds().height + - (BOTTOM_OFFSET_IN_PIXELS); for (LegendEntry le : legendData) { String allText = ""; for (LegendData ld : le.legendParts) { @@ -119,8 +113,8 @@ public abstract class AbstractLegendResource Rectangle2D allTextBounds = target .getStringBounds(le.font, allText); - double xStart = paintProps.getView().getExtent().getMaxX() - - ((RIGHT_OFFSET_IN_PIXELS + allTextBounds.getWidth()) * ratio); + double xStart = paintProps.getCanvasBounds().width + - ((RIGHT_OFFSET_IN_PIXELS + allTextBounds.getWidth())); double maxHeight = 0.0; for (LegendData ld : le.legendParts) { @@ -132,18 +126,17 @@ public abstract class AbstractLegendResource legendStrings.add(string); Rectangle2D textBounds = target.getStringsBounds(string); - xStart += (textBounds.getWidth() * ratio); + xStart += textBounds.getWidth(); if (textBounds.getHeight() > maxHeight) { maxHeight = textBounds.getHeight(); } } - yStart -= (maxHeight * ratio); + yStart -= maxHeight; } - target.drawStrings(legendStrings); - - target.setupClippingPlane(paintProps.getClippingPane()); + target.getExtension(ICanvasRenderingExtension.class).drawStrings( + paintProps, legendStrings.toArray(new DrawableString[0])); } /* diff --git a/cave/com.raytheon.uf.viz.core/plugin.xml b/cave/com.raytheon.uf.viz.core/plugin.xml index e1fa859207..69005c0917 100644 --- a/cave/com.raytheon.uf.viz.core/plugin.xml +++ b/cave/com.raytheon.uf.viz.core/plugin.xml @@ -112,5 +112,8 @@ + + diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractGraphicsTarget.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractGraphicsTarget.java new file mode 100644 index 0000000000..5169a11e1b --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractGraphicsTarget.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 25, 2012            bsteffen     Initial creation
+ * 
+ * 
+ * + * @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 locations, RGB color, + PointStyle pointStyle, float magnification) throws VizException { + List dstrings = new ArrayList(); + 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 getExtension( + Class extensionClass) throws VizException { + return extensionManager.getExtension(extensionClass); + } + +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractView.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractView.java new file mode 100644 index 0000000000..714daea14d --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/AbstractView.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 25, 2012            bsteffen     Initial creation
+ * 
+ * 
+ * + * @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(); + +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IView.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IView.java index 3ee56693fa..cb6fabbb9c 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IView.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/IView.java @@ -166,6 +166,6 @@ public interface IView { public abstract void scaleToClientArea(Rectangle clientArea, int[] dimensions); - public Object clone(); + public IView clone(); } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/GeneralCanvasRenderingExtension.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/GeneralCanvasRenderingExtension.java new file mode 100644 index 0000000000..7c88e974af --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/GeneralCanvasRenderingExtension.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 26, 2012            bsteffen     Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class GeneralCanvasRenderingExtension extends + GraphicsExtension 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 mapStrings = new ArrayList( + 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 mapLines = new ArrayList( + 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; + } + +} diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/ICanvasRenderingExtension.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/ICanvasRenderingExtension.java new file mode 100644 index 0000000000..ff2697a347 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/ICanvasRenderingExtension.java @@ -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. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jun 26, 2012            bsteffen     Initial creation
+ * 
+ * 
+ * + * @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; +} diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DColorBarResource.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DColorBarResource.java index e74af928d9..a32df2c517 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DColorBarResource.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/map/D2DColorBarResource.java @@ -29,7 +29,6 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.viz.core.DrawableColorMap; 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.TextStyle; 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.PaintProperties; 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.preferences.ColorFactory; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; @@ -169,28 +169,25 @@ public class D2DColorBarResource extends private void paintLeftColorBar(IGraphicsTarget target, PaintProperties paintProps, AbstractVizResource rsc, ColorMapParameters colorMapParameters) throws VizException { - IExtent viewExtent = paintProps.getView().getExtent(); - double ratio = (viewExtent.getWidth() / paintProps.getCanvasBounds().width); ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc .getCapability(ImagingCapability.class) : null; float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha(); float brightness = cap != null ? cap.getBrightness() : 1.0f; float contrast = cap != null ? cap.getContrast() : 1.0f; - double x1 = viewExtent.getMinX() + (3 * ratio); - double drawnWidth = ((viewExtent.getMaxX() - x1) * (((paintProps - .getCanvasBounds().width / 2.0) - 7.0) / paintProps - .getCanvasBounds().width)); + double x1 = 3; + double drawnWidth = (paintProps.getCanvasBounds().width / 2.0) - 7.0; double x2 = x1 + drawnWidth; - double y1 = viewExtent.getMinY(); + double y1 = 0; int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25; - double y2 = y1 + (pixels * ratio); + double y2 = y1 + (pixels); DrawableColorMap cmap = new DrawableColorMap(colorMapParameters); cmap.extent = new PixelExtent(x1, x2, y1, y2); cmap.alpha = alpha; cmap.brightness = brightness; cmap.contrast = contrast; - target.drawColorRamp(cmap); + target.getExtension(ICanvasRenderingExtension.class).drawColorRamp( + paintProps, cmap); if (rsc.hasCapability(BlendedCapability.class)) { alpha *= 2.0; @@ -208,29 +205,26 @@ public class D2DColorBarResource extends private void paintRightColorBar(IGraphicsTarget target, PaintProperties paintProps, AbstractVizResource rsc, ColorMapParameters colorMapParameters) throws VizException { - IExtent viewExtent = paintProps.getView().getExtent(); - double ratio = (viewExtent.getWidth() / paintProps.getCanvasBounds().width); ImagingCapability cap = rsc.hasCapability(ImagingCapability.class) ? rsc .getCapability(ImagingCapability.class) : null; float alpha = cap != null ? cap.getAlpha() : paintProps.getAlpha(); float brightness = cap != null ? cap.getBrightness() : 1.0f; float contrast = cap != null ? cap.getContrast() : 1.0f; - double x1 = viewExtent.getMinX(); - double drawnWidth = ((viewExtent.getMaxX() - x1) * (((paintProps - .getCanvasBounds().width / 2.0) - 7.0) / paintProps - .getCanvasBounds().width)); - double x2 = viewExtent.getMaxX() - (3 * ratio); + double x1 = 0; + double drawnWidth = ((paintProps.getCanvasBounds().width / 2.0) - 7.0); + double x2 = paintProps.getCanvasBounds().width - 3; x1 = x2 - drawnWidth; - double y1 = viewExtent.getMinY(); + double y1 = 0; int pixels = paintProps.getCanvasBounds().width < 500 ? 18 : 25; - double y2 = y1 + (pixels * ratio); + double y2 = y1 + pixels; DrawableColorMap cmap = new DrawableColorMap(colorMapParameters); cmap.extent = new PixelExtent(x1, x2, y1, y2); cmap.alpha = alpha; cmap.brightness = brightness; cmap.contrast = contrast; - target.drawColorRamp(cmap); + target.getExtension(ICanvasRenderingExtension.class).drawColorRamp( + paintProps, cmap); alpha *= 2.0; 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 padding = 3 * ratio; + double padding = 3; if (paintProps.getCanvasBounds().width < 500) { colorBarFont.setMagnification(0.9f); } @@ -516,13 +507,14 @@ public class D2DColorBarResource extends drawable.basics.alpha = paintProps.getAlpha(); Rectangle2D rect = target.getStringsBounds(drawable); - double widthDiv2 = (rect.getWidth() / 2) * ratio; + double widthDiv2 = (rect.getWidth() / 2); if (xPos - widthDiv2 > lastXPos) { drawables.add(drawable); lastXPos = xPos + widthDiv2 + padding; } } - target.drawStrings(drawables); + target.getExtension(ICanvasRenderingExtension.class).drawStrings( + paintProps, drawables.toArray(new DrawableString[0])); } } } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java index 22db902226..df9dc5e765 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLTarget.java @@ -22,7 +22,6 @@ package com.raytheon.viz.core.gl.internal; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.awt.image.RenderedImage; import java.io.File; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -30,7 +29,6 @@ import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; 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.Priority; 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.DrawableCircle; 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.DrawableString; import com.raytheon.uf.viz.core.IExtent; 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.VizConstants; 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; @@ -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.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.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.preferences.PreferenceConstants; 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.sun.opengl.util.Screenshot; 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 * */ -public class GLTarget implements IGLTarget { +public class GLTarget extends AbstractGraphicsTarget implements IGLTarget { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(GLTarget.class); @@ -171,9 +157,6 @@ public class GLTarget implements IGLTarget { /** Has a texure load occurred during a draw operation */ 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 */ protected int refreshCount = 0; @@ -251,17 +234,10 @@ public class GLTarget implements IGLTarget { */ protected Rectangle canvasSize; - /** - * - */ - protected RGB backgroundColor = new RGB(0, 0, 0); - protected FontFactory fontFactory; protected Rectangle monitorBounds; - private GraphicsExtensionManager extensionManager; - /** * 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) * @@ -443,32 +408,6 @@ public class GLTarget implements IGLTarget { 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) * @@ -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) * @@ -586,53 +479,6 @@ public class GLTarget implements IGLTarget { 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) * @@ -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) * @@ -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) * @@ -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 public void drawShadedShapes(float alpha, float brightness, 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) { double paneWidth = this.canvasSize.width; if (this.theCanvas == null) { @@ -1300,33 +889,6 @@ public class GLTarget implements IGLTarget { * 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 public void drawWireframeShape(IWireframeShape shape, RGB aColor, float lineWidth, IGraphicsTarget.LineStyle lineStyle, float alpha) @@ -1335,20 +897,6 @@ public class GLTarget implements IGLTarget { 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 public void drawWireframeShape(IWireframeShape shape, RGB aColor, float lineWidth, IGraphicsTarget.LineStyle lineStyle, IFont font, @@ -1552,25 +1100,6 @@ public class GLTarget implements IGLTarget { 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() { 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 */ @@ -1748,55 +1243,6 @@ public class GLTarget implements IGLTarget { 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) * @@ -1834,16 +1280,6 @@ public class GLTarget implements IGLTarget { 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) { Buffer bb = glColorMap.getColorMap(); GLContextBridge.makeMasterContextCurrent(); @@ -1960,7 +1396,7 @@ public class GLTarget implements IGLTarget { throw new IllegalArgumentException( "Background color cannot be null"); } - this.backgroundColor = backgroundColor; + super.setBackgroundColor(backgroundColor); gl.glClearColor(backgroundColor.red / 255f, backgroundColor.green / 255f, backgroundColor.blue / 255f, 1.0f); @@ -2138,12 +1574,6 @@ public class GLTarget implements IGLTarget { return this.canvasSize; } - @Override - @Deprecated - public String getViewType() { - return VizConstants.VIEW_2D; - } - /* * (non-Javadoc) * @@ -2217,69 +1647,6 @@ public class GLTarget implements IGLTarget { 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) * @@ -3033,23 +2400,12 @@ public class GLTarget implements IGLTarget { @Override public final T getExtension( Class extensionClass) throws VizException { - Class toUse = extensionClass; 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 } } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLView2D.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLView2D.java index 5f8dbeb8c5..d75a0b29b0 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLView2D.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLView2D.java @@ -21,17 +21,13 @@ package com.raytheon.viz.core.gl.internal; import javax.media.opengl.GL; import javax.media.opengl.glu.GLU; -import javax.vecmath.Vector3d; 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.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.geom.Plane; -import com.raytheon.uf.viz.core.geom.Ray; import com.raytheon.viz.core.gl.IGLTarget; /** @@ -48,11 +44,7 @@ import com.raytheon.viz.core.gl.IGLTarget; * @author estrabal * @version 1.0 */ -public class GLView2D implements IView { - - private static final Plane mapPlane = new Plane(0.0, 0.0, 1.0, 0.0, false); - - private IExtent extent; +public class GLView2D extends AbstractView { public GLView2D() { this(0, 0, 0, 0); @@ -65,7 +57,7 @@ public class GLView2D implements IView { * @param 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) { - this.extent = pe; + super(pe); } 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) * @@ -150,170 +90,6 @@ public class GLView2D implements IView { 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) * @@ -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) * @@ -382,8 +138,13 @@ public class GLView2D implements IView { * @see java.lang.Object#clone() */ @Override - public Object clone() { + public GLView2D clone() { return new GLView2D((PixelExtent) this.extent.clone()); } + @Override + public Rectangle getCanvasBounds(IGraphicsTarget target) { + return asIGLTarget(target).getBounds(); + } + } diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java index 1c85f68d0d..23ee4b4a41 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java @@ -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.Style; 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.map.IMapDescriptor; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; @@ -412,19 +413,15 @@ public class LightningResource extends } } - target.clearClippingPlane(); - font.setMagnification(magnification); List strings = new ArrayList(); - double ratio = extent.getWidth() / paintProps.getCanvasBounds().width; double height = target.getStringsBounds(new DrawableString("Hy", null)) .getHeight(); if (this.resourceData.isHandlingPositiveStrikes()) { DrawableString pos = new DrawableString(posCount + " + Strikes", color); - pos.setCoordinates(extent.getMinX() + 225 * ratio, extent.getMinY() - + height * 2 * ratio); + pos.setCoordinates(225, height * 2); pos.font = font; pos.verticallAlignment = VerticalAlignment.TOP; pos.horizontalAlignment = HorizontalAlignment.RIGHT; @@ -434,16 +431,16 @@ public class LightningResource extends if (this.resourceData.isHandlingNegativeStrikes()) { DrawableString neg = new DrawableString(negCount + " - Strikes", color); - neg.setCoordinates(extent.getMinX() + 225 * ratio, extent.getMinY() - + height * 3 * ratio); + neg.setCoordinates(225, height * 3); neg.font = font; neg.verticallAlignment = VerticalAlignment.TOP; neg.horizontalAlignment = HorizontalAlignment.RIGHT; strings.add(neg); } - target.drawStrings(strings); - target.setupClippingPlane(paintProps.getClippingPane()); + target.getExtension(ICanvasRenderingExtension.class).drawStrings( + paintProps, strings.toArray(new DrawableString[0])); + } /* diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/RadarTextResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/RadarTextResource.java index cee233ac4a..4d6abcbefd 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/RadarTextResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/RadarTextResource.java @@ -26,7 +26,6 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.time.DataTime; 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.HorizontalAlignment; 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.PaintProperties; 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.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.IResourceGroup; @@ -212,9 +212,8 @@ public class RadarTextResource extends } } - target.clearClippingPlane(); - target.drawStrings(stringsToRender); - target.setupClippingPlane(paintProps.getClippingPane()); + target.getExtension(ICanvasRenderingExtension.class).drawStrings( + paintProps, stringsToRender.toArray(new DrawableString[0])); } /** @@ -235,11 +234,8 @@ public class RadarTextResource extends PaintProperties paintProps, TextPair pair, HorizontalAlignment hAlign, int yOffset, int xOffset, List stringsToRender) throws VizException { - IExtent extent = paintProps.getView().getExtent(); if (pair.text != null && xOffset > 0 && yOffset > 0 && pair.text.length > 0) { - double ratio = extent.getWidth() - / paintProps.getCanvasBounds().width; RGB[] colors = new RGB[pair.text.length]; for (int i = 0; i < pair.text.length; ++i) { colors[i] = pair.color; @@ -247,8 +243,7 @@ public class RadarTextResource extends textFont.setMagnification(pair.magnification); DrawableString dString = new DrawableString(pair.text, colors); dString.font = textFont; - dString.setCoordinates(extent.getMinX() + xOffset * ratio, - extent.getMinY() + yOffset * ratio, 0); + dString.setCoordinates(xOffset, yOffset, 0); dString.textStyle = TextStyle.BLANKED; dString.horizontalAlignment = hAlign; dString.verticallAlignment = VerticalAlignment.TOP; diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java index 34511c7b0f..8ea8b1a2c3 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsPage.java @@ -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.IWireframeShape; 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.viz.core.rsc.jts.JTSCompiler; import com.raytheon.viz.pointdata.drawables.IPointImageExtension; @@ -1095,7 +1096,7 @@ public class RadarGraphicsPage implements IRenderable { width = (maxx - minx) * magnification; } xOffset = (paintProps.getCanvasBounds().width - width) / 2; - + List lines = new ArrayList(); for (Geometry g : this.screenGeometries) { Coordinate[] coords = g.getCoordinates(); @@ -1106,16 +1107,14 @@ public class RadarGraphicsPage implements IRenderable { double x2 = coords[1].x * magnification + xOffset; double y2 = (coords[1].y + 0.25) * magnification * 1.3 + 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(); - line.addPoint(pts1[0], pts1[1]); - line.addPoint(pts2[0], pts2[1]); + line.addPoint(x1, y1); + line.addPoint(x2, y2); 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 @@ -1132,13 +1131,12 @@ public class RadarGraphicsPage implements IRenderable { // if (x < 0.1) { // x = 0; // } - double[] pts = paintProps.getView().getDisplayCoords( - new double[] { x, y }, target); DrawableString string = new DrawableString(str, this.color); string.font = this.font; - string.setCoordinates(pts[0], pts[1]); + string.setCoordinates(x, y); string.verticallAlignment = VerticalAlignment.TOP; - target.drawStrings(string); + target.getExtension(ICanvasRenderingExtension.class) + .drawStrings(paintProps, string); } } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsResource.java index 7d800d2228..02bbce856f 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/graphic/RadarGraphicsResource.java @@ -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.RadarRecord; 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.HorizontalAlignment; -import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.VizApp; 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.map.MapDescriptor; import com.raytheon.uf.viz.core.rsc.LoadProperties; @@ -217,9 +218,6 @@ public class RadarGraphicsResource extends AbstractRadarResource xPos = paintProps.getCanvasBounds().x + paintProps.getCanvasBounds().width - xPos; - double[] pts = paintProps.getView().getDisplayCoords( - new double[] { xPos, yPos }, target); - // Get the Lat/Lon of the screen Extent Envelope screenLatLon = descriptor.pixelToWorld(paintProps .getView().getExtent()); @@ -241,18 +239,22 @@ public class RadarGraphicsResource extends AbstractRadarResource } } - target.drawString(null, offScreenCount + " FEATURES OFF SCREEN", - pts[0], pts[1], 0, TextStyle.NORMAL, - this.getCapability(ColorableCapability.class).getColor(), - HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE, 0.0); + DrawableString offscreen = new DrawableString(offScreenCount + + " FEATURES OFF SCREEN", this.getCapability( + ColorableCapability.class).getColor()); + offscreen.setCoordinates(xPos, yPos); + offscreen.horizontalAlignment = HorizontalAlignment.CENTER; + offscreen.verticallAlignment = VerticalAlignment.MIDDLE; - pts = paintProps.getView().getDisplayCoords( - new double[] { xPos, yPos + 20 }, target); + DrawableString notShown = new DrawableString(filteredCount + + " 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); } } diff --git a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookFrame.java b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookFrame.java index 2ecb564c3e..f321244b2a 100644 --- a/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookFrame.java +++ b/cave/com.raytheon.viz.redbook/src/com/raytheon/viz/redbook/rsc/RedbookFrame.java @@ -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.IWireframeShape; 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.map.IMapDescriptor; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; @@ -367,9 +368,9 @@ public class RedbookFrame implements IRenderable { if (tb.isLegend) { // Left edge with some padding - xOrigin = pe.getMinX() + 2 * xRatio; + xOrigin = 2; // n lines down from top edge - yOrigin = pe.getMinY() + yCellSize * legendLine; + yOrigin = yCellSize * legendLine / yRatio; ++legendLine; vAlign = IGraphicsTarget.VerticalAlignment.TOP; @@ -458,7 +459,7 @@ public class RedbookFrame implements IRenderable { // The value of 50 is taken from AWIPS-1 if ((nCharsOnLine + seg.length()) > 50) { x = xOrigin; - y += yCellSize; + y += yCellSize / yRatio; nCharsOnLine = 0; ++legendLine; } @@ -467,7 +468,7 @@ public class RedbookFrame implements IRenderable { x += drawString(target, seg, x, y, symbolFont, true, vAlign == VerticalAlignment.TOP, - xRatio, yRatio, paintProps); + xRatio, yRatio, paintProps, tb.isLegend); iStart = -1; } @@ -526,7 +527,7 @@ public class RedbookFrame implements IRenderable { // The value of 50 is taken from AWIPS-1 if ((nCharsOnLine + seg.length()) > 50) { x = xOrigin; - y += yCellSize; + y += yCellSize / yRatio; nCharsOnLine = 0; ++legendLine; } @@ -535,7 +536,7 @@ public class RedbookFrame implements IRenderable { drawString(target, seg, x, y, symbolFont, true, 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, double y, boolean symbols, boolean blanked, boolean top, - double xRatio, double yRatio, PaintProperties paintProps) - throws VizException { + double xRatio, double yRatio, PaintProperties paintProps, + boolean isLegend) throws VizException { double magnification = redbookResource.getMagnification(); @@ -568,7 +569,13 @@ public class RedbookFrame implements IRenderable { if (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; } else { double width = s.length() * 12 * xRatio * magnification;