Issue #239 Added creating of fonts and use in wireframe shapes
Former-commit-id:ea082a4c2b
[formerlyd0bdc5d6f0
] [formerlyf2fe88790d
] [formerlyea082a4c2b
[formerlyd0bdc5d6f0
] [formerlyf2fe88790d
] [formerly99209a054f
[formerlyf2fe88790d
[formerly ab047d007f8835554d2ec08e2e11594f7d88a6cb]]]] Former-commit-id:99209a054f
Former-commit-id:9e6267a7d4
[formerly43a4688404
] [formerly 9f0875b8b1183882c7391b33681c8df047a269e8 [formerly41d3652701
]] Former-commit-id: 97b1c6ed66142ec71235b896fbdc43f75d50d479 [formerlyaa07614542
] Former-commit-id:13d609af5e
This commit is contained in:
parent
48b3aa1ef6
commit
d093e7390e
7 changed files with 649 additions and 8 deletions
|
@ -22,6 +22,7 @@ package com.raytheon.uf.viz.collaboration.ui.rsc;
|
|||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationRenderingHandler.ColorMapDataCallback;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
|
||||
|
@ -63,4 +64,9 @@ public class CollaborationDisposingHandler {
|
|||
public void disposeWireframeShape(IWireframeShape shape) {
|
||||
shape.dispose();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void disposeFont(IFont font) {
|
||||
font.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.rsc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.Buffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,6 +29,7 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
|
@ -48,6 +51,8 @@ import com.raytheon.uf.viz.remote.graphics.events.DisposeObjectEvent;
|
|||
import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.CreateColormappedImageEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.fonts.CreateFontEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.fonts.UpdateFontDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImageEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImagesEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.imagery.UpdateImageDataEvent;
|
||||
|
@ -462,4 +467,54 @@ public class CollaborationRenderingHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Font events ==================
|
||||
|
||||
@Subscribe
|
||||
public void createFont(CreateFontEvent event) throws VizException {
|
||||
int fontId = event.getObjectId();
|
||||
IFont font = null;
|
||||
if (event.getFontData() != null) {
|
||||
try {
|
||||
File fontFile = File.createTempFile(event.getFontName(), null);
|
||||
FileUtil.bytes2File(event.getFontData(), fontFile);
|
||||
font = target.initializeFont(fontFile, event.getFontSize(),
|
||||
event.getFontStyle());
|
||||
} catch (IOException e) {
|
||||
throw new VizException("Unable to write font file: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
} else {
|
||||
font = target.initializeFont(event.getFontName(),
|
||||
event.getFontSize(), event.getFontStyle());
|
||||
}
|
||||
font.setMagnification(event.getMagnification());
|
||||
font.setSmoothing(event.isSmoothing());
|
||||
font.setScaleFont(event.isScaleFont());
|
||||
putRenderableObject(fontId, font);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void updateFont(UpdateFontDataEvent event) {
|
||||
IFont font = getRenderableObject(event.getObjectId(), IFont.class);
|
||||
if (font != null) {
|
||||
if (event.getMagnification() != null) {
|
||||
if (event.getScaleFont() != null) {
|
||||
font.setMagnification(event.getMagnification(),
|
||||
event.getScaleFont());
|
||||
} else {
|
||||
font.setMagnification(event.getMagnification());
|
||||
}
|
||||
} else {
|
||||
if (event.getScaleFont() != null) {
|
||||
font.setScaleFont(event.getScaleFont());
|
||||
} else if (event.getSmoothing() != null) {
|
||||
font.setSmoothing(event.getSmoothing());
|
||||
}
|
||||
}
|
||||
font.setMagnification(event.getMagnification());
|
||||
font.setSmoothing(event.getSmoothing());
|
||||
font.setScaleFont(event.getScaleFont());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,14 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.geotools;bundle-version="2.6.4",
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
|
||||
com.raytheon.viz.ui;bundle-version="1.12.1174",
|
||||
javax.vecmath;bundle-version="1.3.1"
|
||||
javax.vecmath;bundle-version="1.3.1",
|
||||
com.raytheon.uf.common.util;bundle-version="1.12.1174"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.viz.remote.graphics,
|
||||
com.raytheon.uf.viz.remote.graphics.events,
|
||||
com.raytheon.uf.viz.remote.graphics.events.colormap,
|
||||
com.raytheon.uf.viz.remote.graphics.events.fonts,
|
||||
com.raytheon.uf.viz.remote.graphics.events.imagery,
|
||||
com.raytheon.uf.viz.remote.graphics.events.mesh,
|
||||
com.raytheon.uf.viz.remote.graphics.events.offscreen,
|
||||
|
|
|
@ -23,7 +23,9 @@ import java.awt.geom.Rectangle2D;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
@ -68,6 +70,7 @@ import com.raytheon.uf.viz.remote.graphics.events.EndFrameEvent;
|
|||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.CreateWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.RenderWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingFont;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingImage;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingImage.DispatchingRenderedImageCallback;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingWireframeShape;
|
||||
|
@ -97,6 +100,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DispatchGraphicsTarget.class);
|
||||
|
||||
private IFont defaultFont;
|
||||
|
||||
private GraphicsExtensionManager extensionManager;
|
||||
|
||||
public DispatchGraphicsTarget(IGraphicsTarget target, Dispatcher dispatcher) {
|
||||
|
@ -176,7 +181,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#initializeFont(java.lang.String)
|
||||
*/
|
||||
public IFont initializeFont(String font) {
|
||||
return wrappedObject.initializeFont(font);
|
||||
return new DispatchingFont(wrappedObject.initializeFont(font),
|
||||
getDispatcher());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +194,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* float, com.raytheon.uf.viz.core.drawables.IFont.Style[])
|
||||
*/
|
||||
public IFont initializeFont(String fontName, float size, Style[] styles) {
|
||||
return wrappedObject.initializeFont(fontName, size, styles);
|
||||
return new DispatchingFont(wrappedObject.initializeFont(fontName, size,
|
||||
styles), getDispatcher());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,7 +207,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* float, com.raytheon.uf.viz.core.drawables.IFont.Style[])
|
||||
*/
|
||||
public IFont initializeFont(File fontFile, float size, Style[] styles) {
|
||||
return wrappedObject.initializeFont(fontFile, size, styles);
|
||||
return new DispatchingFont(wrappedObject.initializeFont(fontFile, size,
|
||||
styles), getDispatcher(), fontFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +265,19 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawStrings(com.raytheon.uf.viz.core.DrawableString[])
|
||||
*/
|
||||
public void drawStrings(DrawableString... parameters) throws VizException {
|
||||
IFont[] originalFonts = new IFont[parameters.length];
|
||||
for (int i = 0; i < parameters.length; ++i) {
|
||||
DrawableString string = parameters[i];
|
||||
originalFonts[i] = string.font;
|
||||
if (string.font instanceof DispatchingFont) {
|
||||
string.font = ((DispatchingFont) string.font)
|
||||
.getWrappedObject();
|
||||
}
|
||||
}
|
||||
wrappedObject.drawStrings(parameters);
|
||||
for (int i = 0; i < parameters.length; ++i) {
|
||||
parameters[i].font = originalFonts[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,7 +287,19 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
*/
|
||||
public void drawStrings(Collection<DrawableString> parameters)
|
||||
throws VizException {
|
||||
List<IFont> originalFonts = new ArrayList<IFont>(parameters.size());
|
||||
for (DrawableString string : parameters) {
|
||||
originalFonts.add(string.font);
|
||||
if (string.font instanceof DispatchingFont) {
|
||||
string.font = ((DispatchingFont) string.font)
|
||||
.getWrappedObject();
|
||||
}
|
||||
}
|
||||
wrappedObject.drawStrings(parameters);
|
||||
int i = 0;
|
||||
for (DrawableString string : parameters) {
|
||||
string.font = originalFonts.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,7 +308,13 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon.uf.viz.core.DrawableString)
|
||||
*/
|
||||
public Rectangle2D getStringsBounds(DrawableString parameters) {
|
||||
return wrappedObject.getStringsBounds(parameters);
|
||||
IFont font = parameters.font;
|
||||
if (font instanceof DispatchingFont) {
|
||||
parameters.font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
Rectangle2D rval = wrappedObject.getStringsBounds(parameters);
|
||||
parameters.font = font;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,7 +325,13 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* java.lang.String)
|
||||
*/
|
||||
public Rectangle2D getStringsBounds(DrawableString parameters, String string) {
|
||||
return wrappedObject.getStringsBounds(parameters, string);
|
||||
IFont font = parameters.font;
|
||||
if (font instanceof DispatchingFont) {
|
||||
parameters.font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
Rectangle2D rval = wrappedObject.getStringsBounds(parameters, string);
|
||||
parameters.font = font;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,7 +447,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
DispatchingWireframeShape wrapper = (DispatchingWireframeShape) shape;
|
||||
shape = wrapper.getWrappedObject();
|
||||
wrappedObject.drawWireframeShape(shape, color, lineWidth, lineStyle,
|
||||
font);
|
||||
((DispatchingFont) font).getWrappedObject());
|
||||
sendDrawWireframeShapeEvent(wrapper, color, lineWidth, lineStyle, font,
|
||||
null);
|
||||
}
|
||||
|
@ -426,6 +470,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
throws VizException {
|
||||
DispatchingWireframeShape wrapper = (DispatchingWireframeShape) shape;
|
||||
shape = wrapper.getWrappedObject();
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
wrappedObject.drawWireframeShape(shape, color, lineWidth, lineStyle,
|
||||
font, alpha);
|
||||
sendDrawWireframeShapeEvent(wrapper, color, lineWidth, lineStyle, font,
|
||||
|
@ -441,6 +488,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
event.setLineWidth(lineWidth);
|
||||
event.setLineStyle(lineStyle);
|
||||
event.setAlpha(alpha);
|
||||
if (font instanceof DispatchingFont) {
|
||||
event.setFontId(((DispatchingFont) font).getObjectId());
|
||||
}
|
||||
dispatch(event);
|
||||
}
|
||||
|
||||
|
@ -716,6 +766,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
*/
|
||||
public void init() {
|
||||
wrappedObject.init();
|
||||
defaultFont = new DispatchingFont(wrappedObject.getDefaultFont(),
|
||||
getDispatcher());
|
||||
}
|
||||
|
||||
private IExtent previousExtent;
|
||||
|
@ -837,7 +889,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* @see com.raytheon.uf.viz.core.IGraphicsTarget#getDefaultFont()
|
||||
*/
|
||||
public IFont getDefaultFont() {
|
||||
return wrappedObject.getDefaultFont();
|
||||
return defaultFont;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -982,6 +1034,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment, Double rotation)
|
||||
throws VizException {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
wrappedObject.drawString(font, text, x, y, z, textStyle, color,
|
||||
horizontalAlignment, verticalAlignment, rotation);
|
||||
}
|
||||
|
@ -1009,6 +1064,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
double z, TextStyle textStyle, RGB color,
|
||||
HorizontalAlignment horizontalAlignment, Double rotation)
|
||||
throws VizException {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
wrappedObject.drawString(font, text, x, y, z, textStyle, color,
|
||||
horizontalAlignment, rotation);
|
||||
}
|
||||
|
@ -1036,6 +1094,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
double z, TextStyle textStyle, RGB[] colors,
|
||||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment) throws VizException {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
wrappedObject.drawStrings(font, text, x, y, z, textStyle, colors,
|
||||
horizontalAlignment, verticalAlignment);
|
||||
}
|
||||
|
@ -1068,6 +1129,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment, Double rotation, float alpha,
|
||||
double magnification) throws VizException {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
wrappedObject.drawString(font, string, xPos, yPos, zPos, textStyle,
|
||||
color, horizontalAlignment, verticalAlignment, rotation, alpha,
|
||||
magnification);
|
||||
|
@ -1082,6 +1146,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
* java.lang.String)
|
||||
*/
|
||||
public Rectangle2D getStringBounds(IFont font, String text) {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
return wrappedObject.getStringBounds(font, text);
|
||||
}
|
||||
|
||||
|
@ -1097,6 +1164,9 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
*/
|
||||
public Rectangle2D getStringBounds(IFont font, String[] text,
|
||||
TextStyle style) {
|
||||
if (font instanceof DispatchingFont) {
|
||||
font = ((DispatchingFont) font).getWrappedObject();
|
||||
}
|
||||
return wrappedObject.getStringBounds(font, text, style);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
* 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.remote.graphics.events.fonts;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont.Style;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
|
||||
/**
|
||||
* Event for creating a font object
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 12, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class CreateFontEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private byte[] fontData;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String fontName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Style[] fontStyle;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float fontSize;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float magnification;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private boolean smoothing;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private boolean scaleFont;
|
||||
|
||||
/**
|
||||
* @return the fontData
|
||||
*/
|
||||
public byte[] getFontData() {
|
||||
return fontData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fontData
|
||||
* the fontData to set
|
||||
*/
|
||||
public void setFontData(byte[] fontData) {
|
||||
this.fontData = fontData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fontName
|
||||
*/
|
||||
public String getFontName() {
|
||||
return fontName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fontName
|
||||
* the fontName to set
|
||||
*/
|
||||
public void setFontName(String fontName) {
|
||||
this.fontName = fontName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fontStyle
|
||||
*/
|
||||
public Style[] getFontStyle() {
|
||||
return fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fontStyle
|
||||
* the fontStyle to set
|
||||
*/
|
||||
public void setFontStyle(Style[] fontStyle) {
|
||||
this.fontStyle = fontStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fontSize
|
||||
*/
|
||||
public float getFontSize() {
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fontSize
|
||||
* the fontSize to set
|
||||
*/
|
||||
public void setFontSize(float fontSize) {
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the magnification
|
||||
*/
|
||||
public float getMagnification() {
|
||||
return magnification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magnification
|
||||
* the magnification to set
|
||||
*/
|
||||
public void setMagnification(float magnification) {
|
||||
this.magnification = magnification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the smoothing
|
||||
*/
|
||||
public boolean isSmoothing() {
|
||||
return smoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param smoothing
|
||||
* the smoothing to set
|
||||
*/
|
||||
public void setSmoothing(boolean smoothing) {
|
||||
this.smoothing = smoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scaleFont
|
||||
*/
|
||||
public boolean isScaleFont() {
|
||||
return scaleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scaleFont
|
||||
* the scaleFont to set
|
||||
*/
|
||||
public void setScaleFont(boolean scaleFont) {
|
||||
this.scaleFont = scaleFont;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* 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.remote.graphics.events.fonts;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
|
||||
/**
|
||||
* Event for updating a font object's magnification, smoothing, or scaling
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 12, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class UpdateFontDataEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Float magnification;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Boolean smoothing;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Boolean scaleFont;
|
||||
|
||||
/**
|
||||
* @return the magnification
|
||||
*/
|
||||
public Float getMagnification() {
|
||||
return magnification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magnification
|
||||
* the magnification to set
|
||||
*/
|
||||
public void setMagnification(Float magnification) {
|
||||
this.magnification = magnification;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the smoothing
|
||||
*/
|
||||
public Boolean getSmoothing() {
|
||||
return smoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param smoothing
|
||||
* the smoothing to set
|
||||
*/
|
||||
public void setSmoothing(Boolean smoothing) {
|
||||
this.smoothing = smoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scaleFont
|
||||
*/
|
||||
public Boolean getScaleFont() {
|
||||
return scaleFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scaleFont
|
||||
* the scaleFont to set
|
||||
*/
|
||||
public void setScaleFont(Boolean scaleFont) {
|
||||
this.scaleFont = scaleFont;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
/**
|
||||
* 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.remote.graphics.objects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.remote.graphics.Activator;
|
||||
import com.raytheon.uf.viz.remote.graphics.Dispatcher;
|
||||
import com.raytheon.uf.viz.remote.graphics.DispatchingObject;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.DisposeObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.fonts.CreateFontEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.fonts.UpdateFontDataEvent;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 12, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DispatchingFont extends DispatchingObject<IFont> implements IFont {
|
||||
|
||||
private float lastMagnification;
|
||||
|
||||
private boolean lastSmoothing;
|
||||
|
||||
private boolean lastScaleFont;
|
||||
|
||||
/**
|
||||
* @param wrappedObject
|
||||
* @param dispatcher
|
||||
*/
|
||||
public DispatchingFont(IFont wrappedObject, Dispatcher dispatcher) {
|
||||
super(wrappedObject, dispatcher);
|
||||
this.lastMagnification = wrappedObject.getMagnification();
|
||||
this.lastSmoothing = wrappedObject.getSmoothing();
|
||||
this.lastScaleFont = wrappedObject.isScaleFont();
|
||||
sendCreateFontEvent(getFontName(), getFontSize(), getStyle(),
|
||||
getMagnification(), getSmoothing(), isScaleFont(), null);
|
||||
}
|
||||
|
||||
public DispatchingFont(IFont wrappedObject, Dispatcher dispatcher,
|
||||
File fontFile) {
|
||||
super(wrappedObject, dispatcher);
|
||||
this.lastMagnification = wrappedObject.getMagnification();
|
||||
this.lastSmoothing = wrappedObject.getSmoothing();
|
||||
this.lastScaleFont = wrappedObject.isScaleFont();
|
||||
sendCreateFontEvent(getFontName(), getFontSize(), getStyle(),
|
||||
getMagnification(), getSmoothing(), isScaleFont(), fontFile);
|
||||
}
|
||||
|
||||
private void sendCreateFontEvent(String fontName, float fontSize,
|
||||
Style[] fontStyle, float magnification, boolean smooth,
|
||||
boolean scaleFont, File fontData) {
|
||||
CreateFontEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
CreateFontEvent.class, this);
|
||||
event.setFontName(fontName);
|
||||
event.setFontSize(fontSize);
|
||||
event.setFontStyle(fontStyle);
|
||||
event.setMagnification(magnification);
|
||||
event.setSmoothing(smooth);
|
||||
event.setScaleFont(scaleFont);
|
||||
if (fontData != null && fontData.exists() && fontData.canRead()) {
|
||||
try {
|
||||
event.setFontData(FileUtil.file2bytes(fontData));
|
||||
} catch (IOException e) {
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
dispatch(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#getFontName()
|
||||
*/
|
||||
public String getFontName() {
|
||||
return wrappedObject.getFontName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#getFontSize()
|
||||
*/
|
||||
public float getFontSize() {
|
||||
return wrappedObject.getFontSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#getStyle()
|
||||
*/
|
||||
public Style[] getStyle() {
|
||||
return wrappedObject.getStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
wrappedObject.dispose();
|
||||
dispatch(RemoteGraphicsEventFactory.createEvent(
|
||||
DisposeObjectEvent.class, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#deriveWithSize(float)
|
||||
*/
|
||||
public IFont deriveWithSize(float size) {
|
||||
return new DispatchingFont(wrappedObject.deriveWithSize(size),
|
||||
getDispatcher());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magnification
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#setMagnification(float)
|
||||
*/
|
||||
public void setMagnification(float magnification) {
|
||||
wrappedObject.setMagnification(magnification);
|
||||
if (lastMagnification != magnification) {
|
||||
lastMagnification = magnification;
|
||||
UpdateFontDataEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
UpdateFontDataEvent.class, this);
|
||||
event.setMagnification(magnification);
|
||||
dispatch(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magnification
|
||||
* @param scaleFont
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#setMagnification(float,
|
||||
* boolean)
|
||||
*/
|
||||
public void setMagnification(float magnification, boolean scaleFont) {
|
||||
wrappedObject.setMagnification(magnification, scaleFont);
|
||||
if (lastMagnification != magnification) {
|
||||
lastMagnification = magnification;
|
||||
UpdateFontDataEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
UpdateFontDataEvent.class, this);
|
||||
event.setScaleFont(scaleFont);
|
||||
event.setMagnification(magnification);
|
||||
dispatch(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#getMagnification()
|
||||
*/
|
||||
public float getMagnification() {
|
||||
return wrappedObject.getMagnification();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param smooth
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#setSmoothing(boolean)
|
||||
*/
|
||||
public void setSmoothing(boolean smooth) {
|
||||
wrappedObject.setSmoothing(smooth);
|
||||
if (lastSmoothing != smooth) {
|
||||
lastSmoothing = smooth;
|
||||
UpdateFontDataEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
UpdateFontDataEvent.class, this);
|
||||
event.setSmoothing(smooth);
|
||||
dispatch(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#getSmoothing()
|
||||
*/
|
||||
public boolean getSmoothing() {
|
||||
return wrappedObject.getSmoothing();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#isScaleFont()
|
||||
*/
|
||||
public boolean isScaleFont() {
|
||||
return wrappedObject.isScaleFont();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scaleFont
|
||||
* @see com.raytheon.uf.viz.core.drawables.IFont#setScaleFont(boolean)
|
||||
*/
|
||||
public void setScaleFont(boolean scaleFont) {
|
||||
wrappedObject.setScaleFont(scaleFont);
|
||||
if (lastScaleFont != scaleFont) {
|
||||
lastScaleFont = scaleFont;
|
||||
UpdateFontDataEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
UpdateFontDataEvent.class, this);
|
||||
event.setScaleFont(scaleFont);
|
||||
dispatch(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue