Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/CrossSectionChartThemePanel.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | 67ae70259011 |
children | 05405292a7ca |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
67 protected LoadArtifactServiceAsync loadService = | 67 protected LoadArtifactServiceAsync loadService = |
68 GWT.create(LoadArtifactService.class); | 68 GWT.create(LoadArtifactService.class); |
69 | 69 |
70 /** Service to query measurement points of cross sections. */ | 70 /** Service to query measurement points of cross sections. */ |
71 CrossSectionKMServiceAsync kmService = GWT.create( | 71 CrossSectionKMServiceAsync kmService = GWT.create( |
72 org.dive4elements.river.client.client.services.CrossSectionKMService.class); | 72 org.dive4elements.river.client.client.services |
73 .CrossSectionKMService.class); | |
73 | 74 |
74 /** UUID of the current "master" cross section. */ | 75 /** UUID of the current "master" cross section. */ |
75 protected String currentCSMasterUUID; | 76 protected String currentCSMasterUUID; |
76 | 77 |
77 /** The layout (used for visual active/inactive feedback). */ | 78 /** The layout (used for visual active/inactive feedback). */ |
81 protected static String CS_KM = "cross_section.km"; | 82 protected static String CS_KM = "cross_section.km"; |
82 | 83 |
83 /** Data item name for CrossSections reference ('master') flag. */ | 84 /** Data item name for CrossSections reference ('master') flag. */ |
84 protected static String CS_IS_MASTER = "cross_section.master?"; | 85 protected static String CS_IS_MASTER = "cross_section.master?"; |
85 | 86 |
86 /** List of cross-section themes through which is moved through synchronously. */ | 87 /** List of cross-section themes through which is moved |
88 * through synchronously. */ | |
87 protected HashSet synchronCrossSectionThemes = new HashSet(); | 89 protected HashSet synchronCrossSectionThemes = new HashSet(); |
88 | 90 |
89 /** Data for master artifact combobox.*/ | 91 /** Data for master artifact combobox.*/ |
90 protected LinkedHashMap<String, String> masters; | 92 protected LinkedHashMap<String, String> masters; |
91 | 93 |
284 public static Double closest(Double[] in, double to, boolean up) { | 286 public static Double closest(Double[] in, double to, boolean up) { |
285 if (in == null || in.length == 0) { | 287 if (in == null || in.length == 0) { |
286 return Double.NaN; | 288 return Double.NaN; |
287 } | 289 } |
288 Arrays.sort(in); | 290 Arrays.sort(in); |
289 GWT.log ("Closest match for " + (up ? "next" : "previous") + " value to: " + | 291 GWT.log ("Closest match for " + (up ? "next" : "previous") |
290 to + " candidates: " + Arrays.toString(in)); | 292 + " value to: " + to + " candidates: " + Arrays.toString(in)); |
291 if (up) { | 293 if (up) { |
292 double max = in[in.length - 1]; | 294 double max = in[in.length - 1]; |
293 for (int i = 0; i < in.length; i++) { | 295 for (int i = 0; i < in.length; i++) { |
294 if (in[i] >= to || in[i] == max) { | 296 if (in[i] >= to || in[i] == max) { |
295 return in[i]; | 297 return in[i]; |
331 artifacts, | 333 artifacts, |
332 feedData, | 334 feedData, |
333 new AsyncCallback<List<Artifact>>() { | 335 new AsyncCallback<List<Artifact>>() { |
334 @Override | 336 @Override |
335 public void onFailure(Throwable caught) { | 337 public void onFailure(Throwable caught) { |
336 GWT.log("Could not feed many artifacts " + caught.getMessage()); | 338 GWT.log("Could not feed many artifacts " |
339 + caught.getMessage()); | |
337 SC.warn(MSG.getString(caught.getMessage())); | 340 SC.warn(MSG.getString(caught.getMessage())); |
338 enable(); | 341 enable(); |
339 } | 342 } |
340 @Override | 343 @Override |
341 public void onSuccess(List<Artifact> artifact) { | 344 public void onSuccess(List<Artifact> artifact) { |
449 public void onSuccess(Map<Integer, Double[]> obj) { | 452 public void onSuccess(Map<Integer, Double[]> obj) { |
450 Double[] kms = obj.get(dbid); | 453 Double[] kms = obj.get(dbid); |
451 Double closest = | 454 Double closest = |
452 CrossSectionChartThemePanel.closest(kms, enteredKm, up); | 455 CrossSectionChartThemePanel.closest(kms, enteredKm, up); |
453 if (Double.isNaN(closest)) { | 456 if (Double.isNaN(closest)) { |
454 GWT.log("Failed to find a closest km. Staying on current km."); | 457 GWT.log("Failed to find a closest km. " |
458 + "Staying on current km."); | |
455 updateCollection(); | 459 updateCollection(); |
456 enable(); | 460 enable(); |
457 return; | 461 return; |
458 } | 462 } |
459 | 463 |
460 GWT.log("Got single km close to " + enteredKm + " for " + dbid + ", it is " | 464 GWT.log("Got single km close to " |
465 + enteredKm + " for " + dbid + ", it is " | |
461 + closest); | 466 + closest); |
462 | 467 |
463 // Do not set value, as it will trigger strange | 468 // Do not set value, as it will trigger strange |
464 // "javascript" bugs. /*item.setValue(closest);*/ | 469 // "javascript" bugs. /*item.setValue(closest);*/ |
465 if (synchronCrossSectionThemes.contains (themeHash | 470 if (synchronCrossSectionThemes.contains (themeHash |
470 List<Artifact> artifacts = new ArrayList<Artifact>(); | 475 List<Artifact> artifacts = new ArrayList<Artifact>(); |
471 for (int i = 0; i < nThemes; i++) { | 476 for (int i = 0; i < nThemes; i++) { |
472 final Theme theme = themes.getThemeAt(i+1); | 477 final Theme theme = themes.getThemeAt(i+1); |
473 if (theme.getFacet().equals("cross_section") && | 478 if (theme.getFacet().equals("cross_section") && |
474 theme.getActive() == 1 && | 479 theme.getActive() == 1 && |
475 synchronCrossSectionThemes.contains(themeHash(theme)) | 480 synchronCrossSectionThemes.contains( |
481 themeHash(theme)) | |
476 ) { | 482 ) { |
477 artifacts.add(artifactReference(theme.getArtifact())); | 483 artifacts.add( |
484 artifactReference(theme.getArtifact())); | |
478 } | 485 } |
479 } | 486 } |
480 sendFeed(artifacts, closest); | 487 sendFeed(artifacts, closest); |
481 } | 488 } |
482 else { | 489 else { |
513 String fieldName = this.getFieldName(colNum); | 520 String fieldName = this.getFieldName(colNum); |
514 | 521 |
515 // Place KMSpinner in Grid with currently chosen km value. | 522 // Place KMSpinner in Grid with currently chosen km value. |
516 if (fieldName.equals(GRID_FIELD_ACTIONS)) { | 523 if (fieldName.equals(GRID_FIELD_ACTIONS)) { |
517 double currentValue = | 524 double currentValue = |
518 Double.valueOf(facetRecord.getTheme().getCollectionItem().getData().get(CS_KM)); | 525 Double.valueOf( |
519 KMSpinner kmSpinner = new KMSpinner(currentValue, facetRecord); | 526 facetRecord.getTheme().getCollectionItem() |
527 .getData().get(CS_KM)); | |
528 KMSpinner kmSpinner = new KMSpinner( | |
529 currentValue, facetRecord); | |
520 kmSpinner.addChangeListener(parent); | 530 kmSpinner.addChangeListener(parent); |
521 return kmSpinner; | 531 return kmSpinner; |
522 } | 532 } |
523 else { | 533 else { |
524 return null; | 534 return null; |
632 if (item.equals("cross_section")) { | 642 if (item.equals("cross_section")) { |
633 // Synchron checking. | 643 // Synchron checking. |
634 MenuItem synchronNavigationMenuItem = new MenuItem(); | 644 MenuItem synchronNavigationMenuItem = new MenuItem(); |
635 final String themeHash = themeHash(facetTheme); | 645 final String themeHash = themeHash(facetTheme); |
636 if (synchronCrossSectionThemes.contains(themeHash)) { | 646 if (synchronCrossSectionThemes.contains(themeHash)) { |
637 synchronNavigationMenuItem.setTitle(MSG.chart_themepanel_asynchron()); | 647 synchronNavigationMenuItem.setTitle( |
648 MSG.chart_themepanel_asynchron()); | |
638 synchronNavigationMenuItem.addClickHandler(new ClickHandler() { | 649 synchronNavigationMenuItem.addClickHandler(new ClickHandler() { |
639 @Override | 650 @Override |
640 public void onClick(MenuItemClickEvent evt) { | 651 public void onClick(MenuItemClickEvent evt) { |
641 synchronCrossSectionThemes.remove (themeHash); | 652 synchronCrossSectionThemes.remove (themeHash); |
642 } | 653 } |
643 }); | 654 }); |
644 } | 655 } |
645 else { | 656 else { |
646 synchronNavigationMenuItem.setTitle(MSG.chart_themepanel_synchron()); | 657 synchronNavigationMenuItem.setTitle( |
658 MSG.chart_themepanel_synchron()); | |
647 synchronNavigationMenuItem.addClickHandler(new ClickHandler() { | 659 synchronNavigationMenuItem.addClickHandler(new ClickHandler() { |
648 @Override | 660 @Override |
649 public void onClick(MenuItemClickEvent evt) { | 661 public void onClick(MenuItemClickEvent evt) { |
650 synchronCrossSectionThemes.add (themeHash); | 662 synchronCrossSectionThemes.add (themeHash); |
651 } | 663 } |