1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.reportcalculator.expression.Expression; 4 import com.calipso.reportgenerator.reportcalculator.expression.Context; 5 6 import java.awt.*; 7 10 public class ColorCondition { 11 12 private Expression expression; 13 private Color color; 14 private MetricState metricState; 15 16 22 public ColorCondition(Expression expression, Color color, MetricState metricState) { 23 this.expression = expression; 24 this.color = color; 25 this.metricState = metricState; 26 } 27 31 public MetricState getMetricState() { 32 return metricState; 33 } 34 35 39 public Expression getExpression() { 40 return expression; 41 } 42 43 47 48 public void setExpression(Expression expression) { 49 this.expression = expression; 50 } 51 52 56 public Color getColor() { 57 return color; 58 } 59 60 64 public void setColor(Color color) { 65 this.color = color; 66 } 67 68 72 public String getMetricName() { 73 return getMetricState().getName(); 74 } 75 76 81 private Context getContext(Object value) { 82 Context context = new Context(); 83 context.add("VALUE", value); 84 return context; 85 } 86 87 92 public boolean matches(Object value) { 93 if(getExpression() != null){ 94 return getExpression().valueIn(getContext(value)); 95 } 96 return false; 97 } 98 99 103 104 public String toString(){ 105 if(getExpression() !=null){ 106 String str = getExpression().toString(); 107 return str.replaceAll("VALUE", getMetricCaption()); 108 } 109 else{ 110 return null; 111 } 112 } 113 114 118 private String getMetricCaption() { 119 return getMetricState().getCaption(); 120 } 121 } 122 | Popular Tags |