public ColorPaletteDef createDeepCopy() { return (ColorPaletteDef) clone(); }
/** * Creates and returns a copy of this object. * * @return a copy of this object */ @Override public final ImageInfo clone() { try { ImageInfo imageInfo = (ImageInfo) super.clone(); if (colorPaletteDef != null) { imageInfo.colorPaletteDef = (ColorPaletteDef) colorPaletteDef.clone(); } if (rgbChannelDef != null) { imageInfo.rgbChannelDef = (RGBChannelDef) rgbChannelDef.clone(); } return imageInfo; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
@Test public void testCreateClone_andEquals() { //preparation final Point[] points = { new Point(1, Color.black), new Point(2, Color.red), new Point(3, Color.green), new Point(4, Color.blue), new Point(5, Color.white), }; final ColorPaletteDef cpd = new ColorPaletteDef(points, 256); cpd.setDiscrete(true); cpd.setAutoDistribute(true); //execution final ColorPaletteDef clone = (ColorPaletteDef) cpd.clone(); //verification assertTrue(cpd.equals(clone)); }