Search in sources :

Example 6 with Box

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;
}
Also used : Box(limelight.util.Box)

Example 7 with Box

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);
}
Also used : Box(limelight.util.Box) Test(org.junit.Test)

Example 8 with Box

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));
}
Also used : MockGraphics(limelight.ui.MockGraphics) Box(limelight.util.Box) Before(org.junit.Before)

Example 9 with Box

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));
}
Also used : Box(limelight.util.Box) Test(org.junit.Test)

Example 10 with Box

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");
}
Also used : Box(limelight.util.Box) Before(org.junit.Before)

Aggregations

Box (limelight.util.Box)80 Test (org.junit.Test)31 MockGraphics (limelight.ui.MockGraphics)11 Before (org.junit.Before)6 AffineTransform (java.awt.geom.AffineTransform)5 Style (limelight.styles.Style)3 TextLocation (limelight.ui.text.TextLocation)3 TypedLayout (limelight.ui.text.TypedLayout)3 BufferedImage (java.awt.image.BufferedImage)2 Panel (limelight.ui.Panel)2 TextLayout (java.awt.font.TextLayout)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LimelightException (limelight.LimelightException)1 FlatStyle (limelight.styles.FlatStyle)1 StringValue (limelight.styles.abstrstyling.StringValue)1 AutoDimensionValue (limelight.styles.values.AutoDimensionValue)1 GreedyDimensionValue (limelight.styles.values.GreedyDimensionValue)1 BufferedImagePool (limelight.ui.BufferedImagePool)1 MockPanel (limelight.ui.MockPanel)1