/*package*/ PointsStyleFrame(PointsView[] ptv, boolean isLine) { _ptv = ptv; _panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); JRadioButton line = new JRadioButton("Line"); line.setSelected(isLine); line.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) {} }); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; _panel.add(line, c); JRadioButton marks = new JRadioButton("Marks"); marks.setSelected(!isLine); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; _panel.add(marks, c); JComboBox lineStyles = new JComboBox(PointsView.Line.values()); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 1; _panel.add(lineStyles, c); JComboBox markStyles = new JComboBox(PointsView.Mark.values()); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 1; _panel.add(markStyles, c); // JLabel sizeLabel = new JLabel("Size:"); // c.fill = GridBagConstraints.HORIZONTAL; // c.anchor = GridBagConstraints.CENTER; // c.weightx = 10; // c.gridx = 0; // c.gridy = 2; // _panel.add(sizeLabel,c); JComboBox size = new JComboBox(_sizes); size.setEditable(true); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 2; _panel.add(size, c); JComboBox colors = new JComboBox(Colors.values()); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 3; _panel.add(colors, c); add(_panel); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
public static int numColors() { return Colors.values().length; }
@Koan public void basicEnumsAccess() { Colors[] colorArray = Colors.values(); assertEquals(colorArray[2], Colors.Green); }
public static final Color resolveIndex(int i) { return Colors.values()[i % Colors.length].getColor(); }
public enum Colors { // 240° BLUE { @Override public Color getColor() { return Color.BLUE; } }, // 120° GREEN { @Override public Color getColor() { return Color.GREEN; } }, // 0° RED { @Override public Color getColor() { return Color.RED; } }, // 180° CYAN { @Override public Color getColor() { return Color.CYAN; } }, // 47° ORANGE { @Override public Color getColor() { return Color.ORANGE; } }, // 180° TEAL { @Override public Color getColor() { return new Color(0, 128, 128); } }, // 60° YELLOW { @Override public Color getColor() { return Color.YELLOW; } }, // 300° MAGENTA { @Override public Color getColor() { return Color.MAGENTA; } }, // 0° PINK { @Override public Color getColor() { return Color.PINK; } }, // 0° BLACK { @Override public Color getColor() { return Color.BLACK; } }, NAVY { @Override public Color getColor() { return new Color(0, 0, 128); } }, // 0° GRAY { @Override public Color getColor() { return Color.GRAY; } }, // 0° LIGHT_GRAY { @Override public Color getColor() { return Color.LIGHT_GRAY; } }, DARK_GRAY { @Override public Color getColor() { return Color.DARK_GRAY; } }, FUCHSIA { @Override public Color getColor() { return new Color(255, 0, 255); } }, // Netscape alias for cyan AQUA { @Override public Color getColor() { return Color.CYAN; } }, LIME { @Override public Color getColor() { return new Color(204, 255, 0); } }, MAROON { @Override public Color getColor() { return new Color(128, 0, 0); } }, OLIVE { @Override public Color getColor() { return new Color(128, 128, 0); } }, PURPLE { @Override public Color getColor() { return new Color(128, 0, 128); } }, SILVER { @Override public Color getColor() { return new Color(192, 192, 192); } }, WHITE { @Override public Color getColor() { return Color.WHITE; } }; public abstract Color getColor(); public static final int length = Colors.values().length; public static final Color resolveIndex(int i) { return Colors.values()[i % Colors.length].getColor(); } };
/** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("SHOW_SPECTRUM")) { CursorPosition pos = getCursorPosition(); if (pos != null) { SpectraVisualizerModule.showNewSpectrumWindow(pos.getDataFile(), pos.getScanNumber()); } } if (command.equals("SETUP_AXES")) { AxesSetupDialog dialog = new AxesSetupDialog(this, IDAPlot.getXYPlot()); dialog.setVisible(true); } if (command.equals("SHOW_DATA_POINTS")) { IDAPlot.switchDataPointsVisible(); } if (command.equals("SWITCH_TOOLTIPS")) { if (tooltipMode) { IDAPlot.showPeaksTooltips(false); toolBar.setTooltipButton(false); tooltipMode = false; } else { IDAPlot.showPeaksTooltips(true); toolBar.setTooltipButton(true); tooltipMode = true; } } if (command.equals("FIND_SPECTRA")) { // Parameters final DoubleParameter inputMZ = new DoubleParameter("Ion m/z", "m/z value of ion to search for."); final MZToleranceParameter inputMZTolerance = new MZToleranceParameter(); final DoubleParameter inputIntensity = new DoubleParameter( "Min. ion intensity", "Only ions with intensities above this value will be searched for."); final BooleanParameter inputNL = new BooleanParameter( "Neutral Loss", "If selected, the ion to be searched for will be a neutral loss ion.\nIn this case, only ions above the min. intensity will be examined.", false); final ComboParameter<Colors> inputColors = new ComboParameter<Colors>( "Color", "The color which the data points will be marked with.", Colors.values()); Parameter<?>[] parameters = new Parameter<?>[5]; parameters[0] = inputMZ; parameters[1] = inputMZTolerance; parameters[2] = inputIntensity; parameters[3] = inputNL; parameters[4] = inputColors; final ParameterSet parametersSearch = new SimpleParameterSet(parameters); ExitCode exitCode = parametersSearch.showSetupDialog(this, true); if (exitCode != ExitCode.OK) return; double searchMZ = parametersSearch.getParameter(inputMZ).getValue(); MZTolerance searchMZTolerance = parametersSearch.getParameter(inputMZTolerance).getValue(); double minIntensity = parametersSearch.getParameter(inputIntensity).getValue(); boolean neutralLoss = parametersSearch.getParameter(inputNL).getValue(); Color highligtColor = Color.red; ; if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.green)) { highligtColor = Color.green; } if (parametersSearch.getParameter(inputColors).getValue().equals(Colors.blue)) { highligtColor = Color.blue; } // Find and highlight spectra with specific ion dataset.highlightSpectra( searchMZ, searchMZTolerance, minIntensity, neutralLoss, highligtColor); // Add legend entry LegendItemCollection chartLegend = IDAPlot.getXYPlot().getLegendItems(); chartLegend.add( new LegendItem( "Ion: " + searchMZ, "", "MS/MS spectra which contain the " + searchMZ + " ion\nTolerance: " + searchMZTolerance.toString() + "\nMin intensity: " + minIntensity, "", new Ellipse2D.Double(0, 0, 7, 7), highligtColor)); IDAPlot.getXYPlot().setFixedLegendItems(chartLegend); } }