001: package org.zkforge.timeline;
002:
003: import java.text.ParseException;
004: import java.text.SimpleDateFormat;
005: import java.util.Date;
006: import java.util.Locale;
007:
008: import org.zkforge.timeline.impl.TimelineComponent;
009: import org.zkforge.timeline.util.TimelineUtil;
010: import org.zkoss.lang.Objects;
011: import org.zkoss.xml.HTMLs;
012: import org.zkoss.zk.ui.Component;
013: import org.zkoss.zk.ui.UiException;
014: import org.zkoss.zk.ui.WrongValueException;
015:
016: /** The hotzone component.
017: *
018: * <p>See also <a href="http://simile.mit.edu/timeline">MIT Timeline</a>
019: *
020: * @author WeiXing Gu, China
021: */
022: public class Hotzone extends TimelineComponent {
023: private Date _start = new Date();
024:
025: private Date _end = new Date();
026:
027: private int _magnify = 7;// default value
028:
029: private String _unit = "week";// default value
030:
031: private int _multiple = 1;// default value
032:
033: public void setParent(Component parent) {
034: if (parent != null && !(parent instanceof Bandinfo))
035: throw new UiException("Unsupported parent for hotzone: "
036: + parent);
037: super .setParent(parent);
038: }
039:
040: public String getInnerAttrs() {
041: final String attrs = super .getInnerAttrs();
042: final StringBuffer sb = new StringBuffer(128);
043: if (attrs != null) {
044: sb.append(attrs);
045: }
046: HTMLs.appendAttribute(sb, "z.pid", getParent().getUuid());
047: if (getStart() != null)
048: HTMLs.appendAttribute(sb, "z.start", TimelineUtil
049: .formatDateTime(getStart()));
050: if (getEnd() != null)
051: HTMLs.appendAttribute(sb, "z.end", TimelineUtil
052: .formatDateTime(getEnd()));
053: HTMLs.appendAttribute(sb, "z.magnify", getMagnify());
054: HTMLs.appendAttribute(sb, "z.unit", TimelineUtil
055: .convertIntervalUnitFromName(getUnit()));
056: HTMLs.appendAttribute(sb, "z.multiple", getMultiple());
057: return sb.toString();
058: }
059:
060: /** Returns the end date.
061: */
062: public Date getEnd() {
063: return _end;
064: }
065:
066: /** Sets the end date.
067: */
068: public void setEnd(Date end) {
069: if (!Objects.equals(end, _end)) {
070: _end = end;
071: //smartUpdate("z.end", end.toString());
072: invalidate();
073: }
074: }
075:
076: public int getMagnify() {
077: return _magnify;
078: }
079:
080: public void setMagnify(int magnify) {
081: if (magnify != _magnify) {
082: _magnify = magnify;
083: //smartUpdate("z.magnify", magnify);
084: invalidate();
085: }
086: }
087:
088: /** Returns the start date.
089: */
090: public Date getStart() {
091: return _start;
092: }
093:
094: /** Sets the start date.
095: */
096: public void setStart(Date start) {
097: if (!Objects.equals(start, _start)) {
098: _start = start;
099: //smartUpdate("z.start", start.toString());
100: invalidate();
101: }
102: }
103:
104: public String getUnit() {
105: return _unit;
106: }
107:
108: public void setUnit(String unit) {
109: if (!Objects.equals(unit, _unit)) {
110: _unit = unit;
111: //smartUpdate("z.unit", unit);
112: invalidate();
113: }
114: }
115:
116: public String getContent() {
117:
118: return "";
119: }
120:
121: public int getMultiple() {
122: return _multiple;
123: }
124:
125: public void setMultiple(int multiple) {
126: if (multiple != _multiple) {
127: _multiple = multiple;
128: //smartUpdate("z.multiple", multiple);
129: invalidate();
130: }
131: }
132:
133: // @Override
134: public void invalidate() {
135: // TODO Auto-generated method stub
136: super.invalidate();
137: if (getParent() != null)
138: getParent().invalidate();
139: }
140: }
|