[950] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.plugin.html.guimodel;
|
---|
| 16 |
|
---|
[2146] | 17 | import de.ugoe.cs.autoquest.eventcore.IEventTargetSpec;
|
---|
[950] | 18 | import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
|
---|
| 19 |
|
---|
| 20 | /**
|
---|
| 21 | * <p>
|
---|
| 22 | * Base class for all HTML GUI elements.
|
---|
| 23 | * </p>
|
---|
| 24 | *
|
---|
| 25 | * @version 1.0
|
---|
| 26 | * @author Patrick Harms
|
---|
| 27 | */
|
---|
[1490] | 28 | public abstract class HTMLGUIElement extends AbstractDefaultGUIElement {
|
---|
[950] | 29 |
|
---|
| 30 | /**
|
---|
| 31 | * <p>
|
---|
| 32 | * Id for object serialization.
|
---|
| 33 | * </p>
|
---|
| 34 | */
|
---|
| 35 | private static final long serialVersionUID = 1L;
|
---|
[1490] | 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;
|
---|
[950] | 43 |
|
---|
| 44 | /**
|
---|
| 45 | * <p>
|
---|
[1490] | 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;
|
---|
| 71 |
|
---|
| 72 | /**
|
---|
| 73 | * <p>
|
---|
[950] | 74 | * Constructor. Creates a new HTMLGUIElement.
|
---|
| 75 | * </p>
|
---|
| 76 | *
|
---|
| 77 | * @param specification
|
---|
| 78 | * specification of created GUI element
|
---|
| 79 | * @param parent
|
---|
| 80 | * parent of the created GUI element; null means that the element is a top-level
|
---|
| 81 | * window
|
---|
| 82 | */
|
---|
| 83 | public HTMLGUIElement(HTMLGUIElementSpec specification, HTMLGUIElement parent) {
|
---|
| 84 | super(specification, parent);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /*
|
---|
| 88 | * (non-Javadoc)
|
---|
| 89 | *
|
---|
| 90 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
|
---|
| 91 | */
|
---|
| 92 | @Override
|
---|
| 93 | public String getPlatform() {
|
---|
| 94 | return "HTML";
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /*
|
---|
| 98 | * (non-Javadoc)
|
---|
| 99 | *
|
---|
[1264] | 100 | * @see java.lang.Object#toString()
|
---|
| 101 | */
|
---|
| 102 | @Override
|
---|
| 103 | public String toString() {
|
---|
| 104 | return super.getSpecification().toString();
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /*
|
---|
| 108 | * (non-Javadoc)
|
---|
| 109 | *
|
---|
[950] | 110 | * @see
|
---|
| 111 | * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore
|
---|
| 112 | * .guimodel.IGUIElementSpec)
|
---|
| 113 | */
|
---|
| 114 | @Override
|
---|
[2146] | 115 | public void updateSpecification(IEventTargetSpec updateSpecification) {
|
---|
| 116 | // nothing to do. There is no need for handle things such as name changes, etc.
|
---|
[950] | 117 | }
|
---|
| 118 |
|
---|
| 119 | /*
|
---|
| 120 | * (non-Javadoc)
|
---|
| 121 | *
|
---|
| 122 | * @see java.lang.Object#toString()
|
---|
| 123 | */
|
---|
| 124 | @Override
|
---|
| 125 | public String getStringIdentifier() {
|
---|
| 126 | String str = this.toString();
|
---|
| 127 | if (getParent() != null) {
|
---|
[994] | 128 | return str + "<-" + getParent().getStringIdentifier();
|
---|
[950] | 129 | }
|
---|
| 130 | return str;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * <p>
|
---|
| 135 | * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
|
---|
| 136 | * </p>
|
---|
| 137 | *
|
---|
| 138 | * @return short element descriptor
|
---|
| 139 | */
|
---|
| 140 | protected String getElementDescriptor() {
|
---|
| 141 | return "Default";
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | }
|
---|