Search in sources :

Example 11 with TablePane

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

the class TablePaneSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    TablePane tablePane = (TablePane) getComponent();
    TablePane.RowSequence rows = tablePane.getRows();
    TablePane.ColumnSequence columns = tablePane.getColumns();
    int rowCount = rows.getLength();
    int columnCount = columns.getLength();
    int[] columnWidthsLocal = getColumnWidths(width);
    int[] rowHeightsLocal = getRowHeights(height, columnWidthsLocal);
    boolean[][] occupiedCells = getOccupiedCells();
    int baseline = -1;
    int rowY = padding.top;
    for (int i = 0; i < rowCount && baseline == -1; i++) {
        TablePane.Row row = rows.get(i);
        boolean rowVisible = false;
        for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
            Component component = row.get(j);
            if (component != null && component.isVisible()) {
                int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j);
                int componentWidth = (columnSpan - 1) * horizontalSpacing;
                for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
                    componentWidth += columnWidthsLocal[j + k];
                }
                int rowSpan = Math.min(TablePane.getRowSpan(component), rowCount - i);
                int componentHeight = (rowSpan - 1) * verticalSpacing;
                for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
                    componentHeight += rowHeightsLocal[i + k];
                }
                baseline = component.getBaseline(Math.max(componentWidth, 0), Math.max(componentHeight, 0));
                if (baseline != -1) {
                    baseline += rowY;
                }
            }
            rowVisible |= occupiedCells[i][j];
        }
        if (rowVisible) {
            rowY += (rowHeightsLocal[i] + verticalSpacing);
        }
    }
    return baseline;
}
Also used : Component(org.apache.pivot.wtk.Component) TablePane(org.apache.pivot.wtk.TablePane)

Example 12 with TablePane

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

the class ColorPaletteTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    Theme theme = Theme.getTheme();
    TablePane tablePane = new TablePane();
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    new TablePane.Column(tablePane, 1, true);
    int numberOfPaletteColors = theme.getNumberOfPaletteColors();
    // ArrayList<String> colors = new ArrayList<>(numberOfPaletteColors);
    for (int i = 0; i < numberOfPaletteColors; i++) {
        TablePane.Row row = new TablePane.Row(tablePane, 1, true);
        row.add(createCell(i * 3));
        row.add(createCell(i * 3 + 1));
        row.add(createCell(i * 3 + 2));
    }
    tablePane.getStyles().put(Style.horizontalSpacing, 4);
    tablePane.getStyles().put(Style.verticalSpacing, 4);
    Border border = new Border(tablePane);
    border.getStyles().put(Style.padding, 6);
    this.window = new Window(border);
    this.window.setTitle("Color Palette");
    this.window.setMaximized(true);
    this.window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Theme(org.apache.pivot.wtk.Theme) Border(org.apache.pivot.wtk.Border) TablePane(org.apache.pivot.wtk.TablePane)

Example 13 with TablePane

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

the class SheetTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
    picture.resample(120);
    BoxPane windowContent = new BoxPane();
    PushButton button = new PushButton(picture);
    button.getStyles().put(Style.toolbar, true);
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setPreferredSize(480, 360);
    frame.getStyles().put(Style.padding, 0);
    frame.open(display);
    final TablePane tablePane = new TablePane();
    tablePane.setPreferredSize(320, 240);
    new TablePane.Column(tablePane, 1, true);
    TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
    TablePane.Row row1 = new TablePane.Row(tablePane, -1);
    final Label sheetContent = new Label("Sheet Content");
    sheetContent.getStyles().put(Style.wrapText, true);
    sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    row0.add(sheetContent);
    Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    promptBody.getStyles().put(Style.wrapText, true);
    final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
    prompt.setTitle("Prompt");
    prompt.getStyles().put(Style.resizable, true);
    prompt.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public void mouseOver(Component component) {
            System.out.println("Mouse Over");
        }

        @Override
        public void mouseOut(Component component) {
            System.out.println("Mouse out");
        }
    });
    Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    alertBody.getStyles().put(Style.wrapText, true);
    final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
    alert.setTitle("Alert");
    BoxPane boxPane = new BoxPane();
    row1.add(boxPane);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    final PushButton closeButton = new PushButton("Close");
    closeButton.getStyles().put(Style.minimumAspectRatio, 3);
    boxPane.add(closeButton);
    sheet = new Sheet(tablePane);
    closeButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            buttonArgument.getWindow().close();
        }
    });
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            prompt.open(frame);
            Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
            Window window = new Window();
            window.setTitle("New Secondary Window");
            window.setMaximized(true);
            window.setContent(new Label("I am a secondary window!"));
            window.open(displayLocal);
        }
    });
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            closeButton.requestFocus();
        }
    });
    DesktopApplicationContext.sizeHostToFit(frame);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) Label(org.apache.pivot.wtk.Label) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Picture(org.apache.pivot.wtk.media.Picture) Prompt(org.apache.pivot.wtk.Prompt) Alert(org.apache.pivot.wtk.Alert) PushButton(org.apache.pivot.wtk.PushButton) Component(org.apache.pivot.wtk.Component) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) Sheet(org.apache.pivot.wtk.Sheet) TablePane(org.apache.pivot.wtk.TablePane) Display(org.apache.pivot.wtk.Display)

Example 14 with TablePane

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

the class LabelAntialiasTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) {
    window = new Window();
    showFontDesktopHints();
    showFontFamilies();
    TablePane content = new TablePane();
    new TablePane.Column(content, 1, true);
    BoxPane topBox = new BoxPane(Orientation.HORIZONTAL);
    topBox.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    topBox.add(new Label("Rotation angle:"));
    rotationAngleSpinner = new Spinner(new NumericSpinnerData(0, 359));
    rotationAngleSpinner.setCircular(true);
    rotationAngleSpinner.setPreferredWidth(40);
    topBox.add(rotationAngleSpinner);
    TablePane.Row topRow = new TablePane.Row(content, -1);
    topRow.add(topBox);
    labelRow = new TablePane.Row(content, 1, true);
    window.setContent(content);
    window.setTitle("Label Antialiasing Test");
    window.setMaximized(true);
    rotationAngleSpinner.getSpinnerSelectionListeners().add(new SpinnerSelectionListener() {

        @Override
        public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
            currentRotationAngle = (Integer) spinner.getSelectedItem();
            if (labelRow.getLength() > 0) {
                labelRow.remove(0, labelRow.getLength());
            }
            labelRow.add(buildLabel(currentRotationAngle));
        }
    });
    rotationAngleSpinner.setSelectedItem(45);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Spinner(org.apache.pivot.wtk.Spinner) SpinnerSelectionListener(org.apache.pivot.wtk.SpinnerSelectionListener) Label(org.apache.pivot.wtk.Label) NumericSpinnerData(org.apache.pivot.wtk.content.NumericSpinnerData) BoxPane(org.apache.pivot.wtk.BoxPane) TablePane(org.apache.pivot.wtk.TablePane)

Example 15 with TablePane

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

the class TablePaneSkin method rowHighlightedChanged.

@Override
public void rowHighlightedChanged(TablePane.Row row) {
    TablePane tablePane = row.getTablePane();
    repaintComponent(getRowBounds(tablePane.getRows().indexOf(row)));
}
Also used : TablePane(org.apache.pivot.wtk.TablePane)

Aggregations

TablePane (org.apache.pivot.wtk.TablePane)19 Component (org.apache.pivot.wtk.Component)12 Label (org.apache.pivot.wtk.Label)4 Window (org.apache.pivot.wtk.Window)4 BoxPane (org.apache.pivot.wtk.BoxPane)3 PushButton (org.apache.pivot.wtk.PushButton)3 Button (org.apache.pivot.wtk.Button)2 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)2 ImageView (org.apache.pivot.wtk.ImageView)2 Spinner (org.apache.pivot.wtk.Spinner)2 SVGElementException (com.kitfox.svg.SVGElementException)1 SVGException (com.kitfox.svg.SVGException)1 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1 Area (java.awt.geom.Area)1 Rectangle2D (java.awt.geom.Rectangle2D)1 URL (java.net.URL)1 BeanAdapter (org.apache.pivot.beans.BeanAdapter)1 DefaultProperty (org.apache.pivot.beans.DefaultProperty)1 Sequence (org.apache.pivot.collections.Sequence)1