com.aspose.words

Class HorizontalRuleFormat

  • java.lang.Object
    • com.aspose.words.HorizontalRuleFormat
public class HorizontalRuleFormat 
extends java.lang.Object

Represents horizontal rule formatting.

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());

Property Getters/Setters Summary
intgetAlignment()
void
setAlignment(intvalue)
           Gets or sets the alignment of the horizontal rule. The value of the property is HorizontalRuleAlignment integer constant.
java.awt.ColorgetColor()
void
setColor(java.awt.Colorvalue)
           Gets or sets the brush color that fills the horizontal rule.
doublegetHeight()
void
setHeight(doublevalue)
           Gets or sets the height of the horizontal rule.
booleangetNoShade()
void
setNoShade(booleanvalue)
           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.
doublegetWidthPercent()
void
setWidthPercent(doublevalue)
           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)
        
        Gets or sets the alignment of the horizontal rule. The value of the property is HorizontalRuleAlignment integer constant.

        The default value is HorizontalRuleAlignment.LEFT.

        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)
        
        Gets or sets the brush color that fills the horizontal rule.

        This is a shortcut to the Fill.Color property.

        The default value is java.awt.Color.GRAY.

        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)
        
        Gets or sets the height of the horizontal rule.

        This is a shortcut to the ShapeBase.Height property.

        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)
        
        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.

        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)
        
        Gets or sets the length of the specified horizontal rule expressed as a percentage of the window width.

        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());