Changeset 1362
- Timestamp:
- 07/17/08 13:05:07 (4 years ago)
- Files:
-
- jmatter-complet/branches/TRY-JPA/jmatter/src/com/u2d/calendar/CalEvent.java (modified) (2 diffs)
- jmatter-complet/branches/TRY-JPA/jmatter/src/com/u2d/type/atom/TimeSpan.java (modified) (2 diffs)
- jmatter-complet/branches/TRY-JPA/modules/swingvm/src/com/u2d/view/swing/calendar/PositionedLayout.java (modified) (5 diffs)
- jmatter-complet/branches/TRY-JPA/modules/swingvm/src/com/u2d/view/swing/calendar/simple/DayView.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jmatter-complet/branches/TRY-JPA/jmatter/src/com/u2d/calendar/CalEvent.java
r1104 r1362 21 21 * @author Eitan Suez 22 22 */ 23 public abstract class CalEvent extends AbstractComplexEObject 23 public abstract class CalEvent extends AbstractComplexEObject implements Comparable<CalEvent> 24 24 { 25 25 /** … … 70 70 } 71 71 72 public int compareTo(CalEvent e) 73 { 74 return timeSpan().compareTo(e.timeSpan()); 75 } 72 76 73 77 public Schedulable schedulable() jmatter-complet/branches/TRY-JPA/jmatter/src/com/u2d/type/atom/TimeSpan.java
r1152 r1362 18 18 */ 19 19 public class TimeSpan extends AbstractAtomicEO 20 implements Searchable 20 implements Searchable, Comparable<TimeSpan> 21 21 { 22 22 private Calendar _startCal; … … 64 64 65 65 assign(start, end); 66 } 67 68 public int compareTo(TimeSpan t) 69 { 70 return _startCal.compareTo(t.startCal()); 66 71 } 67 72 jmatter-complet/branches/TRY-JPA/modules/swingvm/src/com/u2d/view/swing/calendar/PositionedLayout.java
r285 r1362 6 6 import java.awt.*; 7 7 import java.util.*; 8 import java.util.List; 8 9 import javax.swing.*; 9 10 import com.u2d.calendar.*; … … 16 17 private TimeIntervalView _view; 17 18 private java.util.List _events = new ArrayList(); 18 private java.util. List _components = new ArrayList();19 19 private java.util.Map _components = new HashMap(); 20 20 21 public PositionedLayout(TimeIntervalView view) 21 22 { … … 33 34 CalEvent event = (CalEvent) constraints; 34 35 _events.add(event); 35 _components. add(comp);36 _components.put(event, comp); 36 37 } 37 38 } … … 41 42 synchronized (comp.getTreeLock()) 42 43 { 43 for (int i=0; i<_components.size(); i++) 44 { 45 if (_components.get(i) == comp) 46 { 47 _components.remove(i); 48 _events.remove(i); 49 } 50 } 44 Set entrySet = _components.entrySet(); 45 for (Iterator itr = entrySet.iterator(); itr.hasNext(); ) 46 { 47 Map.Entry entry = (Map.Entry) itr.next(); 48 Component c = (Component) entry.getValue(); 49 if (c == comp) 50 { 51 CalEvent event = (CalEvent) entry.getKey(); 52 _events.remove(event); 53 _components.remove(entry); 54 return; 55 } 56 } 51 57 } 52 58 } … … 97 103 public void layoutContainer(Container parent) 98 104 { 99 synchronized (parent.getTreeLock())105 synchronized (parent.getTreeLock()) 100 106 { 101 107 JComponent viewcomp = (JComponent) _view; 102 108 viewcomp.setBounds(parent.getBounds()); 103 109 104 for (int i=0; i<_components.size(); i++) 105 { 106 Component comp = (Component) _components.get(i);110 Collections.sort(_events); 111 for (int i=0; i<_events.size(); i++) 112 { 107 113 CalEvent event = (CalEvent) _events.get(i); 108 comp.setBounds(_view.getBounds(event)); 109 } 110 } 114 List<CalEvent> overlappingEvents = new ArrayList<CalEvent>(); 115 overlappingEvents.add(event); 116 117 CalEvent nextEvent; 118 while ( (i+1) < _events.size() && 119 (nextEvent = (CalEvent) _events.get(i+1)).timeSpan().containsOrIntersects(event.timeSpan())) 120 { 121 overlappingEvents.add(nextEvent); 122 event = nextEvent; 123 i++; 124 } 125 126 layoutEvents(overlappingEvents); 127 } 128 129 } 130 } 131 132 private void layoutEvents(List<CalEvent> events) 133 { 134 int padding = 4; 135 int n = events.size(); 136 for (int i=0; i<n; i++) 137 { 138 CalEvent event = events.get(i); 139 Component comp = (Component) _components.get(event); 140 Rectangle bounds = _view.getBounds(event); 141 int width = bounds.width / n - padding; 142 int x = bounds.x + i*(bounds.width / n) + padding/2; 143 comp.setBounds(new Rectangle(x, bounds.y, width, bounds.height)); 144 } 111 145 } 112 146 jmatter-complet/branches/TRY-JPA/modules/swingvm/src/com/u2d/view/swing/calendar/simple/DayView.java
r941 r1362 267 267 int xPos = _table.getColumn("times").getWidth(); 268 268 TableColumnModel tcmodel = _table.getColumnModel(); 269 int i=1; 270 271 if ( (i+1) > _table.getColumnCount() ) 272 return new Rectangle(0, 0, 0, 0); 273 274 TableColumn column = tcmodel.getColumn(i++); 269 270 TableColumn column = tcmodel.getColumn(1); 275 271 int eventWidth = column.getWidth(); 276 272
