/** * Take out the histogram-related stuff that was in doMakeContents and put it in a standalone * method, so we can wait and call it only after the histogram is actually initialized. */ private void setInitialHistogramRange() { try { Range range = getRange(); double lo = range.getMin(); double hi = range.getMax(); histoWrapper.setHigh(hi); histoWrapper.setLow(lo); } catch (Exception exc) { logException("setInitialHistogramRange", exc); } }
public void updateRange(Range range) { if (ctw != null) ctw.setRange(range); try { SelectRangeWidget srw = getSelectRangeWidget(range); if (srw != null) { srw.setRange(range); } } catch (Exception e) { LogUtil.logException("Error updating select range widget", e); } if (colorScales != null) { ColorScale scale = (ColorScale) colorScales.get(0); try { scale.setRangeForColor(range.getMin(), range.getMax()); } catch (Exception exc) { LogUtil.logException("Error updating display ColorScale range", exc); } } }
/** _more_ */ protected void updateChart() { try { if (!madeChart) { createChart(); } ignoreChartTimeChanges = true; if (isHourly()) { List<Integer> fHours = findForecastHours(); List<TwoFacedObject> tfos = new ArrayList<TwoFacedObject>(); for (Integer i : fHours) { tfos.add(new TwoFacedObject(i + "H", i)); } Object[] selected = chartTimeBox.getSelectedValues(); chartTimeBox.setListData(new Vector(tfos)); GuiUtils.setSelectedItems(chartTimeBox, Misc.toList(selected)); if ((selected == null) && (tfos.size() > 0)) { TwoFacedObject selected0 = tfos.get(0); forecastHours.add((Integer) selected0.getId()); } // chartTimeBox.setSelectedItem(selected); } else { List<DateTime> fTimes = findForecastTimes(); Object[] selected = chartTimeBox.getSelectedValues(); chartTimeBox.setListData(new Vector(fTimes)); GuiUtils.setSelectedItems(chartTimeBox, Misc.toList(selected)); if ((selected == null) && (fTimes.size() > 0)) { DateTime dt0 = fTimes.get(0); forecastTimes.add(dt0); } // chartTimeBox.setSelectedItem(forecastTime); } ignoreChartTimeChanges = false; getSelectedTimes(); chartTimeBox.repaint(); Hashtable<Way, List> wayToTracks = new Hashtable<Way, List>(); for (Way way : chartWays) { wayToTracks.put(way, new ArrayList<Way>()); } List<StormTrack> tracksToUse = new ArrayList<StormTrack>(); for (StormTrack track : stormDisplayState.getTrackCollection().getTracks()) { List trackList = wayToTracks.get(track.getWay()); if (trackList == null) { continue; } if (track.getWay().isObservation()) { tracksToUse.add(track); } else { trackList.add(track); } } StormTrack obsTrack = stormDisplayState.getTrackCollection().getObsTrack(); if (isHourly()) { for (Way way : chartWays) { List<StormTrack> tracksFromWay = wayToTracks.get(way); for (Integer fHour : forecastHours) { List<StormTrackPoint> points = new ArrayList<StormTrackPoint>(); for (StormTrack track : tracksFromWay) { StormTrackPoint stp = track.findPointWithForecastHour(fHour.intValue()); if (stp != null) { // TODO: What time do we use??? points.add(stp); } } if (points.size() > 0) { points = (List<StormTrackPoint>) Misc.sort(points); tracksToUse.add(new StormTrack(stormDisplayState.getStormInfo(), way, points, null)); } } } } else { for (Way way : chartWays) { List<StormTrack> tracksFromWay = wayToTracks.get(way); for (StormTrack track : tracksFromWay) { for (DateTime fTime : forecastTimes) { if (Misc.equals(fTime, track.getStartTime())) { tracksToUse.add(track); } } } } } List<LineState> lines = new ArrayList<LineState>(); for (StormParam param : chartParams) { Hashtable seenWays = new Hashtable(); List<LineState> linesForParam = new ArrayList<LineState>(); for (StormTrack track : tracksToUse) { LineState lineState = null; if (chartDifference && param.getCanDoDifference()) { if (track.getWay().isObservation()) { continue; } track = StormDataSource.difference(obsTrack, track, param); if (track != null) { lineState = makeLine(track, param); } } else { lineState = makeLine(track, param); } if (lineState == null) { continue; } // Only add it if there are values if (lineState.getRange().getMin() == lineState.getRange().getMin()) { if (seenWays.get(track.getWay()) != null) { lineState.setVisibleInLegend(false); } else { seenWays.put(track.getWay(), ""); } linesForParam.add(lineState); } } double max = Double.NEGATIVE_INFINITY; double min = Double.POSITIVE_INFINITY; ; for (LineState lineState : linesForParam) { Range r = lineState.getRange(); min = Math.min(min, r.getMin()); max = Math.max(max, r.getMax()); } // System.err.println(param + " min/max:" + min + "/" + max); boolean first = true; for (LineState lineState : linesForParam) { lineState.setAxisVisible(first); first = false; lineState.setRange(new Range(min, max)); } lines.addAll(linesForParam); } getChart().setTracks(lines); } catch (Exception exc) { stormDisplayState.getStormTrackControl().logException("Updating chart", exc); } }