Search in sources :

Example 6 with ConfigWO

use of org.knime.core.node.config.ConfigWO in project knime-core by knime.

the class FixedHistogramDataModel method save2File.

/**
 * @param directory the directory to write to
 * @param exec the {@link ExecutionMonitor} to provide progress messages
 * @throws IOException if a file exception occurs
 * @throws CanceledExecutionException if the operation is canceled
 */
public void save2File(final File directory, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (exec != null) {
        exec.setProgress(0.0, "Start saving histogram data model to file");
    }
    final File dataFile = new File(directory, CFG_DATA_FILE);
    final FileOutputStream os = new FileOutputStream(dataFile);
    final GZIPOutputStream dataOS = new GZIPOutputStream(os);
    final Config config = new NodeSettings(CFG_DATA);
    final ConfigWO xConf = config.addConfig(CFG_X_COL_SPEC);
    m_xColSpec.save(xConf);
    if (exec != null) {
        exec.setProgress(0.1, "Binning column specification saved");
        exec.setMessage("Start saving aggregation columns...");
    }
    config.addBoolean(CFG_NOMINAL, m_binNominal);
    config.addString(CFG_AGGR_METHOD, m_aggrMethod.getActionCommand());
    final Config aggrConf = config.addConfig(CFG_AGGR_COLS);
    aggrConf.addInt(CFG_AGGR_COL_COUNTER, m_aggrColumns.size());
    int idx = 0;
    for (final ColorColumn col : m_aggrColumns) {
        final ConfigWO aggrColConf = aggrConf.addConfig(CFG_COLOR_COL + idx++);
        col.save2File(aggrColConf, exec);
    }
    if (exec != null) {
        exec.setProgress(0.3, "Start saving bins...");
    }
    final ConfigWO binsConf = config.addConfig(CFG_BINS);
    binsConf.addInt(CFG_BIN_COUNTER, m_bins.size());
    idx = 0;
    for (final BinDataModel bin : m_bins) {
        final ConfigWO binConf = binsConf.addConfig(CFG_BIN + idx++);
        bin.save2File(binConf, exec);
    }
    final ConfigWO missingBin = binsConf.addConfig(CFG_MISSING_BIN);
    m_missingValueBin.save2File(missingBin, exec);
    if (m_invalidValueBin != null) {
        final ConfigWO invalidBin = binsConf.addConfig(CFG_INVALID_BIN);
        m_invalidValueBin.save2File(invalidBin, exec);
    }
    if (exec != null) {
        exec.setProgress(0.8, "Start saving element colors...");
    }
    final List<Color> rowColors = getRowColors();
    final ConfigWO colorColsConf = config.addConfig(CFG_COLOR_COLS);
    colorColsConf.addInt(CFG_ROW_COLOR_COUNTER, rowColors.size());
    idx = 0;
    for (final Color color : rowColors) {
        colorColsConf.addInt(CFG_ROW_COLOR + idx++, color.getRGB());
    }
    config.saveToXML(dataOS);
    dataOS.flush();
    dataOS.close();
    os.flush();
    os.close();
    if (exec != null) {
        exec.setProgress(1.0, "Histogram data model saved");
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) Config(org.knime.core.node.config.Config) FileOutputStream(java.io.FileOutputStream) ColorColumn(org.knime.base.node.viz.histogram.util.ColorColumn) Color(java.awt.Color) ConfigWO(org.knime.core.node.config.ConfigWO) File(java.io.File)

Example 7 with ConfigWO

use of org.knime.core.node.config.ConfigWO in project knime-core by knime.

the class DataCellStringMapper method save.

/**
 * Saves the {@link DataCellStringMapper}> to the given {@link ConfigWO}.
 *
 * @param config Save settings to.
 */
public void save(final ConfigWO config) {
    config.addInt(CFG_UNIQUEINDEX, m_uniqueIndex);
    ConfigWO origstringToString = config.addConfig(CFG_ORIGSTRINGTOSTRING);
    for (Map.Entry<String, String> e : m_origstringToString.entrySet()) {
        String key = e.getKey();
        String value = e.getValue();
        origstringToString.addString(key, value);
    }
    ConfigWO stringToCell = config.addConfig(CFG_STRINGTOCELL);
    for (Map.Entry<String, DataCell> e : m_stringToCell.entrySet()) {
        String key = e.getKey();
        DataCell v = e.getValue();
        stringToCell.addDataCell(key, v);
    }
}
Also used : DataCell(org.knime.core.data.DataCell) ConfigWO(org.knime.core.node.config.ConfigWO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with ConfigWO

use of org.knime.core.node.config.ConfigWO in project knime-core by knime.

the class BinDataModel method save2File.

/**
 * @param config the config object to use
 * @param exec the optional {@link ExecutionMonitor} to provide progress messages
 * @throws CanceledExecutionException if the operation is canceled
 */
public void save2File(final ConfigWO config, final ExecutionMonitor exec) throws CanceledExecutionException {
    config.addString(CFG_X_CAPTION, getXAxisCaption());
    if (getLowerBound() == null || getUpperBound() == null) {
        config.addBoolean(CFG_HAS_BOUNDARIES, false);
    } else {
        config.addBoolean(CFG_HAS_BOUNDARIES, true);
        config.addDouble(CFG_LOWER_BOUND, getLowerBound().doubleValue());
        config.addDouble(CFG_UPPER_BOUND, getUpperBound().doubleValue());
    }
    final ConfigWO barsConf = config.addConfig(CFG_BARS);
    final Collection<BarDataModel> bars = getBars();
    barsConf.addInt(CFG_BAR_COUNTER, bars.size());
    int idx = 0;
    for (final BarDataModel bar : bars) {
        final ConfigWO barConfig = barsConf.addConfig(CFG_BAR + idx++);
        bar.save2File(barConfig, exec);
    }
    if (exec != null) {
        exec.checkCanceled();
    }
}
Also used : ConfigWO(org.knime.core.node.config.ConfigWO) Point(java.awt.Point)

Example 9 with ConfigWO

use of org.knime.core.node.config.ConfigWO in project knime-core by knime.

the class InteractiveHistogramDataModel method save2File.

/**
 * @param dataDir the data directory to write to
 * @param exec the {@link ExecutionMonitor}
 * @throws IOException if the file can't be created
 * @throws CanceledExecutionException if the process was canceled
 */
public void save2File(final File dataDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    final File settingFile = new File(dataDir, CFG_SETTING_FILE);
    final FileOutputStream os = new FileOutputStream(settingFile);
    final GZIPOutputStream dataOS = new GZIPOutputStream(os);
    final Config config = new NodeSettings(CFG_SETTING);
    final List<Color> rowColors = getRowColors();
    final ConfigWO colorColsConf = config.addConfig(CFG_COLOR_COLS);
    colorColsConf.addInt(CFG_ROW_COLOR_COUNTER, rowColors.size());
    int idx = 0;
    for (final Color color : rowColors) {
        colorColsConf.addInt(CFG_ROW_COLOR + idx++, color.getRGB());
    }
    config.saveToXML(dataOS);
    exec.checkCanceled();
    final File dataFile = new File(dataDir, CFG_DATA_FILE);
    DataContainer.writeToZip(m_data, dataFile, exec);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) Config(org.knime.core.node.config.Config) FileOutputStream(java.io.FileOutputStream) Color(java.awt.Color) ConfigWO(org.knime.core.node.config.ConfigWO) File(java.io.File)

Example 10 with ConfigWO

use of org.knime.core.node.config.ConfigWO in project knime-core by knime.

the class FixedPieDataModel method save2File.

/**
 * @param directory the directory to write to
 * @param exec the {@link ExecutionMonitor} to provide progress messages
 * @throws IOException if a file exception occurs
 * @throws CanceledExecutionException if the operation was canceled
 */
public void save2File(final File directory, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (exec != null) {
        exec.setProgress(0.0, "Start saving histogram data model to file");
    }
    final File dataFile = new File(directory, CFG_DATA_FILE);
    final FileOutputStream os = new FileOutputStream(dataFile);
    final GZIPOutputStream dataOS = new GZIPOutputStream(os);
    final Config config = new NodeSettings(CFG_DATA);
    config.addString(CFG_PIE_COL, m_pieCol);
    config.addBoolean(CFG_NUMERIC_PIE_COL, m_numericPieCol);
    config.addString(CFG_AGGR_COL, m_aggrCol);
    config.addBoolean(CFG_HILITING, supportsHiliting());
    config.addBoolean(CFG_DETAILS, detailsAvailable());
    config.addBoolean(CFG_IS_COLOR_COLUMN, m_isColorColumn);
    if (exec != null) {
        exec.setProgress(0.3, "Start saving sections...");
        exec.checkCanceled();
    }
    final Config sectionsConf = config.addConfig(CFG_SECTIONS);
    sectionsConf.addInt(CFG_SECTION_COUNT, m_sections.size());
    int idx = 0;
    for (final PieSectionDataModel section : m_sections) {
        final ConfigWO sectionConf = sectionsConf.addConfig(CFG_SECTION + idx++);
        section.save2File(sectionConf, exec);
    }
    if (exec != null) {
        exec.setProgress(0.8, "Start saving missing section...");
        exec.checkCanceled();
    }
    final ConfigWO missingSection = sectionsConf.addConfig(CFG_MISSING_SECTION);
    m_missingSection.save2File(missingSection, exec);
    config.saveToXML(dataOS);
    dataOS.flush();
    dataOS.close();
    os.flush();
    os.close();
    if (exec != null) {
        exec.setProgress(1.0, "Pie data model saved");
    }
}
Also used : PieSectionDataModel(org.knime.base.node.viz.pie.datamodel.PieSectionDataModel) NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) Config(org.knime.core.node.config.Config) FileOutputStream(java.io.FileOutputStream) ConfigWO(org.knime.core.node.config.ConfigWO) File(java.io.File)

Aggregations

ConfigWO (org.knime.core.node.config.ConfigWO)15 Map (java.util.Map)4 Config (org.knime.core.node.config.Config)4 Color (java.awt.Color)3 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 LinkedHashMap (java.util.LinkedHashMap)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 DataCell (org.knime.core.data.DataCell)3 NodeSettings (org.knime.core.node.NodeSettings)3 HashMap (java.util.HashMap)2 Point (java.awt.Point)1 TreeMap (java.util.TreeMap)1 ColorColumn (org.knime.base.node.viz.histogram.util.ColorColumn)1 PieSectionDataModel (org.knime.base.node.viz.pie.datamodel.PieSectionDataModel)1 RowKey (org.knime.core.data.RowKey)1 Shape (org.knime.core.data.property.ShapeFactory.Shape)1