private void drawScoredText (Graphics2D g, Pair<String, Double> textScore, double offsetFromCenter,
int minX, int maxX, int minY, int maxY,
int rowHeight, int barHeight, int padding,
ColorRamp ramp, double scale) {
int centerX = (minX + maxX) / 2;
int centerY = (minY + maxY) / 2;
int baseline = (int) Math.round(centerY + offsetFromCenter * rowHeight - padding);
int barBaseline = baseline - (rowHeight - 2*padding - barHeight)/2;
double value = textScore.getSecond()/scale;
double colorValue = (value+1.0)/2.0;
int barWidth = (int)Math.round((maxX-centerX)*0.8*value);
String text = textScore.getFirst();
FontMetrics metrics = g.getFontMetrics();
int textBaseline = baseline;
g.setColor(new Color(ramp.getRGB(colorValue)));
if (barWidth > 0) {
g.fillRect(centerX+padding, barBaseline, barWidth, barHeight);
} else {
g.fillRect(centerX+barWidth-padding, barBaseline, -barWidth, barHeight);
}
g.setColor(new Color(255, 255, 128, 192));
if (barWidth < 0) {
g.drawString(text, centerX+padding, textBaseline);
} else {
int textWidth = metrics.stringWidth(text);
g.drawString(text, centerX-padding-textWidth, textBaseline);
}
}