package org.morriskurz.forceplot; import java.util.Arrays; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.knime.core.node.InvalidSettingsException; import org.knime.core.node.NodeSettingsRO; import org.knime.core.node.NodeSettingsWO; import org.knime.js.core.JSONViewContent; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") public class ForcePlotViewValue extends JSONViewContent { private int currentPage = 1; private String[] forcePlotsSVG; @Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } final ForcePlotViewValue other = (ForcePlotViewValue) obj; return new EqualsBuilder().append(currentPage, other.getCurrentPage()) .append(forcePlotsSVG, other.getForcePlotsSVG()).isEquals(); } public int getCurrentPage() { return currentPage; } public String[] getForcePlotsSVG() { return forcePlotsSVG; } @Override public int hashCode() { return new HashCodeBuilder().append(currentPage).append(forcePlotsSVG).toHashCode(); } @Override public void loadFromNodeSettings(final NodeSettingsRO settings) throws InvalidSettingsException { currentPage = settings.getInt("currentPage"); forcePlotsSVG = settings.getStringArray("svgs"); } @Override public void saveToNodeSettings(final NodeSettingsWO settings) { settings.addInt("currentPage", currentPage); settings.addStringArray("svgs", forcePlotsSVG); } public void setCurrentPage(final int currentPage) { this.currentPage = currentPage; } public void setForcePlotsSVG(final String[] forcePlotsSVG) { this.forcePlotsSVG = forcePlotsSVG; } @Override public String toString() { return "ForcePlotViewValue, currentPage = " + currentPage + ", force plots SVGs: " + Arrays.toString(forcePlotsSVG); } }