/** * Copy data from specified 2D short array. * * @param copyAlpha Also copy the alpha information. */ public void copyFrom(short[][] maps, boolean copyAlpha) { final int len = maps.length; beginUpdate(); try { // red component if (len > 0) red.copyFrom(maps[0], 8); if (len > 1) green.copyFrom(maps[1], 8); if (len > 2) blue.copyFrom(maps[2], 8); if (copyAlpha && (len > 3)) alpha.copyFrom(maps[3], 8); } finally { endUpdate(); } }
/** * Copy data from specified source colormap. * * @param copyAlpha Also copy the alpha information. */ public void copyFrom(IcyColorMap srcColorMap, boolean copyAlpha) { beginUpdate(); try { // copy colormap band red.copyFrom(srcColorMap.red); green.copyFrom(srcColorMap.green); blue.copyFrom(srcColorMap.blue); gray.copyFrom(srcColorMap.gray); if (copyAlpha) alpha.copyFrom(srcColorMap.alpha); // copy type setType(srcColorMap.type); } finally { endUpdate(); } }
@Override public boolean loadFromXML(Node node) { if (node == null) return false; beginUpdate(); try { setName(XMLUtil.getElementValue(node, ID_NAME, "")); setEnabled(XMLUtil.getElementBooleanValue(node, ID_ENABLED, true)); setType(IcyColorMapType.valueOf(XMLUtil.getElementValue(node, ID_TYPE, ""))); boolean result = true; result = result && red.loadFromXML(XMLUtil.getElement(node, ID_RED)); result = result && green.loadFromXML(XMLUtil.getElement(node, ID_GREEN)); result = result && blue.loadFromXML(XMLUtil.getElement(node, ID_BLUE)); result = result && gray.loadFromXML(XMLUtil.getElement(node, ID_GRAY)); result = result && alpha.loadFromXML(XMLUtil.getElement(node, ID_ALPHA)); return result; } finally { endUpdate(); } }