package jp.naist.se.stigmata.birthmarks;\r
\r
+/*\r
+ * $Id$\r
+ */\r
+\r
import jp.naist.se.stigmata.BirthmarkElement;\r
\r
+/**\r
+ * \r
+ * @author Haruaki Tamada\r
+ * @version $Revision$ $Date$\r
+ */\r
public class FrequencyBirthmarkElement extends BirthmarkElement implements ValueCountable{\r
private static final long serialVersionUID = 4454345943098520436L;\r
\r
private static final List<Criterion> CRITERIA = new ArrayList<Criterion>();\r
\r
private int threshold = 0;\r
- private Target target;\r
+ private FilterTarget target;\r
private String birthmarkType;\r
\r
static{\r
\r
switch(getCriterion()){\r
case GREATER_EQUALS:\r
- flag = (target == Target.BOTH_TARGET && elem1 >= threshold && elem2 >= threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 >= threshold || elem2 >= threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 >= threshold && elem2 >= threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 >= threshold || elem2 >= threshold));\r
break;\r
case GREATER_THAN:\r
- flag = (target == Target.BOTH_TARGET && elem1 > threshold && elem2 > threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 > threshold || elem2 > threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 > threshold && elem2 > threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 > threshold || elem2 > threshold));\r
break;\r
case LESS_EQUALS:\r
- flag = (target == Target.BOTH_TARGET && elem1 <= threshold && elem2 <= threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 <= threshold || elem2 <= threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 <= threshold && elem2 <= threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 <= threshold || elem2 <= threshold));\r
break;\r
case LESS_THAN:\r
- flag = (target == Target.BOTH_TARGET && elem1 < threshold && elem2 < threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 < threshold || elem2 < threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 < threshold && elem2 < threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 < threshold || elem2 < threshold));\r
break;\r
case EQUALS_AS:\r
- flag = (target == Target.BOTH_TARGET && elem1 == threshold && elem2 == threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 == threshold || elem2 == threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 == threshold && elem2 == threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 == threshold || elem2 == threshold));\r
break;\r
case NOT_EQUALS_AS:\r
- flag = (target == Target.BOTH_TARGET && elem1 != threshold && elem2 != threshold) ||\r
- (target == Target.ONE_OF_TARGET && (elem1 != threshold || elem2 != threshold));\r
+ flag = (target == FilterTarget.BOTH_TARGET && elem1 != threshold && elem2 != threshold) ||\r
+ (target == FilterTarget.ONE_OF_TARGET && (elem1 != threshold || elem2 != threshold));\r
break;\r
default:\r
flag = false;\r
}\r
\r
public boolean isFiltered(ComparisonPair pair){\r
- if(target == Target.BOTH_TARGET || target == Target.ONE_OF_TARGET){\r
+ if(target == FilterTarget.BOTH_TARGET || target == FilterTarget.ONE_OF_TARGET){\r
return isFilteredTwo(pair);\r
}\r
boolean flag = false;\r
if(pair.getTarget1().hasBirthmark(type) && pair.getTarget2().hasBirthmark(type)){\r
int total = 0;\r
int threshold = getThreshold();\r
- if(target == Target.TARGET_1){\r
+ if(target == FilterTarget.TARGET_1){\r
total = pair.getTarget1().getBirthmark(type).getElementCount();\r
}\r
- if(target == Target.TARGET_2){\r
+ if(target == FilterTarget.TARGET_2){\r
total = pair.getTarget2().getBirthmark(type).getElementCount();\r
}\r
switch(getCriterion()){\r
this.threshold = threshold;\r
}\r
\r
- public Target getTarget(){\r
+ public FilterTarget getTarget(){\r
return target;\r
}\r
\r
- public void setTarget(Target target){\r
+ public void setTarget(FilterTarget target){\r
this.target = target;\r
}\r
\r
try{\r
Object value = entry.getValue();\r
if(entry.getKey().equals("target")){\r
- value = Target.valueOf(String.valueOf(value));\r
+ value = FilterTarget.valueOf(String.valueOf(value));\r
}\r
BeanUtils.setProperty(filter, entry.getKey(), value);\r
}catch(IllegalAccessException e){\r
*/\r
\r
/**\r
+ * This enum represents filter target.\r
+ * \r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
*/\r
-public enum Target{\r
+public enum FilterTarget{\r
TARGET_1, TARGET_2, BOTH_TARGET, ONE_OF_TARGET,\r
}
\ No newline at end of file
CRITERIA.add(Criterion.MATCH);\r
CRITERIA.add(Criterion.NOT_MATCH);\r
};\r
- private Target target = Target.BOTH_TARGET;\r
+ private FilterTarget target = FilterTarget.BOTH_TARGET;\r
private String value;\r
\r
public TargetNameComparisonPairFilter(ComparisonPairFilterSpi service){\r
String v = value;\r
if(v == null) v = "";\r
boolean flag;\r
- if(getTarget() == Target.TARGET_1){\r
+ if(getTarget() == FilterTarget.TARGET_1){\r
flag = checkMatch(pair.getTarget1().getName(), v);\r
}\r
- else if(getTarget() == Target.TARGET_2){\r
+ else if(getTarget() == FilterTarget.TARGET_2){\r
flag = checkMatch(pair.getTarget2().getName(), v);\r
}\r
else{\r
this.value = value;\r
}\r
\r
- public Target getTarget(){\r
+ public FilterTarget getTarget(){\r
return target;\r
}\r
\r
- public void setTarget(Target target){\r
+ public void setTarget(FilterTarget target){\r
this.target = target;\r
}\r
\r
}\r
\r
boolean flag;\r
- if(getTarget() == Target.BOTH_TARGET){\r
+ if(getTarget() == FilterTarget.BOTH_TARGET){\r
flag = flag1 && flag2;\r
}\r
else{\r
};\r
\r
private int threshold = 0;\r
- private Target target;\r
+ private FilterTarget target;\r
\r
public TotalElementCountComparisonPairFilter(ComparisonPairFilterSpi service){\r
super(service);\r
\r
public boolean isFiltered(ComparisonPair pair){\r
boolean flag;\r
- if(getTarget() == Target.TARGET_1){\r
+ if(getTarget() == FilterTarget.TARGET_1){\r
flag = checkFiltered(pair.getTarget1().getSumOfElementCount());\r
}\r
- else if(getTarget() == Target.TARGET_2){\r
+ else if(getTarget() == FilterTarget.TARGET_2){\r
flag = checkFiltered(pair.getTarget2().getSumOfElementCount());\r
}\r
else{\r
flag2 = false;\r
break;\r
}\r
- return (getTarget() == Target.BOTH_TARGET && flag1 && flag2) ||\r
- (getTarget() == Target.ONE_OF_TARGET && (flag1 || flag2));\r
+ return (getTarget() == FilterTarget.BOTH_TARGET && flag1 && flag2) ||\r
+ (getTarget() == FilterTarget.ONE_OF_TARGET && (flag1 || flag2));\r
}\r
\r
private boolean checkFiltered(int total){\r
this.threshold = threshold;\r
}\r
\r
- public Target getTarget(){\r
+ public FilterTarget getTarget(){\r
return target;\r
}\r
\r
- public void setTarget(Target target){\r
+ public void setTarget(FilterTarget target){\r
this.target = target;\r
}\r
\r
import jp.naist.se.stigmata.ComparisonPairFilter;\r
import jp.naist.se.stigmata.filter.BirthmarkElementCountComparisonPairFilter;\r
import jp.naist.se.stigmata.filter.BirthmarkElementCountComparisonPairFilterService;\r
-import jp.naist.se.stigmata.filter.Target;\r
+import jp.naist.se.stigmata.filter.FilterTarget;\r
import jp.naist.se.stigmata.spi.BirthmarkSpi;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
import jp.naist.se.stigmata.ui.swing.BirthmarkServiceListCellRenderer;\r
public void resetComponents(){\r
threshold.setText("");\r
criterionType.setSelectedIndex(0);\r
- targetType.setSelectedItem(getDisplayTarget(Target.BOTH_TARGET));\r
+ targetType.setSelectedItem(getDisplayTarget(FilterTarget.BOTH_TARGET));\r
}\r
\r
@Override\r
\r
import jp.naist.se.stigmata.ComparisonPairFilter;\r
import jp.naist.se.stigmata.filter.Criterion;\r
-import jp.naist.se.stigmata.filter.Target;\r
+import jp.naist.se.stigmata.filter.FilterTarget;\r
import jp.naist.se.stigmata.ui.swing.Messages;\r
\r
/**\r
*/\r
public abstract class ComparisonPairFilterPane extends JPanel{\r
private Map<String, Criterion> criterionMap = new HashMap<String, Criterion>();\r
- private Map<String, Target> targetMap = new HashMap<String, Target>();\r
+ private Map<String, FilterTarget> targetMap = new HashMap<String, FilterTarget>();\r
\r
public abstract String[] getErrors();\r
\r
public JComboBox createTargetBox(){\r
JComboBox combo = new JComboBox();\r
combo.setEditable(false);\r
- for(Target target: Target.values()){\r
+ for(FilterTarget target: FilterTarget.values()){\r
String value = Messages.getString("target." + target.name());\r
combo.addItem(value);\r
targetMap.put(value, target);\r
return combo;\r
}\r
\r
- public Target getTarget(String value){\r
+ public FilterTarget getTarget(String value){\r
return targetMap.get(value);\r
}\r
\r
- public String getDisplayTarget(Target target){\r
+ public String getDisplayTarget(FilterTarget target){\r
return Messages.getString("target." + target.name());\r
}\r
\r
import javax.swing.JTextField;\r
\r
import jp.naist.se.stigmata.ComparisonPairFilter;\r
-import jp.naist.se.stigmata.filter.Target;\r
+import jp.naist.se.stigmata.filter.FilterTarget;\r
import jp.naist.se.stigmata.filter.TargetNameComparisonPairFilter;\r
import jp.naist.se.stigmata.filter.TargetNameComparisonPairFilterService;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
public void resetComponents(){\r
value.setText("");\r
criterionType.setSelectedIndex(0);\r
- targetType.setSelectedItem(getDisplayTarget(Target.BOTH_TARGET));\r
+ targetType.setSelectedItem(getDisplayTarget(FilterTarget.BOTH_TARGET));\r
}\r
\r
@Override\r
import javax.swing.JTextField;\r
\r
import jp.naist.se.stigmata.ComparisonPairFilter;\r
-import jp.naist.se.stigmata.filter.Target;\r
+import jp.naist.se.stigmata.filter.FilterTarget;\r
import jp.naist.se.stigmata.filter.TotalElementCountComparisonPairFilter;\r
import jp.naist.se.stigmata.filter.TotalElementCountComparisonPairFilterService;\r
import jp.naist.se.stigmata.spi.ComparisonPairFilterSpi;\r
public void resetComponents(){\r
threshold.setText("");\r
criterionType.setSelectedIndex(0);\r
- targetType.setSelectedItem(getDisplayTarget(Target.BOTH_TARGET));\r
+ targetType.setSelectedItem(getDisplayTarget(FilterTarget.BOTH_TARGET));\r
}\r
\r
@Override\r