- Timestamp:
- 04/07/14 08:42:08 (11 years ago)
- Location:
- trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLDocument.java
r1276 r1490 16 16 17 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IDialog; 18 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 18 19 19 20 /** … … 69 70 } 70 71 72 /* (non-Javadoc) 73 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 74 */ 75 @Override 76 public double getDistanceTo(IGUIElement otherElement) { 77 if (otherElement instanceof HTMLServer) { 78 // use the implementation provided by the server 79 return otherElement.getDistanceTo(this); 80 } 81 else if (otherElement instanceof HTMLDocument) { 82 if (this.getSpecification().getSimilarity(otherElement.getSpecification())) { 83 return DISTANCE_NONE; 84 } 85 else { 86 // use the implementation provided by the server to check if the document resists 87 // at least on the same server 88 return getServer().getDistanceTo(otherElement); 89 } 90 } 91 else if (otherElement instanceof HTMLPageElement) { 92 HTMLDocumentSpec documentSpec = 93 ((HTMLPageElementSpec) otherElement.getSpecification()).getPage(); 94 95 if (this.getSpecification().getSimilarity(documentSpec)) { 96 return DISTANCE_SAME_DOCUMENT; 97 } 98 else { 99 // use the implementation provided by the server to check if the document resists 100 // at least on the same server 101 return getServer().getDistanceTo(otherElement); 102 } 103 } 104 105 return DISTANCE_DISTINCT_SERVER; 106 } 107 71 108 /** 72 109 * <p> -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLGUIElement.java
r1264 r1490 26 26 * @author Patrick Harms 27 27 */ 28 public class HTMLGUIElement extends AbstractDefaultGUIElement {28 public abstract class HTMLGUIElement extends AbstractDefaultGUIElement { 29 29 30 30 /** … … 34 34 */ 35 35 private static final long serialVersionUID = 1L; 36 37 /** 38 * <p> 39 * the default distance value for different servers 40 * </p> 41 */ 42 protected static final double DISTANCE_DISTINCT_SERVER = 1.0; 43 44 /** 45 * <p> 46 * the default distance value for same server but different documents 47 * </p> 48 */ 49 protected static final double DISTANCE_SAME_SERVER = 0.75; 50 51 /** 52 * <p> 53 * the default distance value for same document but different page elements 54 * </p> 55 */ 56 protected static final double DISTANCE_SAME_DOCUMENT = 0.5; 57 58 /** 59 * <p> 60 * the default distance value for same parent div but different page elements 61 * </p> 62 */ 63 protected static final double DISTANCE_SAME_DIV = 0.2; 64 65 /** 66 * <p> 67 * the default distance value for identical elements 68 * </p> 69 */ 70 protected static final double DISTANCE_NONE = 0.0; 36 71 37 72 /** -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElement.java
r1276 r1490 14 14 15 15 package de.ugoe.cs.autoquest.plugin.html.guimodel; 16 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 16 18 17 19 /** … … 78 80 } 79 81 82 /* (non-Javadoc) 83 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 84 */ 85 @Override 86 public double getDistanceTo(IGUIElement otherElement) { 87 if ((otherElement instanceof HTMLServer) || (otherElement instanceof HTMLDocument)) { 88 // use the implementation provided by the server or document 89 return otherElement.getDistanceTo(this); 90 } 91 else if (otherElement instanceof HTMLPageElement) { 92 if (this == otherElement) { 93 return DISTANCE_NONE; 94 } 95 96 HTMLDocumentSpec documentSpec1 = 97 ((HTMLPageElementSpec) this.getSpecification()).getPage(); 98 HTMLDocumentSpec documentSpec2 = 99 ((HTMLPageElementSpec) otherElement.getSpecification()).getPage(); 100 101 if (!documentSpec1.getSimilarity(documentSpec2)) { 102 if (!documentSpec1.getServer().getSimilarity(documentSpec2.getServer())) { 103 return DISTANCE_DISTINCT_SERVER; 104 } 105 else { 106 return DISTANCE_SAME_SERVER; 107 } 108 } 109 else { 110 // check if they have the same parent div element. If so, they are very close. 111 // If not, they may be structured completely differently 112 IGUIElement parentDiv1 = this; 113 114 while (parentDiv1 != null) { 115 if ((parentDiv1 instanceof HTMLPageElement) && 116 ("div".equals(((HTMLPageElement) parentDiv1).getTagName()))) 117 { 118 break; 119 } 120 else { 121 parentDiv1 = parentDiv1.getParent(); 122 } 123 } 124 125 IGUIElement parentDiv2 = (HTMLPageElement) otherElement; 126 127 while (parentDiv2 != null) { 128 if ((parentDiv2 instanceof HTMLPageElement) && 129 ("div".equals(((HTMLPageElement) parentDiv2).getTagName()))) 130 { 131 break; 132 } 133 else { 134 parentDiv2 = parentDiv2.getParent(); 135 } 136 } 137 138 // a check for the identity of the objects is sufficient. That they resist on the 139 // same document was checked beforehand. So even a condense of the GUI model should 140 // not cause an invalid result here. 141 if ((parentDiv1 == parentDiv2) || 142 ((parentDiv1 != null) && (parentDiv1.equals(parentDiv2)))) 143 { 144 return DISTANCE_SAME_DIV; 145 } 146 else { 147 return DISTANCE_SAME_DOCUMENT; 148 } 149 } 150 } 151 152 return DISTANCE_DISTINCT_SERVER; 153 } 154 80 155 /* 81 156 * (non-Javadoc) -
trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLServer.java
r1276 r1490 16 16 17 17 import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame; 18 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 18 19 19 20 /** … … 86 87 } 87 88 89 /* (non-Javadoc) 90 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 91 */ 92 @Override 93 public double getDistanceTo(IGUIElement otherElement) { 94 if (otherElement instanceof HTMLServer) { 95 if (this.equals(otherElement)) { 96 return DISTANCE_NONE; 97 } 98 else { 99 return DISTANCE_DISTINCT_SERVER; 100 } 101 } 102 else if (otherElement instanceof HTMLDocument) { 103 if (this.equals(((HTMLDocument) otherElement).getServer())) { 104 return DISTANCE_SAME_SERVER; 105 } 106 else { 107 return DISTANCE_DISTINCT_SERVER; 108 } 109 } 110 else if (otherElement instanceof HTMLPageElement) { 111 HTMLServerSpec serverSpec = 112 ((HTMLPageElementSpec) otherElement.getSpecification()).getPage().getServer(); 113 114 if (this.getSpecification().getSimilarity(serverSpec)) { 115 return DISTANCE_SAME_SERVER; 116 } 117 else { 118 return DISTANCE_DISTINCT_SERVER; 119 } 120 } 121 122 return DISTANCE_DISTINCT_SERVER; 123 } 124 88 125 }
Note: See TracChangeset
for help on using the changeset viewer.