Commit ee22526e264b626a27048e04130052faf6776c46

Authored by lyandro.santana
1 parent 3f5909dd

Apresentação

git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10341 c2178572-b5ca-4887-91d2-9e3a90c7d55b
src/main/java/br/com/checker/emag/core/PresentationEvaluation.java
1 1 package br.com.checker.emag.core;
2 2  
  3 +import java.awt.Color;
3 4 import java.util.ArrayList;
4 5 import java.util.List;
5 6  
  7 +import fj.data.hlist.HPre.HBool;
6 8 import net.htmlparser.jericho.Attribute;
7 9 import net.htmlparser.jericho.Element;
8 10 import net.htmlparser.jericho.Source;
  11 +import br.com.checker.emag.AvaliadorContraste;
9 12 import br.com.checker.emag.Occurrence;
10 13 import br.com.checker.emag.OccurrenceClassification;
11 14 import br.com.checker.emag.core.SpecificRecommendation.PresentationRecommendation;
... ... @@ -55,32 +58,67 @@ public class PresentationEvaluation extends Evaluation{
55 58 private List<Occurrence> checkRecommendation29() {
56 59 List<Occurrence> occurrences = new ArrayList<Occurrence>();
57 60  
  61 + AvaliadorContraste avaliadorContraste = new AvaliadorContraste();
  62 + Color color = null;
  63 +
58 64 boolean temBgcolor = false;
59 65 for (Element bgcolor : getDocument().getAllElements("body")) {
60 66 Attribute bgc = bgcolor.getAttributes().get("bgcolor");
61 67 if(bgc != null){
62   - occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  68 +
  69 + int rgb = Integer.parseInt(bgc.getValue().replaceFirst("^#",""), 16);
  70 + color = new Color(rgb);
  71 + avaliadorContraste.setCores(color, color);
  72 + avaliadorContraste.avaliar();
  73 +
  74 + if(avaliadorContraste.getContraste() < new Double("4.5"))
  75 + occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  76 +
63 77 temBgcolor = true;
64 78 }
65 79 }
66 80 for (Element bgcolor : getDocument().getAllElements("table")) {
67 81 Attribute bgc = bgcolor.getAttributes().get("bgcolor");
68 82 if(bgc != null){
69   - occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  83 +
  84 + int rgb = Integer.parseInt(bgc.getValue().replaceFirst("^#",""), 16);
  85 + color = new Color(rgb);
  86 + avaliadorContraste.setCores(color, color);
  87 + avaliadorContraste.avaliar();
  88 +
  89 + if(avaliadorContraste.getContraste() < new Double("4.5"))
  90 + occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  91 +
70 92 temBgcolor = true;
71 93 }
72 94 }
73 95 for (Element bgcolor : getDocument().getAllElements("td")) {
74 96 Attribute bgc = bgcolor.getAttributes().get("bgcolor");
75 97 if(bgc != null){
76   - occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  98 +
  99 + int rgb = Integer.parseInt(bgc.getValue().replaceFirst("^#",""), 16);
  100 + color = new Color(rgb);
  101 + avaliadorContraste.setCores(color, color);
  102 + avaliadorContraste.avaliar();
  103 +
  104 + if(avaliadorContraste.getContraste() < new Double("4.5"))
  105 + occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  106 +
77 107 temBgcolor = true;
78 108 }
79 109 }
80 110 for (Element bgcolor : getDocument().getAllElements("tr")) {
81 111 Attribute bgc = bgcolor.getAttributes().get("bgcolor");
82 112 if(bgc != null){
83   - occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  113 +
  114 + int rgb = Integer.parseInt(bgc.getValue().replaceFirst("^#",""), 16);
  115 + color = new Color(rgb);
  116 + avaliadorContraste.setCores(color, color);
  117 + avaliadorContraste.avaliar();
  118 +
  119 + if(avaliadorContraste.getContraste() < new Double("4.5"))
  120 + occurrences.add(buildOccurrence("4.1", true, bgcolor.toString(), bgcolor,"1"));
  121 +
84 122 temBgcolor = true;
85 123 }
86 124 }
... ...