@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (pUtil.modifiedNetworkSet != null && !pUtil.modifiedNetworkSet.contains(network.getSUID())) { for (Protein p : sortResults.get(curalg)) { if (p.getSelectGroups() != null && !p.getSelectGroups().isEmpty()) { networkView .getNodeView(p.getN()) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, p.getOriginColor()); networkView .getNodeView(p.getN()) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, ""); p.getSelectGroups().clear(); } } } else { for (Protein p : sortResults.get(curalg)) { if (network.containsNode(p.getN()) && p.getSelectGroups() != null && !p.getSelectGroups().isEmpty()) { networkView .getNodeView(p.getN()) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, p.getOriginColor()); networkView .getNodeView(p.getN()) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, ""); p.getSelectGroups().clear(); } } } SetColorMap.clear(); selectedSets.clear(); labelPanel.removeAll(); labelPanel.repaint(); networkView.updateView(); SETINDEX = 0; }
@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub Color mixc = null, currentc = null; HashMap<String, Color> mixColors = new HashMap<String, Color>(); JColorChooser jc = new JColorChooser(); currentc = jc.showDialog(null, "Please choose one color", Color.red); if (currentc != null) { pUtil.setSelected(null, network); if (pUtil.modifiedNetworkSet != null && !pUtil.modifiedNetworkSet.contains(network.getSUID())) { for (Protein p : sproteins) { CyNode n = p.getN(); SetColorMap.put(curSetName, currentc); if (p.getSelectGroups() == null || p.getSelectGroups().isEmpty()) { p.setOriginColor( networkView .getNodeView(n) .getVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR)); p.setSelectGroups(new ArrayList<String>()); p.getSelectGroups().add(curSetName); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, currentc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, curSetName); } else { if (ismixcolor) { p.getSelectGroups().add(curSetName); String mixname = ""; double blue = 0, red = 0, green = 0, s = p.getSelectGroups().size(); int r, g, b; int i = 0; for (String set : p.getSelectGroups()) { blue += SetColorMap.get(set).getBlue(); red += SetColorMap.get(set).getRed(); green += SetColorMap.get(set).getGreen(); if (i == 0) mixname += set; else mixname += " + " + set; i++; } r = (int) Math.round(red / s); g = (int) Math.round(green / s); b = (int) Math.round(blue / s); mixc = new Color(r, g, b); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, mixc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, mixname); mixColors.put(mixname, mixc); } else { // p.setOriginColor(networkView.getNodeView(n).getVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR)); p.getSelectGroups().add(curSetName); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, currentc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, curSetName); } } } } else { for (Protein p : sproteins) { CyNode n = p.getN(); if (!network.containsNode(n)) { continue; } SetColorMap.put(curSetName, currentc); if (p.getSelectGroups() == null || p.getSelectGroups().isEmpty()) { p.setOriginColor( networkView .getNodeView(n) .getVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR)); p.setSelectGroups(new ArrayList<String>()); p.getSelectGroups().add(curSetName); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, currentc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, curSetName); } else { if (ismixcolor) { p.getSelectGroups().add(curSetName); String mixname = ""; double blue = 0, red = 0, green = 0, s = p.getSelectGroups().size(); int r, g, b; int i = 0; for (String set : p.getSelectGroups()) { blue += SetColorMap.get(set).getBlue(); red += SetColorMap.get(set).getRed(); green += SetColorMap.get(set).getGreen(); if (i == 0) mixname += set; else mixname += " + " + set; i++; } r = (int) Math.round(red / s); g = (int) Math.round(green / s); b = (int) Math.round(blue / s); mixc = new Color(r, g, b); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, mixc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, mixname); mixColors.put(mixname, mixc); } else { // p.setOriginColor(networkView.getNodeView(n).getVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR)); p.getSelectGroups().add(curSetName); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_FILL_COLOR, currentc); networkView .getNodeView(n) .setVisualProperty(BasicVisualLexicon.NODE_TOOLTIP, curSetName); } } } } JPanel jp = new JPanel(); jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); jp.add(new JLabel(curSetName + " ", createColorIcon(currentc), SwingConstants.LEFT)); JCheckBox temp = new JCheckBox(); temp.addActionListener(new ChooseSetsAction()); jp.add(temp); jp.setBorder(BorderFactory.createTitledBorder("")); jp.setBounds(10, Ylocation, 300, 25); Ylocation += 30; labelPanel.add(jp); JPanel jj = new JPanel(); jj.setLayout(new BoxLayout(jj, BoxLayout.Y_AXIS)); jj.setAlignmentX(Component.LEFT_ALIGNMENT); if (!mixColors.isEmpty()) { for (Entry<String, Color> mix : mixColors.entrySet()) { jj.add( new JLabel(mix.getKey(), createColorIcon(mix.getValue()), SwingConstants.LEFT)); jj.setBounds(10, Ylocation, 300, 25); Ylocation += 30; labelPanel.add(jj); } } labelPanel.repaint(); } }