Issue #228 change plots, grid icons, and radar icons

to use a new PointImageExtension which provides an
interface for drawing images at a single point,
which kml can use to extract plot images.

Change-Id: I29b07ed4f9e8ea95ed131ab1eb3ca27efadaf0e2

Former-commit-id: 13a99abe7b [formerly 0f56c76ab830ef088a9576301c795dca7c855033]
Former-commit-id: d976603262
This commit is contained in:
Ben Steffensmeier 2012-01-31 11:47:21 -06:00 committed by Steve Harris
parent 6a49a1bec3
commit 792dc75f4d
13 changed files with 378 additions and 113 deletions

View file

@ -5,8 +5,8 @@ overflow="visible"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"> xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <defs>
<font id="LargeSpecialSymbols" horiz-adv-x="1536"><font-face <font id="LrgSpecialSymbols" horiz-adv-x="7"><font-face
font-family="LargeSpecialSymbolFont" font-family="LrgSpecialSymbolFont"
units-per-em="12" units-per-em="12"
alphabetic="0" /> alphabetic="0" />
<glyph unicode="199" glyph-name="199" d="M-4 6H2L-1 3L2 0L-1 -3V-2M-1 -3H0M-3 -3V6M-2 7H0L-1 9L-2 7" /> <glyph unicode="199" glyph-name="199" d="M-4 6H2L-1 3L2 0L-1 -3V-2M-1 -3H0M-3 -3V6M-2 7H0L-1 9L-2 7" />

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -8,7 +8,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" style="stroke: rgb(255, 255, 255);">
<style type="text/css"> <style type="text/css">
<![CDATA[ <![CDATA[
@font-face { font-family: "LargeSpecialSymbolFont"; @font-face { font-family: "LargeSpecialSymbolFont";
src: url(LargeSpecialSymbols.svg#LargeSpecialSymbols); } src: url(LargeSpecialSymbols.svg#LrgSpecialSymbols); }
text.special text.special
{ {

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -8,7 +8,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" style="stroke: rgb(255, 255, 255);">
<style type="text/css"> <style type="text/css">
<![CDATA[ <![CDATA[
@font-face { font-family: "LrgSpecialSymbolFont"; @font-face { font-family: "LrgSpecialSymbolFont";
src: url(LargeSpecialSymbols.svg#LargeSpecialSymbols); } src: url(LargeSpecialSymbols.svg#LrgSpecialSymbols); }
text.special text.special
{ {

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -29,8 +29,6 @@ import java.util.Map;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry; import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.prep.IODataPreparer; import com.raytheon.uf.viz.core.data.prep.IODataPreparer;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -38,6 +36,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.viz.core.contours.rsc.displays.AbstractGriddedDisplay; import com.raytheon.viz.core.contours.rsc.displays.AbstractGriddedDisplay;
import com.raytheon.viz.pointdata.PointIconFactory; import com.raytheon.viz.pointdata.PointIconFactory;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension.PointImage;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
/** /**
@ -160,17 +160,18 @@ public class GriddedIconDisplay extends AbstractGriddedDisplay<IImage> {
@Override @Override
protected void paint(PaintProperties paintProps, protected void paint(PaintProperties paintProps,
Collection<GridCellRenderable> renderables) throws VizException { Collection<GridCellRenderable> renderables) throws VizException {
List<DrawableImage> images = new ArrayList<DrawableImage>(); List<PointImage> images = new ArrayList<PointImage>();
for (GridCellRenderable renderable : renderables) { for (GridCellRenderable renderable : renderables) {
if (renderable.resource != empty) { if (renderable.resource != empty) {
images.add(new DrawableImage(renderable.resource, PointImage image = new PointImage(renderable.resource,
new PixelCoverage(renderable.plotLocation, renderable.plotLocation);
renderable.adjustedSize, image.setHeight((double) size * magnification);
renderable.adjustedSize))); image.setWidth((double) size * magnification);
images.add(image);
} }
} }
target.drawRasters(paintProps, target.getExtension(IPointImageExtension.class).drawPointImages(
images.toArray(new DrawableImage[images.size()])); paintProps, images);
} }
} }

View file

@ -22,6 +22,7 @@ Require-Bundle: org.apache.batik,
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174" com.raytheon.uf.common.pointdata;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.pointdata, Export-Package: com.raytheon.viz.pointdata,
com.raytheon.viz.pointdata.drawables,
com.raytheon.viz.pointdata.rsc, com.raytheon.viz.pointdata.rsc,
com.raytheon.viz.pointdata.rsc.retrieve, com.raytheon.viz.pointdata.rsc.retrieve,
com.raytheon.viz.pointdata.util com.raytheon.viz.pointdata.util

View file

@ -152,4 +152,10 @@
name="Plot Models" name="Plot Models"
category="com.raytheon.uf.viz.productbrowser.productbrowserpreferencespage"/> category="com.raytheon.uf.viz.productbrowser.productbrowserpreferencespage"/>
</extension> </extension>
<extension
point="com.raytheon.uf.viz.core.graphicsExtension">
<graphicsExtension
class="com.raytheon.viz.pointdata.drawables.GeneralPointImageExtension">
</graphicsExtension>
</extension>
</plugin> </plugin>

View file

@ -0,0 +1,111 @@
/**
* 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.viz.pointdata.drawables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 7, 2011 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GeneralPointImageExtension extends
GraphicsExtension<IGraphicsTarget> implements IPointImageExtension {
@Override
public void drawPointImages(PaintProperties paintProps,
PointImage... images) throws VizException {
drawPointImages(paintProps, Arrays.asList(images));
}
@Override
public int getCompatibilityValue(IGraphicsTarget target) {
return Compatibilty.GENERIC.value;
}
@Override
public void drawPointImages(PaintProperties paintProps,
Collection<PointImage> images) throws VizException {
List<DrawableImage> drawableImages = new ArrayList<DrawableImage>(
images.size());
double xScale = paintProps.getView().getExtent().getWidth()
/ paintProps.getCanvasBounds().width;
double yScale = paintProps.getView().getExtent().getHeight()
/ paintProps.getCanvasBounds().height;
for (PointImage image : images) {
Double width = image.getWidth();
Double height = image.getHeight();
if (width == null) {
width = (double) image.getImage().getWidth();
}
if (height == null) {
height = (double) image.getImage().getHeight();
}
width = width * xScale;
height = height * yScale;
Coordinate center = new Coordinate(image.getX(), image.getY());
if (image.getHorizontalAlignment().equals(HorizontalAlignment.LEFT)) {
center.x += width / 2;
} else if (image.getHorizontalAlignment().equals(
HorizontalAlignment.RIGHT)) {
center.x -= width / 2;
}
if (image.getVerticalAlignment().equals(VerticalAlignment.TOP)) {
center.y += height / 2;
} else if (image.getVerticalAlignment().equals(
VerticalAlignment.BOTTOM)) {
center.y -= height / 2;
}
PixelCoverage coverage = new PixelCoverage(center, width, height);
DrawableImage drawableImage = new DrawableImage(image.getImage(),
coverage);
drawableImages.add(drawableImage);
}
target.drawRasters(paintProps,
drawableImages.toArray(new DrawableImage[0]));
}
}

View file

@ -0,0 +1,181 @@
/**
* 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.viz.pointdata.drawables;
import java.util.Collection;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Coordinate;
/**
* An Extension for drawing images at a single point with a constant screen size
* that is independent of the zoom level.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 7, 2011 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public interface IPointImageExtension {
public static class PointImage {
// The image to draw at this point
private IImage image;
// anchor position x in target coordinates
private double x;
// anchor position y in target coordinates
private double y;
// height in screen pixels, if this is not provided the image height is
// used
private Double height = null;
// width in screen pixels, if this is not provided the image width is
// used
private Double width = null;
// The alignment relative to x,y
private HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER;
// The alignment relative to x,y
private VerticalAlignment verticalAlignment = VerticalAlignment.MIDDLE;
// optional field, used to make prettier dispalys in some targets(kml)
private String siteId = null;
public PointImage() {
}
public PointImage(IImage image, double x, double y) {
this.image = image;
this.x = x;
this.y = y;
}
public PointImage(IImage image, Coordinate c) {
this.image = image;
this.x = c.x;
this.y = c.y;
}
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
public Double getWidth() {
return width;
}
public void setWidth(Double width) {
this.width = width;
}
public HorizontalAlignment getHorizontalAlignment() {
return horizontalAlignment;
}
public void setHorizontalAlignment(
HorizontalAlignment horizontalAlignment) {
this.horizontalAlignment = horizontalAlignment;
}
public VerticalAlignment getVerticalAlignment() {
return verticalAlignment;
}
public void setVerticalAlignment(VerticalAlignment verticalAlignment) {
this.verticalAlignment = verticalAlignment;
}
public IImage getImage() {
return image;
}
public void setImage(IImage image) {
this.image = image;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public void setLocation(Coordinate c) {
this.x = c.x;
this.y = c.y;
}
public void setLocation(double x, double y) {
this.x = x;
this.y = y;
}
public String getSiteId() {
return siteId;
}
public void setSiteId(String siteId) {
this.siteId = siteId;
}
public boolean hasSiteId() {
return siteId != null;
}
}
public void drawPointImages(PaintProperties paintProps,
PointImage... images) throws VizException;
public void drawPointImages(PaintProperties paintProps,
Collection<PointImage> images) throws VizException;
}

View file

@ -46,8 +46,6 @@ import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.catalog.CatalogQuery; import com.raytheon.uf.viz.core.catalog.CatalogQuery;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -65,6 +63,8 @@ import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.viz.pointdata.PlotModelGenerator; import com.raytheon.viz.pointdata.PlotModelGenerator;
import com.raytheon.viz.pointdata.StaticPlotInfoPV; import com.raytheon.viz.pointdata.StaticPlotInfoPV;
import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry; import com.raytheon.viz.pointdata.StaticPlotInfoPV.SPIEntry;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension.PointImage;
import com.raytheon.viz.pointdata.units.PlotUnits; import com.raytheon.viz.pointdata.units.PlotUnits;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
@ -328,33 +328,14 @@ public class PlotResource extends
} }
continue; continue;
} }
this.screenToWorldRatio = paintProps.getCanvasBounds().width
/ paintProps.getView().getExtent().getWidth();
double scaleValue = (this.plotWidth / 2.0)
/ screenToWorldRatio;
double[] ul = new double[] {
stationPixelLocation[0] - scaleValue,
stationPixelLocation[1] - scaleValue, 0 };
double[] ur = new double[] { PointImage image = new PointImage(
stationPixelLocation[0] + scaleValue, generator.getStation(currentDataUri),
stationPixelLocation[1] - scaleValue, 0 }; stationPixelLocation[0], stationPixelLocation[1]);
image.setHeight(this.plotWidth);
double[] lr = new double[] { image.setWidth(this.plotWidth);
stationPixelLocation[0] + scaleValue, aTarget.getExtension(IPointImageExtension.class)
stationPixelLocation[1] + scaleValue, 0 }; .drawPointImages(paintProps, image);
double[] ll = new double[] {
stationPixelLocation[0] - scaleValue,
stationPixelLocation[1] + scaleValue, 0 };
PixelCoverage pc = new PixelCoverage(new Coordinate(ul[0],
ul[1], ul[2]), new Coordinate(ur[0], ur[1], ur[2]),
new Coordinate(lr[0], lr[1], lr[2]),
new Coordinate(ll[0], ll[1], ll[2]));
aTarget.drawRaster(generator.getStation(currentDataUri),
pc, paintProps, RasterMode.SYNCHRONOUS);
} }
if (newStations.size() > 0) { if (newStations.size() > 0) {
generator.queueStations(newStations, paintProps generator.queueStations(newStations, paintProps

View file

@ -44,9 +44,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.BinOffset; import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -65,6 +63,8 @@ import com.raytheon.viz.pointdata.IPlotModelGeneratorCaller;
import com.raytheon.viz.pointdata.PlotAlertParser; import com.raytheon.viz.pointdata.PlotAlertParser;
import com.raytheon.viz.pointdata.PlotDataThreadPool; import com.raytheon.viz.pointdata.PlotDataThreadPool;
import com.raytheon.viz.pointdata.PlotInfo; import com.raytheon.viz.pointdata.PlotInfo;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension.PointImage;
import com.raytheon.viz.pointdata.rsc.progdisc.AbstractProgDisclosure; import com.raytheon.viz.pointdata.rsc.progdisc.AbstractProgDisclosure;
import com.raytheon.viz.pointdata.rsc.progdisc.AbstractProgDisclosure.IProgDiscListener; import com.raytheon.viz.pointdata.rsc.progdisc.AbstractProgDisclosure.IProgDiscListener;
import com.raytheon.viz.pointdata.rsc.progdisc.DynamicProgDisclosure; import com.raytheon.viz.pointdata.rsc.progdisc.DynamicProgDisclosure;
@ -145,7 +145,7 @@ public class PlotResource2 extends
public static class Station { public static class Station {
public PlotInfo[] info; public PlotInfo[] info;
public DrawableImage plotImage; public PointImage plotImage;
public Object progDiscInfo; public Object progDiscInfo;
@ -216,26 +216,19 @@ public class PlotResource2 extends
return; return;
} }
double screenToWorldRatio = progressiveDisclosure List<PointImage> images = new ArrayList<PointImage>(stationList.size());
.getScreenToWorldRatio();
double scaleValue = (this.plotWidth) / screenToWorldRatio;
List<DrawableImage> images = new ArrayList<DrawableImage>(
stationList.size());
for (Station station : stationList) { for (Station station : stationList) {
if (station.plotImage == null) { if (station.plotImage == null) {
continue; continue;
} }
station.plotImage.setCoverage(new PixelCoverage(
station.pixelLocation, scaleValue, scaleValue));
// set image color so shader can draw in appropriate color // set image color so shader can draw in appropriate color
((SingleColorImage) station.plotImage.getImage()) ((SingleColorImage) station.plotImage.getImage())
.setColor(imageColor); .setColor(imageColor);
images.add(station.plotImage); images.add(station.plotImage);
} }
aTarget.drawRasters(paintProps, aTarget.getExtension(IPointImageExtension.class).drawPointImages(
images.toArray(new DrawableImage[images.size()])); paintProps, images);
} }
@Override @Override
@ -337,7 +330,7 @@ public class PlotResource2 extends
if (stationMap.containsKey(plot.stationId)) { if (stationMap.containsKey(plot.stationId)) {
Station existingStation = stationMap.get(plot.stationId); Station existingStation = stationMap.get(plot.stationId);
if (existingStation.plotImage != null) { if (existingStation.plotImage != null) {
existingStation.plotImage.dispose(); existingStation.plotImage.getImage().dispose();
existingStation.plotImage = null; existingStation.plotImage = null;
} }
boolean dup = false; boolean dup = false;
@ -624,7 +617,7 @@ public class PlotResource2 extends
FrameInformation frameInfo = entry.getValue(); FrameInformation frameInfo = entry.getValue();
for (Station station : frameInfo.stationMap.values()) { for (Station station : frameInfo.stationMap.values()) {
if (station.plotImage != null) { if (station.plotImage != null) {
station.plotImage.dispose(); station.plotImage.getImage().dispose();
station.plotImage = null; station.plotImage = null;
if (station.info != null) { if (station.info != null) {
@ -647,7 +640,8 @@ public class PlotResource2 extends
if (s != null) { if (s != null) {
if (image != null) { if (image != null) {
SingleColorImage si = new SingleColorImage(image); SingleColorImage si = new SingleColorImage(image);
s.plotImage = new DrawableImage(si, null); s.plotImage = new PointImage(si, s.pixelLocation);
s.plotImage.setSiteId(s.info[0].stationId);
si.setColor(imageColor); si.setColor(imageColor);
} else { } else {
frameInfo.stationMap.remove(key[0].stationId); frameInfo.stationMap.remove(key[0].stationId);
@ -670,7 +664,7 @@ public class PlotResource2 extends
if (frameInfo != null) { if (frameInfo != null) {
for (Station s : frameInfo.stationMap.values()) { for (Station s : frameInfo.stationMap.values()) {
if (s != null && s.plotImage != null) { if (s != null && s.plotImage != null) {
s.plotImage.dispose(); s.plotImage.getImage().dispose();
s.plotImage = null; s.plotImage = null;
} }
} }

View file

@ -847,7 +847,7 @@ public class RadarGraphicFunctions {
private static Document loadSVG(String plotModelFile) throws VizException { private static Document loadSVG(String plotModelFile) throws VizException {
Document document = null; Document document = null;
document = docMap.get(plotModelFile); // document = docMap.get(plotModelFile);
if (document == null) { if (document == null) {
String parser = XMLResourceDescriptor.getXMLParserClassName(); String parser = XMLResourceDescriptor.getXMLParserClassName();

View file

@ -72,11 +72,10 @@ import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.geospatial.ReferencedGeometry; import com.raytheon.uf.common.geospatial.ReferencedGeometry;
import com.raytheon.uf.common.geospatial.ReferencedObject.Type; import com.raytheon.uf.common.geospatial.ReferencedObject.Type;
import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle;
import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IRenderable; import com.raytheon.uf.viz.core.drawables.IRenderable;
@ -84,6 +83,8 @@ import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.rsc.jts.JTSCompiler; import com.raytheon.viz.core.rsc.jts.JTSCompiler;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension;
import com.raytheon.viz.pointdata.drawables.IPointImageExtension.PointImage;
import com.raytheon.viz.radar.RadarHelper; import com.raytheon.viz.radar.RadarHelper;
import com.raytheon.viz.radar.rsc.graphic.RadarGraphicFunctions.MesocycloneType; import com.raytheon.viz.radar.rsc.graphic.RadarGraphicFunctions.MesocycloneType;
import com.raytheon.viz.radar.rsc.graphic.RadarGraphicFunctions.PlotObject; import com.raytheon.viz.radar.rsc.graphic.RadarGraphicFunctions.PlotObject;
@ -981,23 +982,6 @@ public class RadarGraphicsPage implements IRenderable {
return images; return images;
} }
public PixelCoverage getPixelCoverage(Coordinate c) {
int scaleWidth = 3;
double[] centerpixels = this.descriptor.worldToPixel(new double[] {
c.x, c.y });
Coordinate ul = new Coordinate(centerpixels[0] - scaleWidth,
centerpixels[1] - scaleWidth);
Coordinate ur = new Coordinate(centerpixels[0] + scaleWidth,
centerpixels[1] - scaleWidth);
Coordinate lr = new Coordinate(centerpixels[0] + scaleWidth,
centerpixels[1] + scaleWidth);
Coordinate ll = new Coordinate(centerpixels[0] - scaleWidth,
centerpixels[1] + scaleWidth);
return new PixelCoverage(ul, ur, lr, ll);
}
public static Coordinate rectifyCoordinate(Coordinate c) { public static Coordinate rectifyCoordinate(Coordinate c) {
c.x += RadarGraphicsDisplay.X_OFFSET; c.x += RadarGraphicsDisplay.X_OFFSET;
c.y += RadarGraphicsDisplay.Y_OFFSET; c.y += RadarGraphicsDisplay.Y_OFFSET;
@ -1067,9 +1051,10 @@ public class RadarGraphicsPage implements IRenderable {
// Paint map-relative text // Paint map-relative text
for (Coordinate c : this.localStringMap.keySet()) { for (Coordinate c : this.localStringMap.keySet()) {
String str = this.localStringMap.get(c); String str = this.localStringMap.get(c);
DrawableString string = new DrawableString(str, this.color);
target.drawString(this.font, str, c.x, c.y, 0.0, TextStyle.NORMAL, string.font = this.font;
this.color, HorizontalAlignment.LEFT, null); string.setCoordinates(c.x, c.y);
target.drawStrings(string);
} }
// Paint screen-relative text // Paint screen-relative text
@ -1096,7 +1081,9 @@ public class RadarGraphicsPage implements IRenderable {
// the target may have messes with our magnification value, // the target may have messes with our magnification value,
// especially in smaller panes. // especially in smaller panes.
magnification = target.getStringBounds(font, "Hy").getHeight() / 14; DrawableString testString = new DrawableString("hy", this.color);
testString.font = this.font;
magnification = target.getStringsBounds(testString).getHeight() / 14;
double width = (maxx - minx) * magnification; double width = (maxx - minx) * magnification;
// If the table wider than our canvas then shrink it // If the table wider than our canvas then shrink it
if (width > paintProps.getCanvasBounds().width) { if (width > paintProps.getCanvasBounds().width) {
@ -1104,7 +1091,7 @@ public class RadarGraphicsPage implements IRenderable {
* paintProps.getCanvasBounds().width * paintProps.getCanvasBounds().width
/ (width + xOffset * 2); / (width + xOffset * 2);
font.setMagnification((float) magnification, false); font.setMagnification((float) magnification, false);
magnification = target.getStringBounds(font, "Hy").getHeight() / 14; magnification = target.getStringsBounds(testString).getHeight() / 14;
width = (maxx - minx) * magnification; width = (maxx - minx) * magnification;
} }
xOffset = (paintProps.getCanvasBounds().width - width) / 2; xOffset = (paintProps.getCanvasBounds().width - width) / 2;
@ -1123,9 +1110,11 @@ public class RadarGraphicsPage implements IRenderable {
new double[] { x1, y1 }, target); new double[] { x1, y1 }, target);
double[] pts2 = paintProps.getView().getDisplayCoords( double[] pts2 = paintProps.getView().getDisplayCoords(
new double[] { x2, y2 }, target); new double[] { x2, y2 }, target);
DrawableLine line = new DrawableLine();
target.drawLine(pts1[0], pts1[1], 0, pts2[0], pts2[1], 0, line.addPoint(pts1[0], pts1[1]);
color, 1.0f); line.addPoint(pts2[0], pts2[1]);
line.basics.color = this.color;
target.drawLine(line);
} }
} }
@ -1145,9 +1134,11 @@ public class RadarGraphicsPage implements IRenderable {
// } // }
double[] pts = paintProps.getView().getDisplayCoords( double[] pts = paintProps.getView().getDisplayCoords(
new double[] { x, y }, target); new double[] { x, y }, target);
target.drawString(this.font, str, pts[0], pts[1], 0.0, DrawableString string = new DrawableString(str, this.color);
TextStyle.NORMAL, color, HorizontalAlignment.LEFT, string.font = this.font;
VerticalAlignment.TOP, null); string.setCoordinates(pts[0], pts[1]);
string.verticallAlignment = VerticalAlignment.TOP;
target.drawStrings(string);
} }
} }
@ -1160,24 +1151,30 @@ public class RadarGraphicsPage implements IRenderable {
// paint symbols on screen // paint symbols on screen
double ratio = (paintProps.getView().getExtent().getWidth() / paintProps double ratio = (paintProps.getView().getExtent().getWidth() / paintProps
.getCanvasBounds().width); .getCanvasBounds().width);
double pixels = 90 * ratio * magnification; double pixels = 90 * magnification;
for (PlotObject po : this.plotObjects) { for (PlotObject po : this.plotObjects) {
Coordinate adjustedCoord = (Coordinate) po.coord.clone(); Coordinate adjustedCoord = (Coordinate) po.coord.clone();
adjustedCoord.x += po.pixelOffset[0] * ratio * magnification; adjustedCoord.x += po.pixelOffset[0] * ratio * magnification;
adjustedCoord.y += po.pixelOffset[1] * ratio * magnification; adjustedCoord.y += po.pixelOffset[1] * ratio * magnification;
target.drawRaster(po.image, new PixelCoverage(adjustedCoord, PointImage image = new PointImage(po.image, adjustedCoord);
pixels, pixels), paintProps); image.setHeight(pixels);
image.setWidth(pixels);
if (po.label != null) { if (po.label != null) {
image.setSiteId(po.label);
// Place the label next to the image // Place the label next to the image
adjustedCoord.x += pixels / 20; adjustedCoord.x += pixels / 20;
target.drawString(this.font, po.label, adjustedCoord.x, DrawableString string = new DrawableString(po.label, this.color);
adjustedCoord.y, 0.0, TextStyle.NORMAL, this.color, string.font = this.font;
HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, string.setCoordinates(adjustedCoord.x, adjustedCoord.y);
null); target.drawStrings(string);
} }
target.getExtension(IPointImageExtension.class).drawPointImages(
paintProps, image);
} }
} }

View file

@ -1,8 +1 @@
This is a testfile This is a testfile
Deleted two lines and added this
adding this line
One more line
Testing again
int commit test
and again
Test ticket 10955 commit