use of limelight.util.Box in project limelight by slagyr.
the class TextPanel method paintOn.
public void paintOn(Graphics2D graphics) {
graphics.setColor(getStyle().getCompiledTextColor().getColor());
float y = 0;
if (lines == null)
return;
synchronized (this) {
for (TextLayout textLayout : lines) {
y += textLayout.getAscent();
int x = getStyle().getCompiledHorizontalAlignment().getX((int) widthOf(textLayout), new Box(0, 0, getWidth(), getHeight()));
textLayout.draw(graphics, x, y);
y += textLayout.getDescent() + textLayout.getLeading();
}
}
}
use of limelight.util.Box in project limelight by slagyr.
the class MultiLineTextModel method getCaretShape.
@Override
public Box getCaretShape() {
TextLocation caretLocation = getCaretLocation();
TypedLayout line = getLines().get(caretLocation.line);
Box caretShape = line.getCaretShape(caretLocation.index);
caretShape.translate(getXOffset(line), getY(caretLocation));
return caretShape;
}
use of limelight.util.Box in project limelight by slagyr.
the class MultiLineTextModel method getSelectionRegions.
@Override
public ArrayList<Box> getSelectionRegions() {
ArrayList<Box> regions = new ArrayList<Box>();
boolean startsAtCaret = getCaretLocation().before(getSelectionLocation());
TextLocation start = startsAtCaret ? getCaretLocation() : getSelectionLocation();
TextLocation end = startsAtCaret ? getSelectionLocation() : getCaretLocation();
ArrayList<TypedLayout> lines = getLines();
int y = getY(start);
for (int i = start.line; i <= end.line; i++) {
TypedLayout line = lines.get(i);
int startX = i == start.line ? line.getX(start.index) + getXOffset(line) : 0;
int endX = i == end.line ? line.getX(end.index) + getXOffset(line) : getContainer().getWidth();
regions.add(new Box(startX, y, endX - startX, line.getHeight()));
y += line.getHeight() + line.getLeading();
}
return regions;
}
use of limelight.util.Box in project limelight by slagyr.
the class TextModel method recalculateOffset.
public void recalculateOffset(XOffsetStrategy xOffsetStrategy, YOffsetStrategy yOffsetStrategy) {
Box boundingBox = getContainer().getConsumableBounds();
Dimension textDimensions = getTextDimensions();
int xOffset, yOffset;
if (textDimensions.width < boundingBox.width)
xOffset = getHorizontalAlignment().getX(textDimensions.width, boundingBox);
else
xOffset = xOffsetStrategy.calculateXOffset(this);
if (textDimensions.height < boundingBox.height)
yOffset = getVerticalAlignment().getY(textDimensions.height, boundingBox);
else
yOffset = yOffsetStrategy.calculateYOffset(this);
setOffset(xOffset, yOffset);
}
use of limelight.util.Box in project limelight by slagyr.
the class ScrollMouseProcessor method mousePressed.
public void mousePressed(MousePressedEvent e) {
sliderDragOn = false;
unitIncrementOn = false;
blockIncrementOn = false;
mouseLocation = e.getLocation();
if (scrollBar.getIncreasingButtonBounds().contains(mouseLocation))
initiateUnitIncrement(scrollBar.getUnitIncrement());
else if (scrollBar.getDecreasingButtonBounds().contains(mouseLocation))
initiateUnitIncrement(-scrollBar.getUnitIncrement());
else if (scrollBar.getTrackBounds().contains(mouseLocation)) {
Box sliderBounds = scrollBar.getSliderBounds();
if (isAfterSlider(mouseLocation, sliderBounds))
initiateBlockIncrement(scrollBar.getBlockIncrement());
else if (isBeforeSlider(mouseLocation, sliderBounds))
initiateBlockIncrement(-scrollBar.getBlockIncrement());
else if (scrollBar.getSliderBounds().contains(mouseLocation)) {
sliderDragOn = true;
sliderDragDelta = (int) (scrollBar.isHorizontal() ? mouseLocation.getX() - scrollBar.getSliderPosition() : mouseLocation.getY() - scrollBar.getSliderPosition());
}
}
}
Aggregations