Java 类weka.core.converters.FileSourcedConverter 实例源码

项目:repo.kmeanspp.silhouette_score    文件:LoaderCustomizer.java   
/**
 * Set the loader to be customized
 * 
 * @param object a weka.gui.beans.Loader
 */
@Override
public void setObject(Object object) {
  m_dsLoader = (weka.gui.beans.Loader) object;

  try {
    m_backup = (weka.core.converters.Loader) GenericObjectEditor
      .makeCopy(m_dsLoader.getLoader());
  } catch (Exception ex) {
    // ignore
  }

  m_LoaderEditor.setTarget(m_dsLoader.getLoader());
  // m_fileEditor.setValue(m_dsLoader.getDataSetFile());
  m_LoaderEditor.setEnvironment(m_env);
  if (m_dsLoader.getLoader() instanceof FileSourcedConverter) {
    setUpFile();
  } else {
    if (m_dsLoader.getLoader() instanceof DatabaseConverter) {
      setUpDatabase();
    } else {
      setUpOther();
    }
  }
}
项目:autoweka    文件:LoaderCustomizer.java   
/**
 * Set the loader to be customized
 *
 * @param object a weka.gui.beans.Loader
 */
public void setObject(Object object) {
  m_dsLoader = (weka.gui.beans.Loader)object;

  try {
    m_backup = 
      (weka.core.converters.Loader)GenericObjectEditor.makeCopy(m_dsLoader.getLoader());
  } catch (Exception ex) {
    // ignore
  }

  m_LoaderEditor.setTarget(m_dsLoader.getLoader());
  //    m_fileEditor.setValue(m_dsLoader.getDataSetFile());
  m_LoaderEditor.setEnvironment(m_env);
  if (m_dsLoader.getLoader() instanceof FileSourcedConverter) {
    setUpFile();
  } else{ 
      if(m_dsLoader.getLoader() instanceof DatabaseConverter) {
          setUpDatabase();
      }
      else
    setUpOther();
  }    
}
项目:umple    文件:LoaderCustomizer.java   
/**
 * Set the loader to be customized
 * 
 * @param object a weka.gui.beans.Loader
 */
@Override
public void setObject(Object object) {
  m_dsLoader = (weka.gui.beans.Loader) object;

  try {
    m_backup = (weka.core.converters.Loader) GenericObjectEditor
      .makeCopy(m_dsLoader.getLoader());
  } catch (Exception ex) {
    // ignore
  }

  m_LoaderEditor.setTarget(m_dsLoader.getLoader());
  // m_fileEditor.setValue(m_dsLoader.getDataSetFile());
  m_LoaderEditor.setEnvironment(m_env);
  if (m_dsLoader.getLoader() instanceof FileSourcedConverter) {
    setUpFile();
  } else {
    if (m_dsLoader.getLoader() instanceof DatabaseConverter) {
      setUpDatabase();
    } else {
      setUpOther();
    }
  }
}
项目:jbossBA    文件:Loader.java   
/**
 * Gets a string that describes the start action. The
 * KnowledgeFlow uses this in the popup contextual menu
 * for the component. The string can be proceeded by
 * a '$' character to indicate that the component can't
 * be started at present.
 * 
 * @return a string describing the start action.
 */
public String getStartMessage() {
  boolean ok = true;
  String entry = Messages.getInstance().getString("Loader_GetStartMessage_Entry_Text");
  if (m_ioThread == null) {
    if (m_Loader instanceof FileSourcedConverter) {
      String temp = ((FileSourcedConverter) m_Loader).retrieveFile().getPath();
      Environment env = (m_env == null) ? Environment.getSystemWide() : m_env;
      try {
        temp = env.substitute(temp);
      } catch (Exception ex) {}
      File tempF = new File(temp);
      if (!tempF.isFile()) {
        ok = false;
      }
    }
    if (!ok) {
      entry = "$"+entry;
    }
  }

  return entry;
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * configures the current converter.
 * 
 * @param dialogType the type of dialog to configure for
 */
protected void configureCurrentConverter(int dialogType) {
  String filename;
  File currFile;

  if ((getSelectedFile() == null) || (getSelectedFile().isDirectory())) {
    return;
  }

  filename = getSelectedFile().getAbsolutePath();

  if (m_CurrentConverter == null) {
    if (dialogType == LOADER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getLoaderForFile(filename);
    } else if (dialogType == SAVER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getSaverForFile(filename);
    } else {
      throw new IllegalStateException("Cannot determine loader/saver!");
    }

    // none found?
    if (m_CurrentConverter == null) {
      return;
    }
  }

  try {
    currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile();
    if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename))) {
      ((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename));
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:SaverCustomizer.java   
/**
 * Set the saver to be customized
 *
 * @param object a weka.gui.beans.Saver
 */
public void setObject(Object object) {
  m_dsSaver = (weka.gui.beans.Saver)object;
  m_SaverEditor.setTarget(m_dsSaver.getSaverTemplate());
  if(m_dsSaver.getSaverTemplate() instanceof DatabaseConverter){
    setUpDatabase();
  }
  else{
    if (m_dsSaver.getSaverTemplate() instanceof FileSourcedConverter) {
      setUpFile();
    } else {
      setUpOther();
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:Loader.java   
/**
 * Gets a string that describes the start action. The KnowledgeFlow uses this
 * in the popup contextual menu for the component. The string can be proceeded
 * by a '$' character to indicate that the component can't be started at
 * present.
 * 
 * @return a string describing the start action.
 */
@Override
public String getStartMessage() {
  boolean ok = true;
  String entry = "Start loading";
  if (m_ioThread == null) {
    if (m_Loader instanceof FileSourcedConverter) {
      String temp = ((FileSourcedConverter) m_Loader).retrieveFile()
        .getPath();
      Environment env = (m_env == null) ? Environment.getSystemWide() : m_env;
      try {
        temp = env.substitute(temp);
      } catch (Exception ex) {
      }
      File tempF = new File(temp);

      // forward slashes are platform independent for resources read from the
      // classpath
      String tempFixedPathSepForResource = temp.replace(File.separatorChar,
        '/');
      if (!tempF.isFile()
        && this.getClass().getClassLoader()
          .getResource(tempFixedPathSepForResource) == null) {
        ok = false;
      }
    }
    if (!ok) {
      entry = "$" + entry;
    }
  }
  return entry;
}
项目:repo.kmeanspp.silhouette_score    文件:SetInstancesPanel.java   
/**
 * Loads results from a set of instances contained in the supplied file.
 * 
 * @param f a value of type 'File'
 */
protected void setInstancesFromFile(File f) {
  boolean incremental = m_readIncrementally;

  try {
    // m_Loader = ConverterUtils.getLoaderForFile(f);
    m_Loader = m_FileChooser.getLoader();
    if (m_Loader == null)
      throw new Exception(
          "No suitable FileSourcedConverter found for file!\n" + f);

    // not an incremental loader?
    if (!(m_Loader instanceof IncrementalConverter))
      incremental = false;

    // load
    ((FileSourcedConverter) m_Loader).setFile(f);
    if (incremental) {
      m_Summary.setShowZeroInstancesAsUnknown(m_showZeroInstancesAsUnknown);
      setInstances(m_Loader.getStructure());
    } else {
      // If we are batch loading then we will know for sure that
      // the data has no instances
      m_Summary.setShowZeroInstancesAsUnknown(false);
      setInstances(m_Loader.getDataSet());
    }
  } catch (Exception ex) {
    JOptionPane.showMessageDialog(this,
        "Couldn't read from file:\n" + f.getName(), "Load Instances",
        JOptionPane.ERROR_MESSAGE);
  }
}
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * configures the current converter.
  * 
  * @param dialogType       the type of dialog to configure for
  */
 protected void configureCurrentConverter(int dialogType) {
   String   filename;
   File currFile;

   if ( (getSelectedFile() == null) || (getSelectedFile().isDirectory()) )
     return;

   filename = getSelectedFile().getAbsolutePath();

   if (m_CurrentConverter == null) {
     if (dialogType == LOADER_DIALOG)
m_CurrentConverter = ConverterUtils.getLoaderForFile(filename);
     else if (dialogType == SAVER_DIALOG)
m_CurrentConverter = ConverterUtils.getSaverForFile(filename);
     else
throw new IllegalStateException("Cannot determine loader/saver!");

     // none found?
     if (m_CurrentConverter == null)
return;
   }

   try {
     currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile();
     if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename)))
((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename));
   }
   catch (Exception e) {
     e.printStackTrace();
   }
 }
项目:autoweka    文件:SaverCustomizer.java   
/**
 * Set the saver to be customized
 *
 * @param object a weka.gui.beans.Saver
 */
public void setObject(Object object) {
  m_dsSaver = (weka.gui.beans.Saver)object;
  m_SaverEditor.setTarget(m_dsSaver.getSaverTemplate());
  if(m_dsSaver.getSaverTemplate() instanceof DatabaseConverter){
    setUpDatabase();
  }
  else{
    if (m_dsSaver.getSaverTemplate() instanceof FileSourcedConverter) {
      setUpFile();
    } else {
      setUpOther();
    }
  }
}
项目:autoweka    文件:Loader.java   
/**
 * Gets a string that describes the start action. The
 * KnowledgeFlow uses this in the popup contextual menu
 * for the component. The string can be proceeded by
 * a '$' character to indicate that the component can't
 * be started at present.
 * 
 * @return a string describing the start action.
 */
public String getStartMessage() {
  boolean ok = true;
  String entry = "Start loading";
  if (m_ioThread == null) {
    if (m_Loader instanceof FileSourcedConverter) {
      String temp = ((FileSourcedConverter) m_Loader).retrieveFile().getPath();
      Environment env = (m_env == null) ? Environment.getSystemWide() : m_env;
      try {
        temp = env.substitute(temp);
      } catch (Exception ex) {}
      File tempF = new File(temp);

      // forward slashes are platform independent for resources read from the
      // classpath
      String tempFixedPathSepForResource = temp.replace(File.separatorChar, '/');
      if (!tempF.isFile() && 
          this.getClass().getClassLoader().getResource(tempFixedPathSepForResource) == null) {
        ok = false;
      }
    }
    if (!ok) {
      entry = "$"+entry;
    }
  }
  return entry;
}
项目:autoweka    文件:SetInstancesPanel.java   
/**
  * Loads results from a set of instances contained in the supplied
  * file.
  *
  * @param f a value of type 'File'
  */
 protected void setInstancesFromFile(File f) {
   boolean incremental = m_readIncrementally;

   try {
     m_Loader = ConverterUtils.getLoaderForFile(f);
     if (m_Loader == null)
throw new Exception("No suitable FileSourcedConverter found for file!\n" + f);

     // not an incremental loader?
     if (!(m_Loader instanceof IncrementalConverter))
incremental = false;

     // load
     ((FileSourcedConverter) m_Loader).setFile(f);
     if (incremental) {
       m_Summary.setShowZeroInstancesAsUnknown(m_showZeroInstancesAsUnknown);
setInstances(m_Loader.getStructure());
     } else {
       // If we are batch loading then we will know for sure that
       // the data has no instances
       m_Summary.setShowZeroInstancesAsUnknown(false);
setInstances(m_Loader.getDataSet());
     }
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(this,
                "Couldn't read from file:\n"
                + f.getName(),
                "Load Instances",
                JOptionPane.ERROR_MESSAGE);
   }
 }
项目:umple    文件:ConverterFileChooser.java   
/**
 * configures the current converter.
 * 
 * @param dialogType the type of dialog to configure for
 */
protected void configureCurrentConverter(int dialogType) {
  String filename;
  File currFile;

  if ((getSelectedFile() == null) || (getSelectedFile().isDirectory())) {
    return;
  }

  filename = getSelectedFile().getAbsolutePath();

  if (m_CurrentConverter == null) {
    if (dialogType == LOADER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getLoaderForFile(filename);
    } else if (dialogType == SAVER_DIALOG) {
      m_CurrentConverter = ConverterUtils.getSaverForFile(filename);
    } else {
      throw new IllegalStateException("Cannot determine loader/saver!");
    }

    // none found?
    if (m_CurrentConverter == null) {
      return;
    }
  }

  try {
    currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile();
    if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename))) {
      ((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename));
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:umple    文件:SaverCustomizer.java   
/**
 * Set the saver to be customized
 *
 * @param object a weka.gui.beans.Saver
 */
public void setObject(Object object) {
  m_dsSaver = (weka.gui.beans.Saver)object;
  m_SaverEditor.setTarget(m_dsSaver.getSaverTemplate());
  if(m_dsSaver.getSaverTemplate() instanceof DatabaseConverter){
    setUpDatabase();
  }
  else{
    if (m_dsSaver.getSaverTemplate() instanceof FileSourcedConverter) {
      setUpFile();
    } else {
      setUpOther();
    }
  }
}
项目:umple    文件:Loader.java   
/**
 * Gets a string that describes the start action. The KnowledgeFlow uses this
 * in the popup contextual menu for the component. The string can be proceeded
 * by a '$' character to indicate that the component can't be started at
 * present.
 * 
 * @return a string describing the start action.
 */
@Override
public String getStartMessage() {
  boolean ok = true;
  String entry = "Start loading";
  if (m_ioThread == null) {
    if (m_Loader instanceof FileSourcedConverter) {
      String temp = ((FileSourcedConverter) m_Loader).retrieveFile()
        .getPath();
      Environment env = (m_env == null) ? Environment.getSystemWide() : m_env;
      try {
        temp = env.substitute(temp);
      } catch (Exception ex) {
      }
      File tempF = new File(temp);

      // forward slashes are platform independent for resources read from the
      // classpath
      String tempFixedPathSepForResource = temp.replace(File.separatorChar,
        '/');
      if (!tempF.isFile()
        && this.getClass().getClassLoader()
          .getResource(tempFixedPathSepForResource) == null) {
        ok = false;
      }
    }
    if (!ok) {
      entry = "$" + entry;
    }
  }
  return entry;
}
项目:umple    文件:SetInstancesPanel.java   
/**
 * Loads results from a set of instances contained in the supplied file.
 * 
 * @param f a value of type 'File'
 */
protected void setInstancesFromFile(File f) {
  boolean incremental = m_readIncrementally;

  try {
    // m_Loader = ConverterUtils.getLoaderForFile(f);
    m_Loader = m_FileChooser.getLoader();
    if (m_Loader == null)
      throw new Exception(
          "No suitable FileSourcedConverter found for file!\n" + f);

    // not an incremental loader?
    if (!(m_Loader instanceof IncrementalConverter))
      incremental = false;

    // load
    ((FileSourcedConverter) m_Loader).setFile(f);
    if (incremental) {
      m_Summary.setShowZeroInstancesAsUnknown(m_showZeroInstancesAsUnknown);
      setInstances(m_Loader.getStructure());
    } else {
      // If we are batch loading then we will know for sure that
      // the data has no instances
      m_Summary.setShowZeroInstancesAsUnknown(false);
      setInstances(m_Loader.getDataSet());
    }
  } catch (Exception ex) {
    JOptionPane.showMessageDialog(this,
        "Couldn't read from file:\n" + f.getName(), "Load Instances",
        JOptionPane.ERROR_MESSAGE);
  }
}
项目:jbossBA    文件:ConverterFileChooser.java   
/**
  * configures the current converter
  * 
  * @param dialogType       the type of dialog to configure for
  */
 protected void configureCurrentConverter(int dialogType) {
   String   filename;
   File currFile;

   if ( (getSelectedFile() == null) || (getSelectedFile().isDirectory()) )
     return;

   filename = getSelectedFile().getAbsolutePath();

   if (m_CurrentConverter == null) {
     if (dialogType == LOADER_DIALOG)
m_CurrentConverter = ConverterUtils.getLoaderForFile(filename);
     else if (dialogType == SAVER_DIALOG)
m_CurrentConverter = ConverterUtils.getSaverForFile(filename);
     else
throw new IllegalStateException(Messages.getInstance().getString("ConverterFileChooser_ConfigureCurrentConverter_IllegalStateException_Text"));

     // none found?
     if (m_CurrentConverter == null)
return;
   }

   try {
     currFile = ((FileSourcedConverter) m_CurrentConverter).retrieveFile();
     if ((currFile == null) || (!currFile.getAbsolutePath().equals(filename)))
((FileSourcedConverter) m_CurrentConverter).setFile(new File(filename));
   }
   catch (Exception e) {
     e.printStackTrace();
   }
 }
项目:jbossBA    文件:SaverCustomizer.java   
/**
 * Set the saver to be customized
 *
 * @param object a weka.gui.beans.Saver
 */
public void setObject(Object object) {
  m_dsSaver = (weka.gui.beans.Saver)object;
  m_SaverEditor.setTarget(m_dsSaver.getSaverTemplate());
  if(m_dsSaver.getSaverTemplate() instanceof DatabaseConverter){
          setUpDatabase();
  }
  else{
      if (m_dsSaver.getSaverTemplate() instanceof FileSourcedConverter) {
          setUpFile();
      } else {
          setUpOther();
      }
  }
}
项目:jbossBA    文件:LoaderCustomizer.java   
/**
 * Set the loader to be customized
 *
 * @param object a weka.gui.beans.Loader
 */
public void setObject(Object object) {
  m_dsLoader = (weka.gui.beans.Loader)object;
  m_LoaderEditor.setTarget(m_dsLoader.getLoader());
  //    m_fileEditor.setValue(m_dsLoader.getDataSetFile());
  if (m_dsLoader.getLoader() instanceof FileSourcedConverter) {
    setUpFile();
  } else{ 
      if(m_dsLoader.getLoader() instanceof DatabaseConverter) {
          setUpDatabase();
      }
      else
    setUpOther();
  }
}
项目:jbossBA    文件:SetInstancesPanel.java   
/**
 * Loads results from a set of instances contained in the supplied file.
 * 
 * @param f a value of type 'File'
 */
protected void setInstancesFromFile(File f) {
  boolean incremental = m_readIncrementally;

  try {
    m_Loader = ConverterUtils.getLoaderForFile(f);
    if (m_Loader == null)
      throw new Exception(Messages.getInstance().getString(
          "SetInstancesPanel_SetInstancesFromFile_Exception_Text_First")
          + f);

    // not an incremental loader?
    if (!(m_Loader instanceof IncrementalConverter))
      incremental = false;

    // load
    ((FileSourcedConverter) m_Loader).setFile(f);
    if (incremental) {
      m_Summary.setShowZeroInstancesAsUnknown(m_showZeroInstancesAsUnknown);
      setInstances(m_Loader.getStructure());
    } else {
      m_Summary.setShowZeroInstancesAsUnknown(false);
      setInstances(m_Loader.getDataSet());
    }
  } catch (Exception ex) {
    JOptionPane
        .showMessageDialog(
            this,
            Messages
                .getInstance()
                .getString(
                    "SetInstancesPanel_SetInstancesFromFile_Exception_JOptionPaneShowMessageDialog_Text_First")
                + f.getName(),
            Messages
                .getInstance()
                .getString(
                    "SetInstancesPanel_SetInstancesFromFile_Exception_JOptionPaneShowMessageDialog_Text_Second"),
            JOptionPane.ERROR_MESSAGE);
  }
}
项目:jbossBA    文件:LoaderCustomizer.java   
public void setUpFile() {
   removeAll();

   File tmp = ((FileSourcedConverter)m_dsLoader.getLoader()).retrieveFile();
   tmp = new File(tmp.getAbsolutePath());
   if (tmp.isDirectory()) {
     m_fileChooser.setCurrentDirectory(tmp);
   } else {
     m_fileChooser.setSelectedFile(tmp);
   }
   FileSourcedConverter loader = (FileSourcedConverter) m_dsLoader.getLoader();
   String[] ext = loader.getFileExtensions();
   ExtensionFileFilter firstFilter = null;
   for (int i = 0; i < ext.length; i++) {
     ExtensionFileFilter ff =
new ExtensionFileFilter(
    ext[i], loader.getFileDescription() + " (*" + ext[i] + ")");
     if (i == 0)
firstFilter = ff;
     m_fileChooser.addChoosableFileFilter(ff);
   }
   if (firstFilter != null)
     m_fileChooser.setFileFilter(firstFilter);
   JPanel about = m_LoaderEditor.getAboutPanel();
   if (about != null) {
     add(about, BorderLayout.NORTH);
   }
   add(m_fileChooser, BorderLayout.CENTER);

   m_relativeFilePath = new JCheckBox(Messages.getInstance().getString("LoaderCustomizer_SetUpDatabase_RelativeFilePath_JCheckBox_Text"));
   m_relativeFilePath.
     setSelected(((FileSourcedConverter)m_dsLoader.getLoader()).getUseRelativePath());

   m_relativeFilePath.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
         ((FileSourcedConverter)m_dsLoader.getLoader()).
           setUseRelativePath(m_relativeFilePath.isSelected());
       }
     });
   JPanel holderPanel = new JPanel();
   holderPanel.setLayout(new FlowLayout());
   holderPanel.add(m_relativeFilePath);
   add(holderPanel, BorderLayout.SOUTH);
 }