/** * Produce a string representation. * * @return simple string representation */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append("TimeBarViewerSynchronizer:\n"); for (TimeBarViewerInterface viewer : _viewers) { buf.append(viewer.toString() + "\n"); } return buf.toString(); }
/** * Set the y axis width value for all viewers but the emitting viewer. * * @param emitting emitting viewer * @param yAxisWidth the width of the y axis */ private void setYAxisWidth(TimeBarViewerInterface emitting, int yAxisWIdth) { for (TimeBarViewerInterface viewer : _viewers) { if (!emitting.equals(viewer)) { // do not set on the emitting viewer viewer.removePropertyChangeListener(this); viewer.setYAxisWidth(yAxisWIdth); viewer.addPropertyChangeListener(this); } } }
/** * Set the start date value for all viewers but the emitting viewer. * * @param emitting emitting viewer * @param startDate value */ private void setStartDate(TimeBarViewerInterface emitting, JaretDate startDate) { for (TimeBarViewerInterface viewer : _viewers) { if (!emitting.equals(viewer)) { // do not set on the emitting viewer viewer.removePropertyChangeListener(this); viewer.setStartDate(startDate.copy()); viewer.addPropertyChangeListener(this); } } }
/** * Set the rowheight value for all viewers but the emitting viewer. * * @param emitting emitting viewer * @param rowHeight value */ private void setRowHeight(TimeBarViewerInterface emitting, int rowHeight) { for (TimeBarViewerInterface viewer : _viewers) { if (!emitting.equals(viewer)) { // do not set on the emitting viewer viewer.removePropertyChangeListener(this); viewer.setRowHeight(rowHeight); viewer.addPropertyChangeListener(this); } } }
/** * Set the pix per second value for all viewers but the emitting viewer. * * @param emitting emitting viewer * @param pixPerSecond value */ private void setPixPerSecond(TimeBarViewerInterface emitting, double pixPerSecond) { for (TimeBarViewerInterface viewer : _viewers) { if (!emitting.equals(viewer)) { // do not set on the emitting viewer viewer.removePropertyChangeListener(this); viewer.setPixelPerSecond(pixPerSecond); viewer.addPropertyChangeListener(this); } } }
/** * Add a viewer to the set of synchronized viewers. * * @param viewer the viewer to be added */ public void addViewer(TimeBarViewerInterface viewer) { if (_viewers == null) { _viewers = new ArrayList<TimeBarViewerInterface>(); } _viewers.add(viewer); viewer.addPropertyChangeListener(this); }
/** * Handle property changes from the different viewers. * * @param evt propertyChange event */ public void propertyChange(PropertyChangeEvent evt) { // System.out.println("propChange "+evt.getPropertyName()); TimeBarViewerInterface emitting = (TimeBarViewerInterface) evt.getSource(); if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_PIXELPERSECOND) && _syncTimeScale) { setPixPerSecond(emitting, emitting.getPixelPerSecond()); } else if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_ROWHEIGHT) && _syncRowHeight) { setRowHeight(emitting, emitting.getRowHeight()); } else if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_STARTDATE) && _syncStartDate) { setStartDate(emitting, emitting.getStartDate()); } else if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_MINDATE)) { setMinDate(emitting, emitting.getMinDate()); } else if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_MAXDATE)) { setMaxDate(emitting, emitting.getMaxDate()); } else if (evt.getPropertyName().equals(TimeBarViewerInterface.PROPERTYNAME_YAXISWIDTH) && _syncYAxisWidth) { setYAxisWidth(emitting, emitting.getYAxisWidth()); } }
/** * Remove a viewer from the set of synchronized viewers. * * @param viewer the viewer to be removed */ public void remViewer(TimeBarViewerInterface viewer) { if (_viewers != null) { _viewers.remove(viewer); viewer.removePropertyChangeListener(this); } }