Package pivot.wtk

Examples of pivot.wtk.Label$LabelListenerList


    }

    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        Label label = (Label)getComponent();
        String text = label.getText();

        if (text == null) {
            text = "";
        }
View Full Code Here


    public Dimensions getPreferredSize() {
        int preferredWidth = 0;
        int preferredHeight = 0;

        Label label = (Label)getComponent();
        String text = label.getText();

        if (text != null
            && text.length() > 0) {
            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
            preferredWidth = (int)Math.ceil(stringBounds.getWidth());
View Full Code Here

    public void paint(Graphics2D graphics) {
        int width = getWidth();
        int height = getHeight();

        Label label = (Label)getComponent();
        String text = label.getText();

        if (text != null
            && text.length() > 0) {
            if (fontRenderContext.isAntiAliased()) {
                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
View Full Code Here

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

                if (field.isDisplayable()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    maximumLabelWidth = Math.max(maximumLabelWidth,
                        label.getPreferredWidth(-1));
                    maximumFieldWidth = Math.max(maximumFieldWidth,
                        field.getPreferredWidth(-1));
                }
            }
        }
View Full Code Here

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

                    if (field.isDisplayable()) {
                        Label label = labels.get(sectionIndex).get(fieldIndex);
                        maximumLabelWidth = Math.max(maximumLabelWidth,
                            label.getPreferredWidth(-1));
                    }
                }
            }

            fieldWidth = Math.max(0, width - (maximumLabelWidth
                + horizontalSpacing + flagImageOffset + FLAG_IMAGE_SIZE));
        }

        // Preferred height is the sum of the maximum value of the label,
        // field, and flag image for each row, plus vertical spacing and
        // preferred separator heights
        for (int sectionIndex = 0, sectionCount = sections.getLength();
            sectionIndex < sectionCount; sectionIndex++) {
            Form.Section section = sections.get(sectionIndex);

            if (showFirstSectionHeading
                || sectionIndex > 0) {
                Separator separator = separators.get(sectionIndex);
                preferredHeight += separator.getPreferredHeight(width);
                preferredHeight += verticalSpacing;
            }

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

                if (field.isDisplayable()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);

                    int preferredRowHeight = Math.max(label.getPreferredHeight(-1),
                        Math.max(field.getPreferredHeight(fieldWidth), FLAG_IMAGE_SIZE));
                    preferredHeight += preferredRowHeight;

                    if (fieldIndex > 0) {
                        preferredHeight += verticalSpacing;
View Full Code Here

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

                if (field.isDisplayable()) {
                    Label label = labels.get(sectionIndex).get(fieldIndex);
                    maximumLabelWidth = Math.max(maximumLabelWidth,
                        label.getPreferredWidth(-1));
                    maximumFieldWidth = Math.max(maximumFieldWidth,
                        field.getPreferredWidth(-1));
                }
            }
        }

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

        // Lay out the components
        int rowY = 0;

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

            Separator separator = separators.get(sectionIndex);
            if (sectionIndex == 0
                && !showFirstSectionHeading) {
                separator.setVisible(false);
            } else {
                separator.setVisible(true);
                separator.setSize(width, separator.getPreferredHeight(width));
                separator.setLocation(0, rowY);
                rowY += separator.getHeight();
            }

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

                Label label = labels.get(sectionIndex).get(fieldIndex);
                ImageView flagImageView = flagImageViews.get(sectionIndex).get(fieldIndex);

                if (field.isDisplayable()) {
                    // Show the row components
                    label.setVisible(true);
                    field.setVisible(true);
                    flagImageView.setVisible(true);

                    // Set the row component sizes
                    label.setSize(label.getPreferredSize());

                    Dimensions fieldSize = null;
                    if (fieldAlignment == HorizontalAlignment.JUSTIFY) {
                        fieldSize = new Dimensions(availableFieldWidth,
                            field.getPreferredHeight(availableFieldWidth));
                    } else {
                        fieldSize = field.getPreferredSize();
                    }

                    field.setSize(fieldSize);
                    flagImageView.setSize(flagImageView.getPreferredSize());

                    int rowHeight = Math.max(label.getHeight(),
                        Math.max(field.getHeight(), FLAG_IMAGE_SIZE));

                    // Set the row component locations
                    int labelX = rightAlignLabels ? maximumLabelWidth - label.getWidth() : 0;
                    label.setLocation(labelX, rowY);

                    int fieldX = 0;
                    switch(fieldAlignment) {
                        case LEFT:
                        case JUSTIFY: {
                            fieldX = maximumLabelWidth + horizontalSpacing;
                            break;
                        }

                        case RIGHT: {
                            fieldX = maximumLabelWidth + horizontalSpacing
                                + Math.max(0, Math.max(availableFieldWidth, maximumFieldWidth)
                                    - field.getWidth());
                            break;
                        }

                        case CENTER: {
                            fieldX = maximumLabelWidth + horizontalSpacing
                                + Math.max(0, (Math.max(availableFieldWidth, maximumFieldWidth)
                                    - field.getWidth()) / 2);
                            break;
                        }
                    }

                    field.setLocation(fieldX, rowY);
                    flagImageView.setLocation(fieldX + field.getWidth() + flagImageOffset,
                        rowY + (rowHeight - flagImageView.getHeight()) / 2);

                    // Update the row y-coordinate
                    rowY += rowHeight + verticalSpacing;
                } else {
                    // Hide the row components
                    label.setVisible(false);
                    field.setVisible(false);
                    flagImageView.setVisible(false);
                }
            }
        }
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);
        updateFieldName(section, index);

        // Create the flag image view
View Full Code Here

    private void updateFieldName(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 name = Form.getName(field);
        label.setText((name == null) ? "" : name + ":");
    }
View Full Code Here

        ImageView typeImageView = wtkxSerializer.getObjectByID("typeImageView");
        typeImageView.setImage(theme.getMessageIcon(prompt.getMessageType()));

        // Set the message
        Label messageLabel = wtkxSerializer.getObjectByID("messageLabel");
        String message = prompt.getMessage();
        messageLabel.setText(message);

        // Set the body
        FlowPane messageFlowPane = wtkxSerializer.getObjectByID("messageFlowPane");
        Component body = prompt.getBody();
        if (body != null) {
View Full Code Here

        TablePane.setColumnSpan(monthYearFlowPane, 7);

        // Add the day labels
        row = new TablePane.Row();
        for (int i = 0; i < 7; i++) {
            Label label = new Label();
            label.getStyles().put("fontBold", true);
            label.getStyles().put("padding", new Insets(2, 2, 4, 2));
            label.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);
            row.add(label);
        }

        tablePane.getRows().add(row);
View Full Code Here

TOP

Related Classes of pivot.wtk.Label$LabelListenerList

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.