List of usage examples for weka.gui AttributeVisualizationPanel setInstances
public void setInstances(Instances newins)
From source file:adams.flow.sink.WekaAttributeSummary.java
License:Open Source License
/** * Displays the token (the panel and dialog have already been created at * this stage).//from w ww. j ava 2 s . com * * @param token the token to display */ @Override protected void display(Token token) { Instances inst; int[] indices; AttributeVisualizationPanel panel; inst = (Instances) token.getPayload(); m_Range.setData(inst); indices = m_Range.getIntIndices(); clearPanel(); if (indices.length == 1) { m_PanelAtt = new AttributeVisualizationPanel(); m_PanelAtt.setInstances(inst); m_PanelAtt.setAttribute(indices[0]); m_Panel.add(m_PanelAtt, BorderLayout.CENTER); } else if (indices.length > 1) { m_TabbedPane = new BaseTabbedPane(); m_Panel.add(m_TabbedPane, BorderLayout.CENTER); for (int index : indices) { panel = new AttributeVisualizationPanel(); panel.setInstances(inst); panel.setAttribute(index); m_TabbedPane.addTab(inst.attribute(index).name(), panel); } } }
From source file:adams.flow.sink.WekaAttributeSummary.java
License:Open Source License
/** * Creates a new display panel for the token. * * @param token the token to display in a new panel, can be null * @return the generated panel//w ww. ja va2 s . c om */ @Override public DisplayPanel createDisplayPanel(Token token) { AbstractDisplayPanel result; result = new AbstractComponentDisplayPanel(getClass().getSimpleName()) { private static final long serialVersionUID = 7384093089760722339L; protected BaseTabbedPane m_TabbedPane; protected AttributeVisualizationPanel m_PanelAtt; @Override protected void initGUI() { super.initGUI(); setLayout(new BorderLayout()); m_PanelAtt = new AttributeVisualizationPanel(); add(m_PanelAtt, BorderLayout.CENTER); } @Override public void display(Token token) { Instances inst; int[] indices; AttributeVisualizationPanel panel; inst = (Instances) token.getPayload(); m_Range.setData(inst); indices = m_Range.getIntIndices(); clearPanel(); if (indices.length == 1) { m_PanelAtt = new AttributeVisualizationPanel(); m_PanelAtt.setInstances(inst); m_PanelAtt.setAttribute(indices[0]); m_Panel.add(m_PanelAtt, BorderLayout.CENTER); } else if (indices.length > 1) { m_TabbedPane = new BaseTabbedPane(); m_Panel.add(m_TabbedPane, BorderLayout.CENTER); for (int index : indices) { panel = new AttributeVisualizationPanel(); panel.setInstances(inst); panel.setAttribute(index); m_TabbedPane.addTab(inst.attribute(index).name(), panel); } } } @Override public void cleanUp() { } @Override public void clearPanel() { removeAll(); } @Override public JComponent supplyComponent() { if (m_TabbedPane != null) return m_TabbedPane; else return m_PanelAtt; } }; if (token != null) result.display(token); return result; }