Changeset 2146 for trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementGroup.java
- Timestamp:
- 05/19/17 11:31:29 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/guimodel/GUIElementGroup.java
- Property svn:mime-type set to text/plain
r1876 r2146 1 // Copyright 201 2Georg-August-Universität Göttingen, Germany1 // Copyright 2015 Georg-August-Universität Göttingen, Germany 2 2 // 3 3 // Licensed under the Apache License, Version 2.0 (the "License"); … … 15 15 package de.ugoe.cs.autoquest.eventcore.guimodel; 16 16 17 import java.util.Collections; 18 import java.util.LinkedList; 19 import java.util.List; 17 import de.ugoe.cs.autoquest.eventcore.HierarchicalEventTargetGroup; 18 import de.ugoe.cs.autoquest.eventcore.IEventTargetSpec; 20 19 21 20 /** 22 21 * <p> 23 * This class is a dummy GUI element to represent groups of GUI elements. A group of GUI elements 24 * can be integrated in any GUI model using the method 25 * {@link GUIModel#groupGUIElements(java.util.List, String)}. A group has the same behavior as 26 * any other parent GUI element. 22 * implementation of event target groups for GUI elements 27 23 * </p> 28 24 * 29 25 * @author Patrick Harms 30 26 */ 31 public class GUIElementGroup extends AbstractDefaultGUIElement {27 public class GUIElementGroup extends HierarchicalEventTargetGroup implements IGUIElement { 32 28 33 /** 34 * <p> 35 * default serial version UID 36 * </p> 37 */ 29 /** */ 38 30 private static final long serialVersionUID = 1L; 39 31 40 /** 41 * the list of grouped GUIElements 42 */ 43 private List<IGUIElement> groupedGUIElements = new LinkedList<IGUIElement>(); 32 /** the internal fake event target specification */ 33 private GroupSpecification groupSpecification; 34 35 /** stores if the usage of the group was observed (just to match the implemented interface */ 36 private boolean usageObserved = false; 44 37 45 38 /** … … 48 41 * </p> 49 42 * 50 * @param groupName the name of the GUI element group51 * @param parent the optional parent GUI element of the group52 * @param guiModelthe GUI model to which the group will belong43 * @param groupName the name of the GUI element group 44 * @param parent the optional parent GUI element of the group 45 * @param eventTargetModel the GUI model to which the group will belong 53 46 */ 54 public GUIElementGroup(String groupName, IGUIElement parent, GUIModel guiModel) { 55 super(new GroupSpecification(groupName), parent); 56 super.setGUIModel(guiModel); 47 public GUIElementGroup(String groupName, 48 IGUIElement parent, 49 GUIModel guiModel) 50 { 51 super(groupName, parent, guiModel); 52 groupSpecification = new GroupSpecification(groupName); 57 53 } 58 54 59 55 /* (non-Javadoc) 60 * @see de.ugoe.cs.autoquest.eventcore. guimodel.IGUIElement#updateSpecification(IGUIElementSpec)56 * @see de.ugoe.cs.autoquest.eventcore.AbstractDefaultHierarchicalEventTarget#getSpecification() 61 57 */ 62 58 @Override 63 public final void updateSpecification(IGUIElementSpec furtherSpec) { 64 // do nothing 65 } 66 67 /* (non-Javadoc) 68 * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform() 69 */ 70 @Override 71 public String getPlatform() { 72 return "none"; 59 public IGUIElementSpec getSpecification() { 60 return groupSpecification; 73 61 } 74 62 … … 78 66 @Override 79 67 public String getStringIdentifier() { 80 return ((GroupSpecification) super.getSpecification()).name;68 return groupSpecification.name; 81 69 } 82 70 83 71 /* (non-Javadoc) 84 * @see java.lang.Object#toString()72 * @see de.ugoe.cs.autoquest.eventcore.AbstractDefaultHierarchicalEventTarget#getParent() 85 73 */ 86 74 @Override 87 public String toString() {88 return getStringIdentifier();75 public IGUIElement getParent() { 76 return (IGUIElement) super.getParent(); 89 77 } 90 78 … … 98 86 99 87 /* (non-Javadoc) 88 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getGUIModel() 89 */ 90 @Override 91 public GUIModel getGUIModel() { 92 return (GUIModel) super.getEventTargetModel(); 93 } 94 95 /* (non-Javadoc) 96 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#isUsed() 97 */ 98 @Override 99 public boolean isUsed() { 100 return usageObserved; 101 } 102 103 /* (non-Javadoc) 104 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#markUsed() 105 */ 106 @Override 107 public void markUsed() { 108 usageObserved = true; 109 } 110 111 /* (non-Javadoc) 100 112 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 101 113 */ … … 105 117 return 0.0; 106 118 } 107 else if ( super.getParent() != null) {108 return super.getParent().getDistanceTo(otherElement);119 else if (getParent() != null) { 120 return getParent().getDistanceTo(otherElement); 109 121 } 110 122 else { 111 123 return 1.0; 112 124 } 113 }114 115 /**116 * <p>117 * returns the list of GUI elements belonging to this group.118 * </p>119 *120 * @return the GUI elements belonging to this group121 *122 */123 public List<IGUIElement> getGroupedElements() {124 return Collections.unmodifiableList(groupedGUIElements);125 }126 127 /**128 * <p>129 * allows adding a new GUI element to the group130 * </p>131 *132 * @param guiElement the new member of the group133 */134 void addToGroup(IGUIElement guiElement) {135 this.groupedGUIElements.add(guiElement);136 125 } 137 126 … … 174 163 175 164 /* (non-Javadoc) 165 * @see de.ugoe.cs.autoquest.eventcore.IEventTargetSpec#getSimilarity(IEventTargetSpec) 166 */ 167 @Override 168 public boolean getSimilarity(IEventTargetSpec other) { 169 return 170 (other instanceof GroupSpecification) && 171 name.equals(((GroupSpecification) other).name); 172 } 173 174 /* (non-Javadoc) 176 175 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType() 177 176 */ … … 189 188 } 190 189 191 /* (non-Javadoc)192 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)193 */194 @Override195 public boolean getSimilarity(IGUIElementSpec other) {196 return197 (other instanceof GroupSpecification) &&198 name.equals(((GroupSpecification) other).name);199 }200 201 190 } 202 203 191 }
Note: See TracChangeset
for help on using the changeset viewer.