package ofc;
import org.zkoss.lang.Objects;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.HtmlBasedComponent;
public class ZKOFC extends HtmlBasedComponent {
/**
*
*/
private static final long serialVersionUID = 1L;
private final String _src = "~./ofc/open-flash-chart.swf";
private final String _jspath = "~./js/ofcz";
private final String _js = "~./js/ofcz/ofc.js";
private String _wmode = "opaque";
private String _bgcolor;
private boolean _autoplay = false;
private boolean _loop = false;
private String _chart;
private String _loading;
public ZKOFC() {
}
public ZKOFC(String loading) {
_loading = loading;
}
public String getChart() {
return _chart;
}
public void setChart(String chart) {
if (!Objects.equals(_chart, chart)) {
_chart = chart;
smartUpdate("ofcd", chart);
}
}
public String getLoading() {
return _loading;
}
public void setLoading(String loading) {
// simple assing because it takes effect only when cerating the flash,
// i.e. don't make sense to smart update it.
_loading = loading;
}
/**
* Gets the background color of Flash movie.
* <p>
* Default: null (the system default)
*
* @return the background color of Flash movie,[ hexadecimal RGB value]
*/
public String getBgcolor() {
return _bgcolor;
}
/**
* Sets the background color of Flash movie.
*
* @param bgcolor [
* hexadecimal RGB value]
*/
public void setBgcolor(String bgcolor) {
if (!Objects.equals(_bgcolor, bgcolor)) {
_bgcolor = bgcolor;
smartUpdate("bgcolor", bgcolor);
}
}
/**
* Returns true if the Flash movie plays repeatly.
* <p>
* Default: false
*
* @return true if the Flash movie plays repeatly
*/
public boolean isLoop() {
return _loop;
}
/**
* Sets whether the Flash movie plays repeatly
*
* @param loop
* false to run the movie only one time, true to run forever
*/
public void setLoop(boolean loop) {
if (_loop != loop) {
_loop = loop;
smartUpdate("loop", loop);
}
}
/**
* @deprecated As of release 3.6.1, use {@link #isAutoplay} instead.
* @return true if should autoplay when browser render the component
*/
public boolean isAutoPlay() {
return isAutoplay();
}
/**
* @deprecated As of release 3.6.1, use {@link #setAutoplay} instead.
* @param autoplay
* to automatically playes the movie uppon load
*/
public void setAutoPlay(boolean autoplay) {
setAutoplay(autoplay);
}
/**
* Return true if the Flash movie starts playing automatically
* <p>
* Default: true
*
* @return true if the Flash movie starts playing automatically
* @since 3.6.1
*/
public boolean isAutoplay() {
return _autoplay;
}
/**
* Sets wether to play the Flash movie automatically.
*
* @param autoplay
* whether to play the Flash movie automatically
* @since 3.6.1
*/
public void setAutoplay(boolean autoplay) {
if (_autoplay != autoplay) {
_autoplay = autoplay;
smartUpdate("play", autoplay);
}
}
/**
* Returns the Window mode property of the Flash movie
* <p>
* Default: "transparent".
*
* @return the Window mode property of the Flash movie
*/
public String getWmode() {
return _wmode;
}
/**
* Sets the Window Mode property of the Flash movie for transparency,
* layering, and positioning in the browser.
*
* @param wmode
* Possible values: window, opaque, transparent.
*/
public void setWmode(String wmode) {
if (!Objects.equals(_wmode, wmode)) {
_wmode = wmode;
smartUpdate("wmode", wmode);
}
}
/**
* Returned the encoded URL of the source flash. It is used only internally
* (for component development).
*
* @since 3.6.1
* @return the encoded src where to find the flash source
*/
public String getEncodedSrc() {
final Desktop dt = getDesktop();
return dt != null ? dt.getExecution().encodeURL(_src) : "";
}
/**
* Returned the encoded URL of the js scrips. It is used only internally
* (for component development).
*
* @since 3.6.1
* @return the encoded js path where to find the scripts
*/
public String getEncodedJsPath() {
final Desktop dt = getDesktop();
return dt != null ? dt.getExecution().encodeURL(_jspath) : "";
}
public String getEncodedJs() {
final Desktop dt = getDesktop();
return dt != null ? dt.getExecution().encodeURL(_js) : "";
}
public boolean isExplorer() {
final Desktop dt = getDesktop();
return dt != null ? dt.getExecution().isExplorer() : true;
}
public boolean isFirefox() {
final Desktop dt = getDesktop();
return dt != null ? dt.getExecution().isGecko() : false;
}
}