/**
  * Implementation of callback from layout algorithm. This method is called once for each revision
  * or branch marker to be added to the view.
  *
  * @see net.sf.versiontree.layout.drawer.IDrawMethod#draw(net.sf.versiontree.data.ITreeElement,
  *     int, int)
  */
 public void draw(ITreeElement element, int x, int y) {
   if (element instanceof IRevision) {
     Revision revision = new Revision(connectors, 0);
     revision.setRevisionData((IRevision) element);
     revision.addMouseListener(this);
     revision.setMenu(this.getMenu());
     revision.setLocation(BORDER + x * (width + hspacing), BORDER + y * (height + vspacing));
     revision.setSize(revision.computeSize(SWT.DEFAULT, SWT.DEFAULT));
     // check if this is the current revision
     if ((revision.getRevisionData().getState() & ITreeElement.STATE_CURRENT) != 0) {
       currentRevision = revision;
       selectionManager.revisionSelected(currentRevision.getRevisionData(), 1);
       logSelectionListener.logEntrySelected(currentRevision.getRevisionData().getLogEntry());
     }
   } else {
     Branch branch = new Branch(connectors, 0);
     branch.setBranchData(((IBranch) element));
     branch.addMouseListener(this);
     branch.setLocation(BORDER + x * (width + hspacing), BORDER + y * (height + vspacing));
     branch.setSize(branch.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   }
 }
 /**
  * Listener for all components on the view. Checks for left clicks on Revisions, changes the
  * selection and notifies the LogEntrySelectionListener.
  */
 public void mouseDown(MouseEvent e) {
   if (e.getSource() instanceof Revision) {
     Revision selected = (Revision) e.getSource();
     // exit if user wants to open contex menu on
     // a already selected revision
     if (e.button == 3 && selected.isSelected()) {
       return;
     }
     selectionManager.revisionSelected(selected.getRevisionData(), e.stateMask);
     redrawAll();
     // notify listener
     if (selected.isSelected()) {
       logSelectionListener.logEntrySelected(selected.getRevisionData().getLogEntry());
     }
   } else if (e.getSource() instanceof Branch) {
     Branch selected = (Branch) e.getSource();
     List<IRevision> revisions = selected.getBranchData().getRevisions();
     if (revisions.size() > 0) {
       selectionManager.branchSelected(revisions, e.stateMask);
       redrawAll();
     }
   }
 }