[Tynstep-svn] r29 - in trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client: toolkit/timeline view

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Sun Nov 29 15:48:31 MST 2009


Author: ChrisBurrell
Date: 2009-11-29 15:48:31 -0700 (Sun, 29 Nov 2009)
New Revision: 29

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBandNotFoundException.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineMouseHandler.java
Modified:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/ScaleBand.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBand.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/TimelineView.java
Log:
New timeline widget

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/ScaleBand.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/ScaleBand.java	2009-11-29 22:44:47 UTC (rev 28)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/ScaleBand.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -1,5 +1,10 @@
 package com.tyndalehouse.step.web.client.toolkit.timeline;
 
+import com.allen_sauer.gwt.log.client.Log;
+import com.extjs.gxt.ui.client.core.El;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+
 /**
  * The TimeBand object represents a section of the timeline that contains the events.
  * @author CJBurrell
@@ -17,9 +22,42 @@
 	}
 
 	@Override
-	protected void addBandToUI() {
-		super.addBandToUI();
+	protected void addBandToUI(int top) {
+		super.addBandToUI(top);
 		
+		Element div = getElement();
+		El gxtDiv = new El(div);
+		
+		gxtDiv.setStyleName("step-scale-band", true);
+		
+		//TODO: change this at some point
+		int width = 64000;
+
+		Unit unit = getUnit();
+		int pixelsPerUnit = getPixelsPerUnit();
+		
+		//how many do i need to generate?
+		int numberOfMarkers = width / pixelsPerUnit;
+		for(int ii = 0; ii < numberOfMarkers; ii++) {
+			Element un = DOM.createDiv();
+			El gxtUn = new El(un);
+			gxtUn.setWidth(pixelsPerUnit);
+			
+			un.setInnerText(""+ii);
+			div.appendChild(un);
+		}
+		
+		
+		
+		//calculate the date
+		
+		Log.debug("client width: " + div.getClientWidth());
+//		gxtDiv.appendChild(un);
+		
+		
+		
+		
+		
 		//also add all the markings for the dates on the band
 	}
 

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBand.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBand.java	2009-11-29 22:44:47 UTC (rev 28)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBand.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -3,10 +3,10 @@
 import java.util.TreeMap;
 
 import com.allen_sauer.gwt.log.client.Log;
+import com.extjs.gxt.ui.client.core.El;
+import com.google.gwt.event.dom.client.MouseDownEvent;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.EventListener;
 import com.google.gwt.user.client.ui.Widget;
 
 /**
@@ -34,7 +34,10 @@
 	private Unit unit;
 
 	private Element bandDiv;
-
+	
+	/** height of the time band, defaults at 50px*/
+	private int height = 100;
+	
 	private int pixelsPerUnit;
 
 	/**
@@ -45,40 +48,39 @@
 
 	// TODO: adjust this
 	private long currentDateX = 200;
+	private boolean showScale = true;
+	private int mouseDownScrollLeft;
+	private Element timebandContainer;
 
+	/**
+	 * @return the showScale
+	 */
+	public boolean isShowScale() {
+		return showScale;
+	}
+
+	/**
+	 * @param showScale the showScale to set
+	 */
+	public void setShowScale(boolean showScale) {
+		this.showScale = showScale;
+	}
+
 	public TimeBand(final Timeline parent, final String id) {
 		this.parent = parent;
 		this.id = id;
+		
+		
 		events = new TreeMap<String, TimeEvent>();
 		bandDiv = DOM.createDiv();
+		timebandContainer = DOM.createDiv();
+		
 		initDivProperties();
+		setElement(timebandContainer);
 	}
-
+		
 	protected void initDivProperties() {
 		bandDiv.setClassName("step-timeband");
-
-		// Draggable dg = new Draggable(this);
-		//		
-		// Listener<DragEvent> dragListener = new Listener<DragEvent>() {
-		// @Override
-		// public void handleEvent(DragEvent be) {
-		// if(be.getType() == Events.DragStart) {
-		// Log.debug("Drag started");
-		// } else if (be.getType() == Events.DragEnd) {
-		// Log.debug("Drag stopped");
-		// } else if(be.getType() == Events.DragCancel) {
-		// Log.debug("Drag cancelled");
-		// }
-		// }
-		// };
-		//		
-		//		
-		//		
-		// addListener(Events.DragStart, dragListener);
-		// addListener(Events.DragEnd, dragListener);
-		// addListener(Events.DragCancel, dragListener);
-		// //sinkEvents(Event.MOUSEEVENTS);
-		//	
 	}
 
 	/**
@@ -230,19 +232,6 @@
 		return events.get(eventId);
 	}
 
-	public void addScrollListener(ScrollListener listener) {
-		// TODO:
-	}
-
-	public void removeScrollListener(ScrollListener listener) {
-		// TODO:
-	}
-
-	public void clearScrollListeners() {
-		// TODO:
-
-	}
-
 	public Long getMinVisibleDate() {
 		// TODO:
 		return null;
@@ -268,12 +257,50 @@
 	}
 
 	protected void paint() {
+		paint(0);
+	}
+	
+	protected void paint(int top) {
 		if (isVisible()) {
-			addBandToUI();
+			addBandToUI(top);
 		} else {
 			removeBandFromUI();
 		}
 
+		//show scale band?
+		if(showScale) {
+			Element scaleBand = DOM.createDiv();
+			El gxtScaleBand = new El(scaleBand);
+			bandDiv.appendChild(scaleBand);
+			
+			gxtScaleBand.setStyleName("step-scale-band", true);
+			
+			//TODO: change this at some point
+			int width = 64000;
+
+			Unit unit = getUnit();
+			int pixelsPerUnit = getPixelsPerUnit();
+			
+			//how many do i need to generate?
+			int relativeLeft = 0;
+			int numberOfMarkers = width / pixelsPerUnit;
+			for(int ii = 0; ii < numberOfMarkers; ii++) {
+				Element un = DOM.createDiv();
+				El gxtUn = new El(un);
+				gxtUn.setWidth(pixelsPerUnit);
+				un.setInnerText(""+ii);
+				gxtScaleBand.appendChild(un);
+				
+				//set left position:
+				gxtUn.setLeft(relativeLeft);
+				gxtUn.setHeight("100%");
+				
+				relativeLeft += pixelsPerUnit;
+			}
+			
+			//new El(bandDiv).setWidth(64000);
+		}
+		
 		// get the events to paint themselves
 		for (TimeEvent te : events.values()) {
 			te.paint();
@@ -281,26 +308,27 @@
 	}
 
 	protected void removeBandFromUI() {
-		parent.getElement().removeChild(bandDiv);
+//		parent.getElement().removeChild(bandDiv);
 	}
 
-	protected void addBandToUI() {
-		parent.getElement().appendChild(bandDiv);
+	@Override
+	protected void onAttach() {
+		super.onAttach();
+		Log.debug("timeband is attached now" + isAttached());
+	};
+	
+	protected void addBandToUI(int top) {
+		parent.getTimelineContainer().appendChild(timebandContainer);
+		timebandContainer.appendChild(bandDiv);
 		
-		//TOOD: left off here and use this.
-		//addDomHandler(, Type<>)
+		El el = new El(timebandContainer);
+		el.setStyleName("step-timeband-container");
+		el.setHeight(getHeight());
+		//el.setTop(top);
 		
-		DOM.setEventListener(bandDiv, new EventListener() {
-
-			// TODO: continue here for the dragging
-			@Override
-			public void onBrowserEvent(Event event) {
-				if (event.getTypeInt() == Event.ONMOUSEDOWN) {
-					Log.debug("An event has been fired on the timeline band");
-				}
-			}
-
-		});
+		El gxtBandDiv = new El(bandDiv);
+		gxtBandDiv.setHeight("100%");
+		gxtBandDiv.setTop(0);
 	}
 
 	public void softPaint() {
@@ -333,4 +361,42 @@
 		return currentDate;
 	}
 
+	/**
+	 * @return the height
+	 */
+	public int getHeight() {
+		return height;
+	}
+
+	/**
+	 * @param height the height to set
+	 */
+	public void setHeight(int height) {
+		this.height = height;
+	}
+
+	public void captureScrollLeft(MouseDownEvent e) {
+		this.mouseDownScrollLeft = timebandContainer.getScrollLeft();
+		
+		Log.debug("mousedown left: " + mouseDownScrollLeft);
+		Log.debug("relative x: " + e.getRelativeX(timebandContainer));
+	}
+
+	public void setScrollLeft(int previousClientX, int newClientX, Unit defaultUnit, int defaultPixelsPerUnit) {
+		//we scroll, but we calculate the unit/scale factor first
+		//say default is 1 Year
+		//this one is 10 years
+		//unit Factor = 0.1 so we scroll 10 times less pixels
+		double unitFactor = (double) defaultUnit.getMilliseconds() / (double) unit.getMilliseconds();
+	
+		//now say instead unit factor is 1, ie. the same unit, but different number of pixels
+		//default is 50 pixels per year, this one is 25 pixels a year
+		//so we want to scroll half
+		double pixelFactor = (double) pixelsPerUnit / (double) defaultPixelsPerUnit;
+		
+		
+		
+		this.timebandContainer.setScrollLeft((int) 
+				(mouseDownScrollLeft + ((previousClientX - newClientX) * (unitFactor*pixelFactor))));
+	}
 }

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBandNotFoundException.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBandNotFoundException.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeBandNotFoundException.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -0,0 +1,14 @@
+package com.tyndalehouse.step.web.client.toolkit.timeline;
+
+public class TimeBandNotFoundException extends Exception {
+
+	public TimeBandNotFoundException(final String message) {
+		super(message);
+	}
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 6234571991235670035L;
+
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java	2009-11-29 22:44:47 UTC (rev 28)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimeEvent.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -1,10 +1,6 @@
 package com.tyndalehouse.step.web.client.toolkit.timeline;
 
-import org.apache.catalina.valves.ExtendedAccessLogValve;
-
 import com.extjs.gxt.ui.client.core.El;
-import com.extjs.gxt.ui.client.event.BaseEvent;
-import com.extjs.gxt.ui.client.util.Padding;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 
@@ -224,21 +220,22 @@
 		long leftPixelPosition = calculateOffsetFromCenter(minDate.longValue());
 		gxtEvent.setLeft((int) leftPixelPosition);
 		
+		
 		if(maxDate != null) {
 			long width = calculateOffsetFromCenter(maxDate.longValue()) - leftPixelPosition;
 			gxtIcon.setWidth((int) width);
-			
+			gxtIcon.setStyleName(eventType, true);
 			gxtLabel.setLeft((int) leftPixelPosition); 
 			gxtLabel.setStyleName(TimelineConstants.DURATION_LABEL, true);
 		} else {
 			//point in time.
 			gxtLabel.setStyleName(TimelineConstants.POINT_IN_TIME_LABEL, true);
-			gxtIcon.setWidth(TimelineConstants.POINT_IN_TIME_WIDTH_SPACE);
+			//gxtIcon.setWidth(TimelineConstants.POINT_IN_TIME_WIDTH_SPACE);
 			gxtLabel.setLeft((int) leftPixelPosition + TimelineConstants.POINT_IN_TIME_WIDTH_SPACE);
 		}
 		
 		//TODO: derive type from database first
-		gxtIcon.setStyleName(eventType, true);
+		//
 		
 		//set the name of the event
 		label.setInnerText(description);

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java	2009-11-29 22:44:47 UTC (rev 28)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/Timeline.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -1,29 +1,197 @@
 package com.tyndalehouse.step.web.client.toolkit.timeline;
 
-import java.util.TreeMap;
+import java.util.ArrayList;
+import java.util.List;
 
+import com.allen_sauer.gwt.log.client.Log;
+import com.extjs.gxt.ui.client.core.El;
+import com.google.gwt.event.dom.client.MouseDownEvent;
+import com.google.gwt.event.dom.client.MouseDownHandler;
+import com.google.gwt.event.dom.client.MouseMoveEvent;
+import com.google.gwt.event.dom.client.MouseMoveHandler;
+import com.google.gwt.event.dom.client.MouseOutEvent;
+import com.google.gwt.event.dom.client.MouseOutHandler;
+import com.google.gwt.event.dom.client.MouseUpEvent;
+import com.google.gwt.event.dom.client.MouseUpHandler;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Widget;
 
+
+/**
+ * div .step-timeline (step-grab step-letgo)
+ * |
+ * |
+ * - div .step-timeline-container
+ *   |
+ *   |
+ *   - div .step-timeband-container
+ *     |
+ *     |
+ *     - div .step-timeband
+ *       |
+ *       |
+ *       - div . step-scale-band
+ *       
+ * @author CJBurrell
+ *
+ */
 public class Timeline extends Widget {
 	//a timeline has many different bands
-	private TreeMap<String, TimeBand> timeBands;
+	/** TODO: change treemap, as not in charge of order in this case!
+	 * or change the ids
+	 */
+	//private TreeMap<String, TimeBand> timeBands;
+	private List<TimeBand> timeBands;
+//	private List<String> timeBandIds;
+	
 	private boolean isHorizontal;
 	private int width;
 	private int height;
+	private Element timelineContainer;
 	
+
 	private Element timelineDiv;
+	private boolean downStatus;
+	private int clientX;
+	private int scrollLeft;
 	
+	
 	public Timeline() {
-		timeBands = new TreeMap<String, TimeBand>();
+		//timeBands = new TreeMap<String, TimeBand>();
+		timeBands = new ArrayList<TimeBand>();
+//		timeBandIds = new ArrayList<String>();
+		
+		
+		timelineContainer = DOM.createDiv();
+		timelineContainer.setClassName("step-timeline-container");
+		
 		timelineDiv = DOM.createDiv();
 		timelineDiv.setClassName("step-timeline");
 		setElement(timelineDiv);
 		
+		TimelineMouseHandler tmh = new TimelineMouseHandler();
+		
+		addDomHandler(new MouseMoveHandler() {
+			@Override
+			public void onMouseMove(MouseMoveEvent event) {
+				//Log.debug("Mouse was moved above timeline");
+//				EventTarget et =  event.getNativeEvent().getEventTarget();
+//				com.google.gwt.dom.client.Element el = et.cast();
+				handle(event);
+			}
+			
+		}, MouseMoveEvent.getType());
+		addDomHandler(new MouseUpHandler() {
+			@Override
+			public void onMouseUp(MouseUpEvent event) {
+				Log.debug("Mouse was upped");
+//				EventTarget et =  event.getNativeEvent().getEventTarget();
+//				com.google.gwt.dom.client.Element el = et.cast();
+				handle(event);
+			}
+			
+		}, MouseUpEvent.getType());
+	
+		addDomHandler(new MouseDownHandler() {
+			@Override
+			public void onMouseDown(MouseDownEvent event) {
+				Log.debug("Mouse was Down");
+				handle(event);
+			}
+		}, MouseDownEvent.getType());
+
+		addDomHandler(new MouseOutHandler() {
+			@Override
+			public void onMouseOut(MouseOutEvent event) {
+				Log.debug("Mouse was out");
+				handle(event);
+			}
+			
+		}, MouseOutEvent.getType());
+
+		
+		disableSelection(getElement());
+		
+		
+//		addDomHandler(() {
+//			@Override
+//			public void onMouseOut(MouseOutEvent event) {
+//				Log.debug("Mouse was out");
+//				handle(event);
+//			}
+//			
+//		}, MouseOutEvent.getType());
 	}
+
+	private native static void disableSelection(Element e) /*-{
+		e.ondrag = function() { return false; };
+		e.onselectstart = function() { return false; };
+		e.style.MozUserSelect = "none";
+	}-*/;
+
+	private void handle(MouseOutEvent event) {
+		// TODO Auto-generated method stub
+		downStatus = false;
+	}
 	
+	public void handle(MouseMoveEvent e) {
+//		EventTarget et =  event.getNativeEvent().getEventTarget();
+//		com.google.gwt.dom.client.Element el = et.cast();				
+		
+		//TODO: customize as a property?
+		TimeBand defaultTimeBand = timeBands.get(0);
+		Unit defaultUnit = defaultTimeBand.getUnit();
+		int defaultPixelsPerUnit = defaultTimeBand.getPixelsPerUnit(); 
+		
+		if(downStatus) {
+			//mouse is down so move the scroll bars on each timeband			
+			//for each timeband, scroll a certain amount... This amount though is relative to the scales
+			//assume timeband 0 is the default
+			for(TimeBand tb : timeBands) {
+				tb.setScrollLeft(clientX, e.getClientX(), defaultUnit, defaultPixelsPerUnit);
+				Log.debug("About to scroll: " + (clientX - e.getClientX()));
+				
+			}
+		}	
+	}
+	
+	public void handle(MouseUpEvent e) {
+		downStatus = false;
+		new El(timelineDiv).setStyleName("step-letgo", true);
+	}
+	
+	public void handle(MouseDownEvent e) {
+		downStatus = true;
+		clientX = e.getClientX();
+		
+		//capture scrollLeft on every timeband
+		for(TimeBand tb : timeBands) {
+			tb.captureScrollLeft(e);
+		}
+		
+		Log.debug("ClientX " + clientX);
+		//scrollLeft = timelineDiv.getScrollLeft();
+		
+		//change cursor to hand grab
+		new El(timelineDiv).setStyleName("step-grab", true);
+		
+		//cursor: hand; /* ? */
+	}
+	
+	
+	
+	@Override
+	protected void onAttach() {
+		super.onAttach();
+		Log.debug("attaching timeline widget");
+	};
+	
+	@Override
+	protected void doAttachChildren() {
+		//not used
+	}
+	
 	/**
 	 * call this when the size of the timeline has changed
 	 */
@@ -34,7 +202,7 @@
 	/**
 	 * call this when you want to force a repaint
 	 */
-	public void paint() {
+	public synchronized void paint() {
 		if(timelineDiv == null) {
 			//this.getElement().appendChild(timelineDiv);
 			
@@ -42,22 +210,35 @@
 			//TODO if called paint again, what do we want to do?
 		}
 
-		for(TimeBand tb : timeBands.values()) {
-			tb.paint();
+		timelineDiv.appendChild(timelineContainer);
+		
+		int relativeTop = 0;
+		for(TimeBand tb : timeBands) {
+			tb.paint(relativeTop);
+			relativeTop += tb.getHeight();
 		}
-	
+		
+		//the total relative at this stage is the total height of the timeline
+		new El(timelineDiv).setHeight(relativeTop);
 	}
 	
-	public void addBand(TimeBand band) {
-		timeBands.put(band.getId(), band);
+	public synchronized void addBand(TimeBand band) {
+		timeBands.add(band);		
 	}
 	
 	public void removeBand(String bandId) {
 		timeBands.remove(bandId);
 	}
 	
-	public TimeBand getBand(String bandId) {
-		return timeBands.get(bandId);
+	public TimeBand getBand(final String bandId) throws TimeBandNotFoundException {
+		//do a linear search - we're not going to have lots of timebands
+		for(TimeBand t : timeBands) {
+			if(t.getId().equals(bandId)) {
+				return t;
+			}
+		}
+		
+		throw new TimeBandNotFoundException("Timeband " + bandId + " was not found.");
 	}
 
 	/**
@@ -105,4 +286,11 @@
 	public int getBandCount() {
 		return timeBands.size();
 	}
+	
+	/**
+	 * @return the timelineContainer
+	 */
+	public Element getTimelineContainer() {
+		return timelineContainer;
+	}
 }

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineMouseHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineMouseHandler.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/toolkit/timeline/TimelineMouseHandler.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -0,0 +1,25 @@
+package com.tyndalehouse.step.web.client.toolkit.timeline;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.event.dom.client.MouseMoveHandler;
+import com.google.gwt.event.shared.GwtEvent;
+
+public class TimelineMouseHandler extends GwtEvent<MouseMoveHandler> {
+
+	public static Type<MouseMoveHandler> TYPE = 
+		new Type<MouseMoveHandler>();
+	
+	@Override
+	public Type<MouseMoveHandler> getAssociatedType() {
+		Log.debug("Type requested from mouse move handler");
+		return TYPE;
+	}
+
+	@Override
+	protected void dispatch(MouseMoveHandler handler) {
+		// TODO Auto-generated method stub
+		Log.debug("Dispatched mousemove handler event");
+		
+	}
+
+}

Modified: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/TimelineView.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/TimelineView.java	2009-11-29 22:44:47 UTC (rev 28)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/client/view/TimelineView.java	2009-11-29 22:48:31 UTC (rev 29)
@@ -1,7 +1,5 @@
 package com.tyndalehouse.step.web.client.view;
 
-import java.util.Calendar;
-
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Widget;
 import com.tyndalehouse.step.web.client.presenter.TimelinePresenter;
@@ -12,26 +10,9 @@
 import com.tyndalehouse.step.web.client.widgets.timeline.TimeLineWidget;
 
 public class TimelineView extends Composite implements TimelinePresenter.Display {
-	
-	// GUI elements
-    private TimeLineWidget simileWidget = null;
 
 	//@Inject
-	public TimelineView(/* ITimeLineRender renderer*/ ) {
-        //ScrollPanel panel = new ScrollPanel();
-        //initWidget(panel);	
-       
-        /*
-        ITimeLineRender render = new TimelineRenderer();
-        simileWidget = new TimeLineWidget("100", "100", render);
-        panel.add(simileWidget);
-        panel.setAlwaysShowScrollBars(false);
-        
-        //no need to initialise here, since it is going to be initialised by the presenter
-        //DatasetHandler.getInstance().initialise(simileWidget,  "step/stonehenge.xml");      
-        simileWidget.setStyleName("timeline-default");
-        */
-        
+	public TimelineView() {
         //to do a custom timeline for testing
         com.tyndalehouse.step.web.client.toolkit.timeline.Timeline testT = 
         	new com.tyndalehouse.step.web.client.toolkit.timeline.Timeline(
@@ -41,32 +22,28 @@
         //TODO: make the timeline class a factory?
         TimeBand tb = new TimeBand(testT, "t1");
         tb.setPixelsPerUnit(50);
+        tb.setHeight(75);
         tb.setUnit(Unit.YEAR);
         tb.setCurrentDate(-62220095958093L);
-
         TimeEvent te1 = new TimeEvent("e1", "John's ministry and the start of Jesus's", -61249478358093L, -61183987158093L, tb);
         TimeEvent te2 = new TimeEvent("e2", "Birth of Jesus promised", -62220095958093L, null, tb);
         TimeEvent te3 = new TimeEvent("e3", "Jesus's minstry in Perea", -61123247958093L, -61118150358093L, tb);
-
-        
-        
         tb.addEvent(te1);
         tb.addEvent(te2);
         tb.addEvent(te3);
-
         testT.addBand(tb);
+
         
-        ScaleBand sb = new ScaleBand(testT, "s1");
-        testT.addBand(sb);
-	
-        //panel.add(testT);
+        TimeBand tb2 = new TimeBand(testT, "t2");
+        tb2.setHeight(50);
+        tb2.setShowScale(true);
+        tb2.setPixelsPerUnit(25);
+        tb2.setUnit(Unit.YEAR);
+        testT.addBand(tb2);
         
-        
         testT.paint();
 	}
 	
-
-	
 	@Override
 	public Widget asWidget() {
 		return this;
@@ -87,6 +64,6 @@
 
 	@Override
 	public TimeLineWidget getTimelineWidget() {
-		return simileWidget;
+		return null; //return simileTimeWidget;
 	}
 }




More information about the Tynstep-svn mailing list