Changeset 2146 for trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/HierarchicalEventTargetGroup.java
- Timestamp:
- 05/19/17 11:31:29 (7 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/HierarchicalEventTargetGroup.java
r2120 r2146 13 13 // limitations under the License. 14 14 15 package de.ugoe.cs.autoquest.eventcore .guimodel;15 package de.ugoe.cs.autoquest.eventcore; 16 16 17 17 import java.util.Collections; … … 21 21 /** 22 22 * <p> 23 * This class is a dummy GUI element to represent groups of GUI elements. A group of GUI elements24 * can be integrated in any GUImodel using the method25 * {@link GUIModel#groupGUIElements(java.util.List, String)}. A group has the same behavior as26 * any other parent GUI element.23 * This class is a dummy hierarchical event target to represent groups of event targets. A group of 24 * event targets can be integrated in any hierarchical event target model using the method 25 * {@link HierarchicalEventTargetModel#groupEventTargets(List, String, IEventTargetFactory)}. A 26 * group has the same behavior as any other parent hierarchical event target. 27 27 * </p> 28 28 * 29 29 * @author Patrick Harms 30 30 */ 31 public class GUIElementGroup extends AbstractDefaultGUIElement {31 public class HierarchicalEventTargetGroup extends AbstractDefaultHierarchicalEventTarget { 32 32 33 33 /** … … 39 39 40 40 /** 41 * the list of grouped GUIElements41 * the list of grouped event targets 42 42 */ 43 private List<IGUIElement> groupedGUIElements = new LinkedList<IGUIElement>(); 43 private List<IHierarchicalEventTarget> groupedEventTargets = 44 new LinkedList<IHierarchicalEventTarget>(); 44 45 45 46 /** 46 47 * <p> 47 * instantiates a GUI element group with a name and its optional parent GUI element48 * instantiates an event target group with a name and its optional parent event target 48 49 * </p> 49 50 * 50 * @param groupName the name of the GUI element group51 * @param parent the optional parent GUI element of the group52 * @param guiModel the GUImodel to which the group will belong51 * @param groupName the name of the event target group 52 * @param parent the optional parent event target of the group 53 * @param eventTargetModel the event target model to which the group will belong 53 54 */ 54 public GUIElementGroup(String groupName, IGUIElement parent, GUIModel guiModel) { 55 public HierarchicalEventTargetGroup(String groupName, 56 IHierarchicalEventTarget parent, 57 HierarchicalEventTargetModel<?> eventTargetModel) 58 { 55 59 super(new GroupSpecification(groupName), parent); 56 super.setGUIModel(guiModel); 57 } 58 59 /* (non-Javadoc) 60 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(IGUIElementSpec) 61 */ 62 @Override 63 public final void updateSpecification(IGUIElementSpec furtherSpec) { 64 // do nothing 60 super.setEventTargetModel(eventTargetModel); 65 61 } 66 62 … … 90 86 91 87 /* (non-Javadoc) 92 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getView()88 * @see IHierarchicalEventTarget#updateSpecification(IEventTargetSpec) 93 89 */ 94 90 @Override 95 public IGUIView getView() { 96 return null; 97 } 98 99 /* (non-Javadoc) 100 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement) 101 */ 102 @Override 103 public double getDistanceTo(IGUIElement otherElement) { 104 if (equals(otherElement)) { 105 return 0.0; 106 } 107 else if (super.getParent() != null) { 108 return super.getParent().getDistanceTo(otherElement); 109 } 110 else { 111 return 1.0; 112 } 91 public void updateSpecification(IEventTargetSpec furtherSpec) { 92 // do nothing 113 93 } 114 94 115 95 /** 116 96 * <p> 117 * returns the list of GUI elements belonging to this group.97 * returns the list of event targets belonging to this group. 118 98 * </p> 119 99 * 120 * @return the GUI elements belonging to this group100 * @return the event targets belonging to this group 121 101 * 122 102 */ 123 public List<I GUIElement> getGroupedElements() {124 return Collections.unmodifiableList(grouped GUIElements);103 public List<IHierarchicalEventTarget> getGroupedEventTargets() { 104 return Collections.unmodifiableList(groupedEventTargets); 125 105 } 126 106 127 107 /** 128 108 * <p> 129 * allows adding a new GUI element to the group109 * allows adding a new event target to the group 130 110 * </p> 131 111 * 132 * @param guiElement the new member of the group112 * @param eventTarget the new member of the group 133 113 */ 134 void addToGroup(I GUIElement guiElement) {135 this.grouped GUIElements.add(guiElement);114 void addToGroup(IHierarchicalEventTarget eventTarget) { 115 this.groupedEventTargets.add(eventTarget); 136 116 } 137 117 138 118 /** 139 119 * <p> 140 * internally required GUI element specification for a GUI element group. This is just a wrapper141 * for a name of a GUI element group120 * internally required event target specification for an event target group. This is just a 121 * wrapper for a name of an event target group 142 122 * </p> 143 123 * 144 124 * @author Patrick Harms 145 125 */ 146 private static class GroupSpecification implements I GUIElementSpec {126 private static class GroupSpecification implements IEventTargetSpec { 147 127 148 128 /** … … 155 135 /** 156 136 * <p> 157 * the name of the GUI element group represented by this specification137 * the name of the event target group represented by this specification 158 138 * </p> 159 139 */ … … 174 154 175 155 /* (non-Javadoc) 176 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType()156 * @see IEventTargetSpec#getSimilarity(IEventTargetSpec) 177 157 */ 178 158 @Override 179 public String getType() { 180 return "GUI element group"; 181 } 182 183 /* (non-Javadoc) 184 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy() 185 */ 186 @Override 187 public String[] getTypeHierarchy() { 188 return new String[] { getType() }; 189 } 190 191 /* (non-Javadoc) 192 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec) 193 */ 194 @Override 195 public boolean getSimilarity(IGUIElementSpec other) { 159 public boolean getSimilarity(IEventTargetSpec other) { 196 160 return 197 161 (other instanceof GroupSpecification) &&
Note: See TracChangeset
for help on using the changeset viewer.