Example usage for java.awt.event ItemEvent getStateChange

List of usage examples for java.awt.event ItemEvent getStateChange

Introduction

In this page you can find the example usage for java.awt.event ItemEvent getStateChange.

Prototype

public int getStateChange() 

Source Link

Document

Returns the type of state change (selected or deselected).

Usage

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jComboBox1/*from   ww w. java  2 s .c  o  m*/
 * 
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxFillOpacity() {
    if (jComboBoxFillOpacity == null) {
        jComboBoxFillOpacity = new OpacityJComboBox();

        jComboBoxFillOpacity.setModel(new DefaultComboBoxModel(OPACITY_VALUES));

        Fill ff = symbolizer.getFill();
        if (ff != null) {
            if (ff.getOpacity() == null)
                ff.setOpacity(ASUtil.ff2.literal(1f));

            ASUtil.selectOrInsert(jComboBoxFillOpacity, ff.getOpacity());
        }

        // Initialize the enabled state
        boolean enabled = (symbolizer.getFill() != null && symbolizer.getFill().getGraphicFill() != null);
        jComboBoxFillOpacity.setEnabled(enabled);
        jLabelFillOpacity.setEnabled(enabled);

        jComboBoxFillOpacity.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {

                    symbolizer.getFill().setOpacity(ASUtil.ff2.literal(e.getItem()));

                    firePropertyChange(PROPERTY_UPDATED, null, null);

                }
            }

        });
        SwingUtil.addMouseWheelForCombobox(jComboBoxFillOpacity);

    }
    return jComboBoxFillOpacity;
}

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jComboBox1/*from w w w  .  j  a v a  2s.  c  o m*/
 * 
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxStrokeWidth() {
    if (jComboBoxStrokeWidth == null) {

        jComboBoxStrokeWidth = new JComboBox();

        jComboBoxStrokeWidth.setModel(new DefaultComboBoxModel(WIDTH_VALUES));
        jComboBoxStrokeWidth.setRenderer(WIDTH_VALUES_RENDERER);

        // TODO .. might not be in list...
        Stroke s = symbolizer.getStroke();
        if (s != null)
            if (s.getWidth() == null) {
                // Having a Stroke but no StrokeWidth doesn't make sense.
                s.setWidth(ASUtil.ff2.literal("1."));
            } else {

                ASUtil.selectOrInsert(jComboBoxStrokeWidth, s.getWidth());
            }
        else {
            jComboBoxStrokeWidth.setEnabled(false);
        }

        jComboBoxStrokeWidth.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {

                    symbolizer.getStroke().setWidth(ASUtil.ff2.literal(e.getItem()));

                    PolygonSymbolEditGUI.this.firePropertyChange(PROPERTY_UPDATED, null, null);

                }
            }

        });

        SwingUtil.addMouseWheelForCombobox(jComboBoxStrokeWidth);
    }
    return jComboBoxStrokeWidth;
}

From source file:Statement.Statement.java

private void cbShopIDItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbShopIDItemStateChanged
    cbShopID = (JComboBox) evt.getSource();
    code = "" + evt.getItem();
    if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) {
        loadRevenue();// w w  w  . jav  a  2 s  .c o m
        loadExpense();

    } else if (evt.getStateChange() == java.awt.event.ItemEvent.DESELECTED) {
        evaluator.list.clear();
    }

}

From source file:modnlp.capte.AlignmentInterfaceWS.java

public void itemStateChanged(ItemEvent e) {

    if (e.getSource() == splitButton) {
        if (e.getStateChange() == ItemEvent.DESELECTED) {

            doSplit = false;/*from ww  w  .ja v a  2  s  .  c  om*/
            System.out.println("Sentence splitting disabled");
        } else {

            doSplit = true;
            System.out.println("Sentence splitting enabled");
        }
    } else if (e.getSource() == convLine) {
        if (e.getStateChange() == ItemEvent.DESELECTED) {

            lineConvert = false;
            System.out.println("No line ending conversion");
        } else {

            lineConvert = true;
            System.out.println("line ending conversion enabled");
        }
    }
}

From source file:org.executequery.gui.ExecuteProcedurePanel.java

/**
 * Invoked when an item has been selected or deselected by the user.
 * The code written for this method performs the operations
 * that need to occur when an item is selected (or deselected).
 *//*from  w w w  .  j av a  2 s.co m*/
public void itemStateChanged(ItemEvent e) {

    // interested in selections only
    if (e.getStateChange() == ItemEvent.DESELECTED) {

        return;
    }

    final Object source = e.getSource();

    GUIUtils.startWorker(new Runnable() {
        public void run() {

            try {

                setInProcess(true);
                reloadProcedureList(source);

            } finally {

                setInProcess(false);
            }

        }

    });

}

From source file:com.litt.core.security.license.gui.ConfigPanel.java

/**
 * Create the panel.//from ww  w.ja  va  2 s .  c om
 */
public ConfigPanel(final Gui gui) {
    GridBagLayout gbl_configPanel = new GridBagLayout();
    gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
            Double.MIN_VALUE };
    this.setLayout(gbl_configPanel);

    JLabel label_18 = new JLabel("?");
    GridBagConstraints gbc_label_18 = new GridBagConstraints();
    gbc_label_18.insets = new Insets(0, 0, 5, 5);
    gbc_label_18.anchor = GridBagConstraints.EAST;
    gbc_label_18.gridx = 0;
    gbc_label_18.gridy = 0;
    this.add(label_18, gbc_label_18);

    comboBox_config = new JComboBox();
    comboBox_config.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                try {
                    LicenseConfig licenseConfig = (LicenseConfig) e.getItem();
                    File licenseFile = new File(licenseConfig.getLicenseFilePath());
                    currentLicenseConfig = licenseConfig;
                    loadLicense(licenseFile);
                    gui.setCurrentLicenseConfig(currentLicenseConfig);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            }
        }
    });
    GridBagConstraints gbc_comboBox_config = new GridBagConstraints();
    gbc_comboBox_config.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_config.gridx = 1;
    gbc_comboBox_config.gridy = 0;
    this.add(comboBox_config, gbc_comboBox_config);

    JButton button_3 = new JButton("?");
    button_3.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            try {
                comboBox_config.removeAllItems();

                File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                Document document = XmlUtils.readXml(configFile);
                Element rootE = document.getRootElement();
                List productList = rootE.elements();
                for (int i = 0; i < productList.size(); i++) {
                    Element productE = (Element) productList.get(i);
                    String productCode = productE.attributeValue("code");

                    List customerList = productE.elements();
                    for (int j = 0; j < customerList.size(); j++) {
                        Element customerE = (Element) customerList.get(j);
                        String customerCode = customerE.attributeValue("code");

                        LicenseConfig licenseConfig = new LicenseConfig();
                        licenseConfig.setProductCode(productCode);
                        licenseConfig.setCustomerCode(customerCode);
                        licenseConfig.setLicenseId(customerE.elementText("licenseId"));
                        licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense"));
                        licenseConfig.setRootFilePath(Gui.HOME_PATH);
                        licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode
                                + File.separator + customerCode + File.separator + "license.xml");
                        licenseConfig.setPriKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key");
                        licenseConfig.setPubKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key");
                        comboBox_config.addItem(licenseConfig);
                        if (i == 0 && j == 0) {
                            File licenseFile = new File(licenseConfig.getLicenseFilePath());
                            currentLicenseConfig = licenseConfig;
                            loadLicense(licenseFile);
                            gui.setCurrentLicenseConfig(currentLicenseConfig);

                            btnDelete.setEnabled(true);
                        }
                    }
                }

            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(self, e1.getMessage());
            }

        }
    });

    btnDelete = new JButton();
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentLicenseConfig != null) {
                try {
                    String productCode = currentLicenseConfig.getProductCode();
                    String customerCode = currentLicenseConfig.getCustomerCode();
                    //congfig.xml
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");
                    Document document = XmlUtils.readXml(configFile);

                    Element customerNode = (Element) document.selectSingleNode(
                            "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']");
                    if (customerNode != null) {
                        customerNode.detach();
                        XmlUtils.writeXml(configFile, document);
                    }
                    //                  
                    File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath());
                    if (licensePathFile.exists()) {
                        FileUtils.deleteDirectory(licensePathFile.getParentFile());
                    }

                    //comboboxitem
                    comboBox_config.removeItemAt(comboBox_config.getSelectedIndex());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if (comboBox_config.getItemCount() <= 0) {
                    btnDelete.setEnabled(false);
                }

            }
        }
    });
    btnDelete.setEnabled(false);
    btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png")));
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.insets = new Insets(0, 0, 5, 0);
    gbc_btnDelete.gridx = 2;
    gbc_btnDelete.gridy = 0;
    add(btnDelete, gbc_btnDelete);
    GridBagConstraints gbc_button_3 = new GridBagConstraints();
    gbc_button_3.insets = new Insets(0, 0, 5, 5);
    gbc_button_3.gridx = 1;
    gbc_button_3.gridy = 1;
    this.add(button_3, gbc_button_3);

    JLabel lblid = new JLabel("?ID");
    GridBagConstraints gbc_lblid = new GridBagConstraints();
    gbc_lblid.anchor = GridBagConstraints.EAST;
    gbc_lblid.insets = new Insets(0, 0, 5, 5);
    gbc_lblid.gridx = 0;
    gbc_lblid.gridy = 2;
    this.add(lblid, gbc_lblid);

    textField_licenseId = new JTextField();
    GridBagConstraints gbc_textField_licenseId = new GridBagConstraints();
    gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5);
    gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_licenseId.gridx = 1;
    gbc_textField_licenseId.gridy = 2;
    this.add(textField_licenseId, gbc_textField_licenseId);
    textField_licenseId.setColumns(10);

    JLabel label = new JLabel("?");
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.insets = new Insets(0, 0, 5, 5);
    gbc_label.gridx = 0;
    gbc_label.gridy = 3;
    add(label, gbc_label);

    comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray());
    GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints();
    gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_licenseType.gridx = 1;
    gbc_comboBox_licenseType.gridy = 3;
    add(comboBox_licenseType, gbc_comboBox_licenseType);

    JLabel label_23 = new JLabel("???");
    GridBagConstraints gbc_label_23 = new GridBagConstraints();
    gbc_label_23.anchor = GridBagConstraints.EAST;
    gbc_label_23.insets = new Insets(0, 0, 5, 5);
    gbc_label_23.gridx = 0;
    gbc_label_23.gridy = 4;
    this.add(label_23, gbc_label_23);

    textField_productName = new JTextField();
    GridBagConstraints gbc_textField_productName = new GridBagConstraints();
    gbc_textField_productName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_productName.gridx = 1;
    gbc_textField_productName.gridy = 4;
    this.add(textField_productName, gbc_textField_productName);
    textField_productName.setColumns(10);

    JLabel label_24 = new JLabel("???");
    GridBagConstraints gbc_label_24 = new GridBagConstraints();
    gbc_label_24.anchor = GridBagConstraints.EAST;
    gbc_label_24.insets = new Insets(0, 0, 5, 5);
    gbc_label_24.gridx = 0;
    gbc_label_24.gridy = 5;
    this.add(label_24, gbc_label_24);

    textField_companyName = new JTextField();
    GridBagConstraints gbc_textField_companyName = new GridBagConstraints();
    gbc_textField_companyName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_companyName.gridx = 1;
    gbc_textField_companyName.gridy = 5;
    this.add(textField_companyName, gbc_textField_companyName);
    textField_companyName.setColumns(10);

    JLabel label_25 = new JLabel("??");
    GridBagConstraints gbc_label_25 = new GridBagConstraints();
    gbc_label_25.anchor = GridBagConstraints.EAST;
    gbc_label_25.insets = new Insets(0, 0, 5, 5);
    gbc_label_25.gridx = 0;
    gbc_label_25.gridy = 6;
    this.add(label_25, gbc_label_25);

    textField_customerName = new JTextField();
    GridBagConstraints gbc_textField_customerName = new GridBagConstraints();
    gbc_textField_customerName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_customerName.gridx = 1;
    gbc_textField_customerName.gridy = 6;
    this.add(textField_customerName, gbc_textField_customerName);
    textField_customerName.setColumns(10);

    JLabel label_26 = new JLabel("");
    GridBagConstraints gbc_label_26 = new GridBagConstraints();
    gbc_label_26.anchor = GridBagConstraints.EAST;
    gbc_label_26.insets = new Insets(0, 0, 5, 5);
    gbc_label_26.gridx = 0;
    gbc_label_26.gridy = 7;
    this.add(label_26, gbc_label_26);

    textField_version = new JTextField();
    GridBagConstraints gbc_textField_version = new GridBagConstraints();
    gbc_textField_version.insets = new Insets(0, 0, 5, 5);
    gbc_textField_version.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_version.gridx = 1;
    gbc_textField_version.gridy = 7;
    this.add(textField_version, gbc_textField_version);
    textField_version.setColumns(10);

    JLabel label_27 = new JLabel("");
    GridBagConstraints gbc_label_27 = new GridBagConstraints();
    gbc_label_27.insets = new Insets(0, 0, 5, 5);
    gbc_label_27.gridx = 0;
    gbc_label_27.gridy = 8;
    this.add(label_27, gbc_label_27);

    datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    //datePicker_expiredDate.setTimePanleVisible(false);
    GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints();
    gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST;
    gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker_expiredDate.gridx = 1;
    gbc_datePicker_expiredDate.gridy = 8;
    this.add(datePicker_expiredDate, gbc_datePicker_expiredDate);

    JButton button_5 = new JButton("");
    button_5.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            if (currentLicenseConfig != null) {
                try {
                    File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath());
                    File licenseFile = new File(currentLicenseConfig.getLicenseFilePath());

                    //??
                    License license = new License();
                    license.setLicenseId(textField_licenseId.getText());
                    license.setLicenseType(
                            ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString());
                    license.setProductName(textField_productName.getText());
                    license.setCompanyName(textField_companyName.getText());
                    license.setCustomerName(textField_customerName.getText());
                    license.setVersion(Version.parseVersion(textField_version.getText()));
                    license.setCreateDate(new Date());
                    license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText()));

                    //????
                    DigitalSignatureTool utils = new DigitalSignatureTool("DSA");
                    utils.readPriKey(priKeyFile.getAbsolutePath()); //??
                    String signedData = utils.sign(license.toString()); //??????
                    license.setSignature(signedData);

                    LicenseManager.writeLicense(license, licenseFile);
                    //config.xml
                    String licenseContent = XmlUtils.readXml(licenseFile).asXML();
                    //DES
                    ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH);
                    licenseContent = security.encrypt(licenseContent);

                    txt_encryptContent.setText(licenseContent);
                    currentLicenseConfig.setEncryptedLicense(licenseContent);
                    System.out.println(licenseContent);
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                    XMLConfiguration config = new XMLConfiguration(configFile);
                    config.setAutoSave(true);

                    config.setProperty("product.customer.encryptedLicense", licenseContent);

                    //??zip?
                    File customerPath = licenseFile.getParentFile();
                    //???license?????
                    File licensePath = new File(customerPath.getParent(), "license");
                    if (!licensePath.exists() && !licensePath.isDirectory()) {
                        licensePath.mkdir();
                    } else {
                        FileUtils.cleanDirectory(licensePath);
                    }

                    //?
                    FileUtils.copyDirectory(customerPath, licensePath);
                    String currentTime = FormatDateTime.formatDateTimeNum(new Date());
                    ZipUtils.zip(licensePath, new File(licensePath.getParentFile(),
                            currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip"));

                    //license
                    FileUtils.deleteDirectory(licensePath);

                    JOptionPane.showMessageDialog(self, "??");
                } catch (Exception e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            } else {
                JOptionPane.showMessageDialog(self, "???");
            }
        }
    });
    GridBagConstraints gbc_button_5 = new GridBagConstraints();
    gbc_button_5.insets = new Insets(0, 0, 5, 5);
    gbc_button_5.gridx = 1;
    gbc_button_5.gridy = 9;
    this.add(button_5, gbc_button_5);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 1;
    gbc_scrollPane.gridy = 10;
    this.add(scrollPane, gbc_scrollPane);

    txt_encryptContent = new JTextArea();
    txt_encryptContent.setLineWrap(true);
    scrollPane.setViewportView(txt_encryptContent);

    //      txt_encryptContent = new JTextArea(20, 20);
    //      GridBagConstraints gbc_6 = new GridBagConstraints();
    //      gbc_6.gridx = 1;
    //      gbc_6.gridy = 10;
    //      this.add(txt_encryptContent, gbc_6);

}

From source file:org.zaproxy.zap.extension.httppanel.component.HttpPanelComponentViewsManager.java

@Override
public void itemStateChanged(ItemEvent e) {

    synchronized (changingComboBoxLocker) {
        if (changingComboBox) {
            return;
        }// w  w w .j a va 2  s.co  m
    }

    if (e.getStateChange() == ItemEvent.SELECTED) {
        if (currentView == null) {
            return;
        }

        ViewItem item = (ViewItem) comboBoxModel.getSelectedItem();

        if (item == null || item.getConfigName().equals(currentView.getName())) {
            return;
        }

        save();
        switchView(item.getConfigName());
    }
}

From source file:ventanas.Reportes.java

private void jComboGraficaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboGraficaItemStateChanged
    int ind1 = jComboGrafica.getSelectedIndex();
    int ind2 = jComboTipo.getSelectedIndex();
    double por = 0, angulo = 0, sum = 0;
    String titulo, titulox, tituloy;
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    DefaultPieDataset pData = new DefaultPieDataset();
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        switch (ind1) {
        case 1:/*from ww w  .j a  v  a 2  s .  c  o m*/
            if (ind2 == 1) {
                List<VistaCategorias> vista1 = new ArrayList<>();
                ObtenerVistaCategorias ob = new ObtenerVistaCategorias();
                vista1 = ob.obtenerVista(r);
                for (int i = 0; i < vista1.size(); i++) {
                    data.setValue(vista1.get(i).getCantidad(), "Categoria", vista1.get(i).getCategoria());
                }
                titulo = "Productos por Categoria";
                titulox = "Categorias";
                tituloy = "Numero de Productos";
                crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy);
            } else {
                if (ind2 == 2) {
                    List<VistaCategorias> vista1 = new ArrayList<>();
                    ObtenerVistaCategorias ob = new ObtenerVistaCategorias();
                    vista1 = ob.obtenerVista(r);
                    for (int i = 0; i < vista1.size(); i++) {
                        sum = vista1.get(i).getCantidad();
                    }
                    for (int i = 0; i < vista1.size(); i++) {
                        por = vista1.get(i).getCantidad() / sum;
                        angulo = por * 360;
                        pData.setValue(vista1.get(i).getCategoria(), angulo);
                    }
                    titulo = "Productos por Categoria";
                    crearPieChart(pData, jPanelGrafica, titulo);
                }
            }
            break;
        case 2:
            if (ind2 == 1) {
                List<GananciaCategoria> ganancia = new ArrayList<>();
                ObtenerGananciaXCategoria ob = new ObtenerGananciaXCategoria();
                ganancia = ob.obtenerGanancia(r);
                for (int i = 0; i < ganancia.size(); i++) {
                    data.setValue(ganancia.get(i).getGanacia(), "Categoria", ganancia.get(i).getCategoria());
                }
                titulo = "Ganancias por Categoria";
                titulox = "Categorias";
                tituloy = "Ganancias";
                crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy);
            } else {
                if (ind2 == 2) {
                    List<GananciaCategoria> ganancia = new ArrayList<>();
                    ObtenerGananciaXCategoria ob = new ObtenerGananciaXCategoria();
                    ganancia = ob.obtenerGanancia(r);
                    System.out.println(ganancia.size());
                    for (int i = 0; i < ganancia.size(); i++) {
                        data.setValue(ganancia.get(i).getGanacia(), "Categoria",
                                ganancia.get(i).getCategoria());
                    }
                    for (int i = 0; i < ganancia.size(); i++) {
                        sum = ganancia.get(i).getGanacia();
                    }
                    for (int i = 0; i < ganancia.size(); i++) {
                        por = ganancia.get(i).getGanacia() / sum;
                        angulo = por * 360;
                        pData.setValue(ganancia.get(i).getCategoria(), angulo);
                    }

                    titulo = "Ganancia por Categoria";
                    crearPieChart(pData, jPanelGrafica, titulo);

                }
            }
            break;
        case 3:
            if (ind2 == 1) {
                List<ProveedorProductosEntregados> lista = new ArrayList<>();
                ObtenerVistaProveedor op = new ObtenerVistaProveedor();
                lista = op.obtenerLista(r);
                for (int i = 0; i < lista.size(); i++) {
                    data.setValue(lista.get(i).getNum_productos_entregados(), "Proveedor",
                            lista.get(i).getProveedor());
                }
                titulo = "Cantidad de productos Entregados";
                titulox = "Proveedor";
                tituloy = "Cantidad";
                crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy);
            } else {
                if (ind2 == 2) {
                    List<ProveedorProductosEntregados> lista = new ArrayList<>();
                    ObtenerVistaProveedor op = new ObtenerVistaProveedor();
                    lista = op.obtenerLista(r);
                    for (int i = 0; i < lista.size(); i++) {
                        data.setValue(lista.get(i).getNum_productos_entregados(), "Proveedor",
                                lista.get(i).getProveedor());
                    }
                    for (int i = 0; i < lista.size(); i++) {
                        sum = lista.get(i).getNum_productos_entregados();
                    }
                    for (int i = 0; i < lista.size(); i++) {
                        por = lista.get(i).getNum_productos_entregados() / sum;
                        angulo = por * 360;
                        pData.setValue(lista.get(i).getProveedor(), angulo);
                    }
                    titulo = "Cantidad de productos Entregados";
                    crearPieChart(pData, jPanelGrafica, titulo);

                }
            }
            break;
        case 4:
            if (ind2 == 1) {
                List<VistaInversioPedido> vista = new ArrayList<>();
                ObtenerVistaInversion obt = new ObtenerVistaInversion();
                vista = obt.obtenerVista(r);
                for (int i = 0; i < vista.size(); i++) {
                    data.setValue(vista.get(i).getInversion(), "Proveedor", vista.get(i).getProveedores());
                }
                titulo = "Cantidad de inversion";
                titulox = "Proveedor";
                tituloy = "Inversion";
                crearBarChart(data, jPanelGrafica, titulo, titulox, tituloy);

            } else {
                if (ind2 == 2) {
                    List<VistaInversioPedido> vista = new ArrayList<>();
                    ObtenerVistaInversion obt = new ObtenerVistaInversion();
                    vista = obt.obtenerVista(r);
                    for (int i = 0; i < vista.size(); i++) {
                        data.setValue(vista.get(i).getInversion(), "Proveedor", vista.get(i).getProveedores());
                    }
                    for (int i = 0; i < vista.size(); i++) {
                        sum = vista.get(i).getInversion();
                    }
                    for (int i = 0; i < vista.size(); i++) {
                        por = vista.get(i).getInversion() / sum;
                        angulo = por * 360;
                        pData.setValue(vista.get(i).getProveedores(), angulo);
                    }
                    titulo = "Cantidad de inversion";
                    crearPieChart(pData, jPanelGrafica, titulo);

                }
            }
            break;
        }
    }
}

From source file:de.tor.tribes.ui.windows.ReportRulesDialog.java

private void fireRuleTypeChangedEvent(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fireRuleTypeChangedEvent
    if (evt == null || evt.getStateChange() == ItemEvent.SELECTED) {
        int idx = jRuleSelection.getSelectedIndex();
        jRuleSettingsPanel.invalidate();
        jRuleSettingsPanel.removeAll();//ww w .ja  va 2  s  .  com
        switch (idx) {
        case 0:
            jRuleSettingsPanel.add(jReportColorPanel, BorderLayout.CENTER);
            break;
        case 1:
            jRuleSettingsPanel.add(jDatePanel, BorderLayout.CENTER);
            break;
        case 2:
            jRuleSettingsPanel.add(jAgePanel, BorderLayout.CENTER);
            break;
        case 3:
            jRuleSettingsPanel.add(jAttackerPanel, BorderLayout.CENTER);
            break;
        case 4:
            jRuleSettingsPanel.add(jDefenderPanel, BorderLayout.CENTER);
            break;
        case 5:
            jRuleSettingsPanel.add(jAttackerAllyPanel, BorderLayout.CENTER);
            break;
        case 6:
            jRuleSettingsPanel.add(jDefenderAllyPanel, BorderLayout.CENTER);
            break;
        case 7:
            jRuleSettingsPanel.add(jNoSettingsPanel, BorderLayout.CENTER);
            jNoSettingsType.setText("OFF");
            break;
        case 8:
            jRuleSettingsPanel.add(jNoSettingsPanel, BorderLayout.CENTER);
            jNoSettingsType.setText("FAKE");
            break;
        case 9:
            jRuleSettingsPanel.add(jNoSettingsPanel, BorderLayout.CENTER);
            jNoSettingsType.setText("SNOB");
            break;
        case 10:
            jRuleSettingsPanel.add(jNoSettingsPanel, BorderLayout.CENTER);
            jNoSettingsType.setText("WALL");
            break;
        case 11:
            jRuleSettingsPanel.add(jNoSettingsPanel, BorderLayout.CENTER);
            jNoSettingsType.setText("BUILDING");
            break;
        }
        jRuleSettingsPanel.revalidate();
        pack();
        repaint();
    }
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JPanel getOptional(final ModelGraph graph, final ViewState state) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBorder(new EtchedBorder());
    panel.add(new JLabel("Optional:"), BorderLayout.NORTH);
    JPanel checkBoxes = new JPanel();
    checkBoxes.setLayout(new GridLayout(1, 1));
    Checkbox checkbox = new Checkbox("ignore", graph.getModel().isOptional());
    checkBoxes.add(checkbox);/*from w w  w. j  av a 2s.c o  m*/
    checkbox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                graph.getModel().setOptional(false);
            } else if (e.getStateChange() == ItemEvent.SELECTED) {
                graph.getModel().setOptional(true);
            } else {
                return;
            }
            DefaultPropView.this.notifyListeners();
            DefaultPropView.this.refreshView(state);
        }

    });
    panel.add(checkBoxes, BorderLayout.CENTER);
    return panel;
}