Issue #2251 make style rules pluggable
Change-Id: I3adc5c94eb4a13686b346d231248faebc696c865 Former-commit-id: 9e31d3facd4d4807db060d6e1de29215b11a448e
This commit is contained in:
parent
06e04a419d
commit
dd7111d7d3
4 changed files with 79 additions and 19 deletions
|
@ -21,10 +21,11 @@ package com.raytheon.viz.core.graphing.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.raytheon.uf.common.style.IStyleType;
|
||||
import com.raytheon.uf.common.style.ParamLevelMatchCriteria;
|
||||
import com.raytheon.uf.common.style.StyleException;
|
||||
import com.raytheon.uf.common.style.StyleManager;
|
||||
import com.raytheon.uf.common.style.StyleRule;
|
||||
import com.raytheon.uf.common.style.StyleException;
|
||||
import com.raytheon.uf.common.style.graph.AxisScale;
|
||||
import com.raytheon.uf.common.style.graph.GraphPreferences;
|
||||
import com.raytheon.uf.common.style.level.SingleLevel;
|
||||
|
@ -37,7 +38,7 @@ import com.raytheon.uf.common.style.level.SingleLevel;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 23, 2007 njensen Initial creation
|
||||
*
|
||||
* Sep 06, 2013 2251 mnash Move Graph prefs style type to here
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -46,6 +47,14 @@ import com.raytheon.uf.common.style.level.SingleLevel;
|
|||
|
||||
public class GraphPrefsFactory {
|
||||
|
||||
public static final IStyleType GRAPH_STYLE_TYPE = new IStyleType() {
|
||||
|
||||
@Override
|
||||
public String[] getExtensions() {
|
||||
return new String[] { "GraphStyleRules.xml" };
|
||||
}
|
||||
};
|
||||
|
||||
public static GraphPreferences buildPreferences(String parameter,
|
||||
SingleLevel level) throws StyleException {
|
||||
GraphPreferences preferences = getPreferences(parameter, level);
|
||||
|
@ -106,7 +115,7 @@ public class GraphPrefsFactory {
|
|||
paramList.add(parameter);
|
||||
match.setParameterName(paramList);
|
||||
StyleRule sr = StyleManager.getInstance().getStyleRule(
|
||||
StyleManager.StyleType.GRAPH, match);
|
||||
GRAPH_STYLE_TYPE, match);
|
||||
if (sr != null) {
|
||||
prefs = (GraphPreferences) sr.getPreferences();
|
||||
}
|
||||
|
|
|
@ -37,10 +37,11 @@ import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.style.IStyleType;
|
||||
import com.raytheon.uf.common.style.ParamLevelMatchCriteria;
|
||||
import com.raytheon.uf.common.style.StyleException;
|
||||
import com.raytheon.uf.common.style.StyleManager;
|
||||
import com.raytheon.uf.common.style.StyleRule;
|
||||
import com.raytheon.uf.common.style.StyleException;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
|
||||
import com.raytheon.uf.viz.core.level.LevelUtilities;
|
||||
|
@ -56,6 +57,7 @@ import com.raytheon.uf.viz.xy.timeseries.rsc.TimeSeriesResourceData;
|
|||
import com.raytheon.uf.viz.xy.timeseries.rsc.TimeSeriesResourceData.AxisParameter;
|
||||
import com.raytheon.uf.viz.xy.varheight.rsc.VarHeightResourceData;
|
||||
import com.raytheon.viz.awipstools.ToolsDataManager;
|
||||
import com.raytheon.viz.core.graphing.util.GraphPrefsFactory;
|
||||
import com.raytheon.viz.grid.GridLevelTranslator;
|
||||
import com.raytheon.viz.grid.rsc.GridLoadProperties;
|
||||
import com.raytheon.viz.volumebrowser.vbui.VBMenuBarItemsMgr.ViewMenu;
|
||||
|
@ -79,7 +81,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* points which contain the word Point
|
||||
* May 03, 2013 DR14824 mgamazaychikov Added alterProductParameters method
|
||||
* Aug 20, 2013 2259 bsteffen Delete old skewt plugin.
|
||||
*
|
||||
* Sep 06, 2013 2251 mnash Move graph prefs style type to
|
||||
* graph plugin
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -391,7 +394,7 @@ public abstract class AbstractDataCatalog implements IDataCatalog {
|
|||
StyleRule sr = null;
|
||||
try {
|
||||
|
||||
StyleManager.StyleType styleType = StyleManager.StyleType.CONTOUR;
|
||||
IStyleType styleType = StyleManager.StyleType.CONTOUR;
|
||||
|
||||
if (displayType.equals(DisplayType.IMAGE)) {
|
||||
styleType = StyleManager.StyleType.IMAGERY;
|
||||
|
@ -405,7 +408,7 @@ public abstract class AbstractDataCatalog implements IDataCatalog {
|
|||
|
||||
if (catalogEntry.getDialogSettings().getViewSelection() == ViewMenu.TIMESERIES
|
||||
|| catalogEntry.getDialogSettings().getViewSelection() == ViewMenu.VARVSHGT) {
|
||||
styleType = StyleManager.StyleType.GRAPH;
|
||||
styleType = GraphPrefsFactory.GRAPH_STYLE_TYPE;
|
||||
}
|
||||
|
||||
sr = StyleManager.getInstance().getStyleRule(styleType, match);
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* 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.common.style;
|
||||
|
||||
import com.raytheon.uf.common.style.StyleManager.StyleType;
|
||||
|
||||
/**
|
||||
* Interface to be extended when adding new extensions for style types, the
|
||||
* initial and main one being {@link StyleType}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 6, 2013 mnash Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IStyleType {
|
||||
String[] getExtensions();
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
package com.raytheon.uf.common.style;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -42,6 +42,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2007 njensen Initial creation
|
||||
* May 21, 2012 DR 14833 gzhang Adding a getter for StyleRuleset
|
||||
* Sep 06, 2013 2251 mnash Add ability to plug in new style types
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -50,9 +51,9 @@ public class StyleManager {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(StyleManager.class);
|
||||
|
||||
public static enum StyleType {
|
||||
IMAGERY("ImageryStyleRules.xml"), GRAPH("GraphStyleRules.xml"), CONTOUR(
|
||||
"ContourStyleRules.xml"), ARROW("ArrowStyleRules.xml");
|
||||
public static enum StyleType implements IStyleType {
|
||||
IMAGERY("ImageryStyleRules.xml"), CONTOUR("ContourStyleRules.xml"), ARROW(
|
||||
"ArrowStyleRules.xml"), GEOMETRY("GeometryStyleRules.xml");
|
||||
|
||||
private String[] extensions;
|
||||
|
||||
|
@ -60,12 +61,16 @@ public class StyleManager {
|
|||
this.extensions = new String[] { extension };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
};
|
||||
|
||||
private static StyleManager instance;
|
||||
|
||||
private Map<StyleType, StyleRuleset> rules = new EnumMap<StyleType, StyleRuleset>(
|
||||
StyleType.class);
|
||||
// although HashMap allows null keys, would rather use this than Hashtable
|
||||
private Map<IStyleType, StyleRuleset> rules = new HashMap<IStyleType, StyleRuleset>();
|
||||
|
||||
private StyleManager() {
|
||||
}
|
||||
|
@ -78,12 +83,12 @@ public class StyleManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private void loadRules(StyleType aType) {
|
||||
private void loadRules(IStyleType aType) {
|
||||
try {
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationFile[] files = pathMgr.listFiles(pathMgr
|
||||
.getLocalSearchHierarchy(LocalizationType.CAVE_STATIC),
|
||||
"styleRules", aType.extensions, true, true);
|
||||
"styleRules", aType.getExtensions(), true, true);
|
||||
StyleRuleset rules = new StyleRuleset();
|
||||
for (LocalizationFile lf : files) {
|
||||
rules.addStyleRules(SerializationUtil.jaxbUnmarshalFromXmlFile(
|
||||
|
@ -106,7 +111,7 @@ public class StyleManager {
|
|||
* @return the best matching style rule, or null if no matches are found
|
||||
* @throws StyleException
|
||||
*/
|
||||
public StyleRule getStyleRule(StyleType aStyleType, MatchCriteria aCriteria)
|
||||
public StyleRule getStyleRule(IStyleType aStyleType, MatchCriteria aCriteria)
|
||||
throws StyleException {
|
||||
synchronized (aStyleType) {
|
||||
if (!this.rules.containsKey(aStyleType)) {
|
||||
|
@ -127,8 +132,7 @@ public class StyleManager {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new StyleException(
|
||||
"Error determining matching rules.", e);
|
||||
throw new StyleException("Error determining matching rules.", e);
|
||||
}
|
||||
}
|
||||
return bestMatch;
|
||||
|
@ -161,7 +165,7 @@ public class StyleManager {
|
|||
* : StyleType
|
||||
* @return: StyleRuleset related to the StyleType
|
||||
*/
|
||||
public StyleRuleset getStyleRuleSet(StyleType st) {
|
||||
public StyleRuleset getStyleRuleSet(IStyleType st) {
|
||||
|
||||
synchronized (st) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue