Example usage for javax.swing DefaultListCellRenderer DefaultListCellRenderer

List of usage examples for javax.swing DefaultListCellRenderer DefaultListCellRenderer

Introduction

In this page you can find the example usage for javax.swing DefaultListCellRenderer DefaultListCellRenderer.

Prototype

public DefaultListCellRenderer() 

Source Link

Document

Constructs a default renderer object for an item in a list.

Usage

From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java

private JPanel getFilterPanel() {
    JPanel ret = new JPanel();
    ret.setBorder(BorderFactory.createTitledBorder(
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.filters")));
    ret.setLayout(new BorderLayout());

    GeocatalogFilterDecorator filter = new GeocatalogFilterDecorator("geocatalog.filters.AllExcludeSystemTable",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.allExceptFilter"),
            new AllExcludeSytemTableFilter());
    listModel.getFilters().add(filter);//from  w  w  w.j  a va 2s.c  o  m

    filter = new GeocatalogFilterDecorator("geocatalog.filters.GeoFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.geoFilter"),
            new GeoFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.FilesFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.fileFilter"),
            new FilesFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.DBsFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.dbFilter"), new DBsFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.AlphanumericFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.alphanumericFilter"),
            new AlphanumericFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.WMSFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.wmsFilter"),
            new WMSFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.RasterFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.rasterFilter"),
            new RasterFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.VectorialFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.vectorialFilter"),
            new VectorialFilter());
    listModel.getFilters().add(filter);

    filter = new GeocatalogFilterDecorator("geocatalog.filters.SystemTableFilter",
            I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.systemTableFilter"),
            new TableSystemFilter());
    listModel.getFilters().add(filter);

    // TODO maybe improve the default filter set.
    // new GeocatalogFilterDecorator[1]
    lstFilters = new JList(
            listModel.getFilters().toArray(new GeocatalogFilterDecorator[1])/* getAvailableFilters() */);
    lstFilters.setCellRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            return super.getListCellRendererComponent(list, ((GeocatalogFilterDecorator) value).getName(),
                    index, isSelected, cellHasFocus);
        }
    });
    lstFilters.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            doFilter();
        }
    });
    lstFilters.setVisibleRowCount(FILTER_VISIBLE_ROW_COUNT);
    JScrollPane scroll = new JScrollPane(lstFilters);
    ret.add(scroll, BorderLayout.CENTER);
    return ret;
}

From source file:org.signserver.admin.gui.ViewCertificateFrame.java

public ViewCertificateFrame(final List<X509Certificate> certificates) {
    this.certificates = certificates;
    this.certificate = certificates.get(0);
    initComponents();//ww w . j  a  v a 2s.c  o m
    chainList.setModel(new AbstractListModel() {

        @Override
        public int getSize() {
            return certificates.size();
        }

        @Override
        public Object getElementAt(int index) {
            return certificates.get(index);
        }
    });
    chainList.setCellRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(final JList list, Object value, final int index,
                final boolean isSelected, final boolean cellHasFocus) {
            if (value instanceof X509Certificate) {
                final X509Certificate cert = (X509Certificate) value;
                value = cert.getSubjectDN().getName();
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }

    });
    chainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                viewCertificate((X509Certificate) chainList.getSelectedValue());
            }
        }
    });

    fieldsList.setCellRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(final JList list, Object value, final int index,
                final boolean isSelected, final boolean cellHasFocus) {
            if (value instanceof Field) {
                value = ((Field) value).getName();
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }

    });
    fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                viewFieldValue((Field) fieldsList.getSelectedValue());
            }
        }
    });

    subjectTextArea.setText(certificate.getSubjectDN().getName());
    issuerTextArea.setText(certificate.getIssuerDN().getName());
    serialNumberField.setText(certificate.getSerialNumber().toString(16));
    notBeforeLabel.setText(String.valueOf(certificate.getNotBefore()));
    notAfterLabel.setText(String.valueOf(certificate.getNotAfter()));

    String fingerprint = "";
    try {
        fingerprint = calcFingerprint(certificate.getEncoded());
    } catch (CertificateEncodingException ex) {
        LOG.error("Error calculating certificate fingerprint", ex);
    }
    fingerprintLabel.setText(fingerprint);

    usages = new ArrayList<String>();
    boolean[] keyUsages = certificate.getKeyUsage();
    if (keyUsages != null) {
        // digitalSignature        (0),
        if (keyUsages[0]) {
            usages.add("digitalSignature");
        }
        // nonRepudiation          (1),
        if (keyUsages[1]) {
            usages.add("nonRepudiation");
        }
        // keyEncipherment         (2),
        if (keyUsages[2]) {
            usages.add("keyEncipherment");
        }
        // dataEncipherment        (3),
        if (keyUsages[3]) {
            usages.add("dataEncipherment");
        }
        // keyAgreement            (4),
        if (keyUsages[4]) {
            usages.add("keyAgreement");
        }
        // keyCertSign             (5),
        if (keyUsages[5]) {
            usages.add("keyCertSign");
        }
        // cRLSign                 (6),
        if (keyUsages[6]) {
            usages.add("cRLSign");
        }
        // encipherOnly            (7),
        if (keyUsages[7]) {
            usages.add("encipherOnly");
        }
        // decipherOnly
        if (keyUsages[8]) {
            usages.add("decipherOnly");
        }
    }

    try {
        final List<String> eku = certificate.getExtendedKeyUsage();
        if (eku != null) {
            usages.addAll(eku);
        }
    } catch (CertificateParsingException ex) {
        LOG.error("Error getting extended key usage", ex);
    }

    usagesList.setModel(new AbstractListModel() {

        @Override
        public int getSize() {
            return usages.size();
        }

        @Override
        public Object getElementAt(int index) {
            return usages.get(index);
        }
    });

    chainList.setSelectedIndex(0);
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

private ListCellRenderer getListCellRenderer(final IndicatorProjectManager projectManager) {
    return new DefaultListCellRenderer() {
        @Override//from   ww w  .  j a v  a 2s .  co m
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            if (component != null && value != null) {
                final OperatorIndicator operatorIndicator = projectManager
                        .getOperatorIndicator(value.toString());
                if (operatorIndicator != null
                        && operatorIndicator.getType() != projectManager.getPreferredOperatorIndicatorType()) {
                    final Font oldFont = component.getFont();
                    component.setFont(oldFont.deriveFont(oldFont.getStyle() | Font.ITALIC));
                }
            }
            return component;
        }
    };
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void initComponents() {
    characterBox.setRenderer(new DefaultListCellRenderer() {

        @Override/*from w  ww. jav  a  2 s . co  m*/
        public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            CharacterFacade character = (CharacterFacade) value;
            return super.getListCellRendererComponent(list, character.getNameRef().get(), index, isSelected,
                    cellHasFocus);
        }

    });

    fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileList.addListSelectionListener(this);

    exportButton.setDefaultCapable(true);
    getRootPane().setDefaultButton(exportButton);

    partyBox.setActionCommand(PARTY_COMMAND);
    exportBox.setActionCommand(EXPORT_TO_COMMAND);
    exportButton.setActionCommand(EXPORT_COMMAND);
    closeButton.setActionCommand(CLOSE_COMMAND);

    exportBox.addActionListener(this);
    partyBox.addActionListener(this);
    exportButton.addActionListener(this);
    closeButton.addActionListener(this);

    exportButton.setEnabled(false);
    progressBar.setStringPainted(true);
    progressBar.setString("Loading Templates");
    progressBar.setIndeterminate(true);

    setTitle("Export a PC or Party");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    UIPropertyContext context = UIPropertyContext.createContext("ExportDialog");
    String defaultOSType = context.getProperty(UIPropertyContext.DEFAULT_OS_TYPE);
    if (defaultOSType != null) {
        for (SheetFilter filter : SheetFilter.values()) {
            if (defaultOSType.equals(filter.toString())) {
                exportBox.setSelectedItem(filter);
            }
        }
    }
}

From source file:pcgen.gui2.dialog.PrintPreviewDialog.java

private <E> void initComponents() {
    setTitle("Print Preview");
    sheetBox.setRenderer(new DefaultListCellRenderer() {

        @Override/*from   w w w.  j  a  va  2s .c o  m*/
        public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
                setToolTipText(value.toString());
            }
            return this;
        }

    });
    sheetBox.setActionCommand(SHEET_COMMAND);
    sheetBox.addActionListener(this);
    pageBox.addItem("0 of 0");
    pageBox.setActionCommand(PAGE_COMMAND);
    pageBox.addActionListener(this);
    zoomBox.addItem(0.25);
    zoomBox.addItem(0.50);

    zoomBox.addItem(0.75);
    zoomBox.addItem(1.00);
    zoomBox.setSelectedItem(0.75);
    zoomBox.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<? extends Object> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            NumberFormat format = NumberFormat.getPercentInstance();
            String formattedValue = format.format(value);
            return super.getListCellRendererComponent(list, formattedValue, index, isSelected, cellHasFocus);
        }

    });
    zoomBox.setEditable(true);
    zoomBox.setEditor(new PercentEditor(zoomBox));
    zoomBox.setActionCommand(ZOOM_COMMAND);
    zoomBox.addActionListener(this);
    zoomInButton.setIcon(Icons.ZoomIn16.getImageIcon());
    zoomInButton.setActionCommand(ZOOM_IN_COMMAND);
    zoomInButton.addActionListener(this);
    zoomOutButton.setIcon(Icons.ZoomOut16.getImageIcon());
    zoomOutButton.setActionCommand(ZOOM_OUT_COMMAND);
    zoomOutButton.addActionListener(this);

    printButton.setText("Print");
    printButton.setActionCommand(PRINT_COMMAND);
    printButton.addActionListener(this);

    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CANCEL_COMMAND);
    cancelButton.addActionListener(this);

    enableEditGroup(false);

    Utility.installEscapeCloseOperation(this);
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildCameraPane() {
    JLabel projectionModeLbl = new JLabel("Projection");

    fov.update();//  w  ww.j a va2 s.  c om

    dof = new DoFAdjuster(renderMan);
    dof.update();

    subjectDistance.update();

    JLabel presetLbl = new JLabel("Preset:");
    CameraPreset[] presets = { CameraPreset.NONE, CameraPreset.ISO_WEST_NORTH, CameraPreset.ISO_NORTH_EAST,
            CameraPreset.ISO_EAST_SOUTH, CameraPreset.ISO_SOUTH_WEST, CameraPreset.SKYBOX_RIGHT,
            CameraPreset.SKYBOX_LEFT, CameraPreset.SKYBOX_UP, CameraPreset.SKYBOX_DOWN,
            CameraPreset.SKYBOX_FRONT, CameraPreset.SKYBOX_BACK, };
    cameraPreset.setModel(new DefaultComboBoxModel(presets));
    cameraPreset.setMaximumRowCount(presets.length);
    final int presetHeight = cameraPreset.getPreferredSize().height;
    final int presetWidth = cameraPreset.getPreferredSize().width;
    cameraPreset.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            label.setPreferredSize(new Dimension(presetWidth, presetHeight));
            CameraPreset preset = (CameraPreset) value;
            label.setIcon(preset.getIcon());
            return label;
        }
    });
    cameraPreset.addActionListener(cameraPresetListener);

    JLabel customPresetLbl = new JLabel("Custom preset:");
    customPreset.setEditable(true);
    updateCustomPresets();
    JButton savePreset = new JButton("save");
    savePreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
                if (name.isEmpty()) {
                    // auto-assign name
                    int nextIndex = customPreset.getItemCount() + 1;
                    outer: while (true) {
                        name = "custom-" + (nextIndex++);
                        for (int i = 0; i < customPreset.getItemCount(); ++i) {
                            String item = (String) customPreset.getItemAt(i);
                            if (name.equals(item)) {
                                continue outer;
                            }
                        }
                        break;
                    }
                } else {
                    for (int i = 0; i < customPreset.getItemCount(); ++i) {
                        String item = (String) customPreset.getItemAt(i);
                        if (name.equals(item)) {
                            selected = i;
                            break;
                        }
                    }
                }
                if (selected == -1) {
                    // add new preset
                    selected = customPreset.getItemCount();
                    customPreset.addItem(name);

                }
                customPreset.setSelectedIndex(selected);
            } else {
                name = (String) customPreset.getSelectedItem();
            }
            renderMan.scene().saveCameraPreset(name);
        }
    });
    JButton loadPreset = new JButton("load");
    loadPreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
            } else {
                name = ((String) customPreset.getSelectedItem()).trim();
            }
            if (!name.isEmpty()) {
                renderMan.scene().loadCameraPreset(name);
            }
        }
    });
    JButton deletePreset = new JButton("delete");
    deletePreset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String name = "";
            int selected = customPreset.getSelectedIndex();
            if (selected == -1) {
                // select name
                name = (String) customPreset.getEditor().getItem();
                name = (name == null) ? "" : name.trim();
            } else {
                name = ((String) customPreset.getSelectedItem()).trim();
            }
            if (!name.isEmpty()) {
                renderMan.scene().deleteCameraPreset(name);
                if (selected != -1) {
                    customPreset.removeItemAt(selected);
                } else {
                    for (int i = 0; i < customPreset.getItemCount(); ++i) {
                        if (name.equals(customPreset.getItemAt(i))) {
                            customPreset.removeItemAt(i);
                            break;
                        }
                    }
                }
            }
        }
    });

    ProjectionMode[] projectionModes = ProjectionMode.values();
    projectionMode.setModel(new DefaultComboBoxModel(projectionModes));
    projectionMode.addActionListener(projectionModeListener);
    updateProjectionMode();

    JButton autoFocusBtn = new JButton("Autofocus");
    autoFocusBtn.setToolTipText("Focuses on the object right in the center, under the crosshairs");
    autoFocusBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().autoFocus();
            dof.update();
            subjectDistance.update();
        }
    });

    JButton cameraToPlayerBtn = new JButton("Camera to player");
    cameraToPlayerBtn.setToolTipText("Move camera to player position");
    cameraToPlayerBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().moveCameraToPlayer();
        }
    });

    JLabel posLbl = new JLabel("Position:");
    cameraX.setColumns(10);
    cameraX.setHorizontalAlignment(JTextField.RIGHT);
    cameraX.addActionListener(cameraPositionListener);
    cameraY.setColumns(10);
    cameraY.setHorizontalAlignment(JTextField.RIGHT);
    cameraY.addActionListener(cameraPositionListener);
    cameraZ.setColumns(10);
    cameraZ.setHorizontalAlignment(JTextField.RIGHT);
    cameraZ.addActionListener(cameraPositionListener);
    updateCameraPosition();

    JLabel dirLbl = new JLabel("Direction:");
    cameraYaw.setColumns(10);
    cameraYaw.setHorizontalAlignment(JTextField.RIGHT);
    cameraYaw.addActionListener(cameraDirectionListener);
    cameraPitch.setColumns(10);
    cameraPitch.setHorizontalAlignment(JTextField.RIGHT);
    cameraPitch.addActionListener(cameraDirectionListener);
    cameraRoll.setColumns(10);
    cameraRoll.setHorizontalAlignment(JTextField.RIGHT);
    cameraRoll.addActionListener(cameraDirectionListener);
    updateCameraDirection();

    JButton centerCameraBtn = new JButton("Center camera");
    centerCameraBtn.setToolTipText("Center camera above loaded chunks");
    centerCameraBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().moveCameraToCenter();
        }
    });

    JSeparator sep1 = new JSeparator();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup().addComponent(posLbl).addComponent(dirLbl))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraX, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraYaw, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraY, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraPitch, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup()
                                    .addComponent(cameraZ, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cameraRoll, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)))
                            .addGroup(layout.createSequentialGroup().addComponent(presetLbl)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(cameraPreset))
                            .addGroup(layout.createSequentialGroup().addComponent(customPresetLbl)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(customPreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(savePreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(loadPreset)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(deletePreset))
                            .addGroup(layout.createSequentialGroup().addComponent(cameraToPlayerBtn)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(centerCameraBtn))
                            .addComponent(sep1)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup().addComponent(projectionModeLbl)
                                            .addComponent(fov.getLabel()).addComponent(dof.getLabel())
                                            .addComponent(subjectDistance.getLabel()))
                                    .addGroup(layout.createParallelGroup().addComponent(projectionMode)
                                            .addComponent(fov.getSlider()).addComponent(dof.getSlider())
                                            .addComponent(subjectDistance.getSlider()))
                                    .addGroup(layout.createParallelGroup().addComponent(fov.getField())
                                            .addComponent(dof.getField())
                                            .addComponent(subjectDistance.getField())))
                            .addComponent(autoFocusBtn))
                    .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout
                    .createParallelGroup(Alignment.BASELINE).addComponent(presetLbl).addComponent(cameraPreset))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(customPresetLbl)
                    .addComponent(customPreset).addComponent(savePreset).addComponent(loadPreset)
                    .addComponent(deletePreset))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(posLbl).addComponent(cameraX)
                    .addComponent(cameraY).addComponent(cameraZ))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(dirLbl)
                    .addComponent(cameraYaw).addComponent(cameraPitch).addComponent(cameraRoll))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(
                    layout.createParallelGroup().addComponent(cameraToPlayerBtn).addComponent(centerCameraBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(
                    sep1, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(projectionModeLbl)
                    .addComponent(projectionMode))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(fov.verticalGroup(layout))
            .addGroup(dof.verticalGroup(layout)).addGroup(subjectDistance.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(autoFocusBtn).addContainerGap());
    return panel;
}

From source file:test.uk.co.modularaudio.util.swing.mvc.combo.Tester.java

public void go() throws Exception {
    final List<IdStringComboItem> sampleItems = new ArrayList<IdStringComboItem>();
    sampleItems.add(new IdStringComboItem("thin", "Nasty, thin, toilet paper"));
    sampleItems.add(new IdStringComboItem("sand", "Harsh, sandpaper like bog roll"));

    final RealComboModel rcm = new RealComboModel(sampleItems);
    final RealComboController rcc = new RealComboController(rcm);
    // Now check the model is indeed updated
    debugModel(rcm);/*from  www  .  j a v  a2s . c om*/

    final ComboModelListener<IdStringComboItem> myListener = new ComboModelListener<IdStringComboItem>() {
        @Override
        public void contentsChanged(final ComboModelListenerEvent e) {
            log.debug("Contents changed event: " + e.toString());
            // Now debug it
            debugModel(rcm);
        }

        @Override
        public void intervalAdded(final ComboModelListenerEvent e) {
            log.debug("Interval added event: " + e.toString());
        }

        @Override
        public void intervalRemoved(final ComboModelListenerEvent e) {
            log.debug("Interval removed event: " + e.toString());
        }

        @Override
        public void selectionChanged(final ComboModelListenerEvent e) {
            log.debug("Selection changed event: " + e.toString());
            final int selectionIndex = e.getIndex0();
            final IdStringComboItem item = rcm.getElementAt(selectionIndex);
            log.debug("The id of the selection is now: " + item.getId());
        }
    };
    rcm.addListener(myListener);
    final MigLayoutStringHelper msh = new MigLayoutStringHelper();
    msh.addLayoutConstraint("fill");
    frame.setLayout(msh.createMigLayout());

    final IdStringComboViewListCellRenderer<IdStringComboItem> cr = new IdStringComboViewListCellRenderer<IdStringComboItem>(
            new DefaultListCellRenderer());
    final ComboView<IdStringComboItem> comboView = new ComboView<IdStringComboItem>(rcm, rcc, cr);
    comboView.setEditable(false);
    frame.add(comboView, "grow");
    final JLabel testLabel = new JLabel("Hmmphg");
    frame.add(testLabel, "");
    frame.setVisible(true);
}

From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java

private void initComponents() throws Exception {
    comboOptions = new UIComboOptions();
    if (!dao.isGuestMode()) {
        List<String> datasetNames = dao.getDatasetNames();
        // create inputs fields
        datasetCombo = new JComboBox(datasetNames.toArray(new String[datasetNames.size()]));
        datasetCombo//from  www.  j a v a2s. co m
                .setPrototypeDisplayValue("White-faced capuchin, ARTS Crofoot Barro Colorado Island, Panama");
        datasetCombo.setRenderer(new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index,
                    boolean isSelected, boolean cellHasFocus) {
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                if (index == -1) {
                    datasetCombo.setToolTipText(value.toString());
                    return this;
                }

                setToolTipText(value.toString());
                Rectangle textRect = new Rectangle(datasetCombo.getSize().width, getPreferredSize().height);
                String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()),
                        value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(),
                        getHorizontalTextPosition(), getVerticalTextPosition(), textRect, new Rectangle(),
                        textRect, getIconTextGap());
                setText(shortText);
                return this;
            }
        });
        AutoCompleteDecorator.decorate(datasetCombo);
        datasetLabel = new JLabel("Dataset: ");
    }
    /*Fei*/
    this.dMaxThresLabel = new JLabel("Dist thres(meters): ");
    this.lMaxThresLabel = new JLabel("Time thres(seconds): ");
    this.minIntervalLengthLabel = new JLabel("Min Interval Length(seconds): ");
    this.dMaxLabelTextedField = new JTextField(5);
    this.lMaxLabelTextedField = new JTextField(5);
    this.minIntervalLengthField = new JTextField(5);
    /**/
    functionCombo = new JComboBox(comboOptions.getFunctionOptions());
    displayMethodCombo = new JComboBox(comboOptions.getDvOption());
    gapCombo = new JComboBox(comboOptions.getGapOption());
    thresGapCombo = new JComboBox(comboOptions.getThresGapOption());
    numRoundCombo = new JComboBox(comboOptions.getNumRoundOption());
    functionLabel = new JLabel("Mining function: ");
    dvLabel = new JLabel("Display method: ");
    gapLabel = new JLabel("Gap(min): ");
    thresGapLabel = new JLabel("ThresGap(hr): ");
    numRoundLabel = new JLabel("# Rounds: ");
    instructionLabel = new JLabel("Please select a dataset and some parameters");
    distThresLabel = new JLabel("Dist thres(meters): ");
    this.interpLabel = new JLabel("Interpolate: ");
    distThresTextedField = new JTextField(5);
    downloadDatasetProgressBar = new JProgressBar(0, 100);
    downloadDatasetProgressBar.setValue(0);
    downloadDatasetProgressBar.setStringPainted(true);
    dataInterpolationHelpButton = new JButton("?");
    miningFucntionHelpButton = new JButton("?");
    miningFucntionParamsHelpButton = new JButton("?");
    this.miningFunctionParamsHelpButtonFollowing = new JButton("?");
    selectIndividualsButton = new JButton("Select individuals");
    selectIndividualsButton.addActionListener(this);
    saveKmlButton = new JButton("Get KML file");
    saveKmlButton.addActionListener(this);
    saveDensityMapButton = new JButton("Get density map");
    saveDensityMapButton.addActionListener(this);

}

From source file:UNUSED.JUNGsamples.ShowLayouts.java

private static JPanel getGraphPanel() {
    g_array = (Graph<? extends Object, ? extends Object>[]) new Graph<?, ?>[graph_names.length];

    Factory<Graph<Integer, Number>> graphFactory = new Factory<Graph<Integer, Number>>() {
        public Graph<Integer, Number> create() {
            return new SparseMultigraph<Integer, Number>();
        }//  w ww  .j a va 2  s.  c o  m
    };

    Factory<Integer> vertexFactory = new Factory<Integer>() {
        int count;

        public Integer create() {
            return count++;
        }
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int count;

        public Number create() {
            return count++;
        }
    };

    g_array[0] = TestGraphs.createTestGraph(false);
    g_array[1] = MixedRandomGraphGenerator.generateMixedRandomGraph(graphFactory, vertexFactory, edgeFactory,
            new HashMap<Number, Number>(), 20, true, new HashSet<Integer>());
    g_array[2] = TestGraphs.getDemoGraph();
    g_array[3] = TestGraphs.createDirectedAcyclicGraph(6, 40, 0.3);
    g_array[4] = TestGraphs.getOneComponentGraph();
    g_array[5] = TestGraphs.createChainPlusIsolates(60, 5);
    g_array[6] = TestGraphs.createChainPlusIsolates(0, 40);

    Graph<? extends Object, ? extends Object> g = g_array[4]; // initial graph

    final VisualizationViewer<Integer, Number> vv = new VisualizationViewer<Integer, Number>(new FRLayout(g));

    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow));

    final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    JButton reset = new JButton("reset");
    reset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Layout<Integer, Number> layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                //            if(layout instanceof IterativeContext) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener());

    JPanel jp = new JPanel();
    jp.setBackground(Color.WHITE);
    jp.setLayout(new BorderLayout());
    jp.add(vv, BorderLayout.CENTER);
    Class[] combos = getCombos();
    final JComboBox jcb = new JComboBox(combos);
    // use a renderer to shorten the layout name presentation
    jcb.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            String valueString = value.toString();
            valueString = valueString.substring(valueString.lastIndexOf('.') + 1);
            return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus);
        }
    });
    jcb.addActionListener(new LayoutChooser(jcb, vv));
    jcb.setSelectedItem(FRLayout.class);

    JPanel control_panel = new JPanel(new GridLayout(2, 1));
    JPanel topControls = new JPanel();
    JPanel bottomControls = new JPanel();
    control_panel.add(topControls);
    control_panel.add(bottomControls);
    jp.add(control_panel, BorderLayout.NORTH);

    final JComboBox graph_chooser = new JComboBox(graph_names);

    graph_chooser.addActionListener(new GraphChooser(jcb));

    topControls.add(jcb);
    topControls.add(graph_chooser);
    bottomControls.add(plus);
    bottomControls.add(minus);
    bottomControls.add(modeBox);
    bottomControls.add(reset);
    return jp;
}

From source file:vistas.dialogos.DlgEmpleadoCRUD.java

private void iniciar() {
    FormularioUtil.activarComponente(this.dcFechaInicio, true);
    FormularioUtil.activarComponente(this.dcFechaNacimiento, true);
    FormularioUtil.activarComponente(this.dcFechaInicio, true);

    cboTipoDocumento.setModel(new DefaultComboBoxModel(tdc.buscarTodos().toArray()));
    cboTipoDocumento.setRenderer(new DefaultListCellRenderer() {

        @Override//from   w w  w . j av a 2s .  c o  m
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            if (value instanceof TipoDocumento) {
                value = ((TipoDocumento) value).getNombre();
            }
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }

    });

    //        cboOficina.setModel(new DefaultComboBoxModel(dc.buscarTodos().toArray()));
    //        cboOficina.setRenderer(new DefaultListCellRenderer() {
    //
    //            @Override
    //            public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    //                if (value instanceof Departamento) {
    //                    value = ((Departamento) value).getNombre();
    //                }
    //                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
    //            }
    //
    //        });
    cboNivelEducativo.setModel(new DefaultComboBoxModel(nec.buscarTodos().toArray()));
    cboNivelEducativo.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            value = value instanceof NivelEducativo ? ((NivelEducativo) value).getDescripcion() : value;
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });

    cboTipoVia.setModel(new DefaultComboBoxModel(tvc.buscarTodos().toArray()));
    cboTipoVia.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            value = value instanceof TipoVia ? ((TipoVia) value).getAbreviatura() : value;
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });

    cboTipoZona.setModel(new DefaultComboBoxModel(tzc.buscarTodos().toArray()));
    cboTipoZona.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            value = value instanceof TipoZona ? ((TipoZona) value).getAbreviatura() : value;
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });

    cboTipoContrato.setModel(new DefaultComboBoxModel(tcc.buscarTodos().toArray()));
    cboTipoContrato.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            value = value instanceof TipoContrato ? ((TipoContrato) value).getDescripcion() : value;
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });

    cboRegimenLaboral.setModel(new DefaultComboBoxModel(rlc.buscarTodos().toArray()));
    cboRegimenLaboral.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            value = value instanceof RegimenLaboral ? ((RegimenLaboral) value).getNombre() : value;
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
        }
    });

    //        cboSituacionEmpleado.setModel(new DefaultComboBoxModel(stc.buscarTodos().toArray()));
    //        cboSituacionEmpleado.setRenderer(new DefaultListCellRenderer() {
    //            @Override
    //            public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    //                value = value instanceof SituacionTrabajador ? ((SituacionTrabajador) value).getDescripcion() : value;
    //                return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
    //            }
    //        });
    if (this.accion == Controlador.MODIFICAR) {
        mostrarDatos(this.empleado);
    }
}