@Test public void testAccept() throws Exception { OpendapLeaf opendapLeafFullyInside = createLeaf(45.0, -8.0, -68.0, 19.0); OpendapLeaf opendapLeafGoingHorizontallyThroughBox = createLeaf(89.0, -1.0, -89.0, 1.0); OpendapLeaf opendapLeafGoingVerticallyThroughBox = createLeaf(45.0, -179.0, -68.0, 179.0); OpendapLeaf opendapLeafContainingOneEdge = createLeaf(55.0, -12.0, 45.0, -8.0); OpendapLeaf opendapLeafWholeWorld = createLeaf(90.0, -180.0, -90.0, 180.0); OpendapLeaf opendapLeafAbove = createLeaf(90.0, -180.0, 80.0, 180.0); OpendapLeaf opendapLeafRight = createLeaf(90, 30.0, -90.0, 180.0); OpendapLeaf opendapLeafBelow = createLeaf(-80.0, -180, -90.0, 180.0); OpendapLeaf opendapLeafLeft = createLeaf(90.0, -180, -90.0, -11.0); assertTrue(regionFilter.accept(opendapLeafFullyInside)); assertTrue(regionFilter.accept(opendapLeafGoingHorizontallyThroughBox)); assertTrue(regionFilter.accept(opendapLeafGoingVerticallyThroughBox)); assertTrue(regionFilter.accept(opendapLeafContainingOneEdge)); assertTrue(regionFilter.accept(opendapLeafWholeWorld)); assertFalse(regionFilter.accept(opendapLeafAbove)); assertFalse(regionFilter.accept(opendapLeafRight)); assertFalse(regionFilter.accept(opendapLeafBelow)); assertFalse(regionFilter.accept(opendapLeafLeft)); }
@Override public JComponent getUI() { final JPanel regionPanel = new JPanel(new BorderLayout()); regionBoundsInputUI = new RegionBoundsInputUI(); regionBoundsInputUI.getUI().setBorder(new EmptyBorder(0, 0, 8, 0)); regionPanel.add(regionBoundsInputUI.getUI(), BorderLayout.NORTH); regionPanel.add(applyButton, BorderLayout.EAST); PropertySet propertySet = regionBoundsInputUI.getBindingContext().getPropertySet(); eastBoundProperty = propertySet.getProperty(RegionBoundsInputUI.PROPERTY_EAST_BOUND); westBoundProperty = propertySet.getProperty(RegionBoundsInputUI.PROPERTY_WEST_BOUND); northBoundProperty = propertySet.getProperty(RegionBoundsInputUI.PROPERTY_NORTH_BOUND); southBoundProperty = propertySet.getProperty(RegionBoundsInputUI.PROPERTY_SOUTH_BOUND); BoundsChangeListener boundsChangeListener = new BoundsChangeListener(); eastBoundProperty.addPropertyChangeListener(boundsChangeListener); westBoundProperty.addPropertyChangeListener(boundsChangeListener); northBoundProperty.addPropertyChangeListener(boundsChangeListener); southBoundProperty.addPropertyChangeListener(boundsChangeListener); updateUI(false, false); return regionPanel; }
timeRangeFilter = new TimeRangeFilter(useTimeRangeFilter); timeRangeFilter.addFilterChangeListener(filterChangeListener); regionFilter = new RegionFilter(useRegionFilter); regionFilter.addFilterChangeListener(filterChangeListener); variableFilter = new VariableFilter(useVariableFilter, catalogTree);
/** * Creates the following filter bounding box: * <p/> * 50.0N/-10.0E ---------- 50.0N/20.0E * | | * | | * | | * -70.0N/-10.0E ----------- -70.0N/20.0E */ @Before public void setUp() throws ValidationException { regionFilter = new RegionFilter(new JCheckBox()); regionFilter.eastBoundProperty = new Property(new PropertyDescriptor("east", Double.class), new DefaultPropertyAccessor()); regionFilter.westBoundProperty = new Property(new PropertyDescriptor("west", Double.class), new DefaultPropertyAccessor()); regionFilter.northBoundProperty = new Property(new PropertyDescriptor("north", Double.class), new DefaultPropertyAccessor()); regionFilter.southBoundProperty = new Property(new PropertyDescriptor("south", Double.class), new DefaultPropertyAccessor()); regionFilter.eastBoundProperty.setValue(20.0); regionFilter.westBoundProperty.setValue(-10.0); regionFilter.northBoundProperty.setValue(50.0); regionFilter.southBoundProperty.setValue(-70.0); }