本文整理汇总了Java中org.w3c.dom.events.EventTarget.addEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java EventTarget.addEventListener方法的具体用法?Java EventTarget.addEventListener怎么用?Java EventTarget.addEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.events.EventTarget
的用法示例。
在下文中一共展示了EventTarget.addEventListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DomIterator
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Constructs and initializes an iterator.
*/
protected DomIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (!root.isSupported("MutationEvents", "2.0"))
{
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
"Iterator needs mutation events", root, 0);
}
this.root = root;
this.whatToShow = whatToShow;
this.filter = filter;
this.expandEntityReferences = entityReferenceExpansion;
// start condition: going right, seen nothing yet.
reference = null;
right = true;
EventTarget target = (EventTarget) root;
target.addEventListener("DOMNodeRemoved", this, false);
}
示例2: DomIterator
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Constructs and initializes an iterator.
*/
protected DomIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (!root.isSupported("MutationEvents", "2.0"))
{
throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR,
"Iterator needs mutation events", root, 0);
}
this.root = root;
this.whatToShow = whatToShow;
this.filter = filter;
this.expandEntityReferences = entityReferenceExpansion;
// start condition: going right, seen nothing yet.
reference = null;
right = true;
EventTarget target = (EventTarget) root;
target.addEventListener("DOMNodeRemoved", this, false);
}
示例3: changed
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
@Override
public void changed (ObservableValue<? extends State> ov, State oldState, State newState) {
if (newState == Worker.State.SUCCEEDED) {
EventListener listener = event -> {
final String href = ((Element)event.getTarget()).getAttribute(HTML_LINK);
if (href != null) {
String domEventType = event.getType();
if (domEventType.equals(EVENT_CLICK)) {
showPage(href);
} else if (domEventType.equals(EVENT_MOUSEOVER)) {
showStatus(href);
} else if (domEventType.equals(EVENT_MOUSEOUT)) {
showStatus(BLANK);
}
}
};
Document doc = myPage.getEngine().getDocument();
NodeList nodes = doc.getElementsByTagName("a");
for (int i = 0; i < nodes.getLength(); i++) {
EventTarget node = (EventTarget)nodes.item(i);
node.addEventListener(EVENT_CLICK, listener, false);
node.addEventListener(EVENT_MOUSEOVER, listener, false);
node.addEventListener(EVENT_MOUSEOUT, listener, false);
}
}
}
示例4: changed
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (State.SUCCEEDED.equals(newValue)) {
Document document = webView.getEngine().getDocument();
NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
for (int i = 0; i < anchors.getLength(); i++) {
Node node = anchors.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT, this, false);
}
}
}
示例5: changed
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
if (SUCCEEDED.equals(newValue)) {
Document document = webView.getEngine().getDocument();
NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
for (int i = 0; i < anchors.getLength(); i++) {
Node node = anchors.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT, this, false);
}
}
}
示例6: addEventListeners
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Adds event listeners to the document to track CSS changes.
*/
protected void addEventListeners(EventTarget doc) {
if (isCSSNavigableDocument) {
cssNavigableDocumentListener = new CSSNavigableDocumentHandler();
CSSNavigableDocument cnd = (CSSNavigableDocument) doc;
cnd.addCSSNavigableDocumentListener(cssNavigableDocumentListener);
} else {
domAttrModifiedListener = new DOMAttrModifiedListener();
doc.addEventListener("DOMAttrModified",
domAttrModifiedListener,
false);
domNodeInsertedListener = new DOMNodeInsertedListener();
doc.addEventListener("DOMNodeInserted",
domNodeInsertedListener,
false);
domNodeRemovedListener = new DOMNodeRemovedListener();
doc.addEventListener("DOMNodeRemoved",
domNodeRemovedListener,
false);
domSubtreeModifiedListener = new DOMSubtreeModifiedListener();
doc.addEventListener("DOMSubtreeModified",
domSubtreeModifiedListener,
false);
domCharacterDataModifiedListener =
new DOMCharacterDataModifiedListener();
doc.addEventListener("DOMCharacterDataModified",
domCharacterDataModifiedListener,
false);
}
}
示例7: addDomMutationListeners
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Registers DOM Mutation Listener on the given document.
*
* @param doc
* The given document
*/
protected void addDomMutationListeners(Document doc) {
EventTarget target = (EventTarget) doc;
nodeInsertion = new NodeInsertionHandler();
target.addEventListener(NODE_INSERTED, nodeInsertion, true);
nodeRemoval = new NodeRemovalHandler();
target.addEventListener(NODE_REMOVED, nodeRemoval, true);
attrModification = new AttributeModificationHandler();
target.addEventListener(ATTRIBUTE_MODIFIED, attrModification,
true);
charDataModification = new CharDataModificationHandler();
target.addEventListener(CHAR_DATA_MODIFIED,
charDataModification, true);
}
示例8: changed
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if(State.SUCCEEDED.equals(newValue)) {
Document document = webView.getEngine().getDocument();
NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
for(int i = 0; i < anchors.getLength(); i++) {
Node node = anchors.item(i);
EventTarget eventTarget = (EventTarget) node;
eventTarget.addEventListener(CLICK_EVENT, this, false);
}
}
}
示例9: addMediaElementEventListeners
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
static void addMediaElementEventListeners(
EventTarget target, MediaModel media) {
// To play the media with SmilPlayer, we should add them
// as EventListener into an EventTarget.
target.addEventListener(SMIL_MEDIA_START_EVENT, media, false);
target.addEventListener(SMIL_MEDIA_END_EVENT, media, false);
target.addEventListener(SMIL_MEDIA_PAUSE_EVENT, media, false);
target.addEventListener(SMIL_MEDIA_SEEK_EVENT, media, false);
}
示例10: addParElementEventListeners
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
static void addParElementEventListeners(
EventTarget target, SlideModel slide) {
// To play the slide with SmilPlayer, we should add it
// as EventListener into an EventTarget.
target.addEventListener(SMIL_SLIDE_START_EVENT, slide, false);
target.addEventListener(SMIL_SLIDE_END_EVENT, slide, false);
}
示例11: enableStop
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Enable capturing of 'mousemove' and 'mouseup' events.
*/
protected void enableStop() {
EventTarget targ = svgp.getDocument().getRootElement();
targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEMOVE, this, false);
targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEUP, this, false);
// FIXME: listen on the background object!
targ.addEventListener(SVGConstants.SVG_EVENT_MOUSEOUT, this, false);
}
示例12: addEventListener
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Add an event listener to the Element.
*
* @param tag Element to add the listener
* @param truedim Tool number for the Element
*/
private void addEventListener(final Element tag, final int truedim) {
EventTarget targ = (EventTarget) tag;
targ.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener() {
@Override
public void handleEvent(Event evt) {
proj.toggleDimInverted(truedim);
context.visChanged(proj);
}
}, false);
}
示例13: addEventListener
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
/**
* Add an event listener to the Element
*
* @param tag Element to add the listener
* @param axis Axis number (including hidden axes)
*/
private void addEventListener(final Element tag, final int axis) {
EventTarget targ = (EventTarget) tag;
targ.addEventListener(SVGConstants.SVG_EVENT_CLICK, new EventListener() {
@Override
public void handleEvent(Event evt) {
if(proj.getVisibleDimensions() > 2) {
proj.toggleAxisVisible(axis);
context.visChanged(proj);
}
}
}, false);
}
示例14: fullRedraw
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
@Override
public void fullRedraw() {
setupCanvas();
setupCSS(svgp);
final StyleLibrary style = context.getStyleLibrary();
double dotsize = style.getLineWidth(StyleLibrary.PLOT);
for(DBIDIter id = sample.getSample().iter(); id.valid(); id.advance()) {
double[] v = proj.fastProjectDataToRenderSpace(rel.get(id));
if(v[0] != v[0] || v[1] != v[1]) {
continue; // NaN!
}
Element tooltip = makeTooltip(id, v[0], v[1], dotsize);
SVGUtil.addCSSClass(tooltip, TOOLTIP_HIDDEN);
// sensitive area.
Element area = svgp.svgRect(v[0] - dotsize, v[1] - dotsize, 2 * dotsize, 2 * dotsize);
SVGUtil.addCSSClass(area, TOOLTIP_AREA);
EventTarget targ = (EventTarget) area;
targ.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, hoverer, false);
targ.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, hoverer, false);
targ.addEventListener(SVGConstants.SVG_CLICK_EVENT_TYPE, hoverer, false);
// NOTE: do not change the sequence in which these are inserted!
layer.appendChild(area);
layer.appendChild(tooltip);
}
}
示例15: attachTo
import org.w3c.dom.events.EventTarget; //导入方法依赖的package包/类
protected void attachTo(Element e) {
EventTarget et = (EventTarget) e;
// Node{Inserted,Removed} is fired *before* the change. This is better;
// fired *after* it has taken effect.
et.addEventListener("DOMSubtreeModified", this, false);
}