Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Label$LabelBindingListenerList


            for (int fieldIndex = 0, fieldCount = section.getLength();
                fieldIndex < fieldCount; fieldIndex++) {
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    maximumLabelWidth = Math.max(maximumLabelWidth, label.getPreferredWidth());

                    int fieldWidth = field.getPreferredWidth();

                    if (showFlagMessagesInline) {
                        // Calculate maximum flag message width
View Full Code Here


                fieldIndex < fieldCount; fieldIndex++) {
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    // Determine the label size and baseline
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    Dimensions labelSize = label.getPreferredSize();
                    int labelAscent = label.getBaseline(labelSize.width, labelSize.height);
                    int labelDescent = labelSize.height - labelAscent;

                    // Determine the field size and baseline
                    Dimensions fieldSize;
                    if (fill && fieldWidth != -1) {
View Full Code Here

                && baseline == -1) {
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    // Determine the label size and baseline
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    Dimensions labelSize = label.getPreferredSize();
                    int labelAscent = label.getBaseline(labelSize.width, labelSize.height);

                    // Determine the field size and baseline
                    Dimensions fieldSize;
                    if (fill && fieldWidth != -1) {
                        fieldSize = new Dimensions(fieldWidth, field.getPreferredHeight(fieldWidth));
View Full Code Here

            for (int fieldIndex = 0, fieldCount = section.getLength();
                fieldIndex < fieldCount; fieldIndex++) {
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    maximumLabelWidth = Math.max(maximumLabelWidth, label.getPreferredWidth());

                    if (showFlagMessagesInline) {
                        // Calculate maximum flag message width
                        Form.Flag flag = Form.getFlag(field);
View Full Code Here

            for (int fieldIndex = 0, fieldCount = section.getLength();
                fieldIndex < fieldCount; fieldIndex++) {
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    maximumLabelWidth = Math.max(maximumLabelWidth, label.getPreferredWidth());

                    if (showFlagMessagesInline) {
                        // Calculate maximum flag message width
                        Form.Flag flag = Form.getFlag(field);

                        if (flag != null) {
                            String message = flag.getMessage();

                            if (message != null) {
                                flagMessageLabel.setText(message);
                                maximumFlagMessageWidth = Math.max(maximumFlagMessageWidth,
                                    flagMessageLabel.getPreferredWidth());
                            }
                        }
                    }
                }
            }
        }

        // Determine the field width
        int width = getWidth();
        int fieldWidth = Math.max(0, width - (maximumLabelWidth + horizontalSpacing));

        if (showFlagIcons) {
            fieldWidth = Math.max(0, fieldWidth - (maximumFlagImageWidth + flagIconOffset));
        }

        if (showFlagMessagesInline) {
            fieldWidth = Math.max(0, fieldWidth - (maximumFlagMessageWidth
                + (INLINE_FIELD_INDICATOR_WIDTH - 2)));
        }

        fieldWidth = Math.max(0, fieldWidth - (padding.left + padding.right));

        // Lay out the components
        int rowY = padding.top;

        for (int sectionIndex = 0, sectionCount = sections.getLength();
            sectionIndex < sectionCount; sectionIndex++) {
            Form.Section section = sections.get(sectionIndex);

            Separator separator = separators.get(sectionIndex);
            if (sectionIndex > 0
                || section.getHeading() != null) {
                int separatorWidth = Math.max(width - (padding.left + padding.right), 0);
                separator.setVisible(true);
                separator.setSize(separatorWidth, separator.getPreferredHeight(separatorWidth));
                separator.setLocation(padding.left, rowY);
                rowY += separator.getHeight();
            } else {
                separator.setVisible(false);
            }

            for (int fieldIndex = 0, fieldCount = section.getLength();
                fieldIndex < fieldCount; fieldIndex++) {
                Label label = labels.get(sectionIndex).get(fieldIndex);
                Component field = section.get(fieldIndex);

                if (field.isVisible()) {
                    // Show the label
                    label.setVisible(true);

                    // Determine the label size and baseline
                    Dimensions labelSize = label.getPreferredSize();
                    label.setSize(labelSize);
                    int labelAscent = label.getBaseline(labelSize.width, labelSize.height);
                    int labelDescent = labelSize.height - labelAscent;

                    // Determine the field size and baseline
                    Dimensions fieldSize;
                    if (fill) {
                        fieldSize = new Dimensions(fieldWidth, field.getPreferredHeight(fieldWidth));
                    } else {
                        fieldSize = field.getPreferredSize();
                    }

                    field.setSize(fieldSize);

                    int fieldAscent = field.getBaseline(fieldSize.width, fieldSize.height);
                    if (fieldAscent == -1) {
                        fieldAscent = labelAscent;
                    }

                    int fieldDescent = fieldSize.height - fieldAscent;

                    // Determine the baseline and row height
                    int maximumAscent = Math.max(labelAscent, fieldAscent);
                    int maximumDescent = Math.max(labelDescent, fieldDescent);

                    int baseline = maximumAscent;
                    int rowHeight = maximumAscent + maximumDescent;

                    // Position the label
                    int labelX = padding.left;
                    if (!leftAlignLabels) {
                        labelX += maximumLabelWidth - label.getWidth();
                    }

                    if (showFlagIcons) {
                        labelX += (maximumFlagImageWidth + flagIconOffset);
                    }

                    int labelY = rowY + (baseline - labelAscent);
                    label.setLocation(labelX, labelY);

                    // Position the field
                    int fieldX = padding.left + maximumLabelWidth + horizontalSpacing;
                    if (showFlagIcons) {
                        fieldX += (maximumFlagImageWidth + flagIconOffset);
                    }

                    int fieldY = rowY + (baseline - fieldAscent);
                    field.setLocation(fieldX, fieldY);

                    // Update the row y-coordinate
                    rowY += rowHeight + verticalSpacing;
                } else {
                    // Hide the label
                    label.setVisible(false);
                }
            }
        }
    }
View Full Code Here

                                    flagIcon = infoIcon;
                                    break;
                                }
                            }

                            Label label = labels.get(sectionIndex).get(fieldIndex);
                            int flagIconX = label.getX() - (flagIcon.getWidth() + flagIconOffset);
                            int flagIconY = label.getY() + (label.getHeight() - flagIcon.getHeight()) / 2;

                            graphics.translate(flagIconX, flagIconY);
                            flagIcon.paint(graphics);
                            graphics.translate(-flagIconX, -flagIconY);
                        }
View Full Code Here

    private void insertField(Form.Section section, Component field, int index) {
        Form form = (Form)getComponent();
        int sectionIndex = form.getSections().indexOf(section);

        // Create the label
        Label label = new Label();
        labels.get(sectionIndex).insert(label, index);
        form.add(label);

        // Add mouse listener
        field.getComponentMouseListeners().add(fieldMouseListener);
View Full Code Here

    private void updateFieldLabel(Form.Section section, int fieldIndex) {
        Form form = (Form)getComponent();
        Component field = section.get(fieldIndex);

        int sectionIndex = form.getSections().indexOf(section);
        Label label = labels.get(sectionIndex).get(fieldIndex);
        String labelText = Form.getLabel(field);
        label.setText((labelText == null) ? "" : labelText + delimiter);
    }
View Full Code Here

    @Override
    public void tooltipTriggered(Component componentArgument, int x, int y) {
        String tooltipText = component.getTooltipText();

        if (tooltipText != null) {
            Tooltip tooltip = new Tooltip(new Label(tooltipText));

            Display display = component.getDisplay();
            Point location = component.mapPointToAncestor(display, x, y);

            // Ensure that the tooltip stays on screen
View Full Code Here

                    }
                }
            }
        });

        Label label = new Label("x");
        label.getStyles().put("font", "{italic:true}");
        flowPane.add(label);

        flowPane = new FlowPane();
        flowPane.getStyles().put("alignToBaseline", true);
        flowPane.getStyles().put("horizontalSpacing", 5);
        boxPane.add(flowPane);

        textInput = new TextInput();
        textInput.setTextSize(3);
        textInput.setMaximumLength(4);
        textInput.setValidator(new IntValidator());
        textInput.setText(String.valueOf(point.y));
        flowPane.add(textInput);

        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
            @Override
            public void focusedChanged(Component component, Component obverseComponent) {
                if (!component.isFocused()) {
                    TextInput textInput = (TextInput)component;
                    Point point = (Point)dictionary.get(key);

                    try {
                        int y = Integer.parseInt(textInput.getText());
                        dictionary.put(key, new Point(point.x, y));
                    } catch (Exception exception) {
                        displayErrorMessage(exception, component.getWindow());
                        textInput.setText(String.valueOf(point.y));
                    }
                }
            }
        });

        label = new Label("y");
        label.getStyles().put("font", "{italic:true}");
        flowPane.add(label);

        return boxPane;
    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Label$LabelBindingListenerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.