VLab Issue #5156 - Change Text display in NCP Point Data station model

Change-Id: Ib33c90ac5d113ade34f3c25822685220771c570e

Former-commit-id: b130dce1753c3ff691405e2edafcded8a511df59
This commit is contained in:
Stephen Gilbert 2014-11-25 10:59:01 -05:00
parent 54e40962af
commit d38edc9cf6
2 changed files with 302 additions and 174 deletions

View file

@ -56,6 +56,7 @@ import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.jobs.JobPool;
@ -79,7 +80,9 @@ import com.vividsolutions.jts.geom.Coordinate;
* 06/17/2014 923 S. Russell altered method setUpSymbolMappingTables()
* 06/17/2014 923 S. Russell altered method createRenderableData()
* 07/08/2014 TTR1027 B. Hebbard Force createRenderableData to recreate wind vectors each time.
* 09/10/2014 Redmine 4230 S. Russell Fix wind barb/brbk menu option in plot model dialog box
* 09/10/2014 Redmine 4230 S. Russell Fix wind barb/brbk menu option in plot model dialog box
* 11/03/2014 Redmine 5156 B. Hebbard Allow use of system fonts in addition to file-based 3
* 11/06/2014 Redmine 5156 B. Hebbard Rename Helvetica & Times lookalike fonts/files to make clear they aren't Java/AWT logical SansSerif & Serif
*/
public class NcPlotImageCreator {
@ -162,42 +165,42 @@ public class NcPlotImageCreator {
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR + "cour.pfa");
private static final File SERIF_NORMAL_FONT_FILE = NcPathManager
private static final File TIMES_LIKE_NORMAL_FONT_FILE = NcPathManager
.getInstance()
.getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR + "VeraSe.ttf");
private static final File SERIF_BOLD_FONT_FILE = NcPathManager
private static final File TIMES_LIKE_BOLD_FONT_FILE = NcPathManager
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR
+ "l049016t.pfa");
private static final File SERIF_ITALIC_FONT_FILE = NcPathManager
private static final File TIMES_LIKE_ITALIC_FONT_FILE = NcPathManager
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR
+ "l049033t.pfa");
private static final File SERIF_BOLD_ITALIC_FONT_FILE = NcPathManager
private static final File TIMES_LIKE_BOLD_ITALIC_FONT_FILE = NcPathManager
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR
+ "l049036t.pfa");
private static final File SANS_SERIF_NORMAL_FONT_FILE = NcPathManager
private static final File HELVETICA_LIKE_NORMAL_FONT_FILE = NcPathManager
.getInstance()
.getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR + "luxisr.ttf");
private static final File SANS_SERIF_ITALIC_FONT_FILE = NcPathManager
private static final File HELVETICA_LIKE_ITALIC_FONT_FILE = NcPathManager
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR
+ "luxisri.ttf");
private static final File SANS_SERIF_BOLD_FONT_FILE = NcPathManager
private static final File HELVETICA_LIKE_BOLD_FONT_FILE = NcPathManager
.getInstance()
.getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR + "luxisb.ttf");
private static final File SANS_SERIF_BOLD_ITALIC_FONT_FILE = NcPathManager
private static final File HELVETICA_LIKE_BOLD_ITALIC_FONT_FILE = NcPathManager
.getInstance().getStaticFile(
NcPathManager.NcPathConstants.FONT_FILES_DIR
+ "luxisbi.ttf");
@ -210,21 +213,21 @@ public class NcPlotImageCreator {
private static IFont COURIER_BOLD_ITALIC_FONT = null;
private static IFont SERIF_BOLD_ITALIC_FONT = null;
private static IFont TIMES_LIKE_BOLD_ITALIC_FONT = null;
private static IFont SANS_SERIF_BOLD_ITALIC_FONT = null;
private static IFont HELVETICA_LIKE_BOLD_ITALIC_FONT = null;
private static IFont SERIF_BOLD_FONT = null;
private static IFont TIMES_LIKE_BOLD_FONT = null;
private static IFont SANS_SERIF_BOLD_FONT = null;
private static IFont HELVETICA_LIKE_BOLD_FONT = null;
private static IFont SERIF_ITALIC_FONT = null;
private static IFont TIMES_LIKE_ITALIC_FONT = null;
private static IFont SANS_SERIF_ITALIC_FONT = null;
private static IFont HELVETICA_LIKE_ITALIC_FONT = null;
private static IFont SERIF_NORMAL_FONT = null;
private static IFont TIMES_LIKE_NORMAL_FONT = null;
private static IFont SANS_SERIF_NORMAL_FONT = null;
private static IFont HELVETICA_LIKE_NORMAL_FONT = null;
private RGB defaultColor;
@ -348,31 +351,32 @@ public class NcPlotImageCreator {
COURIER_NORMAL_FONT = target.initializeFont(COURIER_NORMAL_FONT_FILE,
IFont.FontType.TYPE1, initialFontSize, null);
SERIF_BOLD_FONT = target.initializeFont(SERIF_BOLD_FONT_FILE,
TIMES_LIKE_BOLD_FONT = target.initializeFont(TIMES_LIKE_BOLD_FONT_FILE,
IFont.FontType.TYPE1, initialFontSize,
new IFont.Style[] { IFont.Style.BOLD });
SERIF_BOLD_ITALIC_FONT = target.initializeFont(
SERIF_BOLD_ITALIC_FONT_FILE, IFont.FontType.TYPE1,
TIMES_LIKE_BOLD_ITALIC_FONT = target.initializeFont(
TIMES_LIKE_BOLD_ITALIC_FONT_FILE, IFont.FontType.TYPE1,
initialFontSize, new IFont.Style[] { IFont.Style.BOLD,
IFont.Style.ITALIC });
SERIF_ITALIC_FONT = target.initializeFont(SERIF_ITALIC_FONT_FILE,
IFont.FontType.TYPE1, initialFontSize,
new IFont.Style[] { IFont.Style.ITALIC });
SERIF_NORMAL_FONT = target.initializeFont(SERIF_NORMAL_FONT_FILE,
IFont.FontType.TRUETYPE, initialFontSize, null);
SANS_SERIF_BOLD_FONT = target.initializeFont(SANS_SERIF_BOLD_FONT_FILE,
IFont.FontType.TRUETYPE, initialFontSize,
new IFont.Style[] { IFont.Style.BOLD });
SANS_SERIF_BOLD_ITALIC_FONT = target.initializeFont(
SANS_SERIF_BOLD_ITALIC_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, new IFont.Style[] { IFont.Style.BOLD,
IFont.Style.ITALIC });
SANS_SERIF_ITALIC_FONT = target.initializeFont(
SANS_SERIF_ITALIC_FONT_FILE, IFont.FontType.TRUETYPE,
TIMES_LIKE_ITALIC_FONT = target.initializeFont(
TIMES_LIKE_ITALIC_FONT_FILE, IFont.FontType.TYPE1,
initialFontSize, new IFont.Style[] { IFont.Style.ITALIC });
SANS_SERIF_NORMAL_FONT = target.initializeFont(
SANS_SERIF_NORMAL_FONT_FILE, IFont.FontType.TRUETYPE,
TIMES_LIKE_NORMAL_FONT = target.initializeFont(
TIMES_LIKE_NORMAL_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, null);
HELVETICA_LIKE_BOLD_FONT = target.initializeFont(
HELVETICA_LIKE_BOLD_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, new IFont.Style[] { IFont.Style.BOLD });
HELVETICA_LIKE_BOLD_ITALIC_FONT = target.initializeFont(
HELVETICA_LIKE_BOLD_ITALIC_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, new IFont.Style[] { IFont.Style.BOLD,
IFont.Style.ITALIC });
HELVETICA_LIKE_ITALIC_FONT = target.initializeFont(
HELVETICA_LIKE_ITALIC_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, new IFont.Style[] { IFont.Style.ITALIC });
HELVETICA_LIKE_NORMAL_FONT = target.initializeFont(
HELVETICA_LIKE_NORMAL_FONT_FILE, IFont.FontType.TRUETYPE,
initialFontSize, null);
Tracer.print("< Exit");
}
@ -513,7 +517,6 @@ public class NcPlotImageCreator {
pme.setPosition("WD");
}
// Redmine 4230
// NcPlotImageCreator will not process BRBK unless it has
// the abstract ( not on thcae grid of plot model buttons )
@ -641,12 +644,15 @@ public class NcPlotImageCreator {
if (COURIER_BOLD_FONT == null || COURIER_ITALIC_FONT == null
|| COURIER_NORMAL_FONT == null
|| COURIER_BOLD_ITALIC_FONT == null || SERIF_BOLD_FONT == null
|| SERIF_ITALIC_FONT == null || SERIF_BOLD_ITALIC_FONT == null
|| SERIF_NORMAL_FONT == null || SANS_SERIF_ITALIC_FONT == null
|| SANS_SERIF_BOLD_ITALIC_FONT == null
|| SANS_SERIF_NORMAL_FONT == null
|| SANS_SERIF_BOLD_FONT == null) {
|| COURIER_BOLD_ITALIC_FONT == null
|| TIMES_LIKE_BOLD_FONT == null
|| TIMES_LIKE_ITALIC_FONT == null
|| TIMES_LIKE_BOLD_ITALIC_FONT == null
|| TIMES_LIKE_NORMAL_FONT == null
|| HELVETICA_LIKE_ITALIC_FONT == null
|| HELVETICA_LIKE_BOLD_ITALIC_FONT == null
|| HELVETICA_LIKE_NORMAL_FONT == null
|| HELVETICA_LIKE_BOLD_FONT == null) {
initializeFonts();
}
@ -664,33 +670,58 @@ public class NcPlotImageCreator {
else if (fontName.compareTo("Times") == 0) {
if (fontStyle.compareTo("Bold") == 0) {
font = SERIF_BOLD_FONT;
font = TIMES_LIKE_BOLD_FONT;
} else if (fontStyle.compareTo("Italic") == 0) {
font = SERIF_ITALIC_FONT;
font = TIMES_LIKE_ITALIC_FONT;
} else if (fontStyle.compareTo("Bold-Italic") == 0) {
font = SERIF_BOLD_ITALIC_FONT;
font = TIMES_LIKE_BOLD_ITALIC_FONT;
} else {
font = SERIF_NORMAL_FONT;
font = TIMES_LIKE_NORMAL_FONT;
}
} else {
}
else if (fontName.compareTo("Helvetica") == 0) {
if (fontStyle.compareTo("Bold") == 0) {
font = SANS_SERIF_BOLD_FONT;
font = HELVETICA_LIKE_BOLD_FONT;
} else if (fontStyle.compareTo("Italic") == 0) {
font = SANS_SERIF_ITALIC_FONT;
font = HELVETICA_LIKE_ITALIC_FONT;
} else if (fontStyle.compareTo("Bold-Italic") == 0) {
font = SANS_SERIF_BOLD_ITALIC_FONT;
font = HELVETICA_LIKE_BOLD_ITALIC_FONT;
} else {
font = SANS_SERIF_NORMAL_FONT;
font = HELVETICA_LIKE_NORMAL_FONT;
}
}
else { // use a system (name-based) font, instead of a file-based one
Style[] styles = null;
if (fontStyle.equals("Bold")) {
styles = new Style[] { Style.BOLD };
} else if (fontStyle.equals("Italic")) {
styles = new Style[] { Style.ITALIC };
} else if (fontStyle.equals("Bold-Italic")) {
styles = new Style[] { Style.BOLD, Style.ITALIC };
}
IDisplayPane displayPane = NcDisplayMngr.getActiveNatlCntrsEditor()
.getActiveDisplayPane();
IGraphicsTarget target = displayPane.getTarget();
font = target.initializeFont(fontName, fontSize, styles);
// TODO in this case, need to worry about disposal of the font
// later?
}
if (font != null && fontSize != initialFontSize) {
font = font.deriveWithSize(fontSize);
}
if (font != null) {
font.setMagnification(1);
/*
* set smoothing and scaleFont to false to disable anti-aliasing
* (which cause the fuzziness of the text).
*/
font.setScaleFont(false);
font.setSmoothing(false);
}
Tracer.print("< Exit");
@ -3111,44 +3142,44 @@ public class NcPlotImageCreator {
COURIER_NORMAL_FONT = null;
}
if (SERIF_BOLD_FONT != null) {
SERIF_BOLD_FONT.dispose();
SERIF_BOLD_FONT = null;
if (TIMES_LIKE_BOLD_FONT != null) {
TIMES_LIKE_BOLD_FONT.dispose();
TIMES_LIKE_BOLD_FONT = null;
}
if (SERIF_BOLD_ITALIC_FONT != null) {
SERIF_BOLD_ITALIC_FONT.dispose();
SERIF_BOLD_ITALIC_FONT = null;
if (TIMES_LIKE_BOLD_ITALIC_FONT != null) {
TIMES_LIKE_BOLD_ITALIC_FONT.dispose();
TIMES_LIKE_BOLD_ITALIC_FONT = null;
}
if (SERIF_ITALIC_FONT != null) {
SERIF_ITALIC_FONT.dispose();
SERIF_ITALIC_FONT = null;
if (TIMES_LIKE_ITALIC_FONT != null) {
TIMES_LIKE_ITALIC_FONT.dispose();
TIMES_LIKE_ITALIC_FONT = null;
}
if (SERIF_NORMAL_FONT != null) {
SERIF_NORMAL_FONT.dispose();
SERIF_NORMAL_FONT = null;
if (TIMES_LIKE_NORMAL_FONT != null) {
TIMES_LIKE_NORMAL_FONT.dispose();
TIMES_LIKE_NORMAL_FONT = null;
}
if (SANS_SERIF_BOLD_FONT != null) {
SANS_SERIF_BOLD_FONT.dispose();
SANS_SERIF_BOLD_FONT = null;
if (HELVETICA_LIKE_BOLD_FONT != null) {
HELVETICA_LIKE_BOLD_FONT.dispose();
HELVETICA_LIKE_BOLD_FONT = null;
}
if (SANS_SERIF_BOLD_ITALIC_FONT != null) {
SANS_SERIF_BOLD_ITALIC_FONT.dispose();
SANS_SERIF_BOLD_ITALIC_FONT = null;
if (HELVETICA_LIKE_BOLD_ITALIC_FONT != null) {
HELVETICA_LIKE_BOLD_ITALIC_FONT.dispose();
HELVETICA_LIKE_BOLD_ITALIC_FONT = null;
}
if (SANS_SERIF_ITALIC_FONT != null) {
SANS_SERIF_ITALIC_FONT.dispose();
SANS_SERIF_ITALIC_FONT = null;
if (HELVETICA_LIKE_ITALIC_FONT != null) {
HELVETICA_LIKE_ITALIC_FONT.dispose();
HELVETICA_LIKE_ITALIC_FONT = null;
}
if (SANS_SERIF_NORMAL_FONT != null) {
SANS_SERIF_NORMAL_FONT.dispose();
SANS_SERIF_NORMAL_FONT = null;
if (HELVETICA_LIKE_NORMAL_FONT != null) {
HELVETICA_LIKE_NORMAL_FONT.dispose();
HELVETICA_LIKE_NORMAL_FONT = null;
}
Tracer.print("< Exit");

View file

@ -74,6 +74,7 @@ import org.eclipse.swt.widgets.Scale;
* 02/26/2013 936 Archana Removed references to the 'Standard' font.
* 03/10/2014 921 S. Russell TTR 921: implemented the Clear & Reset buttons
* 06/17/2014 923 S. Russell TTR 923: altered method initWidgets()
* 11/03/2014 R5156 B. Hebbard Add more textFontOptions
*
* </pre>
*
@ -100,13 +101,19 @@ public class EditPlotModelComposite extends Composite {
private Button advancedBtn = null;
private final String[] textSizeOptions = { "10", "12", "14", "16", "18", "20", "22", "24", "32" };
private final String[] textSizeOptions = { "10", "12", "14", "16", "18",
"20", "22", "24", "32" };
private final String[] textFontOptions = { "Courier", "Helvetica", "Times" };
private final String[] textFontOptions = { "Courier", "Helvetica", "Times",
// "Dialog", "DialogInput", // same as SansSerif, Monospaced, resp.
"Monospaced", "SansSerif", "Serif", "Nimbus Sans L",
"Liberation Serif" };
private final String[] textStyleOptions = { "Normal", "Italic", "Bold", "Bold-Italic" };
private final String[] textStyleOptions = { "Normal", "Italic", "Bold",
"Bold-Italic" };
private final String[] plotModelElementPositions = { "TC", "UL", "UC", "UR", "ML", "MC", "MR", "LL", "LC", "LR", "BC" };
private final String[] plotModelElementPositions = { "TC", "UL", "UC",
"UR", "ML", "MC", "MR", "LL", "LC", "LR", "BC" };
private HashMap<String, PlotModelElemButton> plotModelElementsUIMap = new HashMap<String, PlotModelElemButton>();
@ -142,9 +149,11 @@ public class EditPlotModelComposite extends Composite {
private Label wndBrbLbl = null;
private File advancedIconFile = NcPathManager.getInstance().getStaticFile(NcPathConstants.ADVANCED_ICON_IMG);;
private File advancedIconFile = NcPathManager.getInstance().getStaticFile(
NcPathConstants.ADVANCED_ICON_IMG);;
public EditPlotModelComposite(Composite parent, int style, PlotModel pm, INatlCntrsResourceData rscData) {
public EditPlotModelComposite(Composite parent, int style, PlotModel pm,
INatlCntrsResourceData rscData) {
super(parent, style);
editedPlotModel = pm;
this.rscData = rscData;
@ -154,12 +163,14 @@ public class EditPlotModelComposite extends Composite {
mainLayout.marginWidth = 1;
mainLayout.verticalSpacing = 5;
topComposite.setLayout(mainLayout);
plotParamDefns = PlotParameterDefnsMngr.getInstance().getPlotParamDefns(editedPlotModel.getPlugin());
plotParamDefns = PlotParameterDefnsMngr.getInstance()
.getPlotParamDefns(editedPlotModel.getPlugin());
createPlotModelGuiElements();
// TTR 921
origPltMdlElmntsUIMap = new HashMap<String, PlotModelElemButton>(plotModelElementsUIMap);
origPltMdlElmntsUIMap = new HashMap<String, PlotModelElemButton>(
plotModelElementsUIMap);
createTextAttrControls();
@ -188,7 +199,8 @@ public class EditPlotModelComposite extends Composite {
textSizeCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (seldPlotModelElemButton != null) {
seldPlotModelElemButton.getPlotModelElement().setTextSize(textSizeCombo.getText());
seldPlotModelElemButton.getPlotModelElement().setTextSize(
textSizeCombo.getText());
if (applyToAllBtn.getSelection()) {
applyTextChangesToAllParameters();
@ -204,7 +216,8 @@ public class EditPlotModelComposite extends Composite {
textFontCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (seldPlotModelElemButton != null) {
seldPlotModelElemButton.getPlotModelElement().setTextFont(textFontCombo.getText());
seldPlotModelElemButton.getPlotModelElement().setTextFont(
textFontCombo.getText());
// if ("Standard".equals(textFontCombo.getText())) {
// textStyleCombo.select(0);
@ -227,7 +240,8 @@ public class EditPlotModelComposite extends Composite {
textStyleCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (seldPlotModelElemButton != null) {
seldPlotModelElemButton.getPlotModelElement().setTextStyle(textStyleCombo.getText());
seldPlotModelElemButton.getPlotModelElement().setTextStyle(
textStyleCombo.getText());
if (applyToAllBtn.getSelection()) {
applyTextChangesToAllParameters();
@ -261,7 +275,8 @@ public class EditPlotModelComposite extends Composite {
Group parmListGrp = new Group(comp, SWT.SHADOW_NONE);
parmListGrp.setLayout(new GridLayout(1, false));
parmListGrp.setText("Plot Parameters");
availParamsList = new List(parmListGrp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
availParamsList = new List(parmListGrp, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
availParamsList.setLayoutData(gd);
availParamsList.addSelectionListener(new SelectionAdapter() {
@Override
@ -272,12 +287,12 @@ public class EditPlotModelComposite extends Composite {
if (!seldPlotModelElemButton.isParamNameSelected()) {
// seldPlotModelElemButton.setColor( )
}
//if (selectedParm.equalsIgnoreCase("PTND")) {
// swapInAComboBtn("PTND");
//}// else a regular button
//else {
// if (selectedParm.equalsIgnoreCase("PTND")) {
// swapInAComboBtn("PTND");
// }// else a regular button
// else {
seldPlotModelElemButton.setParmName(selectedParm);
//}
// }
}
}
});
@ -316,23 +331,27 @@ public class EditPlotModelComposite extends Composite {
Group selColorGrp = new Group(comp, SWT.SHADOW_NONE);
selColorGrp.setText("Color");
cms = new ColorMatrixSelector(selColorGrp, false, true, 22, 88, 18, 22, 28, 86, 0, 4, 5);
cms = new ColorMatrixSelector(selColorGrp, false, true, 22, 88, 18, 22,
28, 86, 0, 4, 5);
cms.setColorValue(new RGB(0, 255, 0));
cms.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (seldPlotModelElemButton != null) {
RGB rgb = cms.getColorValue();
//if (seldPlotModelElemButton instanceof PlotModelElemComboButton) {
//System.out.println("==> listener using combo btn");
//((PlotModelElemComboButton) seldPlotModelElemButton).setColor(rgb);
//((PlotModelElemComboButton) seldPlotModelElemButton).setButtonAsSelected();
//} else {
//System.out.println("==> listener using single btn");
// if (seldPlotModelElemButton instanceof
// PlotModelElemComboButton) {
// System.out.println("==> listener using combo btn");
// ((PlotModelElemComboButton)
// seldPlotModelElemButton).setColor(rgb);
// ((PlotModelElemComboButton)
// seldPlotModelElemButton).setButtonAsSelected();
// } else {
// System.out.println("==> listener using single btn");
seldPlotModelElemButton.setColor(rgb);
seldPlotModelElemButton.setButtonAsSelected();
//}
// }
}
}
});
@ -373,7 +392,8 @@ public class EditPlotModelComposite extends Composite {
}
});
PlotModelElement pme = editedPlotModel.getPlotModelElement(plotModelElementPositions[0]);
PlotModelElement pme = editedPlotModel
.getPlotModelElement(plotModelElementPositions[0]);
// create a blank element and only add it to the editedPlotModel if the
// user selects a parameter.
@ -421,9 +441,10 @@ public class EditPlotModelComposite extends Composite {
comp.setLayoutData(gd);
// 9 Param Buttons
// 9 Param Buttons
for (int i = 1; i <= 9; i++) {
pme = editedPlotModel.getPlotModelElement(plotModelElementPositions[i]);
pme = editedPlotModel
.getPlotModelElement(plotModelElementPositions[i]);
if (pme == null) {
pme = new PlotModelElement();
@ -432,15 +453,20 @@ public class EditPlotModelComposite extends Composite {
try {
// the center button stores the sky coverage and wind barb params
// the center button stores the sky coverage and wind barb
// params
if (plotModelElementPositions[i].equals("MC")) {
PlotModelElemCenterButton cntrBtn = new PlotModelElemCenterButton(comp, pme, editedPlotModel.getSkyCoverageElement(), editedPlotModel.getWindBarbElement());
PlotModelElemCenterButton cntrBtn = new PlotModelElemCenterButton(
comp, pme, editedPlotModel.getSkyCoverageElement(),
editedPlotModel.getWindBarbElement());
cntrBtn.init();
plotModelElementsUIMap.put(plotModelElementPositions[i], cntrBtn);
plotModelElementsUIMap.put(plotModelElementPositions[i],
cntrBtn);
} else {
pmeBtn = new PlotModelElemButton(comp, pme);
pmeBtn.init();
plotModelElementsUIMap.put(plotModelElementPositions[i], pmeBtn);
plotModelElementsUIMap.put(plotModelElementPositions[i],
pmeBtn);
}
}// end try
@ -488,7 +514,8 @@ public class EditPlotModelComposite extends Composite {
gd.grabExcessHorizontalSpace = true;
comp.setLayoutData(gd);
pme = editedPlotModel.getPlotModelElement(plotModelElementPositions[10]);
pme = editedPlotModel
.getPlotModelElement(plotModelElementPositions[10]);
if (pme == null) {
pme = new PlotModelElement();
pme.setPosition(plotModelElementPositions[10]);
@ -533,8 +560,10 @@ public class EditPlotModelComposite extends Composite {
grp.setLayoutData(gd);
if (advancedIconFile != null && advancedIconFile.exists() && pltMdlElmt.hasAdvancedSettings()) {
Image image = new Image(Display.getCurrent(), advancedIconFile.getAbsolutePath());
if (advancedIconFile != null && advancedIconFile.exists()
&& pltMdlElmt.hasAdvancedSettings()) {
Image image = new Image(Display.getCurrent(),
advancedIconFile.getAbsolutePath());
grp.setBackgroundImage(image);
grp.setToolTipText("Advanced Settings Applied.");
} else {
@ -596,7 +625,8 @@ public class EditPlotModelComposite extends Composite {
if (isParamNameSelected()) {
for (int i = 0; i < availParamsList.getItemCount(); i++) {
if (availParamsList.getItem(i).equals(parmBtn.getText())) {
if (availParamsList.getItem(i)
.equals(parmBtn.getText())) {
availParamsList.setSelection(i);
break;
}
@ -653,16 +683,21 @@ public class EditPlotModelComposite extends Composite {
public void setButtonAsSelected() {
RGB rgb = getColor();
grp.setBackground(new Color(getParent().getDisplay(), cms.getColorValue()));
grp.setBackground(new Color(getParent().getDisplay(), cms
.getColorValue()));
seldPlotModelElemButton.parmBtn.setForeground(new Color(getParent().getDisplay(), rgb));
seldPlotModelElemButton.parmBtn.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
seldPlotModelElemButton.grp.setBackground(new Color(getParent().getDisplay(), rgb));
seldPlotModelElemButton.parmBtn.setForeground(new Color(getParent()
.getDisplay(), rgb));
seldPlotModelElemButton.parmBtn.setBackground(Display.getDefault()
.getSystemColor(SWT.COLOR_BLACK));
seldPlotModelElemButton.grp.setBackground(new Color(getParent()
.getDisplay(), rgb));
}
public void unselectButton() {
// change color back to original grey
grp.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
grp.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
// unselect parm button
parmBtn.setSelection(false);
@ -683,10 +718,13 @@ public class EditPlotModelComposite extends Composite {
checkBtn.setEnabled(true);
checkBtn.setSelection(true); // pltMdlElmt.getEnable() );
parmBtn.setForeground(new Color(getParent().getDisplay(), getColor().red, getColor().green, getColor().blue));
parmBtn.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
parmBtn.setForeground(new Color(getParent().getDisplay(),
getColor().red, getColor().green, getColor().blue));
parmBtn.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_BLACK));
PlotParameterDefn paramDefn = plotParamDefns.getPlotParamDefn(pltMdlElmt.getParamName());
PlotParameterDefn paramDefn = plotParamDefns
.getPlotParamDefn(pltMdlElmt.getParamName());
if (paramDefn == null) {
parmBtn.setToolTipText("");
} else {
@ -694,7 +732,8 @@ public class EditPlotModelComposite extends Composite {
if (paramDefn.getDeriveParams().equals("all")) {
parmBtn.setToolTipText("Derived Parameter");
} else {
parmBtn.setToolTipText("Derived from " + paramDefn.getDeriveParams());
parmBtn.setToolTipText("Derived from "
+ paramDefn.getDeriveParams());
}
} else {
parmBtn.setToolTipText(paramDefn.getMetParamName());
@ -706,7 +745,8 @@ public class EditPlotModelComposite extends Composite {
// the color of the text
parmBtn.setForeground(new Color(getDisplay(), new RGB(0, 0, 0)));
parmBtn.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
parmBtn.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
parmBtn.setToolTipText("");
}
@ -736,11 +776,14 @@ public class EditPlotModelComposite extends Composite {
parmBtn.setText(getButtonLabel());
// Set foreground and background color
parmBtn.setForeground(new Color(getParent().getDisplay(), getColor().red, getColor().green, getColor().blue));
parmBtn.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
parmBtn.setForeground(new Color(getParent().getDisplay(),
getColor().red, getColor().green, getColor().blue));
parmBtn.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_BLACK));
//
PlotParameterDefn paramDefn = plotParamDefns.getPlotParamDefn(parmName);
PlotParameterDefn paramDefn = plotParamDefns
.getPlotParamDefn(parmName);
if (paramDefn == null) {
parmBtn.setToolTipText("");
} else {
@ -748,7 +791,8 @@ public class EditPlotModelComposite extends Composite {
if (paramDefn.getDeriveParams().equals("all")) {
parmBtn.setToolTipText("Derived Parameter");
} else {
parmBtn.setToolTipText("Derived from " + paramDefn.getDeriveParams());
parmBtn.setToolTipText("Derived from "
+ paramDefn.getDeriveParams());
}
} else {
parmBtn.setToolTipText(paramDefn.getMetParamName());
@ -757,7 +801,8 @@ public class EditPlotModelComposite extends Composite {
}
protected RGB getColor() {
return new RGB(pltMdlElmt.getColor().getRed(), pltMdlElmt.getColor().getGreen(), pltMdlElmt.getColor().getBlue());
return new RGB(pltMdlElmt.getColor().getRed(), pltMdlElmt
.getColor().getGreen(), pltMdlElmt.getColor().getBlue());
}
protected void setColor(RGB rgb) {
@ -770,7 +815,8 @@ public class EditPlotModelComposite extends Composite {
private PlotModelElement wndBrbElmt = null;
public PlotModelElemCenterButton(Composite topComp, PlotModelElement pme, PlotModelElement sce, PlotModelElement wbe) {
public PlotModelElemCenterButton(Composite topComp,
PlotModelElement pme, PlotModelElement sce, PlotModelElement wbe) {
super(topComp, pme);
// if either is null then create a new PlotModelElement but don't
// add it to the
@ -789,8 +835,12 @@ public class EditPlotModelComposite extends Composite {
wndBrbElmt.setPosition("WD");
}
if (advancedIconFile != null && advancedIconFile.exists() && (skyCovElmt.hasAdvancedSettings() || wndBrbElmt.hasAdvancedSettings())) {
Image image = new Image(Display.getCurrent(), advancedIconFile.getAbsolutePath());
if (advancedIconFile != null
&& advancedIconFile.exists()
&& (skyCovElmt.hasAdvancedSettings() || wndBrbElmt
.hasAdvancedSettings())) {
Image image = new Image(Display.getCurrent(),
advancedIconFile.getAbsolutePath());
grp.setBackgroundImage(image);
grp.setToolTipText("Advanced Settings Applied.");
} else {
@ -897,7 +947,8 @@ public class EditPlotModelComposite extends Composite {
@Override
public String getButtonLabel() {
if (skyCovElmt.getParamName() == null && wndBrbElmt.getParamName() == null) {
if (skyCovElmt.getParamName() == null
&& wndBrbElmt.getParamName() == null) {
// parmBtn.setText( getParmName() )
return super.getButtonLabel();
@ -907,7 +958,8 @@ public class EditPlotModelComposite extends Composite {
} else if (wndBrbElmt.getParamName() == null) {
return skyCovElmt.getParamName();
} else {
return skyCovElmt.getParamName() + "\n" + wndBrbElmt.getParamName();
return skyCovElmt.getParamName() + "\n"
+ wndBrbElmt.getParamName();
}
}
@ -980,13 +1032,15 @@ public class EditPlotModelComposite extends Composite {
// if any param is selected then set the background color
// ('normal' param selections are checked in the super.)
//
if (wndBrbElmt.getParamName() != null || skyCovElmt.getParamName() != null) {
if (wndBrbElmt.getParamName() != null
|| skyCovElmt.getParamName() != null) {
// Set color in the ColorMatricSelector widget
cms.setColorValue(getColor());
// Set grp background
grp.setBackground(new Color(getParent().getDisplay(), cms.getColorValue()));
grp.setBackground(new Color(getParent().getDisplay(), cms
.getColorValue()));
}
}
@ -995,7 +1049,9 @@ public class EditPlotModelComposite extends Composite {
@Override
public boolean isParamNameSelected() {
return (wndBrbElmt.getParamName() != null || skyCovElmt.getParamName() != null || pltMdlElmt.getParamName() != null);
return (wndBrbElmt.getParamName() != null
|| skyCovElmt.getParamName() != null || pltMdlElmt
.getParamName() != null);
}
@Override
@ -1024,8 +1080,8 @@ public class EditPlotModelComposite extends Composite {
String[] strArray = plotParamDefns.getAllParameterNames(false, true);
//TTR 923 remove "P03X" from the menu ( the dummy XML it comes from in
// plotParameters_obs.xml is needed to make the code run without a
// TTR 923 remove "P03X" from the menu ( the dummy XML it comes from in
// plotParameters_obs.xml is needed to make the code run without a
// a significant amount of reworking
ArrayList<String> parameterNames = new ArrayList<String>();
Collections.addAll(parameterNames, strArray);
@ -1050,7 +1106,8 @@ public class EditPlotModelComposite extends Composite {
// return;
// }
PlotModelElemCenterButton cntrBtn = (PlotModelElemCenterButton) plotModelElementsUIMap.get("MC");
PlotModelElemCenterButton cntrBtn = (PlotModelElemCenterButton) plotModelElementsUIMap
.get("MC");
PlotModelElement wndBrbPme = cntrBtn.getWindBarbPlotModelElement();
PlotModelElement skyCovPme = cntrBtn.getSkyCoveragePlotModelElement();
@ -1079,7 +1136,8 @@ public class EditPlotModelComposite extends Composite {
String name = comboSky.getItem(comboSky.getSelectionIndex());
if (seldPlotModelElemButton instanceof PlotModelElemCenterButton) {
((PlotModelElemCenterButton) seldPlotModelElemButton).setSkyCoverageParamName((name.equals("None") ? null : name));
((PlotModelElemCenterButton) seldPlotModelElemButton).setSkyCoverageParamName((name
.equals("None") ? null : name));
}
}
});
@ -1106,7 +1164,9 @@ public class EditPlotModelComposite extends Composite {
if (seldPlotModelElemButton instanceof PlotModelElemCenterButton) { // sanity
// check
((PlotModelElemCenterButton) seldPlotModelElemButton).setWindBarbParamName((name.equals("None") ? null : name));
((PlotModelElemCenterButton) seldPlotModelElemButton)
.setWindBarbParamName((name.equals("None") ? null
: name));
}
}
});
@ -1117,7 +1177,8 @@ public class EditPlotModelComposite extends Composite {
}
private void setSelectedSkyAndWindParams() {
PlotModelElemCenterButton cntrBtn = (PlotModelElemCenterButton) plotModelElementsUIMap.get("MC");
PlotModelElemCenterButton cntrBtn = (PlotModelElemCenterButton) plotModelElementsUIMap
.get("MC");
String seldSkyCovParam = cntrBtn.getSkyCovParamName();
@ -1150,18 +1211,22 @@ public class EditPlotModelComposite extends Composite {
boolean isTextApplicable = false;
boolean isSymbApplicable = false;
if (seldPlotModelElemButton != null && seldPlotModelElemButton.isParamNameSelected()) {
if (seldPlotModelElemButton != null
&& seldPlotModelElemButton.isParamNameSelected()) {
advancedBtn.setEnabled(true);
// if( seldPlotModelElemButton.getPlotModelElement().getParamName()
// != null ) {
prmDefn = plotParamDefns.getPlotParamDefn(seldPlotModelElemButton.getPlotModelElement().getParamName());
prmDefn = plotParamDefns.getPlotParamDefn(seldPlotModelElemButton
.getPlotModelElement().getParamName());
// add further constraints here on the plot class if necessary
if (prmDefn != null) {
isTextApplicable = prmDefn.getPlotMode().equalsIgnoreCase("text");
isSymbApplicable = prmDefn.getPlotMode().equalsIgnoreCase("table");
isTextApplicable = prmDefn.getPlotMode().equalsIgnoreCase(
"text");
isSymbApplicable = prmDefn.getPlotMode().equalsIgnoreCase(
"table");
}
// if this is the center button and a 'regular' parameter isn't set
// then
@ -1171,7 +1236,8 @@ public class EditPlotModelComposite extends Composite {
else if (seldPlotModelElemButton instanceof PlotModelElemCenterButton) {
PlotModelElemCenterButton cntrBtn = (PlotModelElemCenterButton) seldPlotModelElemButton;
if (cntrBtn.getSkyCovParamName() != null || cntrBtn.getWindBarbParamName() != null) {
if (cntrBtn.getSkyCovParamName() != null
|| cntrBtn.getWindBarbParamName() != null) {
// prmDefn = plotParamMngr.getParamDefn(
// cntrBtn.getSkyCovParamName() );
isTextApplicable = false;
@ -1194,21 +1260,27 @@ public class EditPlotModelComposite extends Composite {
applyToAllBtn.setEnabled(true);
for (int i = 0; i < textSizeCombo.getItemCount(); i++) {
if (textSizeCombo.getItem(i).equals(seldPlotModelElemButton.getPlotModelElement().getTextSize())) {
if (textSizeCombo.getItem(i).equals(
seldPlotModelElemButton.getPlotModelElement()
.getTextSize())) {
textSizeCombo.select(i);
break;
}
}
for (int i = 0; i < textFontCombo.getItemCount(); i++) {
if (textFontCombo.getItem(i).equalsIgnoreCase(seldPlotModelElemButton.getPlotModelElement().getTextFont())) {
if (textFontCombo.getItem(i).equalsIgnoreCase(
seldPlotModelElemButton.getPlotModelElement()
.getTextFont())) {
textFontCombo.select(i);
break;
}
}
for (int i = 0; i < textStyleCombo.getItemCount(); i++) {
if (textStyleCombo.getItem(i).equalsIgnoreCase(seldPlotModelElemButton.getPlotModelElement().getTextStyle())) {
if (textStyleCombo.getItem(i).equalsIgnoreCase(
seldPlotModelElemButton.getPlotModelElement()
.getTextStyle())) {
textStyleCombo.select(i);
break;
}
@ -1267,15 +1339,21 @@ public class EditPlotModelComposite extends Composite {
private void applyTextChangesToAllParameters() {
for (int i = 0; i < 11; i++) {
PlotModelElemButton pmeBtn = plotModelElementsUIMap.get(plotModelElementPositions[i]);
PlotModelElemButton pmeBtn = plotModelElementsUIMap
.get(plotModelElementPositions[i]);
if (pmeBtn != null) {
PlotParameterDefn prmDefn = plotParamDefns.getPlotParamDefn(pmeBtn.getPlotModelElement().getParamName());
PlotParameterDefn prmDefn = plotParamDefns
.getPlotParamDefn(pmeBtn.getPlotModelElement()
.getParamName());
if (prmDefn != null) {
if (prmDefn.getPlotMode().equalsIgnoreCase("text")) {
pmeBtn.getPlotModelElement().setTextSize(textSizeCombo.getText());
pmeBtn.getPlotModelElement().setTextFont(textFontCombo.getText());
pmeBtn.getPlotModelElement().setTextStyle(textStyleCombo.getText());
pmeBtn.getPlotModelElement().setTextSize(
textSizeCombo.getText());
pmeBtn.getPlotModelElement().setTextFont(
textFontCombo.getText());
pmeBtn.getPlotModelElement().setTextStyle(
textStyleCombo.getText());
}
}
}
@ -1313,12 +1391,16 @@ public class EditPlotModelComposite extends Composite {
}
String prevCondParam = pltMdlElmt.getConditionalParameter();
ConditionalColorBar prevCondColorBar = new ConditionalColorBar(pltMdlElmt.getConditionalColorBar());
ConditionalColorBar prevCondColorBar = new ConditionalColorBar(
pltMdlElmt.getConditionalColorBar());
EditPlotModelElementAdvancedDialog editConditionalFilterDlg = new EditPlotModelElementAdvancedDialog(topComposite.getShell(), pltMdlElmt, plotParamDefns);
EditPlotModelElementAdvancedDialog editConditionalFilterDlg = new EditPlotModelElementAdvancedDialog(
topComposite.getShell(), pltMdlElmt, plotParamDefns);
PlotModelElement newPme = (PlotModelElement) editConditionalFilterDlg.open(topComposite.getShell().getLocation().x + topComposite.getShell().getSize().x + 10, topComposite
.getShell().getLocation().y);
PlotModelElement newPme = (PlotModelElement) editConditionalFilterDlg
.open(topComposite.getShell().getLocation().x
+ topComposite.getShell().getSize().x + 10,
topComposite.getShell().getLocation().y);
if (newPme != null) {
pltMdlElmt = newPme;
@ -1329,20 +1411,26 @@ public class EditPlotModelComposite extends Composite {
if (pltMdlElmt.hasAdvancedSettings()) {
if (advancedIconFile != null && advancedIconFile.exists()) {
Image image = new Image(Display.getCurrent(), advancedIconFile.getAbsolutePath());
Image image = new Image(Display.getCurrent(),
advancedIconFile.getAbsolutePath());
seldPlotModelElemButton.grp.setBackgroundImage(image);
}
seldPlotModelElemButton.grp.setToolTipText("Advanced Settings Applied.");
seldPlotModelElemButton.grp
.setToolTipText("Advanced Settings Applied.");
} else {
seldPlotModelElemButton.grp.setBackgroundImage(null);
seldPlotModelElemButton.grp.setToolTipText("");
}
if (skycPltMdlElmt != null && wbPltMdlElmt != null) {
skycPltMdlElmt.setConditionalParameter(pltMdlElmt.getConditionalParameter());
skycPltMdlElmt.setConditionalColorBar(pltMdlElmt.getConditionalColorBar());
wbPltMdlElmt.setConditionalParameter(pltMdlElmt.getConditionalParameter());
wbPltMdlElmt.setConditionalColorBar(pltMdlElmt.getConditionalColorBar());
skycPltMdlElmt.setConditionalParameter(pltMdlElmt
.getConditionalParameter());
skycPltMdlElmt.setConditionalColorBar(pltMdlElmt
.getConditionalColorBar());
wbPltMdlElmt.setConditionalParameter(pltMdlElmt
.getConditionalParameter());
wbPltMdlElmt.setConditionalColorBar(pltMdlElmt
.getConditionalColorBar());
}
}
@ -1378,7 +1466,8 @@ public class EditPlotModelComposite extends Composite {
// Clear special middle center button
if (position.equalsIgnoreCase("MC")) {
pmecb = (PlotModelElemCenterButton) plotModelElementsUIMap.get("MC");
pmecb = (PlotModelElemCenterButton) plotModelElementsUIMap
.get("MC");
pmecb.parmBtn.setText("Parm");
pmecb.parmBtn.setSelection(false);
pmecb.checkBtn.setSelection(false);
@ -1386,9 +1475,12 @@ public class EditPlotModelComposite extends Composite {
pmecb.grp.setBackground(widget_background);
pmecb.parmBtn.setBackground(widget_background);
pmecb.parmBtn.setForeground(widget_foreground);
editedPlotModel.removePlotModelElement(pmecb.getPlotModelElement());
editedPlotModel.removePlotModelElement(pmecb.getSkyCoveragePlotModelElement());
editedPlotModel.removePlotModelElement(pmecb.getWindBarbPlotModelElement());
editedPlotModel.removePlotModelElement(pmecb
.getPlotModelElement());
editedPlotModel.removePlotModelElement(pmecb
.getSkyCoveragePlotModelElement());
editedPlotModel.removePlotModelElement(pmecb
.getWindBarbPlotModelElement());
pmecb.pltMdlElmt = new PlotModelElement();
pmecb.pltMdlElmt.setPosition(position);
pmecb.skyCovElmt.setColorRGB(new RGB(255, 255, 255));
@ -1403,7 +1495,8 @@ public class EditPlotModelComposite extends Composite {
pmeBtn.grp.setBackground(widget_background);
pmeBtn.parmBtn.setBackground(widget_background);
pmeBtn.parmBtn.setForeground(widget_foreground);
editedPlotModel.removePlotModelElement(pmeBtn.getPlotModelElement());
editedPlotModel.removePlotModelElement(pmeBtn
.getPlotModelElement());
pmeBtn.pltMdlElmt = new PlotModelElement();
pmeBtn.pltMdlElmt.setPosition(position);
}
@ -1453,7 +1546,8 @@ public class EditPlotModelComposite extends Composite {
blue = tpme.getColor().getBlue();
rgb = new RGB(red, green, blue);
cntrBtn = (PlotModelElemCenterButton) origPltMdlElmntsUIMap.get(position);
cntrBtn = (PlotModelElemCenterButton) origPltMdlElmntsUIMap
.get(position);
cntrBtn.setColor(rgb);
cntrBtn.setParmName(opme.getParamName());
cntrBtn.pltMdlElmt = opme;
@ -1526,16 +1620,19 @@ public class EditPlotModelComposite extends Composite {
// System.out.print("resoure_name: " + resource_name);
// System.out.println("==> resource_version: " +
// resource_version);
original_resource = ResourceFactory.createResource(resource_name);
original_resource = ResourceFactory
.createResource(resource_name);
origResourceData = original_resource.getResourceData();
origAttrSet = new ResourceAttrSet(origResourceData.getRscAttrSet());
origAttrSet = new ResourceAttrSet(
origResourceData.getRscAttrSet());
origPlotModelRscAttr = origAttrSet.getRscAttr("plotModel");
origPlotModel = (PlotModel) origPlotModelRscAttr.getAttrValue();
} else {
String plugin, plotmodelname = null;
plugin = editedPlotModel.getPlugin();
plotmodelname = editedPlotModel.getName();
origPlotModel = PlotModelMngr.getInstance().getPlotModel(plugin, plotmodelname);
origPlotModel = PlotModelMngr.getInstance().getPlotModel(
plugin, plotmodelname);
}
} catch (Exception e) {