//   Copyright 2012 Georg-August-Universität Göttingen, Germany
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.

package de.ugoe.cs.autoquest.eventcore.guimodel;

import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTarget;

/**
 * <p>
 * Common interface for all GUI elements.
 * </p>
 * 
 * @version 1.0
 * @author Patrick Harms
 */
public interface IGUIElement extends IHierarchicalEventTarget {

    /**
     * <p>
     * Returns the specification of the GUI element.
     * </p>
     * 
     * @return the specification
     */
    public IGUIElementSpec getSpecification();

    /**
     * <p>
     * Returns the parent of the GUI element.
     * </p>
     * 
     * @return the parent
     */
    public IGUIElement getParent();

    /**
     * <p>
     * Returns the view of the GUI to which this GUI element belongs.
     * </p>
     * 
     * @return the parent
     */
    public IGUIView getView();

    /**
     * <p>
     * returns the GUI model to which this GUI element belongs
     * </p>
     */
    public GUIModel getGUIModel();
    
    /**
     * <p>
     * returns true, if a usage of this GUI element in a trace was observed
     * </p>
     *
     * @return as described
     */
    public boolean isUsed();

    /**
     * <p>
     * Marks a GUI element as used.
     * </p>
     */
    public void markUsed();

    /**
     * <p>
     * Defines that {@link IGUIElement} implementations have to define equals.
     * </p>
     * 
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object other);

    /**
     * <p>
     * Defines that {@link IGUIElement} implementations have to define hashCode.
     * </p>
     * 
     * @see Object#hashCode()
     */
    @Override
    public int hashCode();

    /**
     * <p>
     * Returns a measure for the distance of this {@link IGUIElement} to the provided one. Distance
     * means a measure for the distance in display of the rendered GUI. The returned values must be
     * between 0.0 and 1.0 inclusive. 0.0 means no distance, e.g., if the distance to itself shall be
     * returned. 1.0 means the highest distance possible. Two GUI elements that are not visible
     * at the same time independent of the screen resolution (e.g., because they resist in separate
     * views) must have a distance of at least 0.5.  
     * </p>
     * 
     * @param otherElement
     *            the GUI element to measure the distance for
     */
    public double getDistanceTo(IGUIElement otherElement);
}
