weka分类面板运行分析

weka平台

分类面板运行分析

gui表层通用资源文件weka.gui.message.messages.properties

解释部分通用资源文件weka.gui.explorer..message.messages.properties

初始化主界面
ClassifierPanel类
分类面板

GenericObjectEditor类
通用的获取子类的工具
每当监听到参数或者类型修改,调用public void setValue(Object o)方法更新GenericObjectEditor内部子类对象数据,保证内部参数与面板显示同步

其中createChooseClassButton()方法生成选择何种算法的按钮,在生成面板时调用生成按钮
  protected JButton createChooseClassButton() {

    JButton setButton = new JButton(Messages.getInstance().getString("GenericObjectEditor_CreateChooseClassButton_SetButton_JButton_Text"));

    // anonymous action listener shows a JTree popup and allows the user
    // to choose the class they want
    setButton.addActionListener(new ActionListener() {
 public void actionPerformed(ActionEvent e) {

   JPopupMenu popup = getChooseClassPopupMenu();

   // show the popup where the source component is
   if (e.getSource() instanceof Component) {
     Component comp = (Component) e.getSource();
     popup.show(comp, comp.getX(), comp.getY());
     popup.pack();
     popup.repaint();
   }
 }
      });

    return setButton;
  }


主界面生成,当选择挖掘模式Explorer后,分出线程,初始化挖掘模块下所有模版功能

设置该功能为分类,可能出于功能复用的原因,采取了此种方式
m_ClassifierEditor.setClassType(Classifier.class);

设置默认的分类对象
m_ClassifierEditor.setValue(ExplorerDefaults.getClassifier());

监听分类选择,保证同步更新
m_ClassifierEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent e) {
      
       System.out.println("------propertyChange------");
      
        m_StartBut.setEnabled(true);
        // Check capabilities
        Capabilities currentFilter = m_ClassifierEditor.getCapabilitiesFilter();

//获取子类对象,参数已经设置在对象内部
        Classifier classifier = (Classifier) m_ClassifierEditor.getValue();

        Capabilities currentSchemeCapabilities =  null;
        if (classifier != null && currentFilter != null &&
            (classifier instanceof CapabilitiesHandler)) {
          currentSchemeCapabilities = ((CapabilitiesHandler)classifier).getCapabilities();
         
          if (!currentSchemeCapabilities.supportsMaybe(currentFilter) &&
              !currentSchemeCapabilities.supports(currentFilter)) {
            m_StartBut.setEnabled(false);
          }
        }
 repaint();
      }
    });

 


输出面板设置   
m_OutText.setEditable(false);
    m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12));
    m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    m_OutText.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {
      
       System.out.println("1111111mouseClicked11111111mouseClicked1111111mouseClicked11111111");
      
  if ((e.getModifiers() & InputEvent.BUTTON1_MASK)
      != InputEvent.BUTTON1_MASK) {
    m_OutText.selectAll();
  }
      }
    });


GenericObjectEditor此类为通用算法类
各算法都可以被此类实现
修改参数在此类内部修改
classfier
cluster
AssociatorEditor
AttributeEvaluatorEditor

PropertyPanel此类为通用属性面板
初始化面板时调用此类,加载各类型GenericObjectEditor成为不同类型属性面板

首页加载数据时,显示出变量前,对数据进行过预处理,并实例化了各类型的GenericObjectEditor加载到生成的算法面板,这样加载数据完成之后,翻到算法面板,可以直接执行算法,并且选择算法的时候,会对可执行算法进行高亮显示


此方法生成分类界面面板
weka.gui.explorer.ClassifierPanel.ClassifierPanel()


更改算法option,调用
weka.gui.GenericObjectEditor.setValue(Object)方法


ExplorerDefaults默认算法壳
此类不需要输入,直接返回写死的默认的结果

 

 

 

 

posted @ 2013-09-05 10:31  传说中那只猫  阅读(590)  评论(0编辑  收藏  举报