java.lang.ObjectInternableComplexAttr
com.aspose.words.Shading
public class Shading
Example: Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set paragraph borders
BorderCollection borders = builder.getParagraphFormat().getBorders();
borders.setDistanceFromText(20);
borders.getByBorderType(BorderType.LEFT).setLineStyle(LineStyle.DOUBLE);
borders.getByBorderType(BorderType.RIGHT).setLineStyle(LineStyle.DOUBLE);
borders.getByBorderType(BorderType.TOP).setLineStyle(LineStyle.DOUBLE);
borders.getByBorderType(BorderType.BOTTOM).setLineStyle(LineStyle.DOUBLE);
// Set paragraph shading
Shading shading = builder.getParagraphFormat().getShading();
shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS);
shading.setBackgroundPatternColor(new Color(240, 128, 128)); // Light Coral
shading.setForegroundPatternColor(new Color(255, 160, 122)); // Light Salmon
builder.write("I'm a formatted paragraph with double border and nice shading.");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
builder.insertCell();
// Set the borders for the entire table
table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
// Set the cell shading for this cell
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
builder.writeln("Cell #1");
builder.insertCell();
// Specify a different cell shading for the second cell
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
builder.writeln("Cell #2");
// End this row
builder.endRow();
// Clear the cell formatting from previous operations
builder.getCellFormat().clearFormatting();
// Create the second row
builder.insertCell();
// Create larger borders for the first cell of this row. This will be different
// compared to the borders set for the table
builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0);
builder.getCellFormat().getBorders().getRight().setLineWidth(4.0);
builder.getCellFormat().getBorders().getTop().setLineWidth(4.0);
builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0);
builder.writeln("Cell #3");
builder.insertCell();
// Clear the cell formatting from the previous cell
builder.getCellFormat().clearFormatting();
builder.writeln("Cell #4");
doc.save(getArtifactsDir() + "DocumentBuilder.TableBordersAndShading.doc");
Property Getters/Setters Summary | ||
---|---|---|
java.awt.Color | getBackgroundPatternColor() | |
void | setBackgroundPatternColor(java.awt.Color value) | |
Gets or sets the color that's applied to the background of the Shading object. | ||
java.awt.Color | getForegroundPatternColor() | |
void | setForegroundPatternColor(java.awt.Color value) | |
Gets or sets the color that's applied to the foreground of the Shading object. | ||
int | getTexture() | |
void | setTexture(int value) | |
Gets or sets the shading texture. The value of the property is TextureIndex integer constant. |
Method Summary | ||
---|---|---|
void | clearFormatting() | |
Removes shading from the object. | ||
boolean | equals(Shading rhs) | |
Determines whether the specified Shading is equal in value to the current Shading. | ||
boolean | equals(java.lang.Object obj) | |
Determines whether the specified object is equal in value to the current object. | ||
int | hashCode() | |
Serves as a hash function for this type. |
Property Getters/Setters Detail |
---|
getBackgroundPatternColor/setBackgroundPatternColor | |
public java.awt.Color getBackgroundPatternColor() / public void setBackgroundPatternColor(java.awt.Color value) |
Example:
Shows how to apply borders and shading to a paragraph.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set paragraph borders BorderCollection borders = builder.getParagraphFormat().getBorders(); borders.setDistanceFromText(20); borders.getByBorderType(BorderType.LEFT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.RIGHT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.TOP).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.BOTTOM).setLineStyle(LineStyle.DOUBLE); // Set paragraph shading Shading shading = builder.getParagraphFormat().getShading(); shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS); shading.setBackgroundPatternColor(new Color(240, 128, 128)); // Light Coral shading.setForegroundPatternColor(new Color(255, 160, 122)); // Light Salmon builder.write("I'm a formatted paragraph with double border and nice shading.");
getForegroundPatternColor/setForegroundPatternColor | |
public java.awt.Color getForegroundPatternColor() / public void setForegroundPatternColor(java.awt.Color value) |
Example:
Shows how to apply borders and shading to a paragraph.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set paragraph borders BorderCollection borders = builder.getParagraphFormat().getBorders(); borders.setDistanceFromText(20); borders.getByBorderType(BorderType.LEFT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.RIGHT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.TOP).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.BOTTOM).setLineStyle(LineStyle.DOUBLE); // Set paragraph shading Shading shading = builder.getParagraphFormat().getShading(); shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS); shading.setBackgroundPatternColor(new Color(240, 128, 128)); // Light Coral shading.setForegroundPatternColor(new Color(255, 160, 122)); // Light Salmon builder.write("I'm a formatted paragraph with double border and nice shading.");
getTexture/setTexture | |
public int getTexture() / public void setTexture(int value) |
Example:
Shows how to apply borders and shading to a paragraph.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set paragraph borders BorderCollection borders = builder.getParagraphFormat().getBorders(); borders.setDistanceFromText(20); borders.getByBorderType(BorderType.LEFT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.RIGHT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.TOP).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.BOTTOM).setLineStyle(LineStyle.DOUBLE); // Set paragraph shading Shading shading = builder.getParagraphFormat().getShading(); shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS); shading.setBackgroundPatternColor(new Color(240, 128, 128)); // Light Coral shading.setForegroundPatternColor(new Color(255, 160, 122)); // Light Salmon builder.write("I'm a formatted paragraph with double border and nice shading.");
Method Detail |
---|
clearFormatting | |
public void clearFormatting() |
Example:
Shows how to build a nice bordered table.DocumentBuilder builder = new DocumentBuilder(); // Start building a table builder.startTable(); // Set the appropriate paragraph, cell, and row formatting. The formatting properties are preserved // until they are explicitly modified so there's no need to set them for each row or cell builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER); builder.getCellFormat().clearFormatting(); builder.getCellFormat().setWidth(150.0); builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER); builder.getCellFormat().getShading().setBackgroundPatternColor(new Color(173, 255, 47)); //"green-yellow" builder.getCellFormat().setWrapText(false); builder.getCellFormat().setFitText(true); builder.getRowFormat().clearFormatting(); builder.getRowFormat().setHeightRule(HeightRule.EXACTLY); builder.getRowFormat().setHeight(50.0); builder.getRowFormat().getBorders().setLineStyle(LineStyle.ENGRAVE_3_D); builder.getRowFormat().getBorders().setColor(new Color(255, 165, 0)); // "orange" builder.insertCell(); builder.write("Row 1, Col 1"); builder.insertCell(); builder.write("Row 1, Col 2"); builder.endRow(); // Remove the shading (clear background) builder.getCellFormat().getShading().clearFormatting(); builder.insertCell(); builder.write("Row 2, Col 1"); builder.insertCell(); builder.write("Row 2, Col 2"); builder.endRow(); builder.insertCell(); // Make the row height bigger so that a vertically oriented text could fit into cells builder.getRowFormat().setHeight(150.0); builder.getCellFormat().setOrientation(TextOrientation.UPWARD); builder.write("Row 3, Col 1"); builder.insertCell(); builder.getCellFormat().setOrientation(TextOrientation.DOWNWARD); builder.write("Row 3, Col 2"); builder.endRow(); builder.endTable(); builder.getDocument().save(getArtifactsDir() + "DocumentBuilder.InsertTable.docx");
equals | |
public boolean equals(Shading rhs) |
equals | |
public boolean equals(java.lang.Object obj) |
hashCode | |
public int hashCode() |