Example usage for com.jgoodies.forms.layout Sizes constant

List of usage examples for com.jgoodies.forms.layout Sizes constant

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout Sizes constant.

Prototype

public static ConstantSize constant(String encodedValueAndUnit, boolean horizontal) 

Source Link

Document

Creates and returns an instance of ConstantSize from the given encoded size and unit description.

Usage

From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.FormSizeInfoTest.java

License:Open Source License

private void check_bounded_getDisplayString(Size componentSize, String source, String display)
        throws Exception {
    Size expectedSize = Sizes.bounded(componentSize, Sizes.constant("3cm", true), Sizes.constant("40mm", true));
    FormSizeInfo size = new FormSizeInfo(expectedSize, true);
    assertEquals(expectedSize, size.getSize());
    {/* ww w  .jav  a  2 s . com*/
        assertFalse(size.isString());
        assertEquals("com.jgoodies.forms.layout.Sizes.bounded(com.jgoodies.forms.layout.Sizes." + source
                + ", com.jgoodies.forms.layout.Sizes.constant(\"3cm\", true), com.jgoodies.forms.layout.Sizes.constant(\"40mm\", true))",
                size.getSource());
    }
    assertEquals("3cm<" + display + "<40mm", size.getDisplayString());
}

From source file:org.javad.stamp.pdf.ui.AlbumGeneratorPanel.java

License:Apache License

private void initialize() {
    AnnotationProcessor.process(this);
    setModelBean(new GenerateBean());
    setBackground(new Color(248, 248, 255));
    setForeground(new Color(211, 211, 211));
    setDirection(GradientPanel.HORIZONTAL);
    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("79px"),
                    FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                    new ColumnSpec(ColumnSpec.FILL,
                            Sizes.bounded(Sizes.PREFERRED, Sizes.constant("250dlu", true),
                                    Sizes.constant("400dlu", true)),
                            1),/*  w ww. j  a v a  2  s  .  c  o m*/
                    ColumnSpec.decode("left:40px"), FormFactory.UNRELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("22dlu"),
                    FormFactory.UNRELATED_GAP_ROWSPEC, RowSpec.decode("24px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("24px"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC,

                    FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:60px:grow"), FormFactory.UNRELATED_GAP_ROWSPEC, }));
    add(getConfigurationLabel(), "2, 2, right, default");
    add(getConfigPanel(), "4, 2, 2, 1, left, fill");
    add(getInputFileLabel(), "2, 4, fill, center");
    add(getInputFileText(), "4, 4, fill, center");
    add(getBtnInputFile(), "5, 4, left, top");
    add(getOutputFolderLabel(), "2, 6, fill, fill");
    add(getOutputFolderText(), "4, 6, fill, center");
    add(getBtnOutputFolder(), "5, 6, left, top");
    add(getTagLabel(), "2, 8, fill, center");
    add(getTagText(), "4, 8, fill, center");
    add(getCheckRenderBorders(), "4, 10");
    add(getCheckRenderReverse(), "4, 12, left, default");
    add(getPanel(), "4, 14,fill, top");
    add(getLogLabel(), "2, 16, right, top");
    add(getScrollPane(), "4, 16,2,1 fill, fill");

    Preferences prefs = Resources.getPreferencesNode();
    String folderOutput = prefs.get(GeneratorConstants.DEFAULT_OUTPUT_FOLDER_KEY, null);
    String inputFile = prefs.get(GeneratorConstants.DEFAULT_INPUT_FILE_KEY, null);
    if (folderOutput != null) {
        getOutputFolderText().setText(folderOutput);
    }
    if (inputFile != null) {
        getInputFileText().setText(inputFile);
    }

    Logger.getLogger("org.javad").setLevel(Level.INFO);
    Logger.getLogger("org.javad").addHandler(new Handler() {

        @Override
        public void publish(LogRecord record) {
            getLogText().append(record.getMessage() + "\n");
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
            getLogText().setText(null);
        }

    });

    loadConfigurations();

    PageConfigurations configs = PageConfigurations.getInstance();
    configs.addPageConfigurationChangeHandler(this);

}

From source file:org.tinymediamanager.ui.movies.MovieDetailsPanel.java

License:Apache License

/**
 * Instantiates a new movie details panel.
 * //from   w w  w.  ja  va  2  s.  com
 * @param model
 *          the model
 */
public MovieDetailsPanel(MovieSelectionModel model) {
    this.movieSelectionModel = model;

    setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
            FormFactory.UNRELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
            FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("100px:grow"),
            FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC,
            ColumnSpec.decode("100px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("55px"),
            FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC,
                    new RowSpec(RowSpec.CENTER,
                            Sizes.bounded(Sizes.MINIMUM, Sizes.constant("15px", false),
                                    Sizes.constant("50px", false)),
                            0),
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    lblOriginalTitleT = new JLabel(BUNDLE.getString("metatag.originaltitle")); //$NON-NLS-1$
    add(lblOriginalTitleT, "2, 2");

    lblOriginalTitle = new JLabel("");
    add(lblOriginalTitle, "4, 2, 7, 1");

    btnPlay = new JButton("");
    btnPlay.setIcon(IconManager.PLAY);
    btnPlay.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            MediaFile mf = movieSelectionModel.getSelectedMovie().getMediaFiles(MediaFileType.VIDEO).get(0);
            try {
                TmmUIHelper.openFile(mf.getFile());
            } catch (Exception e) {
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, mf, "message.erroropenfile",
                        new String[] { ":", e.getLocalizedMessage() }));
            }
        }
    });
    add(btnPlay, "12, 2, 1, 5");

    lblGenresT = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
    add(lblGenresT, "2, 4");
    lblGenresT.setLabelFor(lblGenres);

    lblGenres = new JLabel("");
    add(lblGenres, "4, 4, 7, 1");

    lblRuntimeT = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
    add(lblRuntimeT, "2, 6");
    lblRuntimeT.setLabelFor(lblRuntime);

    lblRuntime = new JLabel("");
    add(lblRuntime, "4, 6");

    lblMinutes = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
    add(lblMinutes, "6, 6");

    lblReleaseDateT = new JLabel(BUNDLE.getString("metatag.releasedate")); //$NON-NLS-1$
    add(lblReleaseDateT, "8, 6");

    lblReleaseDate = new JLabel("");
    add(lblReleaseDate, "10, 6");

    lblCertificationT = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
    add(lblCertificationT, "2, 8");
    lblCertificationT.setLabelFor(lblCertification);

    lblCertification = new JLabel("");
    add(lblCertification, "4, 8, 7, 1");

    lblProductionT = new JLabel(BUNDLE.getString("metatag.production")); //$NON-NLS-1$
    add(lblProductionT, "2, 10, default, top");
    lblProductionT.setLabelFor(lblProduction);

    lblProduction = new JLabel();
    add(lblProduction, "4, 10, 9, 1");

    lblSpokenLanguagesT = new JLabel(BUNDLE.getString("metatag.spokenlanguages")); //$NON-NLS-1$
    add(lblSpokenLanguagesT, "2, 12");

    lblSpokenLanguages = new JLabel("");
    add(lblSpokenLanguages, "4, 12, 3, 1");

    lblCountryT = new JLabel(BUNDLE.getString("metatag.country")); //$NON-NLS-1$
    add(lblCountryT, "8, 12");

    lblCountry = new JLabel("");
    add(lblCountry, "10, 12, 3, 1");

    lblMoviesetT = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
    add(lblMoviesetT, "2, 14");

    lblMovieSet = new JLabel("");
    add(lblMovieSet, "4, 14, 9, 1");

    lblTagsT = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
    add(lblTagsT, "2, 16");

    lblTags = new JLabel("");
    add(lblTags, "4, 16, 9, 1");

    lblImdbIdT = new JLabel(BUNDLE.getString("metatag.imdb")); //$NON-NLS-1$
    add(lblImdbIdT, "2, 18");

    lblImdbId = new LinkLabel("");
    lblImdbId.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String url = "http://www.imdb.com/title/" + lblImdbId.getNormalText();
            try {
                TmmUIHelper.browseUrl(url);
            } catch (Exception e) {
                LOGGER.error("browse to imdbid", e);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl",
                        new String[] { ":", e.getLocalizedMessage() }));
            }
        }
    });

    add(lblImdbId, "4, 18, 3, 1, left, default");
    lblImdbIdT.setLabelFor(lblImdbId);

    lblTmdbIdT = new JLabel(BUNDLE.getString("metatag.tmdb")); //$NON-NLS-1$
    add(lblTmdbIdT, "8, 18");

    lblTmdbId = new LinkLabel("");
    lblTmdbId.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String url = "http://www.themoviedb.org/movie/" + lblTmdbId.getNormalText();
            try {
                TmmUIHelper.browseUrl(url);
            } catch (Exception e) {
                LOGGER.error("browse to tmdbid", e);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl",
                        new String[] { ":", e.getLocalizedMessage() }));
            }
        }
    });
    add(lblTmdbId, "10, 18, 3, 1, left, default");
    lblTmdbIdT.setLabelFor(lblTmdbId);

    lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
    add(lblMoviePathT, "2, 20");

    lblMoviePath = new LinkLabel("");
    lblMoviePath.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (!StringUtils.isEmpty(lblMoviePath.getNormalText())) {
                // get the location from the label
                File path = new File(lblMoviePath.getNormalText());
                try {
                    // check whether this location exists
                    if (path.exists()) {
                        TmmUIHelper.openFile(path);
                    }
                } catch (Exception ex) {
                    LOGGER.error("open filemanager", ex);
                    MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                            "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
                }
            }
        }
    });
    lblMoviePathT.setLabelFor(lblMoviePath);
    lblMoviePathT.setLabelFor(lblMoviePath);
    add(lblMoviePath, "4, 20, 9, 1");

    initDataBindings();
}