Changeset 1490 for trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageElement.java
- Timestamp:
- 04/07/14 08:42:08 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.