public class XMLSyntax {

	public String ScalableColorXML(HistogramSet hs, int numOfCoeff, int bitDiscarded) {
		int hue=256,sat=256,val=256;
		String s;
		s="<Description xsi:type=\"ScalableColorType\" NumberOfCoefficients=\""+numOfCoeff+
		"\" NumberofBitplanesDiscarded=\""+bitDiscarded+"\">\n"+
		"<Coeff>";
		switch (numOfCoeff) {
		case 256: hue=16;sat=4;val=4; break;
		case 128: hue=8;sat=4;val=4; break;
		case 64: hue=8;sat=2;val=4; break;
		case 32: hue=8;sat=2;val=2; break;
		case 16: hue=4;sat=2;val=2; break;
		}		
		for (int i=0;i<hue;i++) {

				s+=String.valueOf((int) hs.get(0).getValue(i));
				s+=" ";				
		}
		for (int i=0;i<sat;i++) {
				s+=String.valueOf((int) hs.get(1).getValue(i));
				s+=" ";
		}
		for (int i=0;i<val;i++) {
				s+=String.valueOf((int) hs.get(2).getValue(i));
				s+=" ";
		}
		s+="</Coeff>";
		s+="\n</Description>";
		return s;
	}
	
	public String DominantColorXML(VectorSet vs, int dcolors, int method) {
		String s;
		s="<Description xsi:type=\"DominantColorType\" NumberOfColors=\""+dcolors;
		if (method==DominantColor.ALTERNATIVE) {
			s+="\" Method=\"Alternative\"";
		}
		s+="\">\n"+
		"<Values>\n";
		for (int i=0;i<dcolors;i++) {
			s+="<ColorValueIndex>";
			for (int j=0;j<vs.getVector(i).getLength();j++) {
				s+=String.valueOf((int)vs.getVector(i).get(j));
				s+=" ";
			}
			s+="</ColorValueIndex>\n";
		}
		s+="</Values>";
		s+="\n</Description>";
		return s;
	}
}
