Friday, December 27, 2024
Google search engine
HomeLanguagesJavaBidi createLineBidi() method in Java with Examples

Bidi createLineBidi() method in Java with Examples

The createLineBidi() method of java.text.Bidi class is used to create a new bidi object having same base direction and representing every property of current bidi within the range.

Syntax:

public Bidi createLineBidi(int lineStart,
                           int lineLimit)

Parameter: This method takes following argument as parameter

  • lineStart: it is the start point of this new bidi
  • lineLimit: it is the end point for this new bidi

Return Value: This method return a new Bidi object

Below are the examples to illustrate the createLineBidi() method:

Example 1:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi(
                "Geeks For Geeks",
                Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(1, 6);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 5
number of levels : 2
Base Level : 1

Example 2:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi("Tajmahal",
                       Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(3, 5);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 2
number of levels : 1
Base Level : 2

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#createLineBidi-int-int-

RELATED ARTICLES

Most Popular

Recent Comments