@Override public SVGFace getFace(SVGFaceName faceName) { if (!faces.containsKey(faceName)) { switch (faceName) { case UP_HOVERING: case UP_DISABLED: faceName = SVGFaceName.UP; break; case DOWN: case DOWN_HOVERING: case DOWN_DISABLED: faceName = SVGFaceName.DOWN; break; } } return super.getFace(faceName); }
/** * Constructor * @param svgElement * The SVG element defining the button * @param faces * A collection of faces */ protected SVGButtonBase(OMSVGSVGElement svgElement, Map<SVGFaceName, SVGFace> faces) { this(); if (faces != null) { this.faces.putAll(faces); } setSvgElement(svgElement); } /**
/** * Sets whether this button is enabled * @param enabled * true to enable the button, false to disable it */ public void setEnabled(boolean enabled) { if (enabled) { switch(currentFaceName) { case UP_DISABLED: case UP_HOVERING: showFace(SVGFaceName.UP); break; case DOWN_DISABLED: case DOWN_HOVERING: showFace(SVGFaceName.DOWN); break; } } else { switch(currentFaceName) { case UP: case UP_HOVERING: showFace(SVGFaceName.UP_DISABLED); break; case DOWN: case DOWN_HOVERING: showFace(SVGFaceName.DOWN_DISABLED); break; } } }
/** * Sets the SVG element defining the button * @param svgElement * the SVG element defining the button */ public void setSvgElement(OMSVGSVGElement svgElement) { this.svgElement = svgElement; setElement(this.svgElement.getElement()); if (this.svgElement != null) { this.svgElement.addDomHandler(this, MouseOutEvent.getType()); this.svgElement.addDomHandler(this, MouseOverEvent.getType()); this.svgElement.addDomHandler(this, MouseUpEvent.getType()); this.svgElement.addDomHandler(this, MouseDownEvent.getType()); this.svgElement.addDomHandler(this, ClickEvent.getType()); } } /**
/** * Sets the SVG element defining the button * @param svgElement * the SVG element defining the button */ public void setSvgElement(OMSVGSVGElement svgElement) { this.svgElement = svgElement; setElement(this.svgElement.getElement()); if (this.svgElement != null) { this.svgElement.addDomHandler(this, MouseOutEvent.getType()); this.svgElement.addDomHandler(this, MouseOverEvent.getType()); this.svgElement.addDomHandler(this, MouseUpEvent.getType()); this.svgElement.addDomHandler(this, MouseDownEvent.getType()); this.svgElement.addDomHandler(this, ClickEvent.getType()); } } /**
@Override public SVGFace getFace(SVGFaceName faceName) { if (!faces.containsKey(faceName)) { switch (faceName) { case UP_HOVERING: case UP_DISABLED: case DOWN: faceName = SVGFaceName.UP; break; case DOWN_HOVERING: case DOWN_DISABLED: faceName = SVGFaceName.DOWN; break; } } return super.getFace(faceName); } public void setRepeatDelay(int repeatDelayMillis) {
/** * Constructor * @param svgElement * The SVG element defining the button * @param faces * A collection of faces */ protected SVGButtonBase(OMSVGSVGElement svgElement, Map<SVGFaceName, SVGFace> faces) { this(); if (faces != null) { this.faces.putAll(faces); } setSvgElement(svgElement); } /**
/** * Sets whether this button is enabled * @param enabled * true to enable the button, false to disable it */ public void setEnabled(boolean enabled) { if (enabled) { switch(currentFaceName) { case UP_DISABLED: case UP_HOVERING: showFace(SVGFaceName.UP); break; case DOWN_DISABLED: case DOWN_HOVERING: showFace(SVGFaceName.DOWN); break; } } else { switch(currentFaceName) { case UP: case UP_HOVERING: showFace(SVGFaceName.UP_DISABLED); break; case DOWN: case DOWN_HOVERING: showFace(SVGFaceName.DOWN_DISABLED); break; } } }
@Override public SVGFace getFace(SVGFaceName faceName) { if (!faces.containsKey(faceName)) { switch (faceName) { case UP_HOVERING: case UP_DISABLED: faceName = SVGFaceName.UP; break; case DOWN: case DOWN_HOVERING: case DOWN_DISABLED: faceName = SVGFaceName.DOWN; break; } } return super.getFace(faceName); }
/** * Sets the SVG resource defining the button * @param resource * An SVG resource */ public void setResource(SVGResource resource) { setSvgElement(resource.getSvg()); } /**
@Override public SVGFace getFace(SVGFaceName faceName) { if (!faces.containsKey(faceName)) { switch (faceName) { case UP_HOVERING: case UP_DISABLED: case DOWN: faceName = SVGFaceName.UP; break; case DOWN_HOVERING: case DOWN_DISABLED: faceName = SVGFaceName.DOWN; break; } } return super.getFace(faceName); } public void setRepeatDelay(int repeatDelayMillis) {
/** * Sets the SVG resource defining the button * @param resource * An SVG resource */ public void setResource(SVGResource resource) { setSvgElement(resource.getSvg()); } /**
/** * Forces the button to display the specified face * @param faceName * The name of the face to display */ public void showFace(SVGFaceName faceName) { // GWT.log((currentFaceName != null ? currentFaceName.name() : "null") + " -> " + faceName.name()); SVGFace currentFace = currentFaceName != null ? getFace(currentFaceName) : null; SVGFace face = faceName != null ? getFace(faceName) : null; if (face != currentFace) { if (currentFace != null) { for (SVGFaceChange change : currentFace.getChanges()) { change.uninstall(this); } } if (face != null) { for (SVGFaceChange change : face.getChanges()) { change.install(this); } } } currentFaceName = faceName; }
/** * Forces the button to display the specified face * @param faceName * The name of the face to display */ public void showFace(SVGFaceName faceName) { // GWT.log((currentFaceName != null ? currentFaceName.name() : "null") + " -> " + faceName.name()); SVGFace currentFace = currentFaceName != null ? getFace(currentFaceName) : null; SVGFace face = faceName != null ? getFace(faceName) : null; if (face != currentFace) { if (currentFace != null) { for (SVGFaceChange change : currentFace.getChanges()) { change.uninstall(this); } } if (face != null) { for (SVGFaceChange change : face.getChanges()) { change.install(this); } } } currentFaceName = faceName; }