Exemplo n.º 1
0
  @Override
  public Visualization getVisualization() {

    Visualization v = new Visualization();
    PersistentVisualization pv = new PersistentVisualization();

    if (catProvider != null && catProvider.isOn()) {

      for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
        if (tc instanceof TViewPanel) {
          TViewPanel tvp = (TViewPanel) tc;
          TypingData td = tvp.ds.getLookup().lookup(TypingData.class);
          if (ds == td) {
            DataModel dm = catProvider.getDataModel();
            if (dm == tvp.cp.getDataModel()) {
              v.filter = tvp.getFilter();
              v.category = catProvider;
              break;
            }
          }
        }
      }
    }
    pv.distanceFilterValue = uv.getDistanceFilterValue();
    pv.linearSize = uv.getLinearSize();
    v.pv = pv;

    return v;
  }
Exemplo n.º 2
0
  /**
   * Creates new form GTPanel
   *
   * @param name
   * @param gr
   * @param ds
   */
  public GTPanel(String name, UPGMAItem gr, TypingData<? extends Profile> ds) {
    super(Lookups.singleton(gr));
    initComponents();
    this.setName(name);

    this.ds = ds;
    String distanceProvider = gr.getDistanceProvider();
    int split = distanceProvider.lastIndexOf(".") + 1;
    distanceProvider = distanceProvider.substring(split);
    uv = new UPGMAViewer(name, gr.getRoot(), distanceProvider);

    Visualization viz = gr.getVisualization();
    if (viz != null && viz.pv != null) {
      loadVisualization(viz);
    }

    tvc = uv.generateTreeViewComponent();

    this.add(tvc);
    gvCatListen =
        new CategoryChangeListener() {

          @Override
          public void categoryChange(CategoryProvider cp) {

            if (cp.isOn()) {
              catProvider = cp;
              uv.setDefaultRenderer(new ChartRenderer(cp, uv));
              uv.setCategoryProvider(cp);
            } else {
              catProvider = null;
              uv.resetDefaultRenderer();
              uv.setCategoryProvider(null);
            }
          }
        };

    // Let us track category providers...
    // TODO: implement this within a renderer.
    r = ds.getLookup().lookupResult(CategoryProvider.class);
    Iterator<? extends CategoryProvider> i = r.allInstances().iterator();
    while (i.hasNext()) i.next().addCategoryChangeListener(gvCatListen);

    r.addLookupListener(
        new LookupListener() {

          @SuppressWarnings("unchecked")
          @Override
          public void resultChanged(LookupEvent le) {

            Iterator<? extends CategoryProvider> i =
                ((Result<CategoryProvider>) le.getSource()).allInstances().iterator();
            while (i.hasNext()) {
              CategoryProvider cp = i.next();
              cp.removeCategoryChangeListener(gvCatListen);
              cp.addCategoryChangeListener(gvCatListen);
            }
          }
        });
  }
Exemplo n.º 3
0
  @Override
  public void loadVisualization(Visualization viz) {

    if (viz.category != null) {
      catProvider = viz.category;

      uv.setDefaultRenderer(new ChartRenderer(catProvider, uv));
      uv.setCategoryProvider(catProvider);
    }

    if (viz.pv.distanceFilterValue != -1) {
      uv.setDistanceFilterValue(viz.pv.distanceFilterValue);
    }
    if (viz.pv.linearSize) {
      uv.setLinearSize(viz.pv.linearSize);
    }
    uv.repaint();
  }
Exemplo n.º 4
0
 @Override
 protected void componentClosed() {
   uv.closeInfoPanel();
   super.componentClosed();
 }