/** * Uses the calculator with name calcName to construct & display a series for the sg. This should * be the only way new series' are added to the chart, since we need to keep track of all the * current series in the sgSeriesMap * * @param calcName * @param sg */ protected void addSeriesForSG(String calcName, SequenceGroup sg) { BaseCounter calc = null; try { calc = sgReg.getBaseCounterInstance(calcName, sg); } catch (IllegalArgumentException ex) { System.err.println("Could not find base counter of type : " + calcName); return; } List<AbstractSeries> seriesList = sgSeriesMap.get(sg); if (seriesList == null) { System.out.println( "Uh-oh, this sequence group doesn't have an associated list in the sgSeriesMap..."); } // Make a new series from the calculator int windowsize = ((Integer) windowSizeSpinner.getValue()).intValue(); int windowStep = ((Integer) windowStepSpinner.getValue()).intValue(); if (usePartitionsBox.isSelected()) { for (int i = 0; i < sg.getPartitionCount(); i++) { BaseCounterSeries ser = calc.getWindowSeries(windowsize, windowStep, i); ser.setPartitionIndex(i); seriesList.add(ser); ser.setName(calc.getName() + " - " + sg.getPartitionKeyForIndex(i)); if (ser != null && ser.size() > 0) { chart.addDataSeries(ser); chart.repaint(); } } } else { BaseCounterSeries ser = calc.getWindowSeries(windowsize, windowStep); seriesList.add(ser); if (sgSeriesMap.size() > 1) { String name = sg.getName(); if (name == null) { ser.setName(calc.getName()); } else { ser.setName(calc.getName() + " - " + sg.getName()); } } if (ser != null && ser.size() > 0) { chart.addDataSeries(ser); chart.repaint(); } } }
private JScrollPane createStatisticListPanel() { Map<String, BaseCounter> statMap = sgReg.getBaseCounters(); int count = 0; JPanel panel = new JPanel(); panel.setBackground(Color.white); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); Color stripeColor = new Color(235, 235, 235); for (final BaseCounter calc : statMap.values()) { JPanel calcPanel = new JPanel(); calcPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); final String name = calc.getName(); JCheckBox box = new JCheckBox(); if (name.equals( SGStatisticsRegistry.NUC_DIVERSITY)) // bit of a hack here to make sure this box starts box.setSelected(true); // out selected box.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { toggleCalculator(name); } }); calcPanel.add(box); JLabel lab = new JLabel(name); lab.setFont(new Font("Sans", Font.PLAIN, 11)); calcPanel.add(lab); calcPanel.setBackground(Color.white); calcPanel.setMaximumSize(new Dimension(500, 24)); calcPanel.setToolTipText(calc.getDescription()); if (count % 2 == 0) { calcPanel.setBackground(stripeColor); } else { calcPanel.setBackground(Color.white); } panel.add(calcPanel); count++; } JScrollPane pane = new JScrollPane(panel); pane.getVerticalScrollBar().setAlignmentX(JComponent.LEFT_ALIGNMENT); return pane; }