Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

In this page you can find the example usage for java.awt GridBagConstraints HORIZONTAL.

Prototype

int HORIZONTAL

To view the source code for java.awt GridBagConstraints HORIZONTAL.

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java

/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The
 * content of this method is always regenerated by the Form Editor.
 *///from w  w  w.ja  v a  2s. co m
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    GridBagConstraints gridBagConstraints;
    bindingGroup = new BindingGroup();

    final RoundedPanel pnlFotos = new RoundedPanel();
    final SemiRoundedPanel pnlHeaderFotos = new SemiRoundedPanel();
    final JLabel lblHeaderFotos = new JLabel();
    final JPanel jPanel2 = new JPanel();
    final JPanel jPanel1 = new JPanel();
    final JScrollPane jspFotoList = new JScrollPane();
    lstFotos = new JList();
    final JPanel pnlCtrlButtons = new JPanel();
    btnAddImg = new JButton();
    btnRemoveImg = new JButton();
    final JPanel pnlMap = new JPanel();
    final RoundedPanel pnlVorschau = new RoundedPanel();
    final SemiRoundedPanel semiRoundedPanel2 = new SemiRoundedPanel();
    final JLabel lblVorschau = new JLabel();
    final JPanel jPanel3 = new JPanel();
    pnlFoto = new JPanel();
    lblPicture = new JLabel();
    lblBusy = new JXBusyLabel(new Dimension(75, 75));
    final JPanel pnlCtrlBtn = new JPanel();
    btnPrevImg = new JButton();
    btnNextImg = new JButton();

    final FormListener formListener = new FormListener();

    setName("Form"); // NOI18N
    setOpaque(false);
    setLayout(new GridBagLayout());

    pnlFotos.setMinimumSize(new Dimension(400, 200));
    pnlFotos.setName("pnlFotos"); // NOI18N
    pnlFotos.setPreferredSize(new Dimension(400, 200));
    pnlFotos.setLayout(new GridBagLayout());

    pnlHeaderFotos.setBackground(new Color(51, 51, 51));
    pnlHeaderFotos.setForeground(new Color(51, 51, 51));
    pnlHeaderFotos.setName("pnlHeaderFotos"); // NOI18N
    pnlHeaderFotos.setLayout(new FlowLayout());

    lblHeaderFotos.setForeground(new Color(255, 255, 255));
    Mnemonics.setLocalizedText(lblHeaderFotos,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblHeaderFotos.text")); // NOI18N
    lblHeaderFotos.setName("lblHeaderFotos"); // NOI18N
    pnlHeaderFotos.add(lblHeaderFotos);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pnlFotos.add(pnlHeaderFotos, gridBagConstraints);

    jPanel2.setName("jPanel2"); // NOI18N
    jPanel2.setOpaque(false);
    jPanel2.setLayout(new GridBagLayout());

    jPanel1.setName("jPanel1"); // NOI18N
    jPanel1.setOpaque(false);
    jPanel1.setLayout(new GridBagLayout());

    jspFotoList.setMinimumSize(new Dimension(250, 130));
    jspFotoList.setName("jspFotoList"); // NOI18N

    lstFotos.setMinimumSize(new Dimension(250, 130));
    lstFotos.setName("lstFotos"); // NOI18N
    lstFotos.setPreferredSize(new Dimension(250, 130));

    final ELProperty eLProperty = ELProperty.create("${cidsBean." + beanCollProp + "}");
    final JListBinding jListBinding = SwingBindings.createJListBinding(AutoBinding.UpdateStrategy.READ_WRITE,
            this, eLProperty, lstFotos);
    bindingGroup.addBinding(jListBinding);

    lstFotos.addListSelectionListener(formListener);
    jspFotoList.setViewportView(lstFotos);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel1.add(jspFotoList, gridBagConstraints);

    pnlCtrlButtons.setName("pnlCtrlButtons"); // NOI18N
    pnlCtrlButtons.setOpaque(false);
    pnlCtrlButtons.setLayout(new GridBagLayout());

    btnAddImg.setIcon(new ImageIcon(
            getClass().getResource("/de/cismet/cids/custom/objecteditors/wunda_blau/edit_add_mini.png"))); // NOI18N
    Mnemonics.setLocalizedText(btnAddImg,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnAddImg.text")); // NOI18N
    btnAddImg.setBorderPainted(false);
    btnAddImg.setContentAreaFilled(false);
    btnAddImg.setName("btnAddImg"); // NOI18N
    btnAddImg.addActionListener(formListener);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(0, 0, 5, 0);
    pnlCtrlButtons.add(btnAddImg, gridBagConstraints);

    btnRemoveImg.setIcon(new ImageIcon(
            getClass().getResource("/de/cismet/cids/custom/objecteditors/wunda_blau/edit_remove_mini.png"))); // NOI18N
    Mnemonics.setLocalizedText(btnRemoveImg,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnRemoveImg.text")); // NOI18N
    btnRemoveImg.setBorderPainted(false);
    btnRemoveImg.setContentAreaFilled(false);
    btnRemoveImg.setName("btnRemoveImg"); // NOI18N
    btnRemoveImg.addActionListener(formListener);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new Insets(5, 0, 0, 0);
    pnlCtrlButtons.add(btnRemoveImg, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.anchor = GridBagConstraints.NORTH;
    gridBagConstraints.insets = new Insets(0, 5, 0, 0);
    jPanel1.add(pnlCtrlButtons, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(10, 10, 10, 0);
    jPanel2.add(jPanel1, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(0, 0, 2, 0);
    pnlFotos.add(jPanel2, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.anchor = GridBagConstraints.NORTH;
    gridBagConstraints.insets = new Insets(0, 0, 5, 5);
    add(pnlFotos, gridBagConstraints);

    pnlMap.setBorder(BorderFactory.createEtchedBorder());
    pnlMap.setMinimumSize(new Dimension(400, 200));
    pnlMap.setName("pnlMap"); // NOI18N
    pnlMap.setPreferredSize(new Dimension(400, 200));
    pnlMap.setLayout(new BorderLayout());
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.VERTICAL;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(5, 0, 0, 5);
    add(pnlMap, gridBagConstraints);
    pnlMap.add(map, BorderLayout.CENTER);

    pnlVorschau.setName("pnlVorschau"); // NOI18N
    pnlVorschau.setLayout(new GridBagLayout());

    semiRoundedPanel2.setBackground(new Color(51, 51, 51));
    semiRoundedPanel2.setName("semiRoundedPanel2"); // NOI18N
    semiRoundedPanel2.setLayout(new FlowLayout());

    lblVorschau.setForeground(new Color(255, 255, 255));
    Mnemonics.setLocalizedText(lblVorschau,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblVorschau.text")); // NOI18N
    lblVorschau.setName("lblVorschau"); // NOI18N
    semiRoundedPanel2.add(lblVorschau);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pnlVorschau.add(semiRoundedPanel2, gridBagConstraints);

    jPanel3.setName("jPanel3"); // NOI18N
    jPanel3.setOpaque(false);
    jPanel3.setLayout(new GridBagLayout());

    pnlFoto.setName("pnlFoto"); // NOI18N
    pnlFoto.setOpaque(false);
    pnlFoto.setLayout(new GridBagLayout());

    lblPicture.setHorizontalAlignment(SwingConstants.CENTER);
    Mnemonics.setLocalizedText(lblPicture,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblPicture.text")); // NOI18N
    lblPicture.setName("lblPicture"); // NOI18N
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pnlFoto.add(lblPicture, gridBagConstraints);

    lblBusy.setHorizontalAlignment(SwingConstants.CENTER);
    lblBusy.setMaximumSize(new Dimension(140, 40));
    lblBusy.setMinimumSize(new Dimension(140, 60));
    lblBusy.setName("lblBusy"); // NOI18N
    lblBusy.setPreferredSize(new Dimension(140, 60));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pnlFoto.add(lblBusy, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(10, 10, 0, 10);
    jPanel3.add(pnlFoto, gridBagConstraints);

    pnlCtrlBtn.setName("pnlCtrlBtn"); // NOI18N
    pnlCtrlBtn.setOpaque(false);
    pnlCtrlBtn.setPreferredSize(new Dimension(100, 50));
    pnlCtrlBtn.setLayout(new GridBagLayout());

    btnPrevImg.setIcon(new ImageIcon(getClass().getResource("/res/arrow-left.png"))); // NOI18N
    Mnemonics.setLocalizedText(btnPrevImg,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnPrevImg.text")); // NOI18N
    btnPrevImg.setBorderPainted(false);
    btnPrevImg.setFocusPainted(false);
    btnPrevImg.setName("btnPrevImg"); // NOI18N
    btnPrevImg.addActionListener(formListener);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pnlCtrlBtn.add(btnPrevImg, gridBagConstraints);

    btnNextImg.setIcon(new ImageIcon(getClass().getResource("/res/arrow-right.png"))); // NOI18N
    Mnemonics.setLocalizedText(btnNextImg,
            NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnNextImg.text")); // NOI18N
    btnNextImg.setBorderPainted(false);
    btnNextImg.setFocusPainted(false);
    btnNextImg.setName("btnNextImg"); // NOI18N
    btnNextImg.addActionListener(formListener);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pnlCtrlBtn.add(btnNextImg, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(0, 10, 10, 10);
    jPanel3.add(pnlCtrlBtn, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pnlVorschau.add(jPanel3, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(0, 5, 0, 0);
    add(pnlVorschau, gridBagConstraints);

    bindingGroup.bind();
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java

public void init() {

    maxCluster = state.growingLayer.getXSize() * state.growingLayer.getYSize();

    spinnerNoCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1));
    spinnerNoCluster.addChangeListener(new ChangeListener() {
        @Override/*from   w w  w. ja  v a2s  .  c om*/
        public void stateChanged(ChangeEvent e) {
            numClusters = (Integer) ((JSpinner) e.getSource()).getValue();
            SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree()
                    .getAllClusteringElements();
            if (m.containsKey(numClusters)) {
                st = m.get(numClusters).sticky;
            } else {
                st = false;
            }
            sticky.setSelected(st);
            redrawClustering();
        }
    });

    JPanel clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters");

    sticky.setToolTipText(
            "Marks this number of clusters as sticky for a certain leve; the next set of clusters will have a smaller boundary");
    sticky.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            st = sticky.isSelected();
            SortedMap<Integer, ClusterElementsStorage> m = mapPane.getMap().getCurrentClusteringTree()
                    .getAllClusteringElements();
            if (m.containsKey(numClusters)) {
                ClusterElementsStorage c = m.get(numClusters);
                c.sticky = st;
                // System.out.println("test");
                // ((ClusterElementsStorageNode)m.get(numClusters)).sticky = st;
                redrawClustering();
            }
        }
    });

    colorCluster = new JCheckBox("colour", state.colorClusters);
    colorCluster.setToolTipText("Fill the clusters in colours");
    colorCluster.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.colorClusters = colorCluster.isSelected();
            // TODO: Palette anzeigen (?)
            redrawClustering();
        }
    });

    UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerNoCluster, sticky, colorCluster);
    getContentPane().add(clusterPanel, c.nextRow());

    dendogramPanel = UiUtils.makeBorderedPanel(new GridLayout(0, 1), "Dendogram");
    getContentPane().add(dendogramPanel, c.nextRow());

    JPanel numLabelPanel = UiUtils.makeBorderedPanel(new GridBagLayout(), "Labels");
    GridBagConstraintsIFS gcLabels = new GridBagConstraintsIFS();

    labelSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));
    labelSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            numLabels = (Integer) ((JSpinner) e.getSource()).getValue();
            state.clusterWithLabels = numLabels;
            redrawClustering();
        }
    });

    this.showValues = new JCheckBox("values", state.labelsWithValues);
    this.showValues.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.labelsWithValues = showValues.isSelected();
            redrawClustering();
        }
    });

    int start = new Double((1 - state.clusterByValue) * 100).intValue();
    valueQe = new JSlider(0, 100, start);
    valueQe.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int byValue = ((JSlider) e.getSource()).getValue();
            state.clusterByValue = 1 - byValue / 100;
            redrawClustering();
        }
    });

    numLabelPanel.add(new JLabel("# Labels"), gcLabels);
    numLabelPanel.add(labelSpinner, gcLabels.nextCol());
    numLabelPanel.add(showValues, gcLabels.nextCol());
    numLabelPanel.add(valueQe, gcLabels.nextRow().setGridWidth(3).setFill(GridBagConstraints.HORIZONTAL));
    getContentPane().add(numLabelPanel, c.nextRow());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
    labelTable.put(0, new JLabel("by Value"));
    labelTable.put(100, new JLabel("by Qe"));
    valueQe.setToolTipText("Method how to select representative labels - by QE, or the attribute values");
    valueQe.setLabelTable(labelTable);
    valueQe.setPaintLabels(true);

    final JComboBox initialisationBox = new JComboBox(KMeans.InitType.values());
    initialisationBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Object o = mapPane.getMap().getClusteringTreeBuilder();
            if (o instanceof KMeansTreeBuilder) {
                ((KMeansTreeBuilder) o).reInit((KMeans.InitType) initialisationBox.getSelectedItem());
                // FIXME: is this call needed?
                mapPane.getMap().getCurrentClusteringTree().getAllClusteringElements();
                redrawClustering();
            }
        }
    });

    getContentPane().add(UiUtils.fillPanel(kmeansInitialisationPanel, new JLabel("k-Means initialisation"),
            initialisationBox), c.nextRow());

    JPanel borderPanel = new TitledCollapsiblePanel("Border", new GridLayout(1, 4), true);

    JSpinner borderSpinner = new JSpinner(
            new SpinnerNumberModel(ClusteringTree.INITIAL_BORDER_WIDTH_MAGNIFICATION_FACTOR, 0.1, 5, 0.1));
    borderSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            state.clusterBorderWidthMagnificationFactor = ((Double) ((JSpinner) e.getSource()).getValue())
                    .floatValue();
            redrawClustering();
        }
    });

    borderPanel.add(new JLabel("width"));
    borderPanel.add(borderSpinner);

    borderPanel.add(new JLabel("colour"));
    buttonColour = new JButton("");
    buttonColour.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new ClusterBoderColorChooser(state.parentFrame, state.clusterBorderColour, ClusteringControl.this);
        }
    });
    buttonColour.setBackground(state.clusterBorderColour);
    borderPanel.add(buttonColour);

    getContentPane().add(borderPanel, c.nextRow());

    JPanel evaluationPanel = new TitledCollapsiblePanel("Cluster Evaluation", new GridLayout(3, 2), true);

    evaluationPanel.add(new JLabel("quality measure"));
    qualityMeasureButton = new JButton();
    qualityMeasureButton.setText("ent/pur calc");
    qualityMeasureButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("doing entropy here");
            ClusteringTree clusteringTree = state.mapPNode.getClusteringTree();
            if (clusteringTree == null) {
                // we have not clustered yet
                return;
            }
            // System.out.println(clusteringTree.getChildrenCount());

            // FIXME put this in a method and call it on numcluster.change()
            SOMLibClassInformation classInfo = state.inputDataObjects.getClassInfo();
            ArrayList<ClusterNode> clusters = clusteringTree.getNodesAtLevel(numClusters);
            System.out.println(clusters.size());
            // EntropyMeasure.computeEntropy(clusters, classInfo);
            EntropyAndPurityCalculator eapc = new EntropyAndPurityCalculator(clusters, classInfo);
            // FIXME round first
            entropyLabel.setText(String.valueOf(eapc.getEntropy()));
            purityLabel.setText(String.valueOf(eapc.getPurity()));

        }
    });
    evaluationPanel.add(qualityMeasureButton);
    GridBagConstraintsIFS gcEval = new GridBagConstraintsIFS();

    evaluationPanel.add(new JLabel("entropy"), gcEval);
    evaluationPanel.add(new JLabel("purity"), gcEval.nextCol());

    entropyLabel = new JLabel("n/a");
    purityLabel = new JLabel("n/a");

    evaluationPanel.add(entropyLabel, gcEval.nextRow());
    evaluationPanel.add(purityLabel, gcEval.nextCol());

    getContentPane().add(evaluationPanel, c.nextRow());

    JPanel panelButtons = new JPanel(new GridLayout(1, 4));

    JButton saveButton = new JButton("Save");
    saveButton.setFont(smallFont);
    saveButton.setMargin(SMALL_INSETS);
    saveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser;
            if (state.fileChooser.getSelectedFile() != null) {
                fileChooser = new JFileChooser(state.fileChooser.getSelectedFile().getPath());
            } else {
                fileChooser = new JFileChooser();
            }
            fileChooser.addChoosableFileFilter(clusteringFilter);
            fileChooser.addChoosableFileFilter(xmlFilter);

            File filePath = ExportUtils.getFilePath(ClusteringControl.this, fileChooser,
                    "Save Clustering and Labels");

            if (filePath != null) {
                if (xmlFilter.accept(filePath)) {
                    LabelXmlUtils.saveLabelsToFile(state.mapPNode, filePath);
                } else {
                    try {
                        FileOutputStream fos = new FileOutputStream(filePath);
                        GZIPOutputStream gzipOs = new GZIPOutputStream(fos);
                        PObjectOutputStream oos = new PObjectOutputStream(gzipOs);

                        oos.writeObjectTree(mapPane.getMap().getCurrentClusteringTree());
                        oos.writeObjectTree(mapPane.getMap().getManualLabels());
                        oos.writeInt(state.clusterWithLabels);
                        oos.writeBoolean(state.labelsWithValues);
                        oos.writeDouble(state.clusterByValue);
                        oos.writeObject(spinnerNoCluster.getValue());

                        oos.close();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                // keep the selected path for future references
                state.fileChooser.setSelectedFile(filePath.getParentFile());
            }
        }
    });
    panelButtons.add(saveButton);

    JButton loadButton = new JButton("Load");
    loadButton.setFont(smallFont);
    loadButton.setMargin(SMALL_INSETS);
    loadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = getFileChooser();
            fileChooser.setName("Open Clustering");
            fileChooser.addChoosableFileFilter(xmlFilter);
            fileChooser.addChoosableFileFilter(clusteringFilter);

            int returnVal = fileChooser.showDialog(ClusteringControl.this, "Open");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File filePath = fileChooser.getSelectedFile();
                if (xmlFilter.accept(filePath)) {
                    PNode restoredLabels = null;
                    try {
                        restoredLabels = LabelXmlUtils.restoreLabelsFromFile(fileChooser.getSelectedFile());
                        PNode manual = state.mapPNode.getManualLabels();

                        ArrayList<PNode> tmp = new ArrayList<PNode>();
                        for (ListIterator<?> iter = restoredLabels.getChildrenIterator(); iter.hasNext();) {
                            PNode element = (PNode) iter.next();
                            tmp.add(element);
                        }
                        manual.addChildren(tmp);
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Successfully loaded cluster labels.");
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Error loading cluster labels: " + e1.getMessage());
                    }

                } else {

                    try {
                        FileInputStream fis = new FileInputStream(filePath);
                        GZIPInputStream gzipIs = new GZIPInputStream(fis);
                        ObjectInputStream ois = new ObjectInputStream(gzipIs);
                        ClusteringTree tree = (ClusteringTree) ois.readObject();

                        PNode manual = (PNode) ois.readObject();
                        PNode all = mapPane.getMap().getManualLabels();
                        ArrayList<PNode> tmp = new ArrayList<PNode>();
                        for (ListIterator<?> iter = manual.getChildrenIterator(); iter.hasNext();) {
                            PNode element = (PNode) iter.next();
                            tmp.add(element);
                        }
                        all.addChildren(tmp);

                        state.clusterWithLabels = ois.readInt();
                        labelSpinner.setValue(state.clusterWithLabels);
                        state.labelsWithValues = ois.readBoolean();
                        showValues.setSelected(state.labelsWithValues);
                        state.clusterByValue = ois.readDouble();
                        valueQe.setValue(new Double((1 - state.clusterByValue) * 100).intValue());

                        mapPane.getMap().buildTree(tree);
                        spinnerNoCluster.setValue(ois.readObject());

                        ois.close();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Successfully loaded clustering.");
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        Logger.getLogger("at.tuwien.ifs.somtoolbox")
                                .info("Error loading clustering: " + ex.getMessage());
                    }

                }
                // keep the selected path for future references
                state.fileChooser.setSelectedFile(filePath.getParentFile());
            }
        }

    });
    panelButtons.add(loadButton);

    JButton exportImages = new JButton("Export");
    exportImages.setFont(smallFont);
    exportImages.setMargin(SMALL_INSETS);
    exportImages.setToolTipText("Export labels as images (not yet working)");
    exportImages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            if (CommonSOMViewerStateData.fileNamePrefix != null
                    && !CommonSOMViewerStateData.fileNamePrefix.equals("")) {
                fileChooser.setCurrentDirectory(new File(CommonSOMViewerStateData.fileNamePrefix));
            } else {
                fileChooser.setCurrentDirectory(state.getFileChooser().getCurrentDirectory());
            }
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (fileChooser.getSelectedFile() != null) { // reusing the dialog
                fileChooser.setSelectedFile(null);
            }
            fileChooser.setName("Choose path");
            int returnVal = fileChooser.showDialog(ClusteringControl.this, "Choose path");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                // save images
                String path = fileChooser.getSelectedFile().getAbsolutePath();
                Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Writing label images to " + path);
            }
        }
    });
    panelButtons.add(exportImages);

    JButton deleteManual = new JButton("Delete");
    deleteManual.setFont(smallFont);
    deleteManual.setMargin(SMALL_INSETS);
    deleteManual.setToolTipText("Delete manually added labels.");
    deleteManual.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            state.mapPNode.getManualLabels().removeAllChildren();
            Logger.getLogger("at.tuwien.ifs.somtoolbox").info("Manual Labels deleted.");
        }
    });
    panelButtons.add(deleteManual);
    c.anchor = GridBagConstraints.NORTH;
    this.getContentPane().add(panelButtons, c.nextRow());

    this.setVisible(true);
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelForReportTypeInfo() {
    if (jPanelForReportTypeInfo == null) {
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.gridx = -1;//w  w  w. java  2s.c  o  m
        gridBagConstraints5.gridy = -1;
        gridBagConstraints5.gridwidth = 1;
        gridBagConstraints5.anchor = GridBagConstraints.CENTER;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.weighty = 0.0;
        gridBagConstraints5.insets = new Insets(0, 10, 5, 150); // margin // top, left, bottom, right
        jPanelForReportTypeInfo = new JPanel();
        jPanelForReportTypeInfo.setLayout(new GridBagLayout());
        jPanelForReportTypeInfo.setBorder(BorderFactory.createTitledBorder(null, "Report Type",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelForReportTypeInfo.add(getJPanelReportTypeInfo(), gridBagConstraints5);
    }
    return jPanelForReportTypeInfo;
}

From source file:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java

private void getPanel() {
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createTitledBorder(Language.getLabel(20))); // File
    final GridBagConstraints c = new GridBagConstraints();
    int gridy = 0;

    // btn load//from w  w  w . j  a v  a2  s.c  o m
    c.gridx = 0;
    c.gridy = gridy;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(1, 1, 1, 1);
    strLoad = Language.getLabel(21); // Load
    btnLoad = new JButton(strLoad);
    btnLoad.addActionListener(this);
    add(btnLoad, c);
    // btn update
    c.gridx = 1;
    c.gridy = gridy;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(1, 1, 1, 1);
    strUpdate = Language.getLabel(110); // Update
    btnUpdate = new JButton(strUpdate);
    btnUpdate.addActionListener(this);
    btnUpdate.setEnabled(false);
    add(btnUpdate, c);
    gridy++;

    // txt file name
    c.gridx = 0;
    c.gridy = gridy;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(1, 1, 1, 1);
    txtFileName = new JTextField();
    txtFileName.setText(Language.getLabel(112)); // No file loaded
    txtFileName.addActionListener(this);
    txtFileName.setEditable(false);
    add(txtFileName, c);
    gridy++;

    // progress bar
    c.gridx = 0;
    c.gridy = gridy;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(1, 1, 1, 1);
    progressBar = new JProgressBar(0, 100);
    progressBar.setStringPainted(true);
    progressBar.setString("");
    progressBar.setBorderPainted(false);
    progressBar.setValue(0);
    add(progressBar, c);
    gridy++;
}

From source file:course_generator.param.frmEditCurve.java

/**
 * This method is called to initialize the form.
 *//*from   ww  w .  j a v  a  2s.  c o  m*/
private void initComponents() {
    int line = 0;

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("frmEditCurve.title"));
    setPreferredSize(new Dimension(1200, 600));
    setAlwaysOnTop(true);
    setResizable(false);
    setType(java.awt.Window.Type.UTILITY);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());

    //-- Curves list
    ListCurves = new javax.swing.JList<>();
    model = new ParamListModel();
    ListCurves.setModel(model);
    ListCurves.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    ListCurves.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            SelectCurve();
        }
    });
    jScrollPaneCurves = new javax.swing.JScrollPane();
    jScrollPaneCurves.setViewportView(ListCurves);

    Utils.addComponent(paneGlobal, jScrollPaneCurves, 0, 0, 1, 4, 0.5, 1, 10, 10, 0, 0,
            GridBagConstraints.PAGE_START, GridBagConstraints.BOTH);

    //-- Curve management toolbar
    CreateCurvesToolbar();
    Utils.addComponent(paneGlobal, ToolBarAction, 1, 0, 1, 4, 0, 0, 10, 0, 0, 0,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

    lbSelectedCurve = new javax.swing.JLabel();
    lbSelectedCurve.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbSelectedCurve.setText("Selected");
    lbSelectedCurve.setHorizontalAlignment(JLabel.LEFT);
    Utils.addComponent(paneGlobal, lbSelectedCurve, 2, 0, GridBagConstraints.REMAINDER, 1, 1, 0, 10, 0, 5, 10,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);

    //-- Curve name
    lbName = new javax.swing.JLabel();
    lbName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbName.setText(" " + bundle.getString("frmEditCurve.lbName.text") + " ");
    Utils.addComponent(paneGlobal, lbName, 2, 1, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING,
            GridBagConstraints.HORIZONTAL);

    lbNameVal = new javax.swing.JLabel();
    lbNameVal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(paneGlobal, lbNameVal, 3, 1, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

    //-- Curve comment
    lbComment = new javax.swing.JLabel();
    lbComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbComment.setText(" " + bundle.getString("frmEditCurve.lbComment.text") + " ");
    Utils.addComponent(paneGlobal, lbComment, 2, 2, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING,
            GridBagConstraints.HORIZONTAL);

    tfComment = new JTextField();
    tfComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(paneGlobal, tfComment, 3, 2, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);

    //-- Point list
    TablePoints = new javax.swing.JTable();
    TablePoints.setModel(tablemodel);//new ParamPointsModel(param));
    TablePoints.getTableHeader().setReorderingAllowed(false);
    TablePoints.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            //            TableMainMouseClicked(evt);
        }
    });
    TablePoints.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            //            TableMainKeyReleased(evt);
        }
    });

    jScrollPanePoint = new javax.swing.JScrollPane();
    jScrollPanePoint.setViewportView(TablePoints);
    Utils.addComponent(paneGlobal, jScrollPanePoint, 2, 3, 2, 1, 0.5, 0, 0, 0, 0, 0,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

    //-- Edit toolbar
    CreateEditToolbar();
    Utils.addComponent(paneGlobal, ToolBarEdit, 4, 3, 1, 1, 0, 0, 0, 0, 0, 0,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);

    jPanelProfilChart = new ChartPanel(chart);
    Utils.addComponent(paneGlobal, jPanelProfilChart, 5, 3, 1, 1, 1, 0, 0, 0, 0, 10,
            GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);

    yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    yCrosshair.setLabelVisible(true);
    yCrosshair.setLabelBackgroundPaint(Color.WHITE);

    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);

    jPanelProfilChart.addOverlay(crosshairOverlay);
    jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51));
    jPanelProfilChart.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent event) {

            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                yCrosshair.setValue(y);
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });

    // == Bottom button
    // ===========================================================
    btOk = new javax.swing.JButton();
    btOk.setText(bundle.getString("frmEditCurve.btOk.text"));
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    Utils.addComponent(paneGlobal, btOk, 0, 5, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 0, 10, 0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE);

    // --
    pack();

    //-- Refresh the curve list
    RefreshCurveList();

    //-- Center the windows
    setLocationRelativeTo(null);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java

/**
 * This method initializes this/* w w w. j a  va  2  s  .  c  o m*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
    gridBagConstraints15.gridx = 1;
    gridBagConstraints15.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints15.gridy = 0;
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.gridx = 1;
    jLabelLicense = new JLabel();
    jLabelLicense.setText("License :");
    jLabelLicense.setFont(new Font("Dialog", Font.PLAIN, 12));
    jLabelComponent = new JLabel();
    jLabelComponent.setText("Component :");
    jLabelComponent.setFont(new Font("Dialog", Font.PLAIN, 12));
    this.setSize(570, 480);
    this.setLayout(new GridBagLayout());
    this.setBorder(BorderFactory.createTitledBorder(null, "Identification Information",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
    this.add(getJSplitPane(), gridBagConstraints);
    this.add(getJScrollLabel(), gridBagConstraints15);

    getJPanMatchedSourceViewLeft().addScrollAdjustmentObserver(getJPanMatchedSourceViewRight());
    getJPanMatchedSourceViewRight().addScrollAdjustmentObserver(getJPanMatchedSourceViewLeft());

}

From source file:com.vgi.mafscaling.LogPlay.java

private void createPlayer(JPanel panel) {
    playerPanel = new JPanel();
    GridBagLayout gbl_playerPanel = new GridBagLayout();
    gbl_playerPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_playerPanel.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_playerPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    gbl_playerPanel.rowWeights = new double[] { 0.0, 0.0 };
    playerPanel.setLayout(gbl_playerPanel);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = insets0;//w ww.  ja v  a2 s . c  om
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 0;

    progressBar = new JSlider(0, 0, 0);
    progressBar.setMinimum(0);
    progressBar.setMaximum(lastRow);
    setProgressBar(logDataTable.getSelectedRow());
    progressBar.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int row = progressBar.getValue();
            if (playing) {
                if (row == lastRow || (endPlay >= 0 && endPlay < row)) {
                    stop();
                    return;
                }
                if (showMarker) {
                    Rectangle2D dataArea = logView.getChartPanel().getChartRenderingInfo().getPlotInfo()
                            .getDataArea();
                    XYPlot plot = (XYPlot) logView.getChartPanel().getChart().getPlot();
                    double x = plot.getDomainAxis().valueToJava2D(row, dataArea, plot.getDomainAxisEdge());
                    boolean isLeft = (x < (dataArea.getMaxX() - dataArea.getMinX()) / 2) ? true : false;
                    logView.setMarkers(row, isLeft);
                }
            }
            logDataTable.getTable().setRowSelectionInterval(row, row);
            logDataTable.getTable().changeSelection(row, logDataTable.getSelectedColumn(), false, false);
            double x, y, z;
            int origXCol, origYCol, origZCol;
            synchronized (lock) {
                for (TableHolder tableHolder : tables) {
                    try {
                        origXCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.xColIdx);
                        origYCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.yColIdx);
                        origZCol = logDataTable.getCurrentIndexForOriginalColumn(tableHolder.zColIdx);
                        x = Double.valueOf(logDataTable.getValueAt(row, origXCol).toString());
                        y = Double.valueOf(logDataTable.getValueAt(row, origYCol).toString());
                        if (origZCol > 0)
                            z = Double.valueOf(logDataTable.getValueAt(row, origZCol).toString());
                        else
                            z = Double.NaN;
                        tableHolder.table.setCurrentPoint(x, y, z);
                    } catch (Exception ex) {
                        JOptionPane
                                .showMessageDialog(null,
                                        "Invalid numeric value in column " + (tableHolder.xColIdx + 1)
                                                + ", row " + (row + 1),
                                        "Invalid value", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            }
        }
    });
    gbc.weightx = 1.0;
    gbc.gridwidth = gbl_playerPanel.columnWidths.length;
    playerPanel.add(progressBar, gbc);

    stopButton = addPlayerButton(0, new ImageIcon(getClass().getResource("/stop.png")));
    rewButton = addPlayerButton(1, new ImageIcon(getClass().getResource("/rew.png")));
    playButton = addPlayerButton(2, playIcon);
    ffwButton = addPlayerButton(3, new ImageIcon(getClass().getResource("/ffw.png")));
    showIntepCells = addCheckBox(4, "Show interpolation cells");
    showSignifCells = addCheckBox(5, "Show significant cell");
    showTraceLine = addCheckBox(6, "Show trace line");
    showTraceMarker = addCheckBox(7, "Show plot trace marker");

    gbc.weightx = 0.0;
    gbc.gridwidth = 0;
    gbc.gridy = 1;
    panel.add(playerPanel, gbc);
}

From source file:org.intermine.install.swing.NewDerivedTypeDialog.java

/**
 * Initialise to show the properties needed to complete to create the
 * derived source from the given parent.
 * //from w  ww.ja  v a 2  s.  c o  m
 * @param project The Project being edited.
 * @param parentType The parent data source type descriptor.
 * @param name The name of the actual data source to add to the project.
 */
public void initialise(Project project, SourceInfo parentType, String name) {
    Container cp = getContentPane();

    this.project = project;
    parentInfo = parentType;

    nameField.setText(name);
    typeField.setText(parentType.getSource().getType());
    derivedTypeField.setText(name);

    for (JComponent c : additionalFields) {
        cp.remove(c);
    }
    cp.remove(spacerPanel);
    cp.remove(buttonPanel);

    additionalFields.clear();
    wrappers.clear();

    GridBagConstraints cons = GridBagHelper.defaultConstraints();

    cons.gridy = 3;

    SourceTypeDerivation derivation = parentInfo.getSource().getDerivation();
    assert derivation != null : "No derivation on source";
    for (PropertyDescriptor descriptor : derivation.getProperty()) {

        JLabel label = new JLabel(descriptor.getName());
        cons.gridx = 0;
        cons.weightx = 0;
        cp.add(label, cons);
        additionalFields.add(label);

        PropertyComponentWrapper wrapper = PropertyComponentCreator.createComponentFor(descriptor.getName(),
                descriptor, "");
        cons.weightx = 1;
        cons.gridx++;
        cp.add(wrapper.getDisplayComponent(), cons);
        additionalFields.add(wrapper.getDisplayComponent());
        wrappers.add(wrapper);

        cons.gridy++;
    }

    cons.gridx = 0;
    cons.weightx = 1;
    cons.weighty = 1;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.fill = GridBagConstraints.BOTH;
    cp.add(spacerPanel, cons);

    cons.gridy++;
    cons.weighty = 0;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cp.add(buttonPanel, cons);

    pack();
}

From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java

/** 
 * Builds hosting the various sliders/*from w w w.  j  a  v  a 2 s .  co  m*/
 * 
 * @return See above.
 */
private JPanel buildGeneralPane() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridy = 0;
    c.gridx = 0;
    if (model.isGeneralIndex()) {
        content.add(previewToolBar, c);
        c.gridy++;
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.HORIZONTAL;
        content.add(new JSeparator(), c);
        c.gridy++;
    }
    content.add(controlsBar, c);
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE;//reset to default
    c.weightx = 0.0;

    Iterator<ChannelSlider> i = sliders.iterator();
    while (i.hasNext()) {
        c.gridy++;
        content.add(i.next(), c);
    }
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    content.add(viewedBy, c);
    JPanel p = UIUtilities.buildComponentPanel(content);
    p.setBackground(content.getBackground());
    return p;
}

From source file:org.pentaho.mondrian.publish.RepositoryLoginDialog.java

private JPanel buildPublishSettingsPanel(String jndiName, boolean enableXmla) {
    JPanel publishSettingsPanel = new JPanel(new GridBagLayout());
    publishSettingsPanel.setBorder(BorderFactory
            .createTitledBorder(Messages.getString("PublishToServerCommand.PublishSettingsTitle"))); //$NON-NLS-1$
    GridBagConstraints c = new GridBagConstraints();

    c.insets = new Insets(5, 5, 0, 5);
    c.gridwidth = 2;//from  ww w.  ja  v a2  s.  co  m
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    publishSettingsPanel.add(new JLabel(Messages.getString("PublishToServerCommand.DatasourceLabel")), c); //$NON-NLS-1$

    c.insets = new Insets(5, 5, 5, 0);
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    jndiDataSourceName.setText(jndiName);
    publishSettingsPanel.add(jndiDataSourceName, c);

    enableXmlaCheckBox.setSelected(enableXmla);
    c.gridwidth = 2;
    c.insets = new Insets(5, 5, 5, 5);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1.0;
    publishSettingsPanel.add(enableXmlaCheckBox, c);

    c.weightx = 0.0;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridx = 0;
    c.gridy = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    getContentPane().add(publishSettingsPanel, c);

    return publishSettingsPanel;
}