Search in sources :

Example 61 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraTextInputSkin method getCaretRectangle.

private Rectangle getCaretRectangle(TextHitInfo textCaret) {
    TextInput textInput = (TextInput) getComponent();
    AttributedStringCharacterIterator composedText = textInput.getComposedText();
    Bounds selectionStartBounds = getCharacterBounds(textInput.getSelectionStart());
    return GraphicsUtilities.getCaretRectangle(textCaret, composedText, selectionStartBounds.x, padding.top + 1);
}
Also used : Bounds(org.apache.pivot.wtk.Bounds) TextInput(org.apache.pivot.wtk.TextInput) AttributedStringCharacterIterator(org.apache.pivot.text.AttributedStringCharacterIterator)

Example 62 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraPaletteSkin method paint.

@Override
public void paint(Graphics2D graphics) {
    // Call the base class to paint the background
    super.paint(graphics);
    int width = getWidth();
    int height = getHeight();
    int titleBarHeight = titleBarTablePane.getHeight();
    graphics.setStroke(new BasicStroke());
    Palette palette = (Palette) getComponent();
    boolean active = palette.getOwner().isActive();
    boolean enabled = palette.isEnabled();
    Color currentTitleBarBackgroundColor = (active && enabled) ? titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
    Color currentTitleBarBorderColor = (active && enabled) ? titleBarBorderColor : inactiveTitleBarBorderColor;
    Color titleBarBevelColor = TerraTheme.brighten(currentTitleBarBackgroundColor);
    if (!themeIsFlat()) {
        // Draw the title area
        graphics.setPaint(new GradientPaint(width / 2f, 0, titleBarBevelColor, width / 2f, titleBarHeight + 1, currentTitleBarBackgroundColor));
        graphics.fillRect(0, 0, width, titleBarHeight + 1);
        // Draw the border
        graphics.setPaint(currentTitleBarBorderColor);
        GraphicsUtilities.drawRect(graphics, 0, 0, width, titleBarHeight + 1);
        // Draw the content area
        Bounds contentAreaRectangle = new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
        graphics.setPaint(contentBorderColor);
        GraphicsUtilities.drawRect(graphics, contentAreaRectangle.x, contentAreaRectangle.y, contentAreaRectangle.width, contentAreaRectangle.height);
        graphics.setPaint(contentBevelColor);
        GraphicsUtilities.drawLine(graphics, contentAreaRectangle.x + 1, contentAreaRectangle.y + 1, contentAreaRectangle.width - 2, Orientation.HORIZONTAL);
    } else {
        // Draw the title area
        graphics.setPaint(currentTitleBarBackgroundColor);
        graphics.fillRect(0, 0, width, titleBarHeight + 1);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Palette(org.apache.pivot.wtk.Palette) Color(java.awt.Color) Bounds(org.apache.pivot.wtk.Bounds) GradientPaint(java.awt.GradientPaint) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 63 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraPaletteSkin method mouseDown.

@Override
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
    boolean consumed = super.mouseDown(component, button, x, y);
    Window window = (Window) getComponent();
    boolean maximized = window.isMaximized();
    if (button == Mouse.Button.LEFT && !maximized) {
        Bounds titleBarBounds = titleBarTablePane.getBounds();
        if (titleBarBounds.contains(x, y)) {
            dragOffset = new Point(x, y);
            Mouse.capture(component);
        } else {
            if (resizeHandle.isVisible() && x > resizeHandle.getX() && y > resizeHandle.getY()) {
                resizeOffset = new Point(getWidth() - x, getHeight() - y);
                Mouse.capture(component);
            }
        }
    }
    return consumed;
}
Also used : Window(org.apache.pivot.wtk.Window) Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point)

Example 64 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraPaletteSkin method getClientArea.

@Override
public Bounds getClientArea() {
    int width = getWidth();
    int height = getHeight();
    int titleBarHeight = titleBarTablePane.getHeight();
    return new Bounds(0, titleBarHeight + 2, width, height - (titleBarHeight + 2));
}
Also used : Bounds(org.apache.pivot.wtk.Bounds) Point(org.apache.pivot.wtk.Point) GradientPaint(java.awt.GradientPaint)

Example 65 with Bounds

use of org.apache.pivot.wtk.Bounds in project pivot by apache.

the class TerraTreeViewSkin method mouseWheel.

@Override
public boolean mouseWheel(Component component, Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y) {
    if (highlightedNode != null) {
        Bounds nodeBounds = getNodeBounds(highlightedNode);
        highlightedNode.setHighlighted(false);
        highlightedNode = null;
        if (nodeBounds != null) {
            repaintComponent(nodeBounds.x, nodeBounds.y, nodeBounds.width, nodeBounds.height, true);
        }
    }
    return super.mouseWheel(component, scrollType, scrollAmount, wheelRotation, x, y);
}
Also used : Bounds(org.apache.pivot.wtk.Bounds)

Aggregations

Bounds (org.apache.pivot.wtk.Bounds)77 Point (org.apache.pivot.wtk.Point)21 GradientPaint (java.awt.GradientPaint)15 Color (java.awt.Color)10 Graphics2D (java.awt.Graphics2D)9 Rectangle (java.awt.Rectangle)7 TableView (org.apache.pivot.wtk.TableView)7 BasicStroke (java.awt.BasicStroke)6 GeneralPath (java.awt.geom.GeneralPath)5 Button (org.apache.pivot.wtk.Button)5 Component (org.apache.pivot.wtk.Component)5 Span (org.apache.pivot.wtk.Span)5 TextArea (org.apache.pivot.wtk.TextArea)5 TextPane (org.apache.pivot.wtk.TextPane)5 FontRenderContext (java.awt.font.FontRenderContext)4 LineMetrics (java.awt.font.LineMetrics)4 Area (java.awt.geom.Area)4 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 ArrayList (org.apache.pivot.collections.ArrayList)4 ScrollPane (org.apache.pivot.wtk.ScrollPane)4