Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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 org.apache.batik.dom.events;
import java.util.HashSet;
import java.util.Iterator;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.events.MouseEvent;
import org.w3c.dom.views.AbstractView;
/**
* The MouseEvent class provides specific contextual information
* associated with Mouse events.
*
* @author Stephane Hillion
* @version $Id: DOMMouseEvent.java 1733416 2016-03-03 07:07:13Z gadams $
*/
public class DOMMouseEvent extends DOMUIEvent implements MouseEvent {
private int screenX;
private int screenY;
private int clientX;
private int clientY;
private short button;
private EventTarget relatedTarget;
/**
* The modifier keys in effect at the time of the event.
*/
protected HashSet modifierKeys = new HashSet();
/**
* DOM: screenX indicates the horizontal coordinate
* at which the event occurred relative to the origin of the
* screen coordinate system.
*/
public int getScreenX() {
return screenX;
}
/**
* DOM: screenY indicates the vertical coordinate at
* which the event occurred relative to the origin of the screen
* coordinate system.
*/
public int getScreenY() {
return screenY;
}
/**
* DOM: clientX indicates the horizontal coordinate
* at which the event occurred relative to the DOM
* implementation's client area.
*/
public int getClientX() {
return clientX;
}
/**
* DOM: clientY indicates the vertical coordinate at
* which the event occurred relative to the DOM implementation's
* client area.
*/
public int getClientY() {
return clientY;
}
/**
* DOM: ctrlKey indicates whether the 'ctrl' key was
* depressed during the firing of the event.
*/
public boolean getCtrlKey() {
return modifierKeys.contains(DOMKeyboardEvent.KEY_CONTROL);
}
/**
* DOM: shiftKey indicates whether the 'shift' key
* was depressed during the firing of the event.
*/
public boolean getShiftKey() {
return modifierKeys.contains(DOMKeyboardEvent.KEY_SHIFT);
}
/**
* DOM: altKey indicates whether the 'alt' key was
* depressed during the firing of the event. On some platforms
* this key may map to an alternative key name.
*/
public boolean getAltKey() {
return modifierKeys.contains(DOMKeyboardEvent.KEY_ALT);
}
/**
* DOM: metaKey indicates whether the 'meta' key was
* depressed during the firing of the event. On some platforms
* this key may map to an alternative key name.
*/
public boolean getMetaKey() {
return modifierKeys.contains(DOMKeyboardEvent.KEY_META);
}
/**
* DOM: During mouse events caused by the depression or release of
* a mouse button, button is used to indicate which
* mouse button changed state. The values for button
* range from zero to indicate the left button of the mouse, one
* to indicate the middle button if present, and two to indicate
* the right button. For mice configured for left handed use in
* which the button actions are reversed the values are instead
* read from right to left.
*/
public short getButton() {
return button;
}
/**
* DOM: Used to identify a secondary EventTarget related
* to a UI
* event. Currently this attribute is used with the mouseover event to
* indicate the EventTarget which the pointing device exited
* and with the mouseout event to indicate the EventTarget
* which the pointing device entered.
*/
public EventTarget getRelatedTarget() {
return relatedTarget;
}
/**
* DOM: Returns whether the given modifier key was pressed at the
* time of the event.
*/
public boolean getModifierState(String keyIdentifierArg) {
return modifierKeys.contains(keyIdentifierArg);
}
/**
* Returns the modifiers string for this event.
*/
public String getModifiersString() {
if (modifierKeys.isEmpty()) {
return "";
}
StringBuffer sb = new StringBuffer(modifierKeys.size() * 8);
Iterator i = modifierKeys.iterator();
sb.append((String) i.next());
while (i.hasNext()) {
sb.append(' ');
sb.append((String) i.next());
}
return sb.toString();
}
/**
* DOM: The initMouseEvent method is used to
* initialize the value of a MouseEvent created
* through the DocumentEvent interface. This method
* may only be called before the MouseEvent has been
* dispatched via the dispatchEvent method, though it
* may be called multiple times during that phase if necessary.
* If called multiple times, the final invocation takes
* precedence.
*
* @param typeArg Specifies the event type.
* @param canBubbleArg Specifies whether or not the event can bubble.
* @param cancelableArg Specifies whether or not the event's default
* action can be prevented.
* @param viewArg Specifies the Event's
* AbstractView.
* @param detailArg Specifies the Event's mouse click count.
* @param screenXArg Specifies the Event's screen x coordinate
* @param screenYArg Specifies the Event's screen y coordinate
* @param clientXArg Specifies the Event's client x coordinate
* @param clientYArg Specifies the Event's client y coordinate
* @param ctrlKeyArg Specifies whether or not control key was depressed
* during the Event.
* @param altKeyArg Specifies whether or not alt key was depressed during
* the Event.
* @param shiftKeyArg Specifies whether or not shift key was depressed
* during the Event.
* @param metaKeyArg Specifies whether or not meta key was depressed
* during the Event.
* @param buttonArg Specifies the Event's mouse button.
* @param relatedTargetArg Specifies the Event's related
* EventTarget.
*/
public void initMouseEvent(String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
short buttonArg,
EventTarget relatedTargetArg) {
initUIEvent(typeArg, canBubbleArg, cancelableArg,
viewArg, detailArg);
this.screenX = screenXArg;
this.screenY = screenYArg;
this.clientX = clientXArg;
this.clientY = clientYArg;
if (ctrlKeyArg) {
modifierKeys.add(DOMKeyboardEvent.KEY_CONTROL);
}
if (altKeyArg) {
modifierKeys.add(DOMKeyboardEvent.KEY_ALT);
}
if (shiftKeyArg) {
modifierKeys.add(DOMKeyboardEvent.KEY_SHIFT);
}
if (metaKeyArg) {
modifierKeys.add(DOMKeyboardEvent.KEY_META);
}
this.button = buttonArg;
this.relatedTarget = relatedTargetArg;
}
/**
* DOM: Initializes this event object.
*/
public void initMouseEventNS(String namespaceURIArg,
String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
short buttonArg,
EventTarget relatedTargetArg,
String modifiersList) {
initUIEventNS(namespaceURIArg,
typeArg,
canBubbleArg,
cancelableArg,
viewArg,
detailArg);
screenX = screenXArg;
screenY = screenYArg;
clientX = clientXArg;
clientY = clientYArg;
button = buttonArg;
relatedTarget = relatedTargetArg;
modifierKeys.clear();
String[] modifiers = split(modifiersList);
for (int i = 0; i < modifiers.length; i++) {
modifierKeys.add(modifiers[i]);
}
}
}