Search in sources :

Example 1 with DisplayPreferences

use of uk.ac.babraham.SeqMonk.Preferences.DisplayPreferences in project SeqMonk by s-andrews.

the class ChromosomePositionScrollBar method adjustmentValueChanged.

public void adjustmentValueChanged(AdjustmentEvent e) {
    if (ignoreInternal) {
        ignoreInternal = false;
    } else {
        DisplayPreferences dp = DisplayPreferences.getInstance();
        double proportion = getValue() / 10000d;
        int newStart = (int) (dp.getCurrentChromosome().length() * proportion);
        int distance = SequenceRead.length(dp.getCurrentLocation());
        int newEnd = newStart + (distance - 1);
        dp.setLocation(SequenceRead.packPosition(newStart, newEnd, Location.UNKNOWN));
    }
}
Also used : DisplayPreferences(uk.ac.babraham.SeqMonk.Preferences.DisplayPreferences)

Example 2 with DisplayPreferences

use of uk.ac.babraham.SeqMonk.Preferences.DisplayPreferences in project SeqMonk by s-andrews.

the class ChromosomeScaleTrack method paintComponent.

/* (non-Javadoc)
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    DisplayPreferences dp = DisplayPreferences.getInstance();
    if (dp.getCurrentLocation() != lastLocation) {
        // We need to rescale the frequency with which we're drawing points
        scale = new AxisScale(0, SequenceRead.length(dp.getCurrentLocation()));
        lastLocation = dp.getCurrentLocation();
    }
    height = getHeight();
    width = getWidth();
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, width, height);
    g.setColor(Color.DARK_GRAY);
    // Draw a line along the top
    g.drawLine(0, 3, width, 3);
    // Now go through all the scale positions figuring out whether they
    // need to be displayed
    int startBp = SequenceRead.start(lastLocation);
    int endBp = SequenceRead.end(lastLocation);
    int currentBase = 0;
    while (currentBase < endBp) {
        if (currentBase < startBp) {
            currentBase += scale.getInterval();
            continue;
        }
        String name = commify(currentBase);
        int nameWidth = g.getFontMetrics().stringWidth(name);
        int thisX = bpToPixel(currentBase);
        g.drawString(name, thisX - (nameWidth / 2), getHeight() - 2);
        g.drawLine(thisX, 3, thisX, height - (g.getFontMetrics().getAscent() + 3));
        currentBase += scale.getInterval();
    }
}
Also used : AxisScale(uk.ac.babraham.SeqMonk.Utilities.AxisScale) DisplayPreferences(uk.ac.babraham.SeqMonk.Preferences.DisplayPreferences)

Aggregations

DisplayPreferences (uk.ac.babraham.SeqMonk.Preferences.DisplayPreferences)2 AxisScale (uk.ac.babraham.SeqMonk.Utilities.AxisScale)1