Example usage for com.jgoodies.forms.layout CellConstraints xyw

List of usage examples for com.jgoodies.forms.layout CellConstraints xyw

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints xyw.

Prototype

public CellConstraints xyw(int col, int row, int colSpan, String encodedAlignments) 

Source Link

Document

Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.

Usage

From source file:loci.ome.editor.MetadataPane.java

License:Open Source License

/**
 * Fleshes out the GUI of a given TabPanel, adding TablePanels appropriately.
 *///  w  w  w  .j  ava  2  s . c  o m
public void renderTab(TabPanel tp) {
    if (tp.isRendered)
        return;
    tp.isRendered = true;
    tp.removeAll();

    Vector iHoldTables = new Vector();

    //add a title label to show which element
    JPanel titlePanel = new JPanel();
    titlePanel.setLayout(new GridLayout(2, 1));
    JLabel title = new JLabel();
    Font thisFont = title.getFont();
    Font newFont = new Font(thisFont.getFontName(), Font.BOLD, 18);
    title.setFont(newFont);
    if (tp.oNode != null) {
        title.setText(" " + getTreePathName(tp.el, tp.oNode) + ":");
    } else
        title.setText(" " + getTreePathName(tp.el) + ":");
    title.setForeground(new Color(255, 255, 255));

    tp.saveButton = new JButton("QuickSave");
    tp.saveButton.setPreferredSize(new Dimension(100, 17));
    tp.saveButton.setActionCommand("save");
    tp.saveButton.addActionListener(this);
    tp.saveButton.setOpaque(false);
    tp.saveButton.setForeground(TEXT_COLOR);
    if (getState())
        tp.saveButton.setForeground(ADD_COLOR);
    if (!addSave)
        tp.saveButton.setVisible(false);

    Color aColor = getBackground();

    JTextArea descrip = new JTextArea();

    //if title has a description, add it in italics
    if (tp.el.hasAttribute("Description")) {
        if (tp.el.getAttribute("Description").length() != 0) {
            descrip.setEditable(false);
            descrip.setLineWrap(true);
            descrip.setWrapStyleWord(true);
            descrip.setBackground(aColor);
            newFont = new Font(thisFont.getFontName(), Font.ITALIC, thisFont.getSize());
            descrip.setFont(newFont);
            descrip.setText("     " + tp.el.getAttribute("Description"));
        }
    }

    FormLayout myLayout = new FormLayout("pref, 5dlu, pref:grow:right, 5dlu", "5dlu, pref, 5dlu, pref");
    PanelBuilder build = new PanelBuilder(myLayout);
    CellConstraints cellC = new CellConstraints();

    build.add(title, cellC.xy(1, 2, "left, center"));
    build.add(tp.saveButton, cellC.xy(3, 2, "right, center"));
    build.add(descrip, cellC.xyw(1, 4, 4, "fill, center"));
    titlePanel = build.getPanel();
    titlePanel.setBackground(TEXT_COLOR);

    //this sets up titlePanel so we can access its height later to
    //use for "Goto" button scrollpane view setting purposes
    tp.titlePanel = titlePanel;

    //First instantiation of TablePanel. This one corresponds to the
    //actual "top-level" element, e.g. what the main Tab element is
    TablePanel pan = new TablePanel(tp.el, tp, tp.oNode);
    iHoldTables.add(pan);

    //make the nested elements have a further indent to distinguish them

    //look at the template to get the nested Elements we need to display
    //with their own TablePanels
    Vector theseElements = DOMUtil.getChildElements("OMEElement", tp.el);
    //will be a list of those nested elements that have their own nested
    //elements
    Vector branchElements = new Vector(theseElements.size());

    //check out each nested Element
    for (int i = 0; i < theseElements.size(); i++) {
        Element e = null;
        if (theseElements.get(i) instanceof Element) {
            e = (Element) theseElements.get(i);
        }
        if (DOMUtil.getChildElements("OMEElement", e).size() != 0) {
            branchElements.add(e);
        } else {
            if (tp.oNode != null) {
                Vector v = new Vector();
                String aName = e.getAttribute("XMLName");
                if (aName.equals("Image") || aName.equals("Feature") || aName.equals("Dataset")
                        || aName.equals("Project")) {
                    v = DOMUtil.getChildElements(aName, tp.oNode.getDOMElement());
                } else if (tp.oNode.getChildNode("CustomAttributes") != null) {
                    v = DOMUtil.getChildElements(aName,
                            tp.oNode.getChildNode("CustomAttributes").getDOMElement());
                }

                if (v.size() == 0) {
                    OMEXMLNode n = null;
                    TablePanel p = new TablePanel(e, tp, n);
                    iHoldTables.add(p);
                } else {
                    for (int j = 0; j < v.size(); j++) {
                        Element anEle = (Element) v.get(j);

                        OMEXMLNode n = null;
                        String unknownName = aName;

                        try {
                            ReflectedUniverse r = new ReflectedUniverse();
                            if (unknownName.equals("Project") || unknownName.equals("Feature")
                                    || unknownName.equals("CustomAttributes") || unknownName.equals("Dataset")
                                    || unknownName.equals("Image")) {
                                r.exec("import org.openmicroscopy.xml." + unknownName + "Node");
                                r.setVar("DOMElement", anEle);
                                r.exec("result = new " + unknownName + "Node(DOMElement)");
                                n = (OMEXMLNode) r.getVar("result");
                            } else {
                                r.exec("import org.openmicroscopy.xml.st." + unknownName + "Node");
                                r.setVar("DOMElement", anEle);
                                r.exec("result = new " + unknownName + "Node(DOMElement)");
                                n = (OMEXMLNode) r.getVar("result");
                            }
                        } catch (Exception exc) {
                            //System.out.println(exc.toString());
                        }
                        if (n == null) {
                            n = new AttributeNode(anEle);
                        }

                        TablePanel p = new TablePanel(e, tp, n);
                        iHoldTables.add(p);
                    }
                }
            } else {
                OMEXMLNode n = null;

                TablePanel p = new TablePanel(e, tp, n);
                iHoldTables.add(p);
            }
        }
    }

    String rowString = "pref, 10dlu, ";
    for (int i = 0; i < iHoldTables.size(); i++) {
        rowString = rowString + "pref, 5dlu, ";
    }
    rowString = rowString.substring(0, rowString.length() - 2);

    FormLayout layout = new FormLayout("5dlu, 5dlu, pref:grow, 5dlu, 5dlu", rowString);
    tp.setLayout(layout);
    CellConstraints cc = new CellConstraints();

    tp.add(titlePanel, cc.xyw(1, 1, 5));

    int row = 1;
    for (int i = 0; i < iHoldTables.size(); i++) {
        row = row + 2;
        Component c = (Component) iHoldTables.get(i);
        tp.add(c, cc.xyw(i == 0 ? 2 : 3, row, 2, "fill, center"));
    }

    //Layout stuff distinguishes between the title and the data panels
}

From source file:loci.ome.editor.NotePane.java

License:Open Source License

/** Construct the default NotePane object. */
public NotePane() {
    super();//  w  ww  .ja v a2s.  co  m

    tPanels = null;

    titlePanel = new JPanel();
    titlePanel.setLayout(new GridLayout(2, 1));
    JLabel title = new JLabel();
    Font thisFont = title.getFont();
    Font newFont = new Font(thisFont.getFontName(), Font.BOLD, 18);
    title.setFont(newFont);
    title.setText(" Note List:");
    title.setForeground(new Color(255, 255, 255));

    JButton saveButton = new JButton("Export Notes");
    saveButton.setPreferredSize(new Dimension(120, 17));
    saveButton.setActionCommand("save");
    saveButton.addActionListener(this);
    saveButton.setOpaque(false);
    saveButton.setForeground(TEXT_COLOR);

    Color aColor = getBackground();

    JTextArea descrip = new JTextArea();
    descrip.setEditable(false);
    descrip.setLineWrap(true);
    descrip.setWrapStyleWord(true);
    descrip.setBackground(aColor);
    newFont = new Font(thisFont.getFontName(), Font.ITALIC, thisFont.getSize());
    descrip.setFont(newFont);
    descrip.setText("     A comprehensive list of all notes in this file.");

    FormLayout myLayout = new FormLayout("pref, 5dlu, pref:grow:right, 5dlu", "5dlu, pref, 5dlu, pref");
    PanelBuilder build = new PanelBuilder(myLayout);
    CellConstraints cellC = new CellConstraints();

    build.add(title, cellC.xy(1, 2, "left,center"));
    build.add(saveButton, cellC.xy(3, 2, "right,center"));
    build.add(descrip, cellC.xyw(1, 4, 4, "fill,center"));
    titlePanel = build.getPanel();
    titlePanel.setBackground(TEXT_COLOR);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            chooser = new JFileChooser(System.getProperty("user.dir"));
            chooser.setDialogTitle("Export Notes to Text File");
            chooser.setApproveButtonText("Save");
            chooser.setApproveButtonToolTipText("Export notes to " + "selected file.");
            chooser.setFileFilter(new TextFileFilter());
        }
    });
}

From source file:loci.ome.editor.NotePanel.java

License:Open Source License

/**
 * Construct a NotePanel given the parent TablePanel.
 * @param tp The TablePanel that this NotePanel is a part of.
 *//*from  ww w  . jav  a2 s. com*/
public NotePanel(MetadataPane.TablePanel tp) {
    super();

    tableP = tp;
    setBorder(new EmptyBorder(5, 5, 5, 5));
    setBackground(BACK_COLOR);

    boolean editable = tableP.isEditable();

    Vector noteEleList = getNoteElements();
    DefaultListModel thisModel = new DefaultListModel();
    noteList = new ClickableList(thisModel, this);
    noteList.addListSelectionListener(this);

    if (noteEleList != null) {
        for (int i = 0; i < noteEleList.size(); i++) {
            Element e = (Element) noteEleList.get(i);
            thisModel.addElement(e.getAttribute("Name"));
        }
    }

    // buggy...
    //    if (thisModel.getSize() > 0) noteList.setSelectedIndex(0);

    JScrollPane jScroll = new JScrollPane(noteList);
    jScroll.setPreferredSize(new Dimension(150, 100));

    textArea = new JTextArea();
    if (!editable)
        textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.getDocument().addDocumentListener(noteList);
    JScrollPane jNoteScroll = new JScrollPane(textArea);
    jNoteScroll.setPreferredSize(new Dimension(450, 100));
    jNoteScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    FormLayout layout = new FormLayout("pref, 5dlu, pref, 5dlu, pref:grow:right, 5dlu, pref", "pref,2dlu,pref");
    setLayout(layout);
    CellConstraints cc = new CellConstraints();

    if (thisModel.size() == 0)
        nameLabel = new JLabel("Name", NO_NOTES_BULLET, JLabel.LEFT);
    else
        nameLabel = new JLabel("Name", NOTES_BULLET, JLabel.LEFT);
    noteLabel = new JLabel("Notes", NO_NOTES_BULLET, JLabel.LEFT);
    Font thisFont = nameLabel.getFont();
    thisFont = new Font(thisFont.getFontName(), Font.BOLD, thisFont.getSize());
    nameLabel.setFont(thisFont);
    thisFont = noteLabel.getFont();
    thisFont = new Font(thisFont.getFontName(), Font.BOLD, thisFont.getSize());
    noteLabel.setFont(thisFont);

    JButton addBTN = new JButton("New Note");
    //    addBTN.setPreferredSize(new Dimension(120,17));
    addBTN.setActionCommand("add");
    addBTN.addActionListener(noteList);
    addBTN.setToolTipText("Add a new note to the \"Name\" list.");
    addBTN.setForeground(MetadataPane.ADD_COLOR);
    addBTN.setOpaque(false);
    if (!editable)
        addBTN.setEnabled(false);

    JButton delBTN = new JButton("Delete Note");
    //    delBTN.setPreferredSize(new Dimension(120,17));
    delBTN.setActionCommand("remove");
    delBTN.addActionListener(noteList);
    delBTN.setToolTipText("Delete the note selected in the \"Name\" list.");
    delBTN.setForeground(MetadataPane.DELETE_COLOR);
    delBTN.setOpaque(false);
    if (!editable)
        delBTN.setEnabled(false);

    add(nameLabel, cc.xy(1, 1, "left,center"));
    add(noteLabel, cc.xy(3, 1, "left,center"));

    add(addBTN, cc.xy(5, 1, "right,center"));
    add(delBTN, cc.xy(7, 1, "right,center"));

    add(jScroll, cc.xy(1, 3, "fill,center"));
    add(jNoteScroll, cc.xyw(3, 3, 5, "fill,center"));
    setBackground(BACK_COLOR);
    setVisible(false);
    if (noteEleList != null)
        setVisible(true);
}

From source file:loci.visbio.BioTask.java

License:Open Source License

/** Constructs a new VisBio task. */
public BioTask(final TaskManager taskMan, final String name) {
    tm = taskMan;//  w w  w .  ja  va  2 s  .c  om
    title = new JLabel(name);
    title.setFont(title.getFont().deriveFont(Font.BOLD));
    status = new JLabel() {

        @Override
        public Dimension getPreferredSize() {
            // HACK - limit label width to viewport
            final Dimension pref = super.getPreferredSize();
            int width = tm.getControls().getPreferredTaskWidth() - title.getPreferredSize().width
                    - stop.getPreferredSize().width - 25;
            if (pref.width < width)
                width = pref.width;
            return new Dimension(width, pref.height);
        }
    };
    progress = new JProgressBar();
    progress.setIndeterminate(true);
    stop = new JButton("Stop");
    stop.addActionListener(this);
    stop.setEnabled(false);
    setLayout(new BorderLayout());
    setBorder(new EmptyBorder(0, 0, 5, 0));
    final PanelBuilder builder = new PanelBuilder(
            new FormLayout("pref:grow, 3dlu, pref:grow, 3dlu, pref", "pref, pref"));
    final CellConstraints cc = new CellConstraints();
    builder.add(title, cc.xy(1, 1, "left,bottom"));
    builder.add(status, cc.xy(3, 1, "right,bottom"));
    builder.add(progress, cc.xyw(1, 2, 3, "fill,top"));
    builder.add(stop, cc.xywh(5, 1, 1, 2, "center,center"));
    add(builder.getPanel());
}

From source file:loci.visbio.view.ColorPane.java

License:Open Source License

/** Constructs panel with brightness, contrast and transparency sliders. */
protected JPanel makeSliderPanel() {
    // brightness slider
    brightness = new JSlider(0, ColorUtil.COLOR_DETAIL, 0);
    brightness.addChangeListener(this);
    brightness.setAlignmentY(Component.TOP_ALIGNMENT);
    brightness.setToolTipText("Adjusts the brightness of the data");

    // current brightness value
    brightnessValue = new JLabel("999");
    brightnessValue.setToolTipText("Current brightness value");

    // contrast slider
    contrast = new JSlider(0, ColorUtil.COLOR_DETAIL, 0);
    contrast.addChangeListener(this);
    contrast.setAlignmentY(Component.TOP_ALIGNMENT);
    contrast.setToolTipText("Adjusts the contrast of the data");

    // current contrast value
    contrastValue = new JLabel("999");
    contrastValue.setToolTipText("Current contrast value");

    // transparency slider
    opacity = new JSlider(0, ColorUtil.COLOR_DETAIL, ColorUtil.COLOR_DETAIL);
    opacity.addChangeListener(this);
    opacity.setAlignmentY(Component.TOP_ALIGNMENT);
    opacity.setMajorTickSpacing(ColorUtil.COLOR_DETAIL / 4);
    opacity.setMinorTickSpacing(ColorUtil.COLOR_DETAIL / 16);
    opacity.setPaintTicks(true);//  ww  w.  j a v a  2  s. c  om
    opacity.setToolTipText("Adjusts the transparency of the data.");

    // current transparency value
    opacityValue = new JLabel("999");
    opacityValue.setToolTipText("Current transparency value");

    // constant transparency option
    constant = new JRadioButton("Constant", true);
    constant.addActionListener(this);
    if (!LAFUtil.isMacLookAndFeel())
        constant.setMnemonic('a');
    constant.setToolTipText("Switches to a constant value transparency");

    // curved transparency option
    curved = new JRadioButton("Curved");
    curved.addActionListener(this);
    if (!LAFUtil.isMacLookAndFeel())
        curved.setMnemonic('d');
    curved.setToolTipText("Switches to a curved function transparency");

    // transparency model button group
    final ButtonGroup group = new ButtonGroup();
    group.add(constant);
    group.add(curved);

    // lay out components
    final PanelBuilder builder = new PanelBuilder(new FormLayout("pref, 3dlu, pref:grow, 3dlu, pref",
            "pref, 3dlu, pref, 3dlu, top:pref, 3dlu, pref"));
    final CellConstraints cc = new CellConstraints();

    builder.addLabel("&Brightness", cc.xy(1, 1)).setLabelFor(brightness);
    builder.add(brightness, cc.xy(3, 1));
    builder.add(brightnessValue, cc.xy(5, 1));

    builder.addLabel("Contra&st", cc.xy(1, 3)).setLabelFor(contrast);
    builder.add(contrast, cc.xy(3, 3));
    builder.add(contrastValue, cc.xy(5, 3));

    builder.addLabel("O&pacity", cc.xy(1, 5)).setLabelFor(opacity);
    builder.add(opacity, cc.xy(3, 5));
    builder.add(opacityValue, cc.xy(5, 5));

    builder.add(FormsUtil.makeRow(new Object[] { "Transparency model", constant, curved }),
            cc.xyw(1, 7, 5, "center, default"));

    return builder.getPanel();
}

From source file:net.lidskialf.datadog.ui.AboutBox.java

License:Open Source License

/**
 * Build the panel/layout components.//from  w w  w  .  ja v a2  s .com
 *
 * @return The completed JComponent
 */
private JComponent buildPanel() {
    initComponents();

    FormLayout layout = new FormLayout("pref, 4dlu, pref:grow, pref", "pref:grow, 4dlu, pref");
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    builder.add(logo, cc.xy(1, 1, "left, top"));
    builder.add(aboutText, cc.xyw(3, 1, 2, "fill, fill"));
    builder.add(okButton, cc.xy(4, 3, "right, bottom"));

    return builder.getPanel();
}

From source file:net.lidskialf.datadog.ui.BookmarkEditor.java

License:Open Source License

/**
 * Build the panel/layout components./*  w w w.j a va  2s . co m*/
 *
 * @return The completed JComponent
 */
protected JComponent buildPanel() {
    initComponents();

    FormLayout layout = new FormLayout("pref, 4dlu, pref:grow", "pref, pref, pref, 10dlu:grow, pref");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();

    builder.addLabel("Position", cc.xy(1, 1));
    builder.add(positionField, cc.xy(3, 1, "fill, top"));
    builder.addLabel("Description", cc.xy(1, 2));
    builder.add(descriptionField, cc.xy(3, 2, "fill, top"));
    builder.addLabel("Colour", cc.xy(1, 3));
    builder.add(colourButton, cc.xy(3, 3, "left, top"));

    ButtonBarBuilder buttonBuilder = new ButtonBarBuilder();
    buttonBuilder.addGriddedButtons(new JButton[] { okButton, cancelButton, applyButton });

    builder.add(buttonBuilder.getPanel(), cc.xyw(1, 5, 3, "center, top"));

    return builder.getPanel();
}

From source file:net.lidskialf.datadog.ui.SubstreamEditor.java

License:Open Source License

/**
 * Build the panel/layout components./*from  ww  w  .java  2 s . com*/
 *
 * @return The completed JComponent
 */
protected JComponent buildPanel() {
    initComponents();

    FormLayout layout = new FormLayout("pref, 4dlu, pref:grow", "pref, pref, pref, 10dlu:grow, pref");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();
    CellConstraints cc = new CellConstraints();

    builder.addLabel("Label", cc.xy(1, 1));
    builder.add(labelField, cc.xy(3, 1, "fill, top"));
    builder.addLabel("Description", cc.xy(1, 2));
    builder.add(descriptionField, cc.xy(3, 2, "fill, top"));
    builder.addLabel("Colour", cc.xy(1, 3));
    builder.add(colourButton, cc.xy(3, 3, "left, top"));

    ButtonBarBuilder buttonBuilder = new ButtonBarBuilder();
    buttonBuilder.addGriddedButtons(new JButton[] { okButton, cancelButton, applyButton });

    builder.add(buttonBuilder.getPanel(), cc.xyw(1, 5, 3, "center, top"));

    return builder.getPanel();
}