FileDocCategorySizeDatePackage
ColorSchemeAtom.javaAPI DocApache Poi 3.0.17756Mon Jan 01 18:55:34 GMT 2007org.apache.poi.hslf.record

ColorSchemeAtom

public class ColorSchemeAtom extends RecordAtom
A ColorSchemeAtom (type 2032). Holds the 8 RGB values for the different colours of bits of text, that makes up a given colour scheme. Slides (presumably) link to a given colour scheme atom, and that defines the colours to be used
author
Nick Burch

Fields Summary
private byte[]
_header
private static long
_type
private int
backgroundColourRGB
private int
textAndLinesColourRGB
private int
shadowsColourRGB
private int
titleTextColourRGB
private int
fillsColourRGB
private int
accentColourRGB
private int
accentAndHyperlinkColourRGB
private int
accentAndFollowingHyperlinkColourRGB
Constructors Summary
protected ColorSchemeAtom(byte[] source, int start, int len)
For the Colour Scheme (ColorSchem) Atom

		// Sanity Checking - we're always 40 bytes long
		if(len < 40) {
			len = 40;
			if(source.length - start < 40) {
				throw new RuntimeException("Not enough data to form a ColorSchemeAtom (always 40 bytes long) - found " + (source.length - start));
			}
		}

		// Get the header
		_header = new byte[8];
		System.arraycopy(source,start,_header,0,8);

		// Grab the rgb values
		backgroundColourRGB = (int)LittleEndian.getInt(source,start+8+0);
		textAndLinesColourRGB = (int)LittleEndian.getInt(source,start+8+4);
		shadowsColourRGB = (int)LittleEndian.getInt(source,start+8+8);
		titleTextColourRGB = (int)LittleEndian.getInt(source,start+8+12);
		fillsColourRGB = (int)LittleEndian.getInt(source,start+8+16);
		accentColourRGB = (int)LittleEndian.getInt(source,start+8+20);
		accentAndHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+24);
		accentAndFollowingHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+28);
	
public ColorSchemeAtom()
Create a new ColorSchemeAtom, to go with a new Slide

		_header = new byte[8];
		LittleEndian.putUShort(_header, 0, 16);
		LittleEndian.putUShort(_header, 2, (int)_type);
		LittleEndian.putInt(_header, 4, 32);
		 
		// Setup the default rgb values
		backgroundColourRGB = 16777215;
		textAndLinesColourRGB = 0;
		shadowsColourRGB = 8421504;
		titleTextColourRGB = 0;
		fillsColourRGB = 10079232;
		accentColourRGB = 13382451;
		accentAndHyperlinkColourRGB = 16764108;
		accentAndFollowingHyperlinkColourRGB = 11711154;
	
Methods Summary
public intgetAccentAndFollowingHyperlinkColourRGB()
Fetch the RGB value for Accent And Following Hyperlink Colour

 return accentAndFollowingHyperlinkColourRGB; 
public intgetAccentAndHyperlinkColourRGB()
Fetch the RGB value for Accent And Hyperlink Colour

 return accentAndHyperlinkColourRGB; 
public intgetAccentColourRGB()
Fetch the RGB value for Accent Colour

 return accentColourRGB; 
public intgetBackgroundColourRGB()
Fetch the RGB value for Background Colour


	        
	    return backgroundColourRGB; 
public intgetColor(int idx)
Returns color by its index

param
idx 0-based color index
return
color by its index

        int[] clr = {backgroundColourRGB, textAndLinesColourRGB, shadowsColourRGB, titleTextColourRGB,
            fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB};
        return clr[idx];
    
public intgetFillsColourRGB()
Fetch the RGB value for Fills Colour

 return fillsColourRGB; 
public longgetRecordType()
We are of type 3999

 return _type; 
public intgetShadowsColourRGB()
Fetch the RGB value for Shadows Colour

 return shadowsColourRGB; 
public intgetTextAndLinesColourRGB()
Fetch the RGB value for Text And Lines Colour

 return textAndLinesColourRGB; 
public intgetTitleTextColourRGB()
Fetch the RGB value for Title Text Colour

 return titleTextColourRGB; 
public static intjoinRGB(byte r, byte g, byte b)
Convert from split R, G, B values to an integer RGB value

		return joinRGB(new byte[] { r,g,b });
	
public static intjoinRGB(byte[] rgb)
Convert from split R, G, B values to an integer RGB value

		if(rgb.length != 3) {
			throw new RuntimeException("joinRGB accepts a byte array of 3 values, but got one of " + rgb.length + " values!");
		}
		byte[] with_zero = new byte[4];
		System.arraycopy(rgb,0,with_zero,0,3);
		with_zero[3] = 0;
		int ret = (int)LittleEndian.getInt(with_zero,0);
		return ret;
	
public voidsetAccentAndFollowingHyperlinkColourRGB(int rgb)
Set the RGB value for Accent And Following Hyperlink Colour

 accentAndFollowingHyperlinkColourRGB = rgb; 
public voidsetAccentAndHyperlinkColourRGB(int rgb)
Set the RGB value for Accent And Hyperlink Colour

 accentAndHyperlinkColourRGB = rgb; 
public voidsetAccentColourRGB(int rgb)
Set the RGB value for Accent Colour

 accentColourRGB = rgb; 
public voidsetBackgroundColourRGB(int rgb)
Set the RGB value for Background Colour

 backgroundColourRGB = rgb; 
public voidsetFillsColourRGB(int rgb)
Set the RGB value for Fills Colour

 fillsColourRGB = rgb; 
public voidsetShadowsColourRGB(int rgb)
Set the RGB value for Shadows Colour

 shadowsColourRGB = rgb; 
public voidsetTextAndLinesColourRGB(int rgb)
Set the RGB value for Text And Lines Colour

 textAndLinesColourRGB = rgb; 
public voidsetTitleTextColourRGB(int rgb)
Set the RGB value for Title Text Colour

 titleTextColourRGB = rgb; 
public static byte[]splitRGB(int rgb)
Convert from an integer RGB value to individual R, G, B 0-255 values

		byte[] ret = new byte[3];

		// Serialise to bytes, then grab the right ones out
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			writeLittleEndian(rgb,baos);
		} catch(IOException ie) {
			// Should never happen
			throw new RuntimeException(ie);
		}
		byte[] b = baos.toByteArray();
		System.arraycopy(b,0,ret,0,3);

		return ret;
	
public voidwriteOut(java.io.OutputStream out)
Write the contents of the record back, so it can be written to disk

		// Header - size or type unchanged
		out.write(_header);

		// Write out the rgb values
		writeLittleEndian(backgroundColourRGB,out);
		writeLittleEndian(textAndLinesColourRGB,out);
		writeLittleEndian(shadowsColourRGB,out);
		writeLittleEndian(titleTextColourRGB,out);
		writeLittleEndian(fillsColourRGB,out);
		writeLittleEndian(accentColourRGB,out);
		writeLittleEndian(accentAndHyperlinkColourRGB,out);
		writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out);