def test_resizable_component(self): container = OverlayPlotContainer(resizable='', bounds=[200.0, 300.0]) component = PlotComponent(resizable='hv', position=[50.0, 56.0], bounds=[100.0, 110.0]) container.add(component) container.do_layout() self.assert_tuple(component.position, (0.0, 0.0)) self.assert_tuple(component.bounds, (200.0, 300.0)) comp2 = PlotComponent(resizable="h", position=[10, 20], bounds=[100, 150]) container.add(comp2) container.do_layout() self.assert_tuple(comp2.position, (0.0, 20.0)) self.assert_tuple(comp2.bounds, (200.0, 150.0)) comp3 = PlotComponent(resizable="v", position=[30, 40], bounds=[100, 150]) container.add(comp3) container.do_layout() self.assert_tuple(comp3.position, (30.0, 0.0)) self.assert_tuple(comp3.bounds, (100, 300)) return
def test_min_size(self): container = OverlayPlotContainer(resizable='', bounds=[50.0, 50.0]) component = PlotComponent(resizable='', position=[50.0, 60.0], bounds=[100.0, 110.0]) container.add(component) container.do_layout() self.assert_tuple(component.position, (50.0, 60.0)) self.assert_tuple(component.bounds, (100.0, 110.0)) return
def test_fixed_size_component(self): container = OverlayPlotContainer(resizable='', bounds=[200.0, 300.0]) # non-resizable component component = PlotComponent(resizable='', position=[50.0, 60.0], bounds=[100.0, 110.0]) self.assertEqual(container._layout_needed, True) container.do_layout() container.add(component) self.assertEqual(container._layout_needed, True) container.do_layout() self.assertEqual(container._layout_needed, False) # check the results of the layout self.assert_tuple(container.get_preferred_size(), (200.0, 300.0)) self.assert_tuple(component.position, (50.0, 60.0)) self.assert_tuple(component.bounds, (100.0, 110.0)) return
def activate_template(self): """ Converts all contained 'TDerived' objects to real objects using the template traits of the object. This method must be overridden in subclasses. Returns ------- None """ plots = [] i = 0 for r in range(self.rows): row = [] for c in range(self.columns): plot = self.scatter_plots[i].plot if plot is None: plot = PlotComponent() row.append(plot) i += 1 plots.append(row) self.plot = GridPlotContainer(shape=(self.rows, self.columns)) self.plot.component_grid = plots
def get_preferred_size(self): if self.fixed_preferred_size is not None: return self.fixed_preferred_size else: return PlotComponent.get_preferred_size(self)
def __init__(self, preferred_size=None, *args, **kw): if preferred_size is not None: self.fixed_preferred_size = preferred_size PlotComponent.__init__(self, *args, **kw)
def __init__(self, bounds, *args, **kw): kw["bounds"] = bounds if "resizable" not in kw: kw["resizable"] = "" PlotComponent.__init__(self, *args, **kw) return
def __init__(self, bounds, *args, **kw): kw["bounds"] = bounds if not kw.has_key("resizable"): kw["resizable"] = "" PlotComponent.__init__(self, *args, **kw) return