Search in sources :

Example 1 with TooManySectionsException

use of org.knime.base.node.viz.pie.util.TooManySectionsException in project knime-core by knime.

the class InteractivePieVizModel method addRows2Sections.

/**
 * Adds all rows to the available sections.
 * @throws TooManySectionsException if more sections are created than
 * supported
 */
private void addRows2Sections() throws TooManySectionsException {
    final int pieColIdx = m_model.getColIndex(m_pieColSpec.getName());
    final int aggrColIdx;
    if (m_aggrColSpec == null) {
        aggrColIdx = -1;
    } else {
        aggrColIdx = m_model.getColIndex(m_aggrColSpec.getName());
    }
    for (final DataRow row : m_model) {
        final DataCell pieCell = row.getCell(pieColIdx);
        final DataCell aggrCell;
        if (aggrColIdx < 0) {
            aggrCell = null;
        } else {
            aggrCell = row.getCell(aggrColIdx);
        }
        final Color rowColor = m_model.getRowColor(row);
        PieSectionDataModel section;
        if (pieCell.isMissing()) {
            section = getMissingSection();
        } else {
            section = getSection(pieCell);
            if (section == null) {
                if (m_sections.size() >= PieColumnFilter.MAX_NO_OF_SECTIONS) {
                    throw new TooManySectionsException("Selected pie column contains more than " + PieColumnFilter.MAX_NO_OF_SECTIONS + " unique values.");
                }
                // throw new IllegalArgumentException("No section found for: "
                // + pieCell.toString());
                section = new PieSectionDataModel(pieCell.toString(), Color.BLACK, m_model.supportsHiliting());
                m_sections.add(section);
            }
        }
        section.addDataRow(rowColor, row.getKey(), aggrCell);
    }
}
Also used : PieSectionDataModel(org.knime.base.node.viz.pie.datamodel.PieSectionDataModel) Color(java.awt.Color) DataCell(org.knime.core.data.DataCell) DataRow(org.knime.core.data.DataRow) TooManySectionsException(org.knime.base.node.viz.pie.util.TooManySectionsException)

Example 2 with TooManySectionsException

use of org.knime.base.node.viz.pie.util.TooManySectionsException in project knime-core by knime.

the class InteractivePiePlotter method setAggregationColumn.

/**
 * @param colName the name of the new aggregation column
 */
protected void setAggregationColumn(final String colName) {
    if (m_ignoreChanges) {
        return;
    }
    final InteractivePieVizModel vizModel = getVizModel();
    if (vizModel == null) {
        throw new NullPointerException("vizModel must not be null");
    }
    // update the properties panel as well
    final InteractivePieProperties properties = getPropertiesPanel();
    if (properties == null) {
        throw new NullPointerException("Properties must not be null");
    }
    boolean changed = true;
    try {
        changed = vizModel.setAggrColumn(colName);
        resetInfoMsg();
    } catch (final TooManySectionsException e) {
        setInfoMsg(e.getMessage());
    }
    if (changed) {
        modelChanged();
    }
}
Also used : InteractivePieVizModel(org.knime.base.node.viz.pie.datamodel.interactive.InteractivePieVizModel) TooManySectionsException(org.knime.base.node.viz.pie.util.TooManySectionsException)

Example 3 with TooManySectionsException

use of org.knime.base.node.viz.pie.util.TooManySectionsException in project knime-core by knime.

the class FixedPieDataModel method addDataRow.

/**
 * @param row the row to add
 * @param rowColor the color of the roe
 * @param pieCell the cell with the pie value
 * @param aggrCell the cell with the aggregation value
 * @throws TooManySectionsException if more sections are created than
 * supported
 */
public void addDataRow(final DataRow row, final Color rowColor, final DataCell pieCell, final DataCell aggrCell) throws TooManySectionsException {
    if (pieCell == null) {
        throw new NullPointerException("Pie section value must not be null.");
    }
    PieSectionDataModel section;
    if (pieCell.isMissing()) {
        section = getMissingSection();
    } else {
        section = getSection(pieCell);
        if (section == null) {
            if (m_sections.size() >= PieColumnFilter.MAX_NO_OF_SECTIONS) {
                throw new TooManySectionsException("Selected pie column contains more than " + PieColumnFilter.MAX_NO_OF_SECTIONS + " unique values.");
            }
            // throw new IllegalArgumentException("No section found for: "
            // + pieCell.toString());
            section = new PieSectionDataModel(pieCell.toString(), Color.BLACK, supportsHiliting());
            m_sections.add(section);
        }
        m_sectionsInitialized = false;
    }
    section.addDataRow(rowColor, row.getKey(), aggrCell);
}
Also used : PieSectionDataModel(org.knime.base.node.viz.pie.datamodel.PieSectionDataModel) TooManySectionsException(org.knime.base.node.viz.pie.util.TooManySectionsException)

Example 4 with TooManySectionsException

use of org.knime.base.node.viz.pie.util.TooManySectionsException in project knime-core by knime.

the class InteractivePiePlotter method setPieColumn.

/**
 * @param colName the name of the new pie column
 */
protected void setPieColumn(final String colName) {
    if (m_ignoreChanges) {
        return;
    }
    final InteractivePieVizModel vizModel = getVizModel();
    if (vizModel == null) {
        throw new NullPointerException("vizModel must not be null");
    }
    boolean changed = true;
    try {
        changed = vizModel.setPieColumn(colName);
        resetInfoMsg();
    } catch (final TooManySectionsException e) {
        setInfoMsg(e.getMessage());
    }
    if (changed) {
        modelChanged();
    }
}
Also used : InteractivePieVizModel(org.knime.base.node.viz.pie.datamodel.interactive.InteractivePieVizModel) TooManySectionsException(org.knime.base.node.viz.pie.util.TooManySectionsException)

Example 5 with TooManySectionsException

use of org.knime.base.node.viz.pie.util.TooManySectionsException in project knime-core by knime.

the class PieNodeModel method getVizModel.

/**
 * @return the {@link PieVizModel}. Could be null.
 */
public D getVizModel() {
    D vizModel = null;
    try {
        vizModel = getVizModelInternal();
    } catch (final TooManySectionsException e) {
        setWarningMessage(e.getMessage());
        LOGGER.error(e.getMessage());
    }
    if (vizModel == null) {
        return null;
    }
    final AggregationMethod method = AggregationMethod.getMethod4Command(m_aggrMethod.getStringValue());
    vizModel.setAggregationMethod(method);
    return vizModel;
}
Also used : AggregationMethod(org.knime.base.node.viz.aggregation.AggregationMethod) TooManySectionsException(org.knime.base.node.viz.pie.util.TooManySectionsException)

Aggregations

TooManySectionsException (org.knime.base.node.viz.pie.util.TooManySectionsException)5 PieSectionDataModel (org.knime.base.node.viz.pie.datamodel.PieSectionDataModel)2 InteractivePieVizModel (org.knime.base.node.viz.pie.datamodel.interactive.InteractivePieVizModel)2 Color (java.awt.Color)1 AggregationMethod (org.knime.base.node.viz.aggregation.AggregationMethod)1 DataCell (org.knime.core.data.DataCell)1 DataRow (org.knime.core.data.DataRow)1