/** * Stores this color palette definition in the given file * * @param colorPaletteDef thje color palette definition * @param file the file * * @throws IOException if an I/O error occurs */ public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file) throws IOException { final ColorPaletteDef.Point[] points = colorPaletteDef.getPoints(); final PropertyMap propertyMap = new PropertyMap(); final int numPoints = points.length; propertyMap.setPropertyInt(_PROPERTY_KEY_NUM_POINTS, numPoints); propertyMap.setPropertyBool(_PROPERTY_KEY_AUTODISTRIBUTE, colorPaletteDef.isAutoDistribute()); for (int i = 0; i < numPoints; i++) { propertyMap.setPropertyColor(_PROPERTY_KEY_COLOR + i, points[i].getColor()); propertyMap.setPropertyDouble(_PROPERTY_KEY_SAMPLE + i, points[i].getSample()); } propertyMap.store(file, "BEAM Colour Palette Definition File"); /*I18N*/ }
/** * Tests the functionality of set and getPropertyColor */ public void testSetGetPropertyColor() { PropertyMap prop = new PropertyMap(); // "a" is not in the set assertEquals(Color.black, prop.getPropertyColor("a")); assertEquals(null, prop.getPropertyColor("a", null)); assertEquals(Color.yellow, prop.getPropertyColor("a", Color.yellow)); // "b" is in the set and red prop.setPropertyColor("b", Color.red); assertEquals(Color.red, prop.getPropertyColor("b")); assertEquals(Color.red, prop.getPropertyColor("b", null)); assertEquals(Color.red, prop.getPropertyColor("b", Color.yellow)); }