@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TimeCoding that = (TimeCoding) o; boolean startEqual = areEqual(startTime, that.startTime); boolean endEqual = areEqual(endTime, that.endTime); return startEqual && endEqual; }
/** * Checks if the given {@code timeCoding} is within the start and end time of this {@link org.esa.beam.timeseries.core.timeseries.datamodel.TimeCoding}. * * @param timeCoding the time coding to check if it is within this {@code TimeCoding} * * @return whether this {@code TimeCoding} contains the given time coding */ public boolean contains(TimeCoding timeCoding) { if (getStartTime().getAsDate().after(timeCoding.getStartTime().getAsDate())) { return false; } if (getEndTime().getAsDate().before(timeCoding.getEndTime().getAsDate())) { return false; } return true; }
private void addSpecifiedBandOfGivenProduct(String nodeName, Product product) { if (isProductCompatible(product, nodeName)) { final RasterDataNode raster = product.getRasterDataNode(nodeName); TimeCoding rasterTimeCoding = GridTimeCoding.create(product); final ProductData.UTC rasterStartTime = rasterTimeCoding.getStartTime(); final ProductData.UTC rasterEndTime = rasterTimeCoding.getEndTime(); Guardian.assertNotNull("rasterStartTime", rasterStartTime); final String bandName = variableToRasterName(nodeName, rasterTimeCoding); if (!tsProduct.containsBand(bandName)) { // band not already contained if (isAutoAdjustingTimeCoding() || !isTimeCodingSet()) { // automatically setting time coding // OR // first band to add to time series; time bounds of this band will be used // as ts-product's time bounds, no matter if auto adjust is true or false autoAdjustTimeInformation(rasterStartTime, rasterEndTime); } if (getTimeCoding().contains(rasterTimeCoding)) { // add only bands which are in the time bounds final Band addedBand = addBand(raster, rasterTimeCoding, bandName); final List<Band> bandsForVariable = getBandsForVariable(nodeName); if (!bandsForVariable.isEmpty()) { final ImageInfo imageInfo = bandsForVariable.get(0).getImageInfo(ProgressMonitor.NULL); addedBand.setImageInfo(imageInfo.createDeepCopy()); } } // todo no bands added message } } }
@Override public int compare(Band band1, Band band2) { final Date date1 = rasterTimeMap.get(band1).getStartTime().getAsDate(); final Date date2 = rasterTimeMap.get(band2).getStartTime().getAsDate(); return date1.compareTo(date2); } });
@Override public void setTimeCoding(TimeCoding timeCoding) { final ProductData.UTC startTime = timeCoding.getStartTime(); if (tsProduct.getStartTime().getAsCalendar().compareTo(startTime.getAsCalendar()) != 0) { tsProduct.setStartTime(startTime); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.START_TIME_PROPERTY_NAME, startTime, this)); } final ProductData.UTC endTime = timeCoding.getEndTime(); if (tsProduct.getEndTime().getAsCalendar().compareTo(endTime.getAsCalendar()) != 0) { tsProduct.setEndTime(endTime); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.END_TIME_PROPERTY_NAME, endTime, this)); } List<String> variables = getEoVariables(); for (Product product : getAllProducts(ProgressMonitor.NULL)) { for (String variable : variables) { if (isEoVariableSelected(variable)) { addSpecifiedBandOfGivenProduct(variable, product); } } } for (Band band : tsProduct.getBands()) { final TimeCoding bandTimeCoding = getRasterTimeMap().get(band); if (!timeCoding.contains(bandTimeCoding)) { fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.BAND_TO_BE_REMOVED, band, this)); tsProduct.removeBand(band); } } }
private void updateDateLabel(Band band) { String dateString = ""; if (band != null) { final TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(band); final Date startTime = timeCoding.getStartTime().getAsDate(); dateString = dateFormat.format(startTime); } dateLabel.setText(String.format(DATE_PREFIX + " %s", dateString)); }
if (autoStartTime == null) { TimeCoding tsTimeCoding = timeSeries.getTimeCoding(); autoStartTime = tsTimeCoding.getStartTime(); autoEndTime = tsTimeCoding.getEndTime(); varTimeCoding.getStartTime()); autoEndTime = getMaxEndTime(autoEndTime, varTimeCoding.getEndTime());
public static String variableToRasterName(String variableName, TimeCoding timeCoding) { final ProductData.UTC rasterStartTime = timeCoding.getStartTime(); Guardian.assertNotNull("rasterStartTime", rasterStartTime); final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); return variableName + SEPARATOR + dateFormat.format(rasterStartTime.getAsDate()); }
private void setProductTimeCoding(Product tsProduct) { for (Band band : tsProduct.getBands()) { final ProductData.UTC rasterStartTime = getRasterTimeMap().get(band).getStartTime(); final ProductData.UTC rasterEndTime = getRasterTimeMap().get(band).getEndTime(); ProductData.UTC tsStartTime = tsProduct.getStartTime(); if (tsStartTime == null || rasterStartTime.getAsDate().before(tsStartTime.getAsDate())) { tsProduct.setStartTime(rasterStartTime); } ProductData.UTC tsEndTime = tsProduct.getEndTime(); if (rasterEndTime != null) { if (tsEndTime == null || rasterEndTime.getAsDate().after(tsEndTime.getAsDate())) { tsProduct.setEndTime(rasterEndTime); } } } }
private String createSliderLabelText(List<Band> bandList, int index) { Band band = bandList.get(index); TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(band); if (timeCoding != null) { final ProductData.UTC utcStartTime = timeCoding.getStartTime(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); final String dateText = dateFormat.format(utcStartTime.getAsCalendar().getTime()); final String timeText = timeFormat.format(utcStartTime.getAsCalendar().getTime()); return dateText + DATE_SEPARATOR + timeText; } else { return ""; } }
private void createUserInterface() { boolean isAutoAdjustingTimeCoding = timeSeries.isAutoAdjustingTimeCoding(); final TableLayout tableLayout = new TableLayout(2); tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST); tableLayout.setTableWeightX(1.0); tableLayout.setTableFill(TableLayout.Fill.BOTH); tableLayout.setTablePadding(4, 4); tableLayout.setCellColspan(0, 0, 2); JPanel content = new JPanel(tableLayout); autoAdjustBox = createAutoAdjustBox(isAutoAdjustingTimeCoding); startTimeLabel = new JLabel("Start time:"); startTimeBox = createDateComboBox(); final TimeCoding timeCoding = timeSeries.getTimeCoding(); startTimeBox.setCalendar(timeCoding.getStartTime().getAsCalendar()); endTimeLabel = new JLabel("End time:"); endTimeBox = createDateComboBox(); endTimeBox.setCalendar(timeCoding.getEndTime().getAsCalendar()); content.add(autoAdjustBox); content.add(startTimeLabel); content.add(startTimeBox); content.add(endTimeLabel); content.add(endTimeBox); setUiEnabled(!isAutoAdjustingTimeCoding); setContent(content); }
private String getStartDateString() { String startDateString = ""; if (currentView != null && timeSeries != null) { final TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(currentView.getRaster()); Date startDate = timeCoding.getStartTime().getAsDate(); startDateString = dateFormat.format(startDate); } return startDateString; }
final ProductData.UTC startTime = timeCoding.getStartTime(); final ProductData.UTC endTime = timeCoding.getEndTime();
TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(band); if (timeCoding != null) { final Date date = timeCoding.getStartTime().getAsDate(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); columns.add(sdf.format(date));
private TimeSeries computeSingleTimeSeries(final List<Band> bandList, int pixelX, int pixelY, int currentLevel, String positionName) { final Band firstBand = bandList.get(0); final String firstBandName = firstBand.getName(); final int lastUnderscore = firstBandName.lastIndexOf("_"); final String suffix = positionName.isEmpty()?positionName: "_" + positionName; final String timeSeriesName = firstBandName.substring(0, lastUnderscore); final TimeSeries timeSeries = new TimeSeries(timeSeriesName + suffix); for (Band band : bandList) { final TimeCoding timeCoding = this.timeSeries.getRasterTimeMap().get(band); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); final double value = getValue(band, pixelX, pixelY, currentLevel); timeSeries.add(new TimeSeriesDataItem(timePeriod, value)); } } return timeSeries; }
void updateAnnotation(RasterDataNode raster) { removeAnnotation(); final AbstractTimeSeries timeSeries = getTimeSeries(); TimeCoding timeCoding = timeSeries.getRasterTimeMap().get(raster); if (timeCoding != null) { final ProductData.UTC startTime = timeCoding.getStartTime(); final Millisecond timePeriod = new Millisecond(startTime.getAsDate(), ProductData.UTC.UTC_TIME_ZONE, Locale.getDefault()); double millisecond = timePeriod.getFirstMillisecond(); Range valueRange = null; for (int i = 0; i < timeSeriesPlot.getRangeAxisCount(); i++) { valueRange = Range.combine(valueRange, timeSeriesPlot.getRangeAxis(i).getRange()); } if (valueRange != null) { XYAnnotation annotation = new XYLineAnnotation(millisecond, valueRange.getLowerBound(), millisecond, valueRange.getUpperBound()); timeSeriesPlot.addAnnotation(annotation, true); } } }