java.lang.Objectcom.aspose.words.HorizontalRuleFormat
public class HorizontalRuleFormat
Example:
// Use a document builder to insert a horizontal rule
DocumentBuilder builder = new DocumentBuilder();
Shape shape = builder.insertHorizontalRule();
HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat();
horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER);
horizontalRuleFormat.setWidthPercent(70.0);
horizontalRuleFormat.setHeight(3.0);
horizontalRuleFormat.setColor(Color.BLUE);
horizontalRuleFormat.setNoShade(true);
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
builder.getDocument().save(dstStream, SaveFormat.DOCX);
// Get the rule from the document's shape collection and verify it
Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true);
Assert.assertTrue(horizontalRule.isHorizontalRule());
Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade());
Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment());
Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent());
Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight());
Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());
Property Getters/Setters Summary | ||
---|---|---|
int | getAlignment() | |
void | setAlignment(int value) | |
Gets or sets the alignment of the horizontal rule. The value of the property is HorizontalRuleAlignment integer constant. | ||
java.awt.Color | getColor() | |
void | setColor(java.awt.Color value) | |
Gets or sets the brush color that fills the horizontal rule. | ||
double | getHeight() | |
void | setHeight(double value) | |
Gets or sets the height of the horizontal rule. | ||
boolean | getNoShade() | |
void | setNoShade(boolean value) | |
Indicates the presence of 3D shading for the horizontal rule. If true, then the horizontal rule is without 3D shading and solid color is used. | ||
double | getWidthPercent() | |
void | setWidthPercent(double value) | |
Gets or sets the length of the specified horizontal rule expressed as a percentage of the window width. |
Property Getters/Setters Detail |
---|
getAlignment/setAlignment | |
public int getAlignment() / public void setAlignment(int value) |
The default value is
Example:
Shows how to insert horizontal rule shape in a document and customize the formatting.// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat(); horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER); horizontalRuleFormat.setWidthPercent(70.0); horizontalRuleFormat.setHeight(3.0); horizontalRuleFormat.setColor(Color.BLUE); horizontalRuleFormat.setNoShade(true); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); builder.getDocument().save(dstStream, SaveFormat.DOCX); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true); Assert.assertTrue(horizontalRule.isHorizontalRule()); Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade()); Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment()); Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent()); Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight()); Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());
getColor/setColor | |
public java.awt.Color getColor() / public void setColor(java.awt.Color value) |
This is a shortcut to the
The default value is
Example:
Shows how to insert horizontal rule shape in a document and customize the formatting.// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat(); horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER); horizontalRuleFormat.setWidthPercent(70.0); horizontalRuleFormat.setHeight(3.0); horizontalRuleFormat.setColor(Color.BLUE); horizontalRuleFormat.setNoShade(true); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); builder.getDocument().save(dstStream, SaveFormat.DOCX); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true); Assert.assertTrue(horizontalRule.isHorizontalRule()); Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade()); Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment()); Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent()); Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight()); Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());
getHeight/setHeight | |
public double getHeight() / public void setHeight(double value) |
This is a shortcut to the
Valid values range from 0 to 1584 inclusive.
The default value is 1.5.
Example:
Shows how to insert horizontal rule shape in a document and customize the formatting.// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat(); horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER); horizontalRuleFormat.setWidthPercent(70.0); horizontalRuleFormat.setHeight(3.0); horizontalRuleFormat.setColor(Color.BLUE); horizontalRuleFormat.setNoShade(true); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); builder.getDocument().save(dstStream, SaveFormat.DOCX); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true); Assert.assertTrue(horizontalRule.isHorizontalRule()); Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade()); Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment()); Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent()); Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight()); Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());
getNoShade/setNoShade | |
public boolean getNoShade() / public void setNoShade(boolean value) |
The default value is false.
Example:
Shows how to insert horizontal rule shape in a document and customize the formatting.// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat(); horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER); horizontalRuleFormat.setWidthPercent(70.0); horizontalRuleFormat.setHeight(3.0); horizontalRuleFormat.setColor(Color.BLUE); horizontalRuleFormat.setNoShade(true); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); builder.getDocument().save(dstStream, SaveFormat.DOCX); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true); Assert.assertTrue(horizontalRule.isHorizontalRule()); Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade()); Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment()); Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent()); Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight()); Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());
getWidthPercent/setWidthPercent | |
public double getWidthPercent() / public void setWidthPercent(double value) |
Valid values range from 1 to 100 inclusive.
The default value is 100.
Example:
Shows how to insert horizontal rule shape in a document and customize the formatting.// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.getHorizontalRuleFormat(); horizontalRuleFormat.setAlignment(HorizontalRuleAlignment.CENTER); horizontalRuleFormat.setWidthPercent(70.0); horizontalRuleFormat.setHeight(3.0); horizontalRuleFormat.setColor(Color.BLUE); horizontalRuleFormat.setNoShade(true); ByteArrayOutputStream dstStream = new ByteArrayOutputStream(); builder.getDocument().save(dstStream, SaveFormat.DOCX); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape) builder.getDocument().getChild(NodeType.SHAPE, 0, true); Assert.assertTrue(horizontalRule.isHorizontalRule()); Assert.assertTrue(horizontalRule.getHorizontalRuleFormat().getNoShade()); Assert.assertEquals(HorizontalRuleAlignment.CENTER, horizontalRule.getHorizontalRuleFormat().getAlignment()); Assert.assertEquals(70.0, horizontalRule.getHorizontalRuleFormat().getWidthPercent()); Assert.assertEquals(3.0, horizontalRule.getHorizontalRuleFormat().getHeight()); Assert.assertEquals(Color.BLUE.getRGB(), horizontalRule.getHorizontalRuleFormat().getColor().getRGB());