001: package org.zkforge.timeline;
002:
003: import org.zkforge.json.simple.JSONArray;
004: import org.zkforge.timeline.impl.TimelineComponent;
005: import org.zkoss.lang.Objects;
006: import org.zkoss.zk.ui.Component;
007: import org.zkoss.zk.ui.UiException;
008: import org.zkoss.zk.ui.WrongValueException;
009:
010: /** The timeline component.
011: *
012: * <p>See also <a href="http://simile.mit.edu/timeline">MIT Timeline</a>
013: *
014: * @author WeiXing Gu, China
015: */
016: public class Timeline extends TimelineComponent {
017:
018: private String _orient = "horizontal";// default
019:
020: private String _height = "150px";// default
021:
022: private String _width = "100%";// default
023:
024: /**
025: * Returns the orientation of {@link Timeline}.
026: */
027: public String getOrient() {
028: return _orient;
029: }
030:
031: /**
032: * Sets the orientation of {@link Timeline}.
033: */
034: public void setOrient(String orient) throws WrongValueException {
035: if (!"horizontal".equals(orient) && !"vertical".equals(orient))
036: throw new WrongValueException(orient);
037:
038: if (!Objects.equals(_orient, orient)) {
039: _orient = orient;
040: invalidate();
041: }
042: }
043:
044: public String getInnerAttrs() {
045: return "z.orientation=" + getOrient();
046:
047: }
048:
049: // -- Component --//
050: public boolean insertBefore(Component child, Component insertBefore) {
051: if (!(child instanceof Bandinfo))
052: throw new UiException("Unsupported child for timeline: "
053: + child);
054: return super .insertBefore(child, insertBefore);
055: }
056:
057: /** Returns the height.
058: * @return the height
059: */
060: public String getHeight() {
061: return _height;
062: }
063:
064: /** Sets the height.
065: * @param height
066: * the height to set
067: */
068: public void setHeight(String height) {
069: if (!Objects.equals(_height, height)) {
070: _height = height;
071: smartUpdate("z.height", height);
072: // invalidate();
073: }
074: }
075:
076: /** Returns the width
077: */
078: public String getWidth() {
079: return _width;
080: }
081:
082: /** Sets the width.
083: */
084: public void setWidth(String width) {
085: if (!Objects.equals(_width, width)) {
086: _width = width;
087: smartUpdate("z.width", width);
088: // invalidate();
089: }
090:
091: }
092:
093: /*public void reLayout() {
094: //
095: }*/
096:
097: public void performFiltering(String filterText) {
098: smartUpdate("z.filter", filterText);
099: }
100:
101: public void clearFilter() {
102: smartUpdate("z.clearFilter", "");
103: }
104:
105: public void performHighlitht(String highlightText[]) {
106: JSONArray matchers = new JSONArray();
107: for (int i = 0; i < highlightText.length; i++) {
108: matchers.add(highlightText[i]);
109: }
110: // System.out.println(matchers.toString());
111: smartUpdate("z.highlight", matchers.toString());
112: }
113:
114: public void clearHighlight() {
115: smartUpdate("z.clearHighlight", "");
116: }
117: }
|