/** * Called when one of the sliding window size or step values has changed. This attempts to be * 'smart' and instead of recalculating everything from scratch, */ private void newWindowSizeAction() { if (sgSeriesMap == null) return; XYSeries data; int windowSize = (Integer) windowSizeSpinner.getValue(); int windowStep = (Integer) windowStepSpinner.getValue(); int tot = 0; for (AbstractSeries series : chart.getAllSeries()) { if (series instanceof BaseCounterSeries) { BaseCounterSeries bcSer = (BaseCounterSeries) series; BaseCounter bc = bcSer.getCalculator(); int partitionIndex = bcSer.getPartitionIndex(); // System.out.println("Replacing series for calc with name : " + bcSer.getName() + " and // partition : " + bcSer.getPartitionIndex()); if (partitionIndex > -1) { bcSer.replaceSeries(bc.getWindowPointSeries(windowSize, windowStep, partitionIndex)); } else bcSer.replaceSeries(bc.getWindowPointSeries(windowSize, windowStep)); } else { // System.err.println("Hmm, one of the series (" + series.getName() + ") is not a // basecounter, cannot recalculate it for the new window size.");/ } } chart.repaint(); }
/** * Remove all series associated with the class specified * * @param toRemove */ public void removeSeriesByClass(Class toRemove) { List<AbstractSeries> activeSeries = chart.getAllSeries(); for (AbstractSeries series : activeSeries) { if (series instanceof BaseCounterSeries) { BaseCounter bc = ((BaseCounterSeries) series).getCalculator(); if (bc.getClass() == toRemove) { chart.removeSeries(series); } } } }
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; }
/** * 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(); } } }