private boolean setMinMax(double min, double max) { if (model != null) { if (min > max) { throw new IllegalArgumentException("min should be less than max"); } else if (min == max) { // Avoid setting values at this point return false; } double previousBoundsMin = model.getCustomMin(); double previousBoundsMax = model.getCustomMax(); // Custom bounds if (model.getCustomMin() == model.getPreviousMin()) { model.setCustomMin(min); } else if (model.getCustomMin() < min) { model.setCustomMin(min); } if (model.getCustomMax() == model.getPreviousMax()) { model.setCustomMax(max); } else if (model.getCustomMax() > max) { model.setCustomMax(max); } model.setPreviousMin(min); model.setPreviousMax(max); if (model.hasValidBounds()) { fireTimelineModelEvent( new TimelineModelEvent( TimelineModelEvent.EventType.MIN_MAX, model, new double[] {min, max})); if (model.getCustomMax() != max || model.getCustomMin() != min) { fireTimelineModelEvent( new TimelineModelEvent( TimelineModelEvent.EventType.CUSTOM_BOUNDS, model, new double[] {min, max})); } } if ((Double.isInfinite(previousBoundsMax) || Double.isInfinite(previousBoundsMin)) && model.hasValidBounds()) { fireTimelineModelEvent( new TimelineModelEvent(TimelineModelEvent.EventType.VALID_BOUNDS, model, true)); } else if (!Double.isInfinite(previousBoundsMax) && !Double.isInfinite(previousBoundsMin) && !model.hasValidBounds()) { fireTimelineModelEvent( new TimelineModelEvent(TimelineModelEvent.EventType.VALID_BOUNDS, model, false)); } return true; } return false; }
@Override public void setEnabled(boolean enabled) { if (model != null) { if (enabled != model.isEnabled() && model.hasValidBounds()) { model.setEnabled(enabled); fireTimelineModelEvent( new TimelineModelEvent(TimelineModelEvent.EventType.ENABLED, model, enabled)); } if (!enabled) { // Disable filtering dynamicController.setVisibleInterval(new TimeInterval()); } } }