Search in sources :

Example 1 with Position

use of org.fxmisc.richtext.model.TwoDimensional.Position in project RichTextFX by FXMisc.

the class TwoLevelNavigatorTest method testNegativeOffsetWithBackwardBias.

@Test
public void testNegativeOffsetWithBackwardBias() {
    Position pos = navigator.position(4, 10);
    pos = pos.offsetBy(-10, Backward);
    assertEquals(3, pos.getMajor());
    assertEquals(10, pos.getMinor());
}
Also used : Position(org.fxmisc.richtext.model.TwoDimensional.Position) Test(org.junit.Test)

Example 2 with Position

use of org.fxmisc.richtext.model.TwoDimensional.Position in project RichTextFX by FXMisc.

the class TwoLevelNavigatorTest method testPositiveOffsetWithForwardBias.

@Test
public void testPositiveOffsetWithForwardBias() {
    Position pos = navigator.offsetToPosition(10, Forward);
    assertEquals(1, pos.getMajor());
    assertEquals(0, pos.getMinor());
}
Also used : Position(org.fxmisc.richtext.model.TwoDimensional.Position) Test(org.junit.Test)

Example 3 with Position

use of org.fxmisc.richtext.model.TwoDimensional.Position in project RichTextFX by FXMisc.

the class TwoLevelNavigatorTest method testRightBoundary.

@Test
public void testRightBoundary() {
    Position pos = navigator.offsetToPosition(100, Forward);
    assertEquals(4, pos.getMajor());
    assertEquals(60, pos.getMinor());
    pos = pos.clamp();
    assertEquals(4, pos.getMajor());
    assertEquals(9, pos.getMinor());
}
Also used : Position(org.fxmisc.richtext.model.TwoDimensional.Position) Test(org.junit.Test)

Example 4 with Position

use of org.fxmisc.richtext.model.TwoDimensional.Position in project RichTextFX by FXMisc.

the class TwoLevelNavigatorTest method testNegativeOffsetWithForwardBias.

@Test
public void testNegativeOffsetWithForwardBias() {
    Position pos = navigator.position(4, 10);
    pos = pos.offsetBy(-10, Forward);
    assertEquals(4, pos.getMajor());
    assertEquals(0, pos.getMinor());
}
Also used : Position(org.fxmisc.richtext.model.TwoDimensional.Position) Test(org.junit.Test)

Example 5 with Position

use of org.fxmisc.richtext.model.TwoDimensional.Position in project RichTextFX by FXMisc.

the class TwoLevelNavigatorTest method testZeroOffsetWithForwardBias.

@Test
public void testZeroOffsetWithForwardBias() {
    Position pos = navigator.position(2, 10);
    pos = pos.offsetBy(0, Forward);
    assertEquals(3, pos.getMajor());
    assertEquals(0, pos.getMinor());
    // additional zero forward offset should have no effect
    assertEquals(pos, pos.offsetBy(0, Forward));
}
Also used : Position(org.fxmisc.richtext.model.TwoDimensional.Position) Test(org.junit.Test)

Aggregations

Position (org.fxmisc.richtext.model.TwoDimensional.Position)11 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)1 IndexRange (javafx.scene.control.IndexRange)1