aspose.pdf
Class Color

java.lang.Object
  extended by aspose.pdf.Color

public class Color
extends java.lang.Object

Represents the colorspaces used in aspose.pdf including CmykColorSpace and GrayColorSpace.

Typical usages are the following:

[Java] Pdf pdf1 = new Pdf(); Section sec1 = pdf1.getSections().add(); Graph graph1 = new Graph(sec1,200,400); sec1.getParagraphs().add(graph1); float[] posArr = new float[]{100,0,300,0}; Line l1 = new Line(graph1,posArr); l1.getGraphInfo().setColor(new aspose.pdf.Color("Red")); graph1.getShapes().add(l1); posArr = new float[]{100,50,300,50}; Line l2 = new Line(graph1,posArr); l2.getGraphInfo().setColor(new aspose.pdf.Color((short)0,(short)128,(short)128)); graph1.getShapes().add(l2); posArr = new float[]{100,100,300,100}; Line l3 = new Line(graph1,posArr); l3.getGraphInfo().setColor(new aspose.pdf.Color((short)0,(short)128,(short)64,(short)0)); graph1.getShapes().add(l3); posArr = new float[]{100,150,300,150}; Line l4 = new Line(graph1,posArr); l4.getGraphInfo().setColor(new aspose.pdf.Color((short)140)); graph1.getShapes().add(l4); pdf1.save(...); [XML] <?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf"> <Section> <Graph Height="200" Width="400"> <Line Color="Red" Position="100 0 300 0" /> <Line Color="rgb 0 128 128" Position="100 50 300 50" /> <Line Color="cmyk 0 128 64 0" Position="100 100 300 100" /> <Line Color="gray 140" Position="100 150 300 150" /> </Graph> </Section> </Pdf>


Constructor Summary
Color()
          Constructor - initializes a new instance of the Color class.
Color(short grayValue)
          Constructor - Initializes a new instance of the Color class with GrayColorSpace.
Color(short r, short g, short b)
          Constructor - initializes a new instance of the class with the specified red, green, and blue values in the range (0 - 255).
Color(short c, short m, short y, short k)
          Constructor - initializes a new instance of the Color class with CmykColorSpace.
Color(java.lang.String colorName)
          Constructor - initializes a new instance of the Color class with RgbColorSpace from specified color name.
 
Method Summary
 java.lang.Object clone()
          Clones a new Color object.
 CmykColorSpace getCmykColorSpace()
          Gets a CmykColorSpace object that indicates the CMYK colorspace.
 ColorSpaceType getColorSpaceType()
          Gets a ColorSpaceType object that indicates the colorspace type.
 GrayColorSpace getGrayColorSpace()
          Gets a GrayColorSpace object that indicates the gray colorspace.
 java.awt.Color getRgbColorSpace()
          Gets a object that indicates the RGB colorspace.
 boolean isSame(Color color)
          A boolean value indicates whether two Color are the same.
 void setCmykColorSpace(CmykColorSpace value)
          Sets a object that indicates the CMYK colorspace.
 void setColorSpaceType(ColorSpaceType value)
          Sets a ColorSpaceType object that indicates the colorspace type.
 void setGrayColorSpace(GrayColorSpace value)
          Sets a object that indicates the gray colorspace.
 void setRgbColorSpace(java.awt.Color value)
          Sets a object that indicates the RGB colorspace.
 int toArgb()
          The ARGB color.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Color

public Color()
Constructor - initializes a new instance of the Color class.


Color

public Color(short grayValue)
Constructor - Initializes a new instance of the Color class with GrayColorSpace.

Parameters:
grayValue - Short value.

Color

public Color(short r,
             short g,
             short b)
Constructor - initializes a new instance of the class with the specified red, green, and blue values in the range (0 - 255). If the value greater than 255, still use 255 instead of it, if the value less than 0, use (value + 256) instead of it.

Parameters:
r - The red component
g - The green component
b - The blue component

Color

public Color(short c,
             short m,
             short y,
             short k)
Constructor - initializes a new instance of the Color class with CmykColorSpace.

Parameters:
c - The cyan value.
m - The magenta value.
y - The yellow value.
k - The black value.

Color

public Color(java.lang.String colorName)
Constructor - initializes a new instance of the Color class with RgbColorSpace from specified color name.

Parameters:
colorName - The color name.
Method Detail

toArgb

public int toArgb()
The ARGB color.


getColorSpaceType

public ColorSpaceType getColorSpaceType()
Gets a ColorSpaceType object that indicates the colorspace type.

Returns:
A ColorSpaceType object.

setColorSpaceType

public void setColorSpaceType(ColorSpaceType value)
Sets a ColorSpaceType object that indicates the colorspace type.

Parameters:
value - A ColorSpaceType object.

getRgbColorSpace

public java.awt.Color getRgbColorSpace()
Gets a object that indicates the RGB colorspace.

Returns:
A Color object.

setRgbColorSpace

public void setRgbColorSpace(java.awt.Color value)
Sets a object that indicates the RGB colorspace. The alpha component of the ARGB will be ignored. Note that you can use the constructor to create a color object with RGB colorspace and need not use this class directly.

Parameters:
value - A Color object.

getCmykColorSpace

public CmykColorSpace getCmykColorSpace()
Gets a CmykColorSpace object that indicates the CMYK colorspace. Note that you can use the constructor to create a color object with CMYK colorspace and need not use this class directly.

Returns:
A CmykColorSpace object.

setCmykColorSpace

public void setCmykColorSpace(CmykColorSpace value)
Sets a object that indicates the CMYK colorspace.

Parameters:
value - A CmykColorSpace object.

getGrayColorSpace

public GrayColorSpace getGrayColorSpace()
Gets a GrayColorSpace object that indicates the gray colorspace. Note that you can use the constructor to create a color object with gray colorspace and need not use this class directly.

Returns:
A GrayColorSpace object.

setGrayColorSpace

public void setGrayColorSpace(GrayColorSpace value)
Sets a object that indicates the gray colorspace.

Parameters:
value - GrayColorSpace object.

clone

public java.lang.Object clone()
Clones a new Color object.

Overrides:
clone in class java.lang.Object
Returns:
The new Color object.

isSame

public boolean isSame(Color color)
A boolean value indicates whether two Color are the same. *

Parameters:
color - The Color object to be compared.
Returns:
A boolean value.