1 /*
2 * File: TimeBarViewerInterface.java
3 * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de)
4 * A commercial license is available, see http://www.jaret.de.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 package de.jaret.util.ui.timebars;
21
22 import java.awt.Rectangle;
23 import java.beans.PropertyChangeListener;
24 import java.util.List;
25
26 import de.jaret.util.date.Interval;
27 import de.jaret.util.date.JaretDate;
28 import de.jaret.util.misc.Pair;
29 import de.jaret.util.ui.timebars.mod.IntervalModificator;
30 import de.jaret.util.ui.timebars.model.FocussedIntervalListener;
31 import de.jaret.util.ui.timebars.model.HierarchicalTimeBarModel;
32 import de.jaret.util.ui.timebars.model.HierarchicalViewState;
33 import de.jaret.util.ui.timebars.model.IIntervalRelation;
34 import de.jaret.util.ui.timebars.model.ISelectionRectListener;
35 import de.jaret.util.ui.timebars.model.ITimeBarChangeListener;
36 import de.jaret.util.ui.timebars.model.ITimeBarViewState;
37 import de.jaret.util.ui.timebars.model.TBRect;
38 import de.jaret.util.ui.timebars.model.TimeBarModel;
39 import de.jaret.util.ui.timebars.model.TimeBarNode;
40 import de.jaret.util.ui.timebars.model.TimeBarRow;
41 import de.jaret.util.ui.timebars.model.TimeBarSelectionModel;
42 import de.jaret.util.ui.timebars.strategy.IOverlapStrategy;
43
44 /**
45 * This interface has to be implemented by the Swing and SWT version of the timebar viewer. Its use is mainly for the
46 * TimeBarViewerDelegate to interact with the concrete implementation it supports. Applications should use the specific
47 * TimeBarViewer (Swing or SWT) directly.
48 *
49 * @author Peter Kliem
50 * @version $Id: TimeBarViewerInterface.java 1083 2011-07-01 20:29:16Z kliem $
51 */
52 public interface TimeBarViewerInterface {
53 /**
54 * Constant value indicating the time scale should be drawn on top of the diagram.
55 */
56 int TIMESCALE_POSITION_TOP = 0;
57
58 /**
59 * Constant value indicating the time scale should be drawn at the bottom of the diagram.
60 */
61 int TIMESCALE_POSITION_BOTTOM = 1;
62
63 /**
64 * Constant value indicating no time scale should be painted.
65 */
66 int TIMESCALE_POSITION_NONE = 2;
67
68 /**
69 * enum for the possible orientations.
70 *
71 * @see setOrientation.
72 */
73 enum Orientation {
74 /**
75 * horizontal orientation.
76 */
77 HORIZONTAL,
78 /**
79 * vertical orientation.
80 */
81 VERTICAL
82 };
83
84 /** default for the rowheight. */
85 int DEFAULT_ROWHEIGHT = 50;
86 /** default for the xaxis (timescale) height. */
87 int DEFAULT_XAXISHEIGHT = 50;
88 /** default for the yaxis width. */
89 int DEFAULT_YAXISWIDTH = 150;
90
91 /** property name constant of the bound property. */
92 String PROPERTYNAME_STARTDATE = "StartDate";
93 /** property name constant of the bound property. */
94 String PROPERTYNAME_FIRSTROW = "FirstRow";
95 /** property name constant of the bound property. */
96 String PROPERTYNAME_FIRSTROWOFFSET = "FirstRowOffset";
97 /** property name constant of the bound property. */
98 String PROPERTYNAME_ROWHEIGHT = "RowHeight";
99 /** property name constant of the bound property. */
100 String PROPERTYNAME_XAXISHEIGHT = "XAxisHeight";
101 /** property name constant of the bound property. */
102 String PROPERTYNAME_YAXISWIDTH = "YAxisWidth";
103 /** property name constant of the bound property. */
104 String PROPERTYNAME_ROWFILTER = "RowFilter";
105 /** property name constant of the bound property. */
106 String PROPERTYNAME_ROWSORTER = "RowSorter";
107 /** property name constant of the bound property. */
108 String PROPERTYNAME_INTERVALFILTER = "IntervalFilter";
109 /** property name constant of the bound property. */
110 String PROPERTYNAME_MAXDATE = "MaxDate";
111 /** property name constant of the bound property. */
112 String PROPERTYNAME_MINDATE = "MinDate";
113 /** property name constant of the bound property. */
114 String PROPERTYNAME_PIXELPERSECOND = "PixelPerSecond";
115 /** property name constant of the bound property. */
116 String PROPERTYNAME_ROWHEIGHTDRAGGINGALLOWED = "RowHeightDraggingAllowed";
117
118 /**
119 * Retrieve the delegate ATTENTION: the delegate is for mostly internal usage only. The interface and behavior may
120 * change.
121 *
122 * @return the delegate used by the viewer.
123 */
124 TimeBarViewerDelegate getDelegate();
125
126 /**
127 * Update the x scrollbar.
128 *
129 * @param max max value for the scrollbar (seconds)
130 * @param pos current positions in seconds
131 * @param secondsDisplayed the number of seconds displayed by the viewer
132 */
133 void updateXScrollBar(int max, int pos, int secondsDisplayed);
134
135 /**
136 * Update the y scrollbar.
137 *
138 * @param max max value for the scrollbar (row)
139 * @param pos first row displayed
140 * @param rowsDisplayed number of rows currently displayed
141 */
142 void updateYScrollBar(int max, int pos, int rowsDisplayed);
143
144 /**
145 * Mark the whole viewer as dirty causing a repaint.
146 *
147 */
148 void repaint();
149
150 /**
151 * Mark area to be repainted.
152 *
153 * @param rect java.awt.Rectangle that needs to be repainted
154 */
155 void repaint(Rectangle rect);
156
157 /**
158 * Mark area the needs repaint.
159 *
160 * @param x x coordinate
161 * @param y y coordinate
162 * @param width width of the area
163 * @param height height of the area
164 */
165 void repaint(int x, int y, int width, int height);
166
167 /**
168 * Return the height of the viewer.
169 *
170 * @return height
171 */
172 int getHeight();
173
174 /**
175 * Return the width of the viewer.
176 *
177 * @return width
178 */
179 int getWidth();
180
181 /**
182 * Get the corresponding date for an x coordinate in the viewer area.
183 *
184 * @param x in the viewer area
185 * @return corresponding date
186 */
187 JaretDate dateForX(int x);
188
189 /**
190 * Get the corresponding date for a point in the viewer area.
191 *
192 * @param x x coordinate in the viewer area
193 * @param y y coordinate in the viewer area
194 * @return corresponding date
195 */
196 JaretDate dateForXY(int x, int y);
197
198 /**
199 * Get the corresponding x coordinate in the viewer area for a given date.
200 *
201 * @param date Date
202 * @return x coordinate in the viewer area
203 */
204 int xForDate(JaretDate date);
205
206 /**
207 * Check whether a location is contained in a rendered interval.
208 *
209 * @param interval Interval to be checked
210 * @param intervalRect bounding rect for the interval
211 * @param x location x
212 * @param y location y
213 * @param overlapping true if there are overlapping intervals and drawing mode is not drawOverlapped
214 * @return true if contained
215 */
216 boolean timeBarContains(Interval interval, Rectangle intervalRect, int x, int y, boolean overlapping);
217
218 /**
219 * Calculate/get the containing rectangle of a rendered interval.
220 *
221 * @param interval Interval for which the containing rect should be calculated
222 * @param intervalRect Rectangle in the viewer (bounding rectangle)
223 * @param overlappig true if there are overlapping intervals and drawing mode is not drawOverlapped
224 * @return java.awt.Rectangle containing rectangle
225 */
226 Rectangle timeBarContainingRect(Interval interval, Rectangle intervalRect, boolean overlappig);
227
228 /**
229 * Set the cursor type.
230 *
231 * @param cursorType java.awt.cursor type
232 */
233 void setCursor(int cursorType);
234
235 /**
236 * Return the tool tip text of the viewer.
237 *
238 * @return ToolTipText for the viewer
239 */
240 String getToolTipText();
241
242 /**
243 * Get the tooltip text for a given location in a rendered interval.
244 *
245 * @param interval Interval
246 * @param intervalRect bounding rectangle for the interval
247 * @param x location x
248 * @param y location y
249 * @return the tooltip text or null if none could be found
250 */
251 String getIntervalToolTipText(Interval interval, Rectangle intervalRect, int x, int y);
252
253 /**
254 * Provide the tooltip for a relation if any.
255 *
256 * @param x x coordinate
257 * @param y y coordinate
258 * @return tooltip text or <code>null</code>
259 */
260 String getRelationTooltip(int x, int y);
261
262 /**
263 * Return the pixel per second ratio.
264 *
265 * @return pixel per second
266 */
267 double getPixelPerSecond();
268
269 /**
270 * Sets the scale ox the x axis as pixel per second, thus a value of 1000.0 / (24.0 * 60 * 60) will result in
271 * displaying one day over 1000 pixel. The property is a bound property and can be listened to by a
272 * PropertyChangeListener.
273 *
274 * @param pixelPerSecond pixel per second.
275 */
276 void setPixelPerSecond(double pixelPerSecond);
277
278 /**
279 * Set the scaling of the x axis by specifying the number of seconds that should be displayed.
280 *
281 * @param seconds number of seconds that will be displayed on the x axis
282 * @param center if set to <code>true</code> the center date will be fixed while scaling
283 */
284 void setSecondsDisplayed(int seconds, boolean center);
285
286 /**
287 * Set the scaling of the x axis by specifying the number of seconds that should be displayed.
288 *
289 * @param seconds number of seconds that will be displayed on the x axis
290 * @param centerDate date that will be fixed while scaling
291 */
292 void setSecondsDisplayed(int seconds, JaretDate centerDate);
293
294 /**
295 * Retrieve the current row height or the default row height if variable row heights/widths are enabled.
296 *
297 * @return row height in pixel
298 */
299 int getRowHeight();
300
301 /**
302 * Set the height for the rows in pixel. This property is bound.
303 *
304 * @param rowHeight new row height
305 */
306 void setRowHeight(int rowHeight);
307
308 /**
309 * Retrive the current start date of the displayed time span.
310 *
311 * @return start date of the visual section
312 */
313 JaretDate getStartDate();
314
315 /**
316 * Set the start date of the display.
317 *
318 * @param startDate first date to be displayed
319 */
320 void setStartDate(JaretDate startDate);
321
322 /**
323 * Retrieve the minimum value present in the data of the viewer.
324 *
325 * @return minimum date that can be displayed
326 */
327 JaretDate getMinDate();
328
329 /**
330 * Set the minimum date to be displayed. Note: this will only have an effect if min/max is not adjusted by the
331 * model.
332 *
333 * @param minDate minimum date to be displayed
334 */
335 void setMinDate(JaretDate minDate);
336
337 /**
338 * Retrieve the maximum date that can be displayed.
339 *
340 * @return maximum date that can be displayed
341 */
342 JaretDate getMaxDate();
343
344 /**
345 * Set the maximum date to be displayed. Note: this will only have an effect if min/max is not adjusted by the
346 * model.
347 *
348 * @param maxDate maximum date to be displayed
349 */
350 void setMaxDate(JaretDate maxDate);
351
352 /**
353 * Retrieve the adjustment policy for min and max date.
354 *
355 * @return true if min/max are adjusted by the model
356 */
357 boolean getAdjustMinMaxDatesByModel();
358
359 /**
360 * Set the adjustment policy.
361 *
362 * @param adjustMinMaxDatesByModel if set to true min and max dates are set by the model
363 */
364 void setAdjustMinMaxDatesByModel(boolean adjustMinMaxDatesByModel);
365
366 /**
367 * Retrieve the index of the first row that is displayed.
368 *
369 * @return index of the first displayed row
370 */
371 int getFirstRowDisplayed();
372
373 /**
374 * Set the first row to be displayed.
375 *
376 * @param firstRow upmost row to be displayed
377 * @param pixOffset pixel offset
378 */
379 void setFirstRow(int firstRow, int pixOffset);
380
381 /**
382 * Set the first row to be displayed.
383 *
384 * @param rowIdx index of the first row to be displayed
385 */
386 void setFirstRowDisplayed(int rowIdx);
387
388 /**
389 * Set the the first row to be displayed.
390 *
391 * @param row row that should be the topmost row displayed.
392 */
393 void setFirstRowDisplayed(TimeBarRow row);
394
395 /**
396 * Retrieve the pixeloffset for the first row.
397 *
398 * @return pixel offset of the first row
399 */
400 int getFirstRowOffset();
401
402 /**
403 * Set the pixeloffset of the first row.
404 *
405 * @param offset pixeloffset for the first row
406 */
407 void setFirstRowOffset(int offset);
408
409 /**
410 * Set the last row in the viewer. If there are not enough rows for the row beeing the last row the row will be
411 * displayed as far down as possible by setting the first row to 0.
412 *
413 * @param index index of the row to be displayed at the bottom of the viewer.
414 */
415 void setLastRow(int index);
416
417 /**
418 * Set the last row in the viewer. If there are not enough rows for the row beeing the last row the row will be
419 * displayed as far down as possible by setting the first row to 0.
420 *
421 * @param row the row to be displayed at the bottom of the viewer.
422 */
423 void setLastRow(TimeBarRow row);
424
425 /**
426 * Get the selection model of the viewer.
427 *
428 * @return the selection model of the viewer
429 */
430 TimeBarSelectionModel getSelectionModel();
431
432 /**
433 * Set the selectionmodel to be used by the viewer.
434 *
435 * @param selectionModel selection model to be used
436 */
437 void setSelectionModel(TimeBarSelectionModel selectionModel);
438
439 /**
440 * Set the width of the y axis (the header area). The width is initialized with the width announced by the header
441 * renderer.
442 *
443 * @param width width in pixel
444 */
445 void setYAxisWidth(int width);
446
447 /**
448 * Retrieve the width of the y axis (header area).
449 *
450 * @return width of the header area
451 */
452 int getYAxisWidth();
453
454 /**
455 * Set the width of the hierarchy area of the viewer. The width is initialized by the hierarchy renderer if set and
456 * applicable.
457 *
458 * @param width width in pixels
459 */
460 void setHierarchyWidth(int width);
461
462 /**
463 * Retrieve the width of the hierarchy area.
464 *
465 * @return the width of the hierarchy area
466 */
467 int getHierarchyWidth();
468
469 /**
470 * Retrieve the height (or width when orientation is vertical) of the timescale.
471 *
472 * @return returns the xAxisHeight.
473 */
474 int getXAxisHeight();
475
476 /**
477 * Set the height (or width) of the timescale.
478 *
479 * @param height height or width for the time scale
480 */
481 void setXAxisHeight(int height);
482
483 /**
484 * Set the autoscroll behaviour. If autoscroll is enabled, drag and select by selection rect will autoscroll the
485 * viewer.
486 *
487 * @param enableAutoscroll true for enabling autoscroll
488 */
489 void setAutoscrollEnabled(boolean enableAutoscroll);
490
491 /**
492 * Get the autoscroll behaviour.
493 *
494 * @return true if autoscroll is enabled.
495 */
496 boolean isAutoscrollEnabled();
497
498 /**
499 * Retrieve the status of row grid drawing.
500 *
501 * @return true if the row grid drawing is enabled
502 */
503 boolean getDrawRowGrid();
504
505 /**
506 * Set the row grid drawing status. If set to true rows will be separated by lines.
507 *
508 * @param drawRowGrid if true, rows will be separated by a thin line
509 */
510 void setDrawRowGrid(boolean drawRowGrid);
511
512 /**
513 * Add an intervalModificator controlling changes on the intervals.
514 *
515 * @param intervalModificator interval modificator to add
516 */
517 void addIntervalModificator(IntervalModificator intervalModificator);
518
519 /**
520 * Remove an interval modificator.
521 *
522 * @param intervalModificator interval modificator to remove
523 */
524 void remIntervalModificator(IntervalModificator intervalModificator);
525
526 /**
527 * Fire a property change.
528 *
529 * @param string property name
530 * @param oldValue old value
531 * @param newValue new value
532 */
533 void firePropertyChange(String string, double oldValue, double newValue);
534
535 /**
536 * Fire a property change.
537 *
538 * @param propName property name
539 * @param oldValue old value
540 * @param newValue new value
541 */
542 void firePropertyChangeX(String propName, Object oldValue, Object newValue);
543
544 /**
545 * Add a PropertyChangeListener.
546 *
547 * @param listener property change listener to add
548 */
549 void addPropertyChangeListener(PropertyChangeListener listener);
550
551 /**
552 * Remove a property change listener.
553 *
554 * @param listener listener to remove
555 */
556 void removePropertyChangeListener(PropertyChangeListener listener);
557
558 /**
559 * Retrieve the tooltip for a position on the timescale.
560 *
561 * @param x x coordinate
562 * @param y y coordinate
563 * @return the tooltip text or <code>null</code> indicating no tt is available
564 */
565 String getTimeScaleToolTipText(int x, int y);
566
567 /**
568 * Retrieve the tooltip for a position on a row.
569 *
570 * @param row row displayed on the location
571 * @param x x coordinate
572 * @param y y coordinate
573 * @return the tooltip text or <code>null</code> indicating no tt is available
574 */
575 String getHeaderToolTipText(TimeBarRow row, int x, int y);
576
577 /**
578 * Retrieve the tooltip for a position in the hierarchy.
579 *
580 * @param node node displayed at the location
581 * @param x x coordinate
582 * @param y y coordinate
583 * @return the tooltip text or <code>null</code> indicating no tt is available
584 */
585 String getHierarchyToolTipText(TimeBarNode node, int x, int y);
586
587 /**
588 * Retrieve the statndard viewstate of the viewer containing the row heights/column widths.
589 *
590 * @return the viewstate used by the viewer
591 */
592 ITimeBarViewState getTimeBarViewState();
593
594 /**
595 * Retrieve the hierarchical viewstate used by the viewer.
596 *
597 * @return the hierarchical viewstate
598 */
599 HierarchicalViewState getHierarchicalViewState();
600
601 /**
602 * Set the hierarchical viewstate to be used. Most probably no one needs to do this, since a default viewstate is
603 * used when setting a hierarchical model.
604 *
605 * @param hierarchicalViewState viewstate to use
606 */
607 void setHierarchicalViewState(HierarchicalViewState hierarchicalViewState);
608
609 /**
610 * Set the flat model to be displayed.
611 *
612 * @param model the model to be displyed
613 */
614 void setModel(TimeBarModel model);
615
616 /**
617 * Set a hierarchical model to be displayed.
618 *
619 * @param hModel hierarchial model
620 */
621 void setModel(HierarchicalTimeBarModel hModel);
622
623 /**
624 * Retrieve the flat model used by the viewer. This will always return a flat model, even if a hierarchical model
625 * has been set. In this case the warpping flat model is returned.
626 *
627 * @return the flat model used by the viewer
628 */
629 TimeBarModel getModel();
630
631 /**
632 * Retrieve the hierarchical model of the viewer. This may be <code>null</code> if a flat model has been set
633 * directly.
634 *
635 * @return the hierarchical model or null
636 */
637 HierarchicalTimeBarModel getHierarchicalModel();
638
639 /**
640 * Get the width for marker painting (as requested by a marker renderer).
641 *
642 * @param marker marker to check the width for
643 * @return overall width for marker painting
644 */
645 int getMarkerWidth(TimeBarMarker marker);
646
647 /**
648 * Set a title for the viewer to be displayed.
649 *
650 * @param title or <code>null</code> indicating no title.
651 */
652 void setTitle(String title);
653
654 /**
655 * Retrieve the title.
656 *
657 * @return the title.
658 */
659 String getTitle();
660
661 /**
662 * Display the context menu for the normal viewer body.
663 *
664 * @param x x coordinate for the menu
665 * @param y y coordinate for the menu
666 */
667 void displayBodyContextMenu(int x, int y);
668
669 /**
670 * Display the context menu for the time scale.
671 *
672 * @param x x coordinate for the menu
673 * @param y y coordinate for the menu
674 */
675 void displayTimeScaleContextMenu(int x, int y);
676
677 /**
678 * Display the context menu for an interval.
679 *
680 * @param interval interval clicked on
681 * @param x x coordinate for the menu
682 * @param y y coordinate for the menu
683 */
684 void displayIntervalContextMenu(Interval interval, int x, int y);
685
686 /**
687 * Display the header context menu.
688 *
689 * @param row row clicked on
690 * @param x x coordinate for the menu
691 * @param y y coordinate for the menu
692 */
693 void displayHeaderContextMenu(TimeBarRow row, int x, int y);
694
695 /**
696 * Display the hierarchy area context menu.
697 *
698 * @param row row clicked on
699 * @param x x coordinate for the menu
700 * @param y y coordinate for the menu
701 */
702 void displayHierarchyContextMenu(TimeBarRow row, int x, int y);
703
704 /**
705 * Display the title area context menu.
706 *
707 * @param x x coordinate for the menu
708 * @param y y coordinate for the menu
709 */
710 void displayTitleContextMenu(int x, int y);
711
712 /**
713 * Check whether the given position should toggle expanded state of a node.
714 *
715 * @param node the node rendered
716 * @param x x coordinate
717 * @param y y coordinate
718 * @return true if toggling should occur
719 */
720 boolean isInToggleArea(TimeBarNode node, int x, int y);
721
722 /**
723 * Check whether the given position is in the selection area of the hierarchy.
724 *
725 * @param node the node
726 * @param x x coordinate
727 * @param y y coordinate
728 * @return true if the coordniate is in the hierarchy area
729 */
730 boolean isInHierarchySelectionArea(TimeBarNode node, int x, int y);
731
732 /**
733 * Add a timebar marker.
734 *
735 * @param marker marker to add
736 */
737 void addMarker(TimeBarMarker marker);
738
739 /**
740 * Remove a timebar marker.
741 *
742 * @param marker marker to remove
743 */
744 void remMarker(TimeBarMarker marker);
745
746 /**
747 * Retrieve the list of al markers.
748 *
749 * @return List of all added timebar markers
750 */
751 List<TimeBarMarker> getMarkers();
752
753 /**
754 * Directly set a list of markers.
755 *
756 * @param markers list of timebar markers
757 */
758 void addMarkers(List<TimeBarMarker> markers);
759
760 /**
761 * Retrieve the selection delta used to determine whether a marker or interval edge is clicked/dragged.
762 *
763 * @return max distance for detection
764 */
765 int getSelectionDelta();
766
767 /**
768 * Set the selection delta used to determine whether a marker or interval edge is clicked/dragged. A larger
769 * selection delta will result in easier selection of of interval bounds and other in place draggable elements but
770 * may cause problems when draggable elements are near to each other since more elements are in range and the
771 * selected element will be determined by the sequence of checks in the code of the viewer.
772 * <p>
773 * A selection delta of n means clicks willl have to be on the element or (n-1) pixels away to consider an element
774 * hit.
775 * </p>
776 *
777 * @param selectionDelta max distance for detection
778 */
779 void setSelectionDelta(int selectionDelta);
780
781 /**
782 * Check whether it is allowed to drag the limiting lines of the hierarchy ara and the header (yaxis) area.
783 *
784 * @return true if dragging is allowed.
785 */
786 boolean isLineDraggingAllowed();
787
788 /**
789 * Set the allowance for line dragging of the limiting lines for hierarchy and header(yaxis) areas.
790 *
791 * @param lineDraggingAllowed true for enabling the drag possibility
792 */
793 void setLineDraggingAllowed(boolean lineDraggingAllowed);
794
795 /**
796 * Check whether row height dragging is allowed.
797 *
798 * @return <code>true</code> if enabled
799 */
800 boolean isRowHeightDragginAllowed();
801
802 /**
803 * Set whether row height dragging should be allowed.
804 *
805 * @param rowHeightDraggingAllowed <code>true</code> to allow interactive dragging of row heights
806 */
807 void setRowHeightDraggingAllowed(boolean rowHeightDraggingAllowed);
808
809 /**
810 * Retrieve whether marker dragging in the diagram area is activated.
811 *
812 * @return <code>true</code> if marker dragging in the diagram area is allowed
813 */
814 boolean getMarkerDraggingInDiagramArea();
815
816 /**
817 * Set whether marker dragging is allowed in the diagram area (If intervals are modificable the marker will only be
818 * grabbed when no other operation is applicable).
819 *
820 * @param allowed <code>true</code> for allowing marker drag in the diagram area.
821 */
822 void setMarkerDraggingInDiagramArea(boolean allowed);
823
824 /**
825 * Retrieve the y coordinate in the diagram pane for the given row.
826 *
827 * @param row row
828 * @return y coordinate in the diagram pane or -1 if the y coordinate could not be retrieved
829 */
830 int getYForRow(TimeBarRow row);
831
832 /**
833 * Retrieve the row for a given y coodinate (x if oriented vertcal; use getRowForXY instead!).
834 *
835 * @param y coordinate
836 * @return row or <code>null</code>
837 */
838 TimeBarRow getRowForY(int y);
839
840 /**
841 * Retrieve the row for a given point.
842 *
843 * @param x x coordinate
844 * @param y y coordinate
845 * @return row or <code>null</code>
846 */
847 TimeBarRow getRowForXY(int x, int y);
848
849 /**
850 * Check whether th delegate is setup for millisecond accuracy. This will only have an impact on the x scroll bar.
851 *
852 * @return true if ms accuracy ist set
853 */
854 boolean isMilliAccuracy();
855
856 /**
857 * Set the delegates status concerning millisecond accuracy. If set to true the x scroll bar will operate in
858 * milliseconds (normal operation: seconds).
859 *
860 * @param milliAccuracy true to use ms accuracy
861 */
862 void setMilliAccuracy(boolean milliAccuracy);
863
864 /**
865 * Retrieve the state of the variable xscale state. If true a list of intervals contlrols different pps values for
866 * different intervals on the axis.
867 *
868 * @return true if a varying pps value is used
869 */
870 boolean hasVariableXScale();
871
872 /**
873 * Set the state for the variable xscale.
874 *
875 * @param state true if a variable scale should be used.
876 */
877 void setVariableXScale(boolean state);
878
879 /**
880 * Retrieve the row that hold intervals (PpsIntervals) defining the pps value for different intervals.
881 *
882 * @return the row or <code>null</code> if no variable xscale has been defined.
883 */
884 TimeBarNode getPpsRow();
885
886 /**
887 * Do horizontal scrolling by diff pixel. The method ought to copy the content of the diagramRect and produce dirty
888 * regions for the parts not affected by the scroll. The method is intended to be used by the TimeBarViewerDelegate
889 * only.
890 *
891 * @param diff pixel difference (positive for right scroll)
892 */
893 void doScrollHorizontal(int diff);
894
895 /**
896 * Do vertical scrolling by diff pixel. The method ought to copy the content of the diagramRect and produce dirty
897 * regions for the parts not affected by the scroll. The method is intended to be used by the TimeBarViewerDelegate
898 * only.
899 *
900 * @param diff pixel difference (positive for downwards scroll)
901 */
902 void doScrollVertical(int diff);
903
904 /**
905 * Get whether optimzed scrollnig is used.
906 *
907 * @return true if optimized scrolling is used
908 */
909 boolean getOptimizeScrolling();
910
911 /**
912 * Set whether optimized scrolling should be used. The default is <code>false</code> since this may cause problems
913 * on some platforms using SWT (Linux/GTK and OSX/intel). Optimized scrolling can not be used together with a
914 * variable xscale.
915 *
916 * @param optimizeScrolling true for optimized scrolling
917 */
918 void setOptimizeScrolling(boolean optimizeScrolling);
919
920 /**
921 * Retrieve the orientation of the viewer.
922 *
923 * @return the orientation of the viewer
924 */
925 Orientation getTBOrientation();
926
927 /**
928 * Set the orientation of the viewer.
929 *
930 * @param orientation the new orientation for the viewer
931 */
932 void setTBOrientation(Orientation orientation);
933
934 /**
935 * Get the number of rows (columns) that the viewer scales itself to.
936 *
937 * @return number of rows to display or -1 if no scale has been set
938 */
939 int getAutoScaleRows();
940
941 /**
942 * Set a number of rows (columns) to be displayed by the viewer. The row height will always be changed to math the
943 * number of rows to display.
944 *
945 * @param rows the number of rows or -1 for no special scaling (default)
946 */
947 void setAutoScaleRows(int rows);
948
949 /**
950 * Called by the delegate whenever the selection changed (to support selction provider under SWT).
951 */
952 void fireSelectionChanged();
953
954 /**
955 * Add a listener to be informaed about interval changes.
956 *
957 * @param listener listener
958 */
959 void addTimeBarChangeListener(ITimeBarChangeListener listener);
960
961 /**
962 * Remove a timebar change listener.
963 *
964 * @param listener listener to remove
965 */
966 void removeTimeBarChangeListener(ITimeBarChangeListener listener);
967
968 /**
969 * Add a listener to be informed when the focus inside the viewer changes.
970 *
971 * @param listener listener to be added.
972 */
973 void addFocussedIntervalListener(FocussedIntervalListener listener);
974
975 /**
976 * Remove a focussedIntervalListener.
977 *
978 * @param listener listener to be removed from the listener list.
979 */
980 void remFocussedIntervalListener(FocussedIntervalListener listener);
981
982 /**
983 * Add a listener to be informed when the selection rect changes.
984 *
985 * @param listener listener to be added.
986 */
987 void addSelectionRectListener(ISelectionRectListener listener);
988
989 /**
990 * Remove a selection rect listener.
991 *
992 * @param listener listener to be removed from the listener list.
993 */
994 void remSelectionRectListener(ISelectionRectListener listener);
995
996 /**
997 * Check whether a row delimiter line is hit by a coordinate.
998 *
999 * @param x x coord
1000 * @param y y coord
1001 * @return <code>true</code> if a row line is hit
1002 */
1003 boolean rowLineHit(int x, int y);
1004
1005 /**
1006 * Check whether a given point is in the row axis area (hierarchy or header).
1007 *
1008 * @param x x coordinate
1009 * @param y y coordinate
1010 * @return <code>true</code> if the point is in either hierarchy or header area
1011 */
1012 boolean isInRowAxis(int x, int y);
1013
1014 /**
1015 * Check whether a given point is in the main diagram area.
1016 *
1017 * @param x x coordinate
1018 * @param y y coordinate
1019 * @return <code>true</code> if the point is in the diagram rectangle
1020 */
1021 boolean isInDiagram(int x, int y);
1022
1023 /**
1024 * Check whether a date is currently visible.
1025 *
1026 * @param date dat eto check
1027 * @return <code>true</code> if the date is currently displayed
1028 */
1029 boolean isDisplayed(JaretDate date);
1030
1031 /**
1032 * Retrieve the strategy for filtering when painting (see {@link #setStrictClipTimeCheck(boolean)}).
1033 *
1034 * @return <code>true</code> if strict checking is enabled
1035 */
1036 boolean getStrictClipTimeCheck();
1037
1038 /**
1039 * Set the optimization strategy for interval filtering when painting.
1040 *
1041 * @param strictClipTimeCheck If set to true, intervals are filtered strictly by their interval bounds, disallowing
1042 * rendering beyond the bounding box calculated by the interval bounds. Defaults to false resulting in filtering by
1043 * the preferred drawing area.
1044 */
1045 void setStrictClipTimeCheck(boolean strictClipTimeCheck);
1046
1047 /**
1048 * Retrieve the time to be additionally considered (looking back) when deciding which intervals are to be painted.
1049 * Only taken into accoutn when StrictClipTimeCheck is false. Default is 120 Minutes.
1050 *
1051 * @return time in minutes
1052 */
1053 int getScrollLookBackMinutes();
1054
1055 /**
1056 * Set the additional time to be considered when deciding whether to draw an interval looking back. Only taken into
1057 * account when StrictClipTimeCheck is true.
1058 *
1059 * @param scrollLookBackMinutes time in minutes
1060 */
1061 void setScrollLookBackMinutes(int scrollLookBackMinutes);
1062
1063 /**
1064 * Retrieve the time to be additionally considered (looking forward) when deciding which intervals are to be
1065 * painted. Only taken into account when StrictClipTimeCheck is true.
1066 *
1067 * @return time in mnutes
1068 */
1069 int getScrollLookForwardMinutes();
1070
1071 /**
1072 * Set the additional time to be considered when deciding whether to draw an interval looking forward. Only taken
1073 * into account when StrictClipTimeCheck is true.
1074 *
1075 * @param scrollLookForwardMinutes time in minutes
1076 */
1077 void setScrollLookForwardMinutes(int scrollLookForwardMinutes);
1078
1079 /**
1080 * Get the seconds currently displayed by the diagram.
1081 *
1082 * @return the number of seconds currently displayed by the diagram geometry
1083 */
1084 int getSecondsDisplayed();
1085
1086 /**
1087 * Retrieve the used strategy for determing overlap information.
1088 *
1089 * @return the overlap strategy
1090 */
1091 IOverlapStrategy getOverlapStrategy();
1092
1093 /**
1094 * Set the strategy to be used for calculating overlap information.
1095 *
1096 * @param overlapStrategy the strytegy to be used. May not be <code>null</code>.
1097 */
1098 void setOverlapStrategy(IOverlapStrategy overlapStrategy);
1099
1100 /**
1101 * Retrieve the name set on the viewer.
1102 *
1103 * @return the name or <code>null</code> if no name has been set
1104 */
1105 String getName();
1106
1107 /**
1108 * Set a name as a simple string property for internal application use.
1109 *
1110 * @param name name of the viewer
1111 */
1112 void setName(String name);
1113
1114 /**
1115 * Retrieve the currently set autoscroll delta.
1116 *
1117 * @return the autoscroll delat in pixel
1118 */
1119 int getAutoscrollDelta();
1120
1121 /**
1122 * Set the autoscroll delta. This value will be used to deteremine the autoscroll deltas when the mouse pointer is
1123 * not in the diagram rectangle. It is specified in pixel so it is always relative to the timescale. The value will
1124 * also be used to limit the maximum delta when resizing an interval (edge dragging) with the cursor outside the
1125 * diagram rectangle.
1126 *
1127 * @param autoscrollDelta delta in pixel
1128 */
1129 void setAutoscrollDelta(int autoscrollDelta);
1130
1131 /**
1132 * If <code>true</code> all selected intervals will be dragged together with the interval on that the drag happened.
1133 *
1134 * @return the state of the flag
1135 */
1136 boolean getDragAllSelectedIntervals();
1137
1138 /**
1139 * If set to <code>true</code> all selected intervals are dragged when an interval is dragged. The default is false.
1140 *
1141 * @param dragAllSelectedIntervals <code>true</code> to drag all selcted intervals
1142 */
1143 void setDragAllSelectedIntervals(boolean dragAllSelectedIntervals);
1144
1145 /**
1146 * Retrieve the list of relations hit for a coordinate. This method is in the interface to allow tookit independent
1147 * implementation of the relation select mechanism.
1148 *
1149 * @param x x coordinate
1150 * @param y y coordinate
1151 * @return the list of relations or <code>null</code> if no relations can be found
1152 */
1153 List<IIntervalRelation> getRelationsForCoord(int x, int y);
1154
1155 /**
1156 * Retrieve the state of the scroll to focus flag.
1157 *
1158 * @return <code>true</code> if the viewer should scroll to the focussed interval
1159 */
1160 boolean getScrollOnFocus();
1161
1162 /**
1163 * If set to true the viewer will scroll to the begin of an interval if it's focussed.
1164 *
1165 * @param scrollOnFocus <code>true</code> for scrolling to the focussed interval
1166 */
1167 void setScrollOnFocus(boolean scrollOnFocus);
1168
1169 /**
1170 * Retrieve whether the root node is shown when using a hierachical model.
1171 *
1172 * @return <code>true</code> if the root is not shown
1173 */
1174 boolean getHideRoot();
1175
1176 /**
1177 * Set whether the root node should be shown when using a hierachical model.
1178 *
1179 * @param hideRoot <code>true</code> if the root node should be hidden
1180 */
1181 void setHideRoot(boolean hideRoot);
1182
1183 /**
1184 * Retrieve the selected region.
1185 *
1186 * @return the selected region or <code>null</code>
1187 */
1188 TBRect getRegionRect();
1189
1190 /**
1191 * Remove the selction of a region if existent.
1192 */
1193 void clearRegionRect();
1194
1195 /**
1196 * Enable/Disable region selections.
1197 *
1198 * @param enabled <code>true</code> enabling
1199 */
1200 void setRegionRectEnable(boolean enabled);
1201
1202 /**
1203 * Retrieve whether region selections are enabled.
1204 *
1205 * @return true if region selections are enabled
1206 */
1207 boolean getRegionRectEnable();
1208
1209 /**
1210 * Set whether all intervals in a non overlapping drawn row should use the same height/width.
1211 *
1212 * @param useUniformHeight <code>true</code> for uniform heights/widths
1213 */
1214 void setUseUniformHeight(boolean useUniformHeight);
1215
1216 /**
1217 * Retrieve whether uniform height is use for all intervals in a row.
1218 *
1219 * @return <code>true</code> if all intervals in a non overlapping drawn row should use the same height/width
1220 */
1221 boolean getUseUniformHeight();
1222
1223 /**
1224 * Set a date range and scaling that will be set as the initial display right after the viewer is displayed.
1225 *
1226 * @param startDate start date
1227 * @param secondsDisplayed seconds to be displayed in the viewer
1228 */
1229 void setInitialDisplayRange(JaretDate startDate, int secondsDisplayed);
1230
1231 /**
1232 * Retrieve the row and date of the click leading to the activation of a context menu.
1233 *
1234 * @return Pair containing the row and date of the click position. Might be <code>null</code> if no click has been
1235 * recorded.
1236 */
1237 Pair<TimeBarRow, JaretDate> getPopUpInformation();
1238
1239 /**
1240 * Scroll a date into the visible area of the viewer.
1241 *
1242 * @param date date to be shown.
1243 * @return the number of seconds the start date have been modified
1244 */
1245 int scrollDateToVisible(JaretDate date);
1246
1247 /**
1248 * Make sure the specified row is visible.
1249 *
1250 * @param row TimeBarRow to be in the visible area.
1251 */
1252 void scrollRowToVisible(TimeBarRow row);
1253
1254 /**
1255 * Make sure the specified interval is in the visibe area of the viewer. If the interval does not fit in the visible
1256 * area, the beginning of the interval will be displayed.
1257 *
1258 * @param row TimeBarRow of the interval
1259 * @param interval inteval.
1260 */
1261 void scrollIntervalToVisible(TimeBarRow row, Interval interval);
1262
1263 }