Ignore:
Timestamp:
08/23/12 10:42:41 (12 years ago)
Author:
sherbold
Message:
  • started changing the similarity structure of the GUI model. The equality is now absolute (i.e., boolean instead of an int indicating the degree). Also, lists of equally observed name/hash combinations are now stored. There still seem to be mistakes, however, the structural changes to the interfaces warrant a commit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/guimodel/JFCGUIElementSpec.java

    r588 r589  
    55// Copyright : Patrick Harms, 2012 
    66package de.ugoe.cs.quest.plugin.jfc.guimodel; 
     7 
     8import java.util.LinkedList; 
     9import java.util.List; 
     10 
     11import org.apache.commons.collections15.CollectionUtils; 
    712 
    813import de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec; 
     
    1924 
    2025    /** */ 
    21     private String name = null; 
     26    private List<String> name = new LinkedList<String>(); 
    2227     
    2328    /** */ 
     
    3136     
    3237    /** */ 
    33     private String elementHash = null; 
     38    private List<String> elementHash = new LinkedList<String>(); 
    3439     
    3540    /* (non-Javadoc) 
     
    3742     */ 
    3843    @Override 
    39     public int getSimilarity(IGUIElementSpec other) { 
     44    public boolean getSimilarity(IGUIElementSpec other) { 
    4045        if (this == other) 
    4146        { 
    42             return 100; 
     47            return true; 
    4348        } 
    4449         
    4550        if (!(other instanceof JFCGUIElementSpec)) 
    4651        { 
    47             return 0; 
     52            return false; 
    4853        } 
    4954         
    5055        JFCGUIElementSpec otherSpec = (JFCGUIElementSpec) other; 
    51         int result = 0; 
    52  
    53         if ((type == otherSpec.type) || ((type != null) && (type.equals(otherSpec.type)))) { 
    54             result += 50; 
    55         } 
    56  
    57         if ((icon == otherSpec.icon) || ((icon != null) && (icon.equals(otherSpec.icon)))) { 
    58             result += 10; 
    59         } 
    60  
    61         if (index == otherSpec.index) { 
    62             result += 10; 
    63         } 
    64  
    65         if ((name == otherSpec.name) || ((name != null) && (name.equals(otherSpec.name)))) { 
    66             result += 15; 
    67         } 
    68  
    69         if (elementHash == otherSpec.elementHash || ((elementHash!=null) && elementHash.equals(otherSpec.elementHash))) { 
    70             result += 15; 
     56         
     57        boolean retVal = false; 
     58         
     59        boolean titleEqual = CollectionUtils.containsAny(name, otherSpec.name); 
     60        boolean hashEqual = CollectionUtils.containsAny(elementHash, otherSpec.elementHash); 
     61         
     62        if( type.equals("Class") ) { 
     63            retVal = type.equals(otherSpec.type) && (titleEqual || hashEqual); 
     64        } else { 
     65            retVal = type.equals(otherSpec.type) && index==otherSpec.index && (titleEqual || hashEqual); 
    7166        } 
    7267         
    73         return result; 
     68        return retVal; 
    7469    } 
    7570 
     
    10297     */ 
    10398    public String getName() { 
    104         return name; 
     99        // TODO for now always returns first matched name 
     100        if( name.isEmpty() ) { 
     101            return null; 
     102        } 
     103        return name.get(0); 
    105104    } 
    106105 
     
    130129     */ 
    131130    public String getElementHash() { 
    132         return elementHash; 
     131        // TODO for now always returns the first hash value 
     132        if( elementHash.isEmpty() ) { 
     133            return null; 
     134        } 
     135        return elementHash.get(0); 
    133136    } 
    134137 
     
    137140     */ 
    138141    public void setName(String name) { 
    139         this.name = name; 
     142        if( !this.name.contains(name) && name!=null ) { 
     143            this.name.add(name); 
     144        } 
    140145    } 
    141146 
     
    165170     */ 
    166171    public void setElementHash(String elementHash) { 
    167         this.elementHash = elementHash; 
     172        if( !this.elementHash.contains(elementHash) ) { 
     173            this.elementHash.add(elementHash); 
     174        } 
    168175    } 
    169176 
Note: See TracChangeset for help on using the changeset viewer.