Example usage for java.util Vector removeAll

List of usage examples for java.util Vector removeAll

Introduction

In this page you can find the example usage for java.util Vector removeAll.

Prototype

public boolean removeAll(Collection<?> c) 

Source Link

Document

Removes from this Vector all of its elements that are contained in the specified Collection.

Usage

From source file:Main.java

public static void main(String args[]) {
    Vector<Integer> v = new Vector<Integer>(5);
    for (int i = 0; i < 10; i++) {
        v.add(0, i);//from w ww  .j a va2  s .c  om
    }
    System.out.println(v);

    Vector<Integer> v2 = new Vector<Integer>(5);
    for (int i = 0; i < 10; i++) {
        v2.add(0, i);
    }
    System.out.println(v2);

    System.out.println(v2.equals(v));

    v2.removeAll(v);

    System.out.println(v2);
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);//from  www.j a v a 2 s  . c om
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println(vec);
    System.out.println("Size of the vector: " + vec.size());

    // let us remove all the elements
    System.out.println("Removing all the elements");
    vec.removeAll(vec);
    System.out.println("Size of the vector: " + vec.size());
}

From source file:RemoveVector.java

static boolean removeAll(Vector v, Object e) {
    Vector v1 = new Vector();
    v1.add(e);/*  ww  w .j a  v  a 2s.  c  o m*/
    return v.removeAll(v1);
}

From source file:main.Draft_text_categorization.java

public static Map<String, Integer> docAsVectorToMap(String path) {
    //Scanner scan = new Scanner(StopWords.class.getResourceAsStream(path));
    InputStream fileIs = StopWords.class.getResourceAsStream(path);
    if (fileIs == null) {
        try {/*from w  w  w.  ja v  a  2s.c o  m*/
            fileIs = new FileInputStream(new File(path));
        } catch (FileNotFoundException e) {
            System.out.println("Error: Fichero no encontrado");
        }
    }
    String[] stop_words_vector = StopWords.stop_words;

    Set<String> stop_words_set = new HashSet<>();
    for (String stop_word : stop_words_vector) {
        stop_words_set.add(stop_word.toLowerCase());
    }

    // Vector que contiene todos los trminos de un documento
    Vector<String> docToCategorize = fileToVector(fileIs);
    // Eliminamos las stop_words del documento
    docToCategorize.removeAll(stop_words_set);

    // 2.2) asignar peso a cada trmino (# apariciones)
    // Calculamos los pesos de cada palabra de la noticia
    Map<String, Integer> docWithWeights = wordCounterForVector(docToCategorize);

    return docWithWeights;
}

From source file:net.sf.javaml.clustering.AQBC.java

/**
 * Remove the instances in q from sp//  w ww. j  av  a 2s . co  m
 * 
 * @param sp
 * @param q
 */
private void removeInstances(Vector<TaggedInstance> sp, Vector<TaggedInstance> q) {
    sp.removeAll(q);

}

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

@Override
public void refreshView(final ViewState state) {
    this.removeAll();

    tableMenu = new JPopupMenu("TableMenu");
    this.add(tableMenu);
    override = new JMenuItem(OVERRIDE);
    override.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
            String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
            Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
            if (staticMet == null) {
                staticMet = new Metadata();
            }/*ww  w.ja va 2 s .c o m*/
            if (e.getActionCommand().equals(OVERRIDE)) {
                if (!staticMet.containsKey(key)) {
                    staticMet.addMetadata(key, (String) DefaultPropView.this.table.getValueAt(row, 2));
                    String envReplace = (String) DefaultPropView.this.table.getValueAt(row, 3);
                    if (Boolean.valueOf(envReplace)) {
                        staticMet.addMetadata(key + "/envReplace", envReplace);
                    }
                    state.getSelected().getModel().setStaticMetadata(staticMet);
                    DefaultPropView.this.notifyListeners();
                }
            }
        }
    });
    delete = new JMenuItem(DELETE);
    delete.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
            String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
            Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
            if (staticMet == null) {
                staticMet = new Metadata();
            }
            staticMet.removeMetadata(key);
            staticMet.removeMetadata(key + "/envReplace");
            state.getSelected().getModel().setStaticMetadata(staticMet);
            DefaultPropView.this.notifyListeners();
        }

    });
    tableMenu.add(override);
    tableMenu.add(delete);

    if (state.getSelected() != null) {
        JPanel masterPanel = new JPanel();
        masterPanel.setLayout(new BoxLayout(masterPanel, BoxLayout.Y_AXIS));
        masterPanel.add(this.getModelIdPanel(state.getSelected(), state));
        masterPanel.add(this.getModelNamePanel(state.getSelected(), state));
        if (!state.getSelected().getModel().isParentType()) {
            masterPanel.add(this.getInstanceClassPanel(state.getSelected(), state));
        }
        masterPanel.add(this.getExecutionTypePanel(state.getSelected(), state));
        masterPanel.add(this.getPriorityPanel(state));
        masterPanel.add(this.getExecusedIds(state.getSelected()));
        if (state.getSelected().getModel().getExecutionType().equals("condition")) {
            masterPanel.add(this.getTimeout(state.getSelected(), state));
            masterPanel.add(this.getOptional(state.getSelected(), state));
        }
        JScrollPane scrollPane = new JScrollPane(table = this.createTable(state),
                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollPane.getHorizontalScrollBar().setUnitIncrement(10);
        scrollPane.getVerticalScrollBar().setUnitIncrement(10);
        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.setBorder(new EtchedBorder());
        final JLabel metLabel = new JLabel("Static Metadata");
        metLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        final JLabel extendsLabel = new JLabel("<extends>");
        extendsLabel.setFont(new Font("Serif", Font.PLAIN, 10));
        extendsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        extendsLabel.addMouseListener(new MouseListener() {

            private JScrollPane availableScroller;
            private JScrollPane mineScroller;
            private JList mineList;
            private JList availableList;
            private DefaultListModel mineModel;
            private DefaultListModel availableModel;

            public void mouseClicked(MouseEvent e) {
                final JPopupMenu popup = new JPopupMenu();
                popup.setLayout(new BorderLayout());

                JPanel main = new JPanel();
                main.setLayout(new BoxLayout(main, BoxLayout.X_AXIS));

                JPanel mine = new JPanel();
                mine.setBorder(new EtchedBorder());
                mine.setLayout(new BorderLayout());
                JLabel mineLabel = new JLabel("Mine");
                mineScroller = new JScrollPane(mineList = createJList(mineModel = new DefaultListModel(),
                        state.getSelected().getModel().getExtendsConfig()));
                mineScroller.setPreferredSize(new Dimension(250, 80));
                mine.add(mineLabel, BorderLayout.NORTH);
                mine.add(mineScroller, BorderLayout.CENTER);

                JPanel available = new JPanel();
                available.setBorder(new EtchedBorder());
                available.setLayout(new BorderLayout());
                JLabel availableLabel = new JLabel("Available");
                Vector<String> availableGroups = new Vector<String>(state.getGlobalConfigGroups().keySet());
                availableGroups.removeAll(state.getSelected().getModel().getExtendsConfig());
                availableScroller = new JScrollPane(availableList = this
                        .createJList(availableModel = new DefaultListModel(), availableGroups));
                availableScroller.setPreferredSize(new Dimension(250, 80));
                available.add(availableLabel, BorderLayout.NORTH);
                available.add(availableScroller, BorderLayout.CENTER);

                JPanel buttons = new JPanel();
                buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS));
                JButton addButton = new JButton("<---");
                addButton.addMouseListener(new MouseListener() {

                    public void mouseClicked(MouseEvent e) {
                        String selected = availableList.getSelectedValue().toString();
                        Vector<String> extendsConfig = new Vector<String>(
                                state.getSelected().getModel().getExtendsConfig());
                        extendsConfig.add(selected);
                        state.getSelected().getModel().setExtendsConfig(extendsConfig);
                        availableModel.remove(availableList.getSelectedIndex());
                        mineModel.addElement(selected);
                        popup.revalidate();
                        DefaultPropView.this.notifyListeners();
                    }

                    public void mouseEntered(MouseEvent e) {
                    }

                    public void mouseExited(MouseEvent e) {
                    }

                    public void mousePressed(MouseEvent e) {
                    }

                    public void mouseReleased(MouseEvent e) {
                    }

                });
                JButton removeButton = new JButton("--->");
                removeButton.addMouseListener(new MouseListener() {

                    public void mouseClicked(MouseEvent e) {
                        String selected = mineList.getSelectedValue().toString();
                        Vector<String> extendsConfig = new Vector<String>(
                                state.getSelected().getModel().getExtendsConfig());
                        extendsConfig.remove(selected);
                        state.getSelected().getModel().setExtendsConfig(extendsConfig);
                        mineModel.remove(mineList.getSelectedIndex());
                        availableModel.addElement(selected);
                        popup.revalidate();
                        DefaultPropView.this.notifyListeners();
                    }

                    public void mouseEntered(MouseEvent e) {
                    }

                    public void mouseExited(MouseEvent e) {
                    }

                    public void mousePressed(MouseEvent e) {
                    }

                    public void mouseReleased(MouseEvent e) {
                    }

                });
                buttons.add(addButton);
                buttons.add(removeButton);

                main.add(mine);
                main.add(buttons);
                main.add(available);
                popup.add(main, BorderLayout.CENTER);
                popup.show(extendsLabel, e.getX(), e.getY());
            }

            public void mouseEntered(MouseEvent e) {
                extendsLabel.setForeground(Color.blue);
            }

            public void mouseExited(MouseEvent e) {
                extendsLabel.setForeground(Color.black);
            }

            public void mousePressed(MouseEvent e) {
            }

            public void mouseReleased(MouseEvent e) {
            }

            private JList createJList(DefaultListModel model, final List<String> list) {
                for (String value : list) {
                    model.addElement(value);
                }
                JList jList = new JList(model);
                jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
                jList.setLayoutOrientation(JList.VERTICAL);
                return jList;
            }
        });
        JLabel metGroupLabel = new JLabel("(Sub-Group: "
                + (state.getCurrentMetGroup() != null ? state.getCurrentMetGroup() : "<base>") + ")");
        metGroupLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        JPanel labelPanel = new JPanel();
        labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS));
        JPanel top = new JPanel();
        top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));
        top.add(extendsLabel);
        top.add(metLabel);
        labelPanel.add(top);
        labelPanel.add(metGroupLabel);
        panel.add(labelPanel, BorderLayout.NORTH);
        panel.add(scrollPane, BorderLayout.CENTER);
        masterPanel.add(panel);
        this.add(masterPanel);
    } else {
        this.add(new JPanel());
    }
    this.revalidate();
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.FileSelectionTable.java

/** Removes the selected files from the queue. */
private void removeSelectedFiles() {
    table.removeKeyListener(keyListener);
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length == 0)
        return;/*from  w ww .  j ava 2s.c  o m*/
    DefaultTableModel dtm = (DefaultTableModel) table.getModel();
    Vector<?> v = dtm.getDataVector();
    List<Object> indexes = new ArrayList<Object>();
    for (int i = 0; i < table.getRowCount(); i++) {
        if (table.isRowSelected(i))
            indexes.add(v.get(i));
    }
    v.removeAll(indexes);
    dtm.setDataVector(v, this.columnHeadings);
    table.clearSelection();
    formatTableModel();
    table.repaint();
    table.addKeyListener(keyListener);
    int n = table.getRowCount();
    firePropertyChange(REMOVE_PROPERTY, n - 1, n);
    enabledControl(table.getRowCount() > 0);
    model.onSelectionChanged();
}