use of limelight.util.Box in project limelight by slagyr.
the class FittingXOffsetStrategy method calculateXOffset.
public int calculateXOffset(limelight.ui.model.text.TextModel model) {
int xOffset = model.getXOffset();
Box boundingBox = model.getContainer().getConsumableBounds();
int absoluteCaretX = model.getAbsoluteX(model.getCaretLocation());
int relativeCaretX = absoluteCaretX + xOffset;
if (relativeCaretX >= boundingBox.width)
xOffset = (absoluteCaretX - boundingBox.width + model.getCaretWidth()) * -1;
else if (relativeCaretX < 0)
xOffset = absoluteCaretX * -1;
return xOffset;
}
use of limelight.util.Box in project limelight by slagyr.
the class TextPanelCaretPainterTest method willPaintTheCaretAtTheCaretX.
@Test
public void willPaintTheCaretAtTheCaretX() {
model.setCaretOn(true);
painter.paint(graphics, model);
assertEquals(new Box(40, 0, 1, 10), graphics.filledShapes.get(0).shape);
}
use of limelight.util.Box in project limelight by slagyr.
the class TextPanelSelectionPainterTest method setUp.
@Before
public void setUp() {
assumeTrue(TestUtil.notHeadless());
container = new limelight.ui.model.text.MockTextContainer();
container.bounds = new Box(0, 0, 150, 28);
model = new limelight.ui.model.text.MultiLineTextModel(container);
model.setTypedLayoutFactory(MockTypedLayoutFactory.instance);
model.setText("Some Text");
model.setCaretLocation(TextLocation.at(0, 4));
graphics = new MockGraphics();
container.cursorOn = true;
painter = TextPanelSelectionPainter.instance;
model.startSelection(TextLocation.at(0, 6));
}
use of limelight.util.Box in project limelight by slagyr.
the class MultiLineTextModelTest method shouldSelectionRegionsWithCenteredText.
@Test
public void shouldSelectionRegionsWithCenteredText() throws Exception {
container.getStyle().setHorizontalAlignment("center");
model.setText("1 line\nand\nanother line\n.");
model.startSelection(TextLocation.origin);
ArrayList<Box> regions = model.getSelectionRegions();
assertEquals(new Box(45, 0, 105, 10), regions.get(0));
assertEquals(new Box(0, 11, 150, 10), regions.get(1));
assertEquals(new Box(0, 22, 150, 10), regions.get(2));
assertEquals(new Box(0, 33, 80, 10), regions.get(3));
}
use of limelight.util.Box in project limelight by slagyr.
the class MultiLineTextModelTest method setUp.
@Before
public void setUp() {
assumeTrue(TestUtil.notHeadless());
container = new limelight.ui.model.text.MockTextContainer();
container.bounds = new Box(0, 0, 150, 75);
model = new MultiLineTextModel(container);
model.setTypedLayoutFactory(MockTypedLayoutFactory.instance);
model.setText("I took the one less traveled by. And that has made all the difference");
}
Aggregations