}
public void render(RenderContext context, Rectangle arect) {
Genome genome = GenomeManager.getInstance().getCurrentGenome();
this.trackMinY = arect.getMinY();
Rectangle adjustedRect = calculateDrawingRect(arect);
double adjustedRectMaxX = adjustedRect.getMaxX();
double adjustedRectMaxY = adjustedRect.getMaxY();
double adjustedRectY = adjustedRect.getY();
this.maxY = adjustedRectMaxY;
this.scale = context.getScale();
int bufferX = (int) adjustedRectMaxX;
int bufferY = (int) adjustedRectMaxY;
Color[][] drawBuffer = new Color[bufferX + 1][bufferY + 1];
double origin = context.getOrigin();
double locScale = context.getScale();
// Get the Y axis definition, consisting of minimum, maximum, and base value. Often
// the base value is == min value which is == 0.
DataRange axisDefinition = this.getDataRange();
float maxValue = axisDefinition.getMaximum();
float minValue = axisDefinition.getMinimum();
// Calculate the Y scale factor.
double yScaleFactor = adjustedRect.getHeight() / (maxValue - minValue);
//int lastPx = 0;
String chrName = context.getChr();
ArrayList<String> chrList = new ArrayList();
if (chrName.equals("All")) {
for (String key : gData.getLocations().keySet()) {
chrList.add(key);
}
} else {
chrList.add(chrName);
}
double dx = Math.ceil(1 / locScale) + 1;
double rangeMaxValue = Math.ceil(gData.getMaxValue());
double pointSizeScale = rangeMaxValue / maxPointSize;
Color drawColor = this.primaryColor;
Object[] chrs = this.gData.getLocations().keySet().toArray();
int xMinPointSize = (int) (1 / locScale);
// Loop through data points, chromosome by chromosome
for (String chr : chrList) {
if (this.gData.getLocations().containsKey(chr) && this.gData.getValues().containsKey(chr)) {
// Choose a color for the chromosome
// Use specific color for each chromosome
if (this.useChrColors)
drawColor = ChromosomeColors.getColor(chr);
// Use two alternating colors for chromosomes
else if (this.alternatingColors) {
int chrCounter = 0;
while (chrCounter < chrs.length && !chrs[chrCounter].toString().equals(chr))
chrCounter++;
if (chrCounter % 2 == 0)
drawColor = this.secondaryColor;
else
drawColor = this.primaryColor;
}
IntArrayList locations = this.gData.getLocations().get(chr);
DoubleArrayList values = this.gData.getValues().get(chr);
int size = locations.size();
// Loop through data points in a chromosome
for (int j = 0; j < size; j++) {
// Get location, e.g. start for the data point
int start;
if (chrName.equals("All"))
start = genome.getGenomeCoordinate(chr, locations.get(j));
else
start = locations.get(j);
// Based on location, calculate X-coordinate, or break if outside of the view
double pX = ((start - origin) / locScale);