import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
-import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Map;
RGBIntensity intensity = intensities.get(j);
- g2d.setColor(new Color((float)intensity.getRed(), (float)intensity.getGreen(), (float)intensity.getBlue(), 1f));
- Rectangle2D colorVertical = new Rectangle2D.Double(colorVerticalLeft, colorVerticalTop, colorVerticalWidth, colorVerticalHeigth);
- g2d.fill(colorVertical);
+ if (colorBarsOptions.isUseGradients()) {
+
+ RGBIntensity upperLimitIntensity;
+ if (j + 1 != intensities.size())
+ upperLimitIntensity = intensities.get(j + 1);
+ else
+ upperLimitIntensity = intensity;
+
+ double minRed = intensity.getRed();
+ double minGreen = intensity.getGreen();
+ double minBlue = intensity.getBlue();
+
+ double maxRed = upperLimitIntensity.getRed();
+ double maxGreen = upperLimitIntensity.getGreen();
+ double maxBlue = upperLimitIntensity.getBlue();
+
+ double redDelta = (maxRed - minRed) / colorVerticalWidth;
+ double greenDelta = (maxGreen - minGreen) / colorVerticalWidth;
+ double blueDelta = (maxBlue - minBlue) / colorVerticalWidth;
+
+ for (int k = 0; k < colorVerticalWidth; k++) {
+
+
+ g2d.setColor(new Color((float)(minRed + (k * redDelta)), (float)(minGreen + (k * greenDelta)), (float)(minBlue + (k * blueDelta)), 1f));
+ Rectangle2D colorVertical = new Rectangle2D.Double(colorVerticalLeft + k, colorVerticalTop, 1, colorVerticalHeigth);
+ g2d.fill(colorVertical);
+ }
+
+ } else {
+ g2d.setColor(new Color((float)intensity.getRed(), (float)intensity.getGreen(), (float)intensity.getBlue(), 1f));
+ Rectangle2D colorVertical = new Rectangle2D.Double(colorVerticalLeft, colorVerticalTop, colorVerticalWidth, colorVerticalHeigth);
+ g2d.fill(colorVertical);
+ }
+
+
double value = min + j * interval;
String str = Double.toString(value);
int i = 0;
- for (Entry<String, DynamicSizeContribution> object : dynamicSizingContributions.entrySet()) {
- DynamicSizeContribution cc = object.getValue();
-
- double min = cc.getDefaultMin();
- double max = cc.getDefaultMax();
- String unit = cc.getUnit();
- String label = cc.getLabel();
-
- DynamicSizeMap map = cc.getDefaultSizeMap();
-
- List<Double> sizes = map.getSizes();
-
- double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i));
- i++;
-
- g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
- g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f));
-
- Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight);
- g2d.fill(vertical);
-
- double sizeVerticalLeft = sizeBarBoxLeft + 5;
- double sizeVerticalTop = sizeBarBoxTop + 15;
- double sizeVerticalHeigth = colorBarBoxHeight - 30;
-
- double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size();
-
- Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9));
- g2d.setFont(rulerFont);
-
- double interval = (max - min) / sizes.size();
-
- for (int j = 0; j < sizes.size(); j++) {
+ if (dynamicSizingContributions != null) {
+ for (Entry<String, DynamicSizeContribution> object : dynamicSizingContributions.entrySet()) {
+ DynamicSizeContribution cc = object.getValue();
+
+ if (!cc.isUsed())
+ continue;
+
+ double min = cc.getDefaultMin();
+ double max = cc.getDefaultMax();
+ String unit = cc.getUnit();
+ String label = cc.getLabel();
- Double size = sizes.get(j);
+ DynamicSizeMap map = cc.getDefaultSizeMap();
- g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f));
- double sizedWidth = (size / 5) * sizeVerticalHeigth;
- Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth);
- g2d.fill(rect);
+ List<Double> sizes = map.getSizes();
- double value = min + j * interval;
- String str = Double.toString(value);
- if (str.length() > 4) {
- str = str.substring(0, 3);
+ double sizeBarBoxTop = (sizeBarBoxTopInitial + (colorBarBoxHeight * i));
+ i++;
+
+ g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
+ g2d.setColor(new Color(0.9f, 0.9f, 0.9f, 0.95f));
+
+ Rectangle2D vertical = new Rectangle2D.Double(sizeBarBoxLeft, sizeBarBoxTop, colorBarBoxWidth, colorBarBoxHeight);
+ g2d.fill(vertical);
+
+ double sizeVerticalLeft = sizeBarBoxLeft + 5;
+ double sizeVerticalTop = sizeBarBoxTop + 15;
+ double sizeVerticalHeigth = colorBarBoxHeight - 30;
+
+ double sizeVerticalWidth = (sizeBarBoxWidth - 10) / sizes.size();
+
+ Font rulerFont = new Font("Tahoma", Font.PLAIN, DPIUtil.upscale(9));
+ g2d.setFont(rulerFont);
+
+ double interval = (max - min) / sizes.size();
+
+ for (int j = 0; j < sizes.size(); j++) {
+
+ Double size = sizes.get(j);
+
+ g2d.setColor(new Color((float)0, (float)0, (float)0.8, 0.8f));
+ double sizedWidth = (size / 5) * sizeVerticalHeigth;
+ Rectangle2D rect = new Rectangle2D.Double(sizeVerticalLeft, (sizeVerticalTop), sizedWidth, sizeVerticalHeigth);
+ g2d.fill(rect);
+
+ double value = min + j * interval;
+ String str = Double.toString(value);
+ if (str.length() > 4) {
+ str = str.substring(0, 3);
+ }
+ g2d.setColor(Color.BLACK);
+ g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight));
+
+ sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth;
}
g2d.setColor(Color.BLACK);
- g2d.drawString(str, (float)(sizeVerticalLeft - 8), (float)(sizeBarBoxTop + sizeBarBoxHeight));
- sizeVerticalLeft = sizeVerticalLeft + sizeVerticalWidth;
+ String str = Double.toString(max);
+ g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight));
+
+ str = object.getKey() + " - " + label + " [" + unit + "]";
+ g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10);
}
- g2d.setColor(Color.BLACK);
-
- String str = Double.toString(max);
- g2d.drawString(str, (int)(sizeBarBoxLeft + sizeBarBoxWidth - 30), (int)(sizeBarBoxTop + sizeBarBoxHeight));
-
- str = object.getKey() + " - " + label + " [" + unit + "]";
- g2d.drawString(str, (int)sizeBarBoxLeft + 5, (int)sizeBarBoxTop + 10);
}
}