Merge lp:~flngr/gephi/gephi0.8-timeline-fixes into lp:~gephi.team/gephi/0.8

Proposed by Julian Bilcke on 2011-03-01
Status: Merged
Approved by: Sébastien Heymann on 2011-03-02
Approved revision: 2123
Merge reported by: Sébastien Heymann
Merged at revision: not available
Proposed branch: lp:~flngr/gephi/gephi0.8-timeline-fixes
Merge into: lp:~gephi.team/gephi/0.8
Diff against target: 286 lines (+93/-34)
5 files modified
DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java (+65/-24)
DesktopTimeline/src/org/gephi/desktop/timeline/TimelineModelImpl.java (+7/-1)
DynamicImpl/src/org/gephi/dynamic/DynamicModelPersistenceProvider.java (+17/-3)
ImportAPI/src/org/gephi/io/importer/impl/ImportContainerImpl.java (+2/-2)
ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterGEXF.java (+2/-4)
To merge this branch: bzr merge lp:~flngr/gephi/gephi0.8-timeline-fixes
Reviewer Review Type Date Requested Status
Sébastien Heymann 2011-03-01 Approve on 2011-03-02
Review via email: mp+51797@code.launchpad.net

Commit message

fixed some issues with the timeline not showing the proper time format, and incorrect selection zone resize

Description of the change

Fixed bug with the timeline not showing the correct format (date)
when loading a GEXF: https://bugs.launchpad.net/gephi/+bug/709234

Also fixed a small bug with the slider (was incorrectly resized when moved)

To post a comment you must log in.
review: Approve

Merged on rev 2123.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java'
2--- DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java 2010-09-17 15:45:18 +0000
3+++ DesktopTimeline/src/org/gephi/desktop/timeline/MinimalDrawer.java 2011-03-01 19:02:23 +0000
4@@ -215,7 +215,7 @@
5 st = 1.0 * (double) width;
6 newfrom = sf * (1.0 / width);
7 newto = st * (1.0 / width);
8- }
9+ }
10 }
11
12
13@@ -243,7 +243,7 @@
14 System.out.println("all date max: " + new DateTime(new Date(max)));
15 */
16
17- if (max <= min
18+ if (max <= min
19 || min == Double.NEGATIVE_INFINITY
20 || max == Double.POSITIVE_INFINITY
21 || max == Double.NEGATIVE_INFINITY
22@@ -254,7 +254,7 @@
23 if (model.getFromFloat() == Double.NEGATIVE_INFINITY
24 || model.getToFloat() == Double.POSITIVE_INFINITY) {
25 System.out.println("cannot show a selection with negative values");
26- return;
27+ return;
28 }
29
30 /*
31@@ -599,24 +599,41 @@
32 }
33
34 public void mouseClicked(MouseEvent e) {
35+ latestMousePositionX = e.getX();
36+ currentMousePositionX = latestMousePositionX;
37 //throw new UnsupportedOperationException("Not supported yet.");
38+ /*
39+ int w = getWidth();
40+ // small feature: when the zone is too small, and if we double-click,
41+ // we want to expand the timeline
42+ if (e.getClickCount() == 2) {
43+ if (w != 0) {
44+ if (sf > 0.1 && st < 0.9) {
45+ newfrom = 0;
46+ newto = w;
47+ repaint();
48+ }
49+ }
50+
51+ } else if (e.getClickCount() == 2) {
52+ if (w != 0) {
53+ newto = st * (1.0 / w);
54+ repaint(); // so it will repaint all panels
55+ }
56+
57+ }
58+ */
59 }
60
61 public void mousePressed(MouseEvent e) {
62 if (model == null) {
63 return;
64 }
65-
66 int x = e.getX();
67- float w = getWidth();
68+ latestMousePositionX = x;
69+ currentMousePositionX = latestMousePositionX;
70 int r = 16;//skin.getSelectionHookSideLength();
71
72- // SELECTED ZONE BEGIN POSITION, IN PIXELS
73- //int sf = (int) (model.getFromFloat() * (double) w);
74-
75- // SELECTED ZONE END POSITION, IN PIXELS
76- //int st = (int) (model.getToFloat() * (double) w);
77-
78 if (currentState == TimelineState.IDLE) {
79 if (inRange(x, (int) sf - 1, (int) sf + r + 1)) {
80 highlightedComponent = HighlightedComponent.LEFT_HOOK;
81@@ -633,8 +650,10 @@
82
83 public void mouseEntered(MouseEvent e) {
84 //throw new UnsupportedOperationException("Not supported yet.");
85- latestMousePositionX = e.getX();
86- currentMousePositionX = latestMousePositionX;
87+ if (currentState == TimelineState.IDLE) {
88+ latestMousePositionX = e.getX();
89+ currentMousePositionX = latestMousePositionX;
90+ }
91 mouseInside = true;
92 }
93
94@@ -642,6 +661,8 @@
95 //throw new UnsupportedOperationException("Not supported yet.");
96 if (currentState == TimelineState.IDLE) {
97 highlightedComponent = HighlightedComponent.NONE;
98+ latestMousePositionX = e.getX();
99+ currentMousePositionX = latestMousePositionX;
100 }
101 mouseInside = false;
102 repaint();
103@@ -653,7 +674,8 @@
104
105 public void mouseReleased(MouseEvent evt) {
106
107- latestMousePositionX = null;
108+ latestMousePositionX = evt.getX();
109+ currentMousePositionX = latestMousePositionX;
110 //highlightedComponent = HighlightedComponent.NONE;
111 currentState = TimelineState.IDLE;
112 this.getParent().repaint(); // so it will repaint upper and bottom panes
113@@ -750,26 +772,45 @@
114 }
115 latestMousePositionX = x;
116
117+ // minimal selection zone width (a security to not crush it!)
118+ int s = settings.selection.minimalWidth;
119+
120 switch (currentState) {
121 case RESIZE_FROM:
122- if ((sf + delta <= 0)) {
123- sf = 0;
124- } else if (Math.abs(st - sf + delta) > settings.selection.minimalWidth) {
125- sf += delta;
126+
127+ //problem: moving the left part will crush the security zone
128+ if ((sf + delta) >= (st - s)) {
129+ sf = st - s;
130 } else {
131+ if (sf + delta <= 0) {
132+ sf = 0;
133+ } else {
134+ sf += delta;
135+ }
136 }
137+
138+
139+
140 break;
141 case RESIZE_TO:
142- if ((st + delta >= w)) {
143- st = w;
144- } else if (Math.abs((st + delta) - sf) > settings.selection.minimalWidth) {
145- st += delta;
146+ if ((st + delta) <= (sf + s)) {
147+ st = sf + s;
148+ } else {
149+ if ((st + delta >= w)) {
150+ st = w;
151+ } else {
152+ st += delta;
153+ }
154 }
155 break;
156 case MOVING:
157- if ((sf + delta <= 0)) {
158+ // collision on the left..
159+ if ((sf + delta) < 0) {
160+ st = (st - sf);
161 sf = 0;
162- } else if (st + delta >= w) {
163+ // .. or the right
164+ } else if ((st + delta) >= w) {
165+ sf = w - (st - sf);
166 st = w;
167 } else {
168 sf += delta;
169
170=== modified file 'DesktopTimeline/src/org/gephi/desktop/timeline/TimelineModelImpl.java'
171--- DesktopTimeline/src/org/gephi/desktop/timeline/TimelineModelImpl.java 2010-09-29 19:50:54 +0000
172+++ DesktopTimeline/src/org/gephi/desktop/timeline/TimelineModelImpl.java 2011-03-01 19:02:23 +0000
173@@ -62,7 +62,8 @@
174 enabled = !Double.isInfinite(dynamicModel.getVisibleInterval().getLow()) && !Double.isInfinite(dynamicModel.getVisibleInterval().getHigh());
175 dynamicController.addModelListener(this);
176
177- unit = dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATE) ? DateTime.class : null;
178+ unit = (dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATE)
179+ ||dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATETIME)) ? DateTime.class : Double.class;
180 customMin = Double.NEGATIVE_INFINITY;
181 customMax = Double.POSITIVE_INFINITY;
182 modelMin = Double.NEGATIVE_INFINITY;
183@@ -85,6 +86,11 @@
184
185 public void dynamicModelChanged(DynamicModelEvent event) {
186 if (event.getSource() == dynamicModel) {
187+
188+ // TODO: should be in its own event "UNIT_CHANGED"
189+ unit = (dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATE)
190+ ||dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATETIME)) ? DateTime.class : Double.class;
191+
192 switch (event.getEventType()) {
193 case VISIBLE_INTERVAL:
194 fireTimelineModelEvent(new TimelineModelEvent(TimelineModelEvent.EventType.VISIBLE_INTERVAL, this, event.getData()));
195
196=== modified file 'DynamicImpl/src/org/gephi/dynamic/DynamicModelPersistenceProvider.java'
197--- DynamicImpl/src/org/gephi/dynamic/DynamicModelPersistenceProvider.java 2011-03-01 04:01:08 +0000
198+++ DynamicImpl/src/org/gephi/dynamic/DynamicModelPersistenceProvider.java 2011-03-01 19:02:23 +0000
199@@ -70,9 +70,12 @@
200 writer.writeStartElement("dynamicmodel");
201
202 writer.writeStartElement("timeformat");
203- if (model.getTimeFormat().equals(DynamicModel.TimeFormat.DATE)) {
204+ if (model.getTimeFormat().equals(DynamicModel.TimeFormat.DATETIME)) {
205+ writer.writeAttribute("value", "datetime");
206+ } else if (model.getTimeFormat().equals(DynamicModel.TimeFormat.DATE)) {
207 writer.writeAttribute("value", "date");
208- } else {
209+ } else {
210+ // default: if equals(DynamicModel.TimeFormat.DOUBLE)
211 writer.writeAttribute("value", "double");
212 }
213 writer.writeEndElement();
214@@ -88,8 +91,10 @@
215 case XMLStreamReader.START_ELEMENT:
216 if ("timeformat".equalsIgnoreCase(reader.getLocalName())) {
217 String val = reader.getAttributeValue(null, "value");
218- if (val.equals("date")) {
219+ if (val.equalsIgnoreCase("date")) {
220 model.setTimeFormat(DynamicModel.TimeFormat.DATE);
221+ } if (val.equalsIgnoreCase("datetime")) {
222+ model.setTimeFormat(DynamicModel.TimeFormat.DATETIME);
223 } else {
224 model.setTimeFormat(DynamicModel.TimeFormat.DOUBLE);
225 }
226@@ -102,5 +107,14 @@
227 break;
228 }
229 }
230+ // Start & End
231+ /*
232+ if (!start.isEmpty()) {
233+ container.setTimeIntervalMin(start);
234+ }
235+ if (!end.isEmpty()) {
236+ container.setTimeIntervalMax(end);
237+ }
238+ */
239 }
240 }
241
242=== modified file 'ImportAPI/src/org/gephi/io/importer/impl/ImportContainerImpl.java'
243--- ImportAPI/src/org/gephi/io/importer/impl/ImportContainerImpl.java 2010-10-18 09:23:29 +0000
244+++ ImportAPI/src/org/gephi/io/importer/impl/ImportContainerImpl.java 2011-03-01 19:02:23 +0000
245@@ -372,7 +372,7 @@
246 }
247
248 public void setTimeIntervalMax(String timeIntervalMax) {
249- if (timeFormat.equals(TimeFormat.DATE)) {
250+ if (timeFormat.equals(TimeFormat.DATE) || timeFormat.equals(TimeFormat.DATETIME)) {
251 try {
252 this.timeIntervalMax = DynamicUtilities.getDoubleFromXMLDateString(timeIntervalMax);
253 } catch (Exception ex) {
254@@ -388,7 +388,7 @@
255 }
256
257 public void setTimeIntervalMin(String timeIntervalMin) {
258- if (timeFormat.equals(TimeFormat.DATE)) {
259+ if (timeFormat.equals(TimeFormat.DATE) || timeFormat.equals(TimeFormat.DATETIME)) {
260 try {
261 this.timeIntervalMin = DynamicUtilities.getDoubleFromXMLDateString(timeIntervalMin);
262 } catch (Exception ex) {
263
264=== modified file 'ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterGEXF.java'
265--- ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterGEXF.java 2011-02-26 16:59:23 +0000
266+++ ImportPlugin/src/org/gephi/io/importer/plugin/file/ImporterGEXF.java 2011-03-01 19:02:23 +0000
267@@ -210,18 +210,16 @@
268 report.logIssue(new Issue(NbBundle.getMessage(ImporterGEXF.class, "importerGEXF_error_defaultedgetype", defaultEdgeType), Issue.Level.SEVERE));
269 }
270 }
271-
272 //TimeFormat
273 if (!timeFormat.isEmpty()) {
274 if ("double".equalsIgnoreCase(timeFormat) || "float".equalsIgnoreCase(timeFormat)) {
275 container.setTimeFormat(TimeFormat.DOUBLE);
276 } else if ("date".equalsIgnoreCase(timeFormat)) {
277 container.setTimeFormat(TimeFormat.DATE);
278- } else if ("datetime".equalsIgnoreCase(timeFormat) ||
279- "dateTime".equalsIgnoreCase(timeFormat)) {
280+ } else if ("datetime".equalsIgnoreCase(timeFormat)) {
281 container.setTimeFormat(TimeFormat.DATETIME);
282 }
283- } else if (mode.equals("dynamic")) {
284+ } else if (mode.equalsIgnoreCase("dynamic")) {
285 container.setTimeFormat(TimeFormat.DOUBLE);
286 }
287

Subscribers

People subscribed via source and target branches