📄 dbfhandler.java
字号:
} if (key == null) { Debug.output("No key for rule (" + prefix + ") found in properties."); } displayMinScale = PropUtils.floatFromProperties(props, prefix + RuleActionRender + "." + RuleActionMinScale, displayMinScale); displayMaxScale = PropUtils.floatFromProperties(props, prefix + RuleActionRender + "." + RuleActionMaxScale, displayMaxScale); labelMinScale = PropUtils.floatFromProperties(props, prefix + RuleActionLabel + "." + RuleActionMinScale, labelMinScale); labelMaxScale = PropUtils.floatFromProperties(props, prefix + RuleActionLabel + "." + RuleActionMaxScale, labelMaxScale); tooltipIndicies = getIndicies(prefix + RuleActionTooltip, props); infolineIndicies = getIndicies(prefix + RuleActionInfoline, props); labelIndicies = getIndicies(prefix + RuleActionLabel, props); da = null; boolean renderProperties = PropUtils.booleanFromProperties(props, prefix + RuleActionRender, false); if (renderProperties) { da = new DrawingAttributes(); da.setProperties(prefix, props); } } public Properties getProperties(Properties props) { props = super.getProperties(props); if (dbf == null) { return props; } String prefix = PropUtils.getScopedPropertyPrefix(this); props.put(prefix + RuleKeyColumnProperty, PropUtils.unnull(dbf.getColumnName(keyIndex))); if (this.op != null) { props.put(prefix + RuleOperatorProperty, this.op.getPropertyNotation()); } if (val != null) { props.put(prefix + RuleValueProperty, PropUtils.unnull(val.toString())); } if (displayMinScale != Float.MIN_VALUE) { props.put(prefix + RuleActionRender + "." + RuleActionMinScale, Float.toString(displayMinScale)); } if (displayMaxScale != Float.MAX_VALUE) { props.put(prefix + RuleActionRender + "." + RuleActionMaxScale, Float.toString(displayMaxScale)); } if (labelMinScale != Float.MIN_VALUE) { props.put(prefix + RuleActionLabel + "." + RuleActionMinScale, Float.toString(labelMinScale)); } if (labelMaxScale != Float.MAX_VALUE) { props.put(prefix + RuleActionLabel + "." + RuleActionMaxScale, Float.toString(labelMaxScale)); } if (tooltipIndicies != null && tooltipIndicies.length > 0) { props.put(prefix + RuleActionTooltip, getColumnNamesFromIndicies(tooltipIndicies)); } if (infolineIndicies != null && infolineIndicies.length > 0) { props.put(prefix + RuleActionInfoline, getColumnNamesFromIndicies(infolineIndicies)); } if (labelIndicies != null && labelIndicies.length > 0) { props.put(prefix + RuleActionLabel, getColumnNamesFromIndicies(labelIndicies)); } if (da != null) { props.put(prefix + RuleActionRender, Boolean.toString(true)); da.getProperties(props); } return props; } /** * Asks the Op class to evaluate the provided value against the Rules * value. * * @param val * @return */ public boolean evaluate(Object val) { return op.evaluate(this.val, val); } /** * Given a prefix + ActionProperty, get the column names listed as the * property value and figure out what the indexes of the columns are. * * @param actionProperty prefix + ActionProperty * @param props * @return int[] of column indexes in the dbf file reflecting the order * and number of column names listed as the property value. */ public int[] getIndicies(String actionProperty, Properties props) { int[] indicies = null; String actionLabel = props.getProperty(actionProperty); if (actionLabel != null) { Vector columnNames = PropUtils.parseSpacedMarkers(actionLabel); int numCols = columnNames.size(); indicies = new int[numCols]; for (int i = 0; i < numCols; i++) { String columnName = (String) columnNames.get(i); indicies[i] = dbf.getColumnIndexForName(columnName); } } return indicies; } /** * Given a prefix + ActionProperty, get the column names listed as the * property value and figure out what the indexes of the columns are. * * @param int[] of column indexes in the dbf file reflecting the order * and number of column names to be listed as a property value. * @return String for use in properties of space-separated column names. */ public String getColumnNamesFromIndicies(int[] indicies) { StringBuffer buf = new StringBuffer(); int numCols = indicies.length; for (int i = 0; i < numCols; i++) { buf.append(dbf.getColumnName(indicies[i]) + " "); } return buf.toString().trim(); } public DrawingAttributes getDa() { return da; } public void setDa(DrawingAttributes da) { this.da = da; } public float getDisplayMaxScale() { return displayMaxScale; } public void setDisplayMaxScale(float displayMaxScale) { this.displayMaxScale = displayMaxScale; } public float getDisplayMinScale() { return displayMinScale; } public void setDisplayMinScale(float displayMinScale) { this.displayMinScale = displayMinScale; } public int[] getInfolineIndicies() { return infolineIndicies; } public void setInfolineIndicies(int[] infolineIndicies) { this.infolineIndicies = infolineIndicies; } public int getKeyIndex() { return keyIndex; } public void setKeyIndex(int keyIndex) { this.keyIndex = keyIndex; } public int[] getLabelIndicies() { return labelIndicies; } public void setLabelIndicies(int[] labelIndicies) { this.labelIndicies = labelIndicies; } public float getLabelMaxScale() { return labelMaxScale; } public void setLabelMaxScale(float labelMaxScale) { this.labelMaxScale = labelMaxScale; } public float getLabelMinScale() { return labelMinScale; } public void setLabelMinScale(float labelMinScale) { this.labelMinScale = labelMinScale; } public Op getOp() { return op; } public void setOp(Op op) { this.op = op; } public int[] getTooltipIndicies() { return tooltipIndicies; } public void setTooltipIndicies(int[] tooltipIndicies) { this.tooltipIndicies = tooltipIndicies; } public Object getVal() { return val; } public void setVal(Object val) { this.val = val; } } /** * The Op class (operation) is used by the Rules to evaluate a rule key * value against a OMGraphics key value. * * @author dietrick */ public abstract static class Op { protected String description; protected String propertyNotation; /** * equals: equals */ public final static Op EQUALS = new Op("equals", "equals") { public boolean compare(int kvcr) { return kvcr == 0; } }; /** * lt: less than */ public final static Op LESS_THAN = new Op("less than", "lt") { public boolean compare(int kvcr) { return kvcr > 0; } }; /** * lte: less than or equals */ public final static Op LESS_THAN_EQUALS = new Op("less than or equals", "lte") { public boolean compare(int kvcr) { return kvcr == 0 || kvcr > 0; } }; /** * gt: greater than */ public final static Op GREATER_THAN = new Op("greater than", "gt") { public boolean compare(int kvcr) { return kvcr < 0; } }; /** * gte: greater than or equals */ public final static Op GREATER_THAN_EQUALS = new Op( "greater than or equals", "gte") { public boolean compare(int kvcr) { return kvcr == 0 || kvcr < 0; } }; /** * ne: not equals */ public final static Op NOT_EQUALS = new Op("not equals", "ne") { public boolean compare(int kvcr) { return kvcr != 0; } }; /** * noop: no-op (nothing passes rule) */ public final static Op NONE = new Op("no-op", "noop") { public boolean compare(int kvcr) { return false; } }; /** * all: all (everything passes rule) */ public final static Op ALL = new Op("all", "all") { public boolean compare(int kvcr) { return true; } }; /** * starts: starts with */ public final static Op STARTS_WITH = new Op("starts with", "starts") { public boolean compare(int kvcr) { return kvcr == 0; } public boolean evaluate(Object key, Object val) { return (val.toString()).startsWith(key.toString()); } }; /** * ends: ends with */ public final static Op ENDS_WITH = new Op("ends with", "ends") { public boolean compare(int kvcr) { return kvcr == 0; } public boolean evaluate(Object key, Object val) { return (val.toString()).endsWith(key.toString()); } }; public Op(String desc, String propNotation) { this.description = desc; this.propertyNotation = propNotation; } public boolean evaluate(Object key, Object val) { int compare = 0; if (key == null) { return true; } if (val instanceof String) { compare = ((String) key).compareTo(val.toString()); } else if (val instanceof Double) { if (key instanceof String) { java.text.DecimalFormat df = new java.text.DecimalFormat(); DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.ENGLISH); df.setDecimalFormatSymbols(dfs); try { key = new Double(df.parse((String) key).doubleValue()); } catch (java.text.ParseException pe) { } } compare = ((Double) key).compareTo((Double) val); } return compare(compare); } public abstract boolean compare(int keyValcompareResult); public static Op[] POSSIBLES = new Op[] { EQUALS, GREATER_THAN, GREATER_THAN_EQUALS, LESS_THAN, LESS_THAN_EQUALS, NOT_EQUALS, NONE, ALL, STARTS_WITH, ENDS_WITH }; public static Op resolve(String opString) { if (opString == null) { return null; } for (int i = 0; i < POSSIBLES.length; i++) { Op cur = POSSIBLES[i]; if (cur.propertyNotation.equalsIgnoreCase(opString)) { return cur; } } return null; } public String getDescription() { return description; } public String getPropertyNotation() { return propertyNotation; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -