BarChart.java
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:84k
源码类别:
OA系统
开发平台:
Java
- // Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2002-12-03 18:39:45
- // Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
- // Decompiler options: packimports(3)
- // Source File Name: BarChart.java
- package cn.com.fcsoft.chart;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.util.*;
- // Referenced classes of package com.objectplanet.chart:
- // Chart, ChartSample, LineChart, PieChart
- public class BarChart extends Chart
- {
- private void paintBar(Graphics g, int i, int j)
- {
- ChartSample chartsample = getSample(i, j);
- int k = getSeriesCount();
- if(chartsample == null || chartsample.value == null || chartsample.value.isNaN() || chartsample.getFloatValue() == 0.0D && barType == 1 && k > 1)
- return;
- int l = getSeriesRange(i);
- double d = chartsample.getFloatValue();
- if(barType != 1 && (d < super.currentLowerRange[l] && super.currentLowerRange[l] > 0.0D || d > super.currentUpperRange[l] && super.currentUpperRange[l] < 0.0D))
- return;
- if(multiColorOn)
- {
- if(getSeriesCount() > 1 || barType == 1 || super.multiSeriesOn)
- g.setColor(getSampleColor(i));
- else
- g.setColor(getSampleColor(j));
- } else
- {
- g.setColor(getSampleColor(0));
- }
- boolean flag = chartsample != null && chartsample.isSelected();
- Rectangle rectangle = barBounds[i][j];
- Color color = getChartForeground();
- if(barOutlineOn)
- {
- g.fillRect(rectangle.x, rectangle.y, rectangle.width + 1, rectangle.height);
- Color color1 = g.getColor();
- if(barOutlineColor != null)
- g.setColor(barOutlineColor);
- else
- g.setColor(color);
- g.drawRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- if(flag)
- g.drawRect(rectangle.x + 1, rectangle.y + 1, rectangle.width - 2, rectangle.height != 2 ? rectangle.height - 2 : 1);
- g.setColor(color1);
- } else
- {
- if(super.gridAlignment == 1)
- g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- else
- g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- if(flag)
- {
- Color color2 = g.getColor();
- if(barOutlineColor != null)
- g.setColor(barOutlineColor);
- else
- g.setColor(color);
- if(super.gridAlignment == 1)
- g.drawRect(rectangle.x, rectangle.y, rectangle.width - 1, rectangle.height);
- else
- g.drawRect(rectangle.x, rectangle.y, rectangle.width - 1, rectangle.height - 1);
- g.setColor(color2);
- }
- }
- if(is3DModeOn())
- paint3DBar(g, rectangle, flag, d);
- }
- public void setBarLabelsOn(boolean flag)
- {
- super.sampleLabelsOn = flag;
- super.hasChanged = true;
- autoRepaint();
- }
- public void setAutoLabelSpacingOn(boolean flag)
- {
- autoLabelSpacingOn = flag;
- super.hasChanged = true;
- autoRepaint();
- }
- protected void processEvent(AWTEvent awtevent)
- {
- switch(awtevent.getID())
- {
- case 504:
- default:
- break;
- case 505:
- selectedSample = -1;
- selectedSeries = -1;
- repaint();
- break;
- case 503:
- case 506:
- MouseEvent mouseevent = (MouseEvent)awtevent;
- boolean flag = isValueLabelsOn() && valueLabelStyle == 2;
- flag = flag || super.sampleLabelsOn && (super.barLabelStyle == 1 || super.barLabelStyle == 2);
- if(!flag)
- break;
- mousePosition.x = mouseevent.getX();
- mousePosition.y = mouseevent.getY();
- ChartSample chartsample = super.checkSelection(mousePosition);
- if(chartsample != null)
- {
- mousePosition.x = -1;
- mousePosition.y = -1;
- } else
- {
- chartsample = checkSelection(mousePosition);
- }
- if(chartsample != null)
- {
- if(chartsample.getIndex() != selectedSample || chartsample.getSeries() != selectedSeries)
- {
- selectedSample = chartsample.getIndex();
- selectedSeries = chartsample.getSeries();
- repaint();
- }
- break;
- }
- boolean flag1 = selectedSample != -1 || selectedSeries != -1;
- selectedSample = -1;
- selectedSeries = -1;
- if(flag1)
- repaint();
- break;
- }
- super.processEvent(awtevent);
- }
- public void setBarLabels(String as[])
- {
- super.barLabels = as;
- super.hasChanged = true;
- autoRepaint();
- }
- public String[] getBarLabels()
- {
- if(super.barLabels != null)
- return super.barLabels;
- else
- return getSampleLabels();
- }
- public String[] getLegendLabels()
- {
- if(super.legendLabels != null)
- return super.legendLabels;
- if(getSeriesCount() > 1 || barType == 1 || super.multiSeriesOn)
- return getSeriesLabels();
- else
- return getSampleLabels();
- }
- public void setBarType(int i)
- {
- if(i == 0 || i == 1)
- {
- barType = i;
- super.hasChanged = true;
- autoRepaint();
- } else
- {
- throw new IllegalArgumentException("Invalid bar type: " + i);
- }
- }
- public int getBarType()
- {
- return barType;
- }
- double getHighestValue(int i)
- {
- if(barType == 0)
- return super.getHighestValue(i);
- double d = 0.0D;
- int j = getSampleCount();
- int k = getSeriesCount();
- for(int l = 0; l < j; l++)
- {
- double d1 = 0.0D;
- for(int i1 = 0; i1 < k; i1++)
- {
- ChartSample chartsample = getSample(i1, l);
- if(chartsample != null && chartsample.value != null && !chartsample.value.isNaN() && chartsample.value.doubleValue() > 0.0D)
- d1 += chartsample.value.doubleValue();
- }
- d = Math.max(d, d1);
- }
- return d;
- }
- double getLowestValue(int i)
- {
- if(barType == 0)
- return super.getLowestValue(i);
- double d = 0.0D;
- int j = getSampleCount();
- int k = getSeriesCount();
- for(int l = 0; l < j; l++)
- {
- double d1 = 0.0D;
- for(int i1 = 0; i1 < k; i1++)
- {
- ChartSample chartsample = getSample(i1, l);
- if(chartsample != null && chartsample.value != null && !chartsample.value.isNaN() && chartsample.value.doubleValue() < 0.0D)
- d1 += chartsample.value.doubleValue();
- }
- d = Math.min(d, d1);
- }
- return d;
- }
- public void setBarAlignment(int i)
- {
- if(i == 0 || i == 1)
- {
- super.gridAlignment = i;
- super.hasChanged = true;
- autoRepaint();
- } else
- {
- throw new IllegalArgumentException("Alignment must be HORIZONTAL or VERTICAL");
- }
- }
- public int getgridAlignment()
- {
- return super.gridAlignment;
- }
- protected void calculateChartData(Rectangle rectangle, Rectangle rectangle1)
- {
- calculateZeroLines(rectangle);
- int i = getSampleCount();
- int j = getSeriesCount();
- if(is3DModeOn() && i > 0 && j > 0)
- if(super.depth3d >= 0)
- {
- super.depth3dPoint.x = super.depth3d;
- super.depth3dPoint.y = -super.depth3d;
- } else
- if(super.gridAlignment == 1)
- {
- double d = (double)rectangle.width / (double)i;
- double d3 = d * barWidthFraction;
- if(barType == 0)
- d3 /= j;
- super.depth3dPoint.x = (int)Math.round(d3 * 1.25D);
- super.depth3dPoint.y = (int)Math.round(-d3 / 1.25D);
- } else
- {
- double d1 = (double)rectangle.height / (double)i;
- double d4 = d1 * barWidthFraction;
- if(barType == 0)
- d4 /= j;
- super.depth3dPoint.x = (int)Math.round(d4 * 1.25D * 0.75D);
- super.depth3dPoint.y = (int)Math.round(-((d4 / 1.25D) * 0.75D));
- }
- if(barBounds == null || barBounds.length != j || barBounds[0].length != i)
- {
- Rectangle arectangle[][] = new Rectangle[j][i];
- for(int l = 0; l < j; l++)
- {
- for(int j1 = 0; j1 < i; j1++)
- if(barBounds != null && l < barBounds.length && j1 < barBounds[0].length && barBounds[l][j1] != null)
- arectangle[l][j1] = barBounds[l][j1];
- }
- barBounds = arectangle;
- }
- for(int k = 0; k < i; k++)
- {
- for(int i1 = 0; i1 < j; i1++)
- if(barBounds[i1][k] == null)
- barBounds[i1][k] = new Rectangle();
- }
- double d2 = 0.0D;
- double d5 = rectangle1.width;
- if(i > 0 && j > 0)
- {
- if(super.gridAlignment == 1)
- d2 = (double)rectangle1.width / (double)i;
- else
- d2 = (double)rectangle1.height / (double)i;
- d5 = d2 * barWidthFraction;
- if(barType == 0)
- d5 /= j;
- }
- double d6 = d2 * (1.0D - barWidthFraction);
- double d7 = 0.0D;
- boolean flag = is3DModeOn();
- if(super.gridAlignment == 1)
- {
- d7 = (double)rectangle1.x + d6 / 2D;
- if(flag)
- d7 -= super.depth3dPoint.x;
- } else
- {
- d7 = (double)rectangle1.y + d6 / 2D;
- if(flag)
- d7 -= super.depth3dPoint.y;
- }
- if(super.gridAlignment == 1)
- {
- for(int k1 = 0; k1 < i; k1++)
- {
- for(int i2 = 0; i2 < j; i2++)
- {
- Rectangle rectangle2 = barBounds[i2][k1];
- rectangle2.x = (int)Math.round(d7);
- rectangle2.width = (int)Math.round(d7 + d5) - rectangle2.x;
- boolean flag1 = barType == 1;
- int k2 = flag1 ? 0 : getSeriesRange(i2);
- double d8 = getSampleValue(i2, k1);
- if(d8 >= 0.0D)
- {
- double d10 = 0.0D;
- if(super.currentUpperRange[k2] != 0.0D)
- d10 = (d8 / super.currentUpperRange[k2]) * (double)(super.zeroLine[k2] - rectangle1.y);
- rectangle2.height = (int)Math.round(d10);
- rectangle2.y = super.zeroLine[k2] - rectangle2.height;
- rectangle2.height = Math.max(0, rectangle2.height);
- if(flag1 && i2 > 0)
- {
- double d14 = 0.0D;
- for(int i4 = 0; i4 < i2; i4++)
- if(getSampleValue(i4, k1) >= 0.0D)
- d14 += getSampleValue(i4, k1);
- double d18 = 0.0D;
- if(super.currentUpperRange[k2] != 0.0D)
- d18 = (d14 / super.currentUpperRange[k2]) * (double)(super.zeroLine[k2] - rectangle1.y);
- double d22 = (double)super.zeroLine[k2] - d18 - d10;
- rectangle2.y = (int)Math.round(d22);
- rectangle2.height = (int)Math.round((d10 + d22) - (double)Math.round(d22));
- }
- int i3 = rectangle2.y + rectangle2.height;
- int k3 = rectangle1.y + rectangle1.height;
- if(i3 > k3)
- rectangle2.height -= i3 - k3;
- } else
- {
- double d11 = 0.0D;
- if(super.currentLowerRange[k2] != 0.0D)
- d11 = (d8 / super.currentLowerRange[k2]) * (double)((rectangle1.y + rectangle1.height) - super.zeroLine[k2]);
- rectangle2.height = (int)Math.round(d11);
- rectangle2.y = super.zeroLine[k2];
- if(flag1 && i2 > 0)
- {
- double d15 = 0.0D;
- for(int j4 = 0; j4 < i2; j4++)
- if(getSampleValue(j4, k1) < 0.0D)
- d15 += getSampleValue(j4, k1);
- double d19 = 0.0D;
- if(super.currentLowerRange[k2] != 0.0D)
- d19 = (d15 / super.currentLowerRange[k2]) * (double)((rectangle1.y + rectangle1.height) - super.zeroLine[k2]);
- double d23 = (double)super.zeroLine[k2] + d19;
- rectangle2.y = (int)Math.round(d23);
- rectangle2.height = (int)Math.round((d11 + d23) - (double)Math.round(d23));
- }
- if(rectangle2.y < rectangle1.y)
- {
- rectangle2.height -= rectangle1.y - rectangle2.y;
- rectangle2.y = rectangle1.y;
- }
- }
- if(flag)
- rectangle2.y -= super.depth3dPoint.y;
- if(barType == 0 || i2 == j - 1)
- d7 += d5;
- }
- d7 += d6;
- }
- } else
- {
- for(int l1 = 0; l1 < i; l1++)
- {
- for(int j2 = 0; j2 < j; j2++)
- {
- Rectangle rectangle3 = barBounds[j2][l1];
- rectangle3.y = (int)Math.round(d7);
- rectangle3.height = (int)Math.round(d7 + d5) - rectangle3.y;
- boolean flag2 = barType == 1;
- int l2 = flag2 ? 0 : getSeriesRange(j2);
- double d9 = getSampleValue(j2, l1);
- if(d9 >= 0.0D)
- {
- double d12 = 0.0D;
- if(super.currentUpperRange[l2] != 0.0D)
- d12 = (d9 / super.currentUpperRange[l2]) * (double)((rectangle1.x + rectangle1.width) - super.zeroLine[l2]);
- rectangle3.width = (int)Math.round(d12);
- rectangle3.x = super.zeroLine[l2];
- if(barType == 1 && j2 > 0)
- {
- double d16 = 0.0D;
- for(int k4 = 0; k4 < j2; k4++)
- if(getSampleValue(k4, l1) >= 0.0D)
- d16 += getSampleValue(k4, l1);
- double d20 = 0.0D;
- if(super.currentUpperRange[l2] != 0.0D)
- d20 = (d16 / super.currentUpperRange[l2]) * (double)((rectangle1.x + rectangle1.width) - super.zeroLine[l2]);
- double d24 = (double)super.zeroLine[l2] + d20;
- rectangle3.x = (int)Math.round(d24);
- rectangle3.width = (int)Math.round((d12 + d24) - (double)Math.round(d24));
- }
- if(rectangle3.x < rectangle1.x)
- {
- rectangle3.width -= rectangle1.x - rectangle3.x;
- rectangle3.x = rectangle1.x;
- }
- } else
- {
- double d13 = 0.0D;
- if(super.currentLowerRange[l2] != 0.0D)
- d13 = (d9 / super.currentLowerRange[l2]) * (double)(super.zeroLine[l2] - rectangle1.x);
- rectangle3.width = (int)Math.round(d13);
- rectangle3.x = super.zeroLine[l2] - rectangle3.width;
- if(barType == 1 && j2 > 0)
- {
- double d17 = 0.0D;
- for(int l4 = 0; l4 < j2; l4++)
- if(getSampleValue(l4, l1) < 0.0D)
- d17 += getSampleValue(l4, l1);
- double d21 = 0.0D;
- if(super.currentLowerRange[l2] != 0.0D)
- d21 = (d17 / super.currentLowerRange[l2]) * (double)(super.zeroLine[l2] - rectangle1.x);
- double d25 = (double)super.zeroLine[l2] - d21 - d13;
- rectangle3.x = (int)Math.round(d25);
- rectangle3.width = (int)Math.round((d13 + d25) - (double)Math.round(d25));
- }
- int j3 = rectangle3.x + rectangle3.width;
- int l3 = rectangle1.x + rectangle1.width;
- if(j3 > l3)
- rectangle3.width -= j3 - l3;
- }
- if(flag)
- rectangle3.x -= super.depth3dPoint.x;
- if(barType == 0 || j2 == j - 1)
- d7 += d5;
- }
- d7 += d6;
- }
- }
- }
- private void paintBarLabels(Graphics g, Rectangle rectangle)
- {
- if(!super.sampleLabelsOn || super.barLabelStyle == 1)
- return;
- String as[] = getBarLabels();
- if(as == null)
- return;
- Font font = getFont("barLabelFont");
- g.setFont(font);
- FontMetrics fontmetrics = g.getFontMetrics();
- if(super.gridAlignment == 1)
- {
- int i = getLabelAngle("barLabelAngle");
- int k = 0;
- int i1 = Math.min(as.length, getSampleCount());
- for(int k1 = 0; k1 < i1; k1++)
- if(as[k1] != null)
- {
- Color color1 = getSampleLabelColor(k1);
- if(color1 != null)
- g.setColor(color1);
- else
- g.setColor(getForeground());
- Dimension dimension1 = getLabelSize(as[k1], font);
- Dimension dimension3 = getAngledLabelSize(dimension1, i);
- int i2 = barBounds[0][k1].x;
- int k2 = (barBounds[barBounds.length - 1][k1].x + barBounds[barBounds.length - 1][k1].width) - i2;
- int i3 = i2 + k2 / 2;
- if(i % 90 == 0)
- i2 = i3 - dimension3.width / 2;
- else
- if(i % 180 > 90)
- i2 = (i3 + k2 / 2) - dimension3.width;
- else
- i2 = i3 - k2 / 2;
- int k3 = rectangle.x - 2 - (is3DModeOn() ? super.depth3dPoint.x : 0);
- if(i3 >= k3 && i3 <= rectangle.x + rectangle.width + 2)
- {
- int i4 = rectangle.y + rectangle.height + 6;
- if(i % 180 == 0)
- i4 += fontmetrics.getMaxAscent() - 4;
- if(is3DModeOn())
- i4 -= super.depth3dPoint.y;
- if(super.sampleScrollerOn)
- i4 += 10;
- if(isValueLabelsOn() && valueLabelStyle == 0 && super.lowerRange[0] < 0.0D)
- {
- int k4 = rectangle.y;
- int l4 = super.zeroLine[0] - (is3DModeOn() ? super.depth3dPoint.y : 0);
- for(int i5 = 0; i5 < barBounds.length; i5++)
- {
- int k5 = barBounds[i5][k1].y + barBounds[i5][k1].height;
- if(k5 > k4 && k5 > l4)
- k4 = k5;
- }
- i4 = Math.max(i4, k4 + fontmetrics.getMaxAscent() + 10);
- k4 = (rectangle.y + rectangle.height) - (is3DModeOn() ? super.depth3dPoint.y : 0);
- i4 = Math.min(i4, k4 + fontmetrics.getMaxAscent() + 10);
- }
- if(autoLabelSpacingOn)
- {
- if(as[k1] != null && as[k1].trim().length() > 0 && (i2 > k || k1 == 0))
- {
- paintLabel(g, as[k1], i2, i4, dimension1, 0, i);
- k = i2 + dimension3.width;
- }
- } else
- {
- paintLabel(g, as[k1], i2, i4, dimension1, 0, i);
- }
- }
- }
- } else
- {
- int j = getLabelAngle("barLabelAngle");
- int l = Math.min(as.length, getSampleCount());
- for(int j1 = 0; j1 < l; j1++)
- if(as[j1] != null)
- {
- Color color = getSampleLabelColor(j1);
- if(color != null)
- g.setColor(color);
- else
- g.setColor(getForeground());
- Dimension dimension = getLabelSize(as[j1], font);
- Dimension dimension2 = getAngledLabelSize(dimension, j);
- int l1 = (barBounds[barBounds.length - 1][j1].y + barBounds[barBounds.length - 1][j1].height) - barBounds[0][j1].y;
- int j2 = barBounds[0][j1].y + l1 / 2;
- int l2 = j2 - dimension2.height / 2;
- if(j % 180 == 0)
- l2 += fontmetrics.getAscent() - 1;
- else
- if(j % 180 > 90)
- l2 = j2 - l1 / 2;
- else
- l2 = (j2 + l1 / 2) - dimension2.height;
- if(j % 180 != 0 || l2 >= rectangle.y - 2 && l2 <= (rectangle.y + rectangle.height) - (is3DModeOn() ? super.depth3dPoint.y : 0))
- {
- int j3 = rectangle.x - dimension2.width - 3;
- if(is3DModeOn())
- j3 -= super.depth3dPoint.x;
- if(super.sampleScrollerOn)
- j3 -= 10;
- if(isValueLabelsOn() && valueLabelStyle == 0 && super.lowerRange[0] < 0.0D)
- {
- int l3 = rectangle.x + rectangle.width;
- int j4 = 0;
- double d = 0.0D;
- for(int j5 = 0; j5 < barBounds.length; j5++)
- if(getSampleValue(j5, j1) < 0.0D)
- {
- if(barType == 1)
- d += getSampleValue(j5, j1);
- else
- d = getSampleValue(j5, j1);
- if(barBounds[j5][j1].x < l3)
- {
- String s = getLabel("valueLabelPrefix");
- String s1 = getLabel("valueLabelPostfix");
- l3 = barBounds[j5][j1].x;
- String s2 = formatNumber(d, getSampleDecimalCount(0));
- s2 = s == null ? s2 : s + s2;
- s2 = s1 == null ? s2 : s2 + s1;
- j4 = fontmetrics.stringWidth(s2);
- }
- }
- j3 = Math.min(j3, l3 - j4 - dimension2.width - 3);
- l3 = rectangle.x - (is3DModeOn() ? super.depth3dPoint.x : 0);
- j3 = Math.max(j3, l3 - j4 - dimension2.width - 3);
- l3 -= super.sampleScrollerOn ? 10 : 0;
- j3 = Math.min(j3, l3 - dimension2.width - 3);
- }
- paintLabel(g, as[j1], j3, l2, dimension, 1, j);
- }
- }
- }
- }
- private void paintFloatingLabels(Graphics g, Rectangle rectangle)
- {
- boolean flag = valueLabelStyle == 2 || super.barLabelStyle == 1 || super.barLabelStyle == 2;
- if(flag && selectedSeries >= 0 && selectedSample >= -1)
- {
- Font font = getFont("floatingLabelFont");
- g.setFont(font);
- FontMetrics fontmetrics = g.getFontMetrics();
- if(selectedSample >= 0)
- {
- String s = constructFloatingLabel(selectedSeries, selectedSample, true);
- paintFloatingLabel(g, rectangle, selectedSeries, selectedSample, s, font, fontmetrics);
- } else
- if(isFloatingOnLegendOn())
- {
- int i = getSampleCount();
- for(int j = 0; j < i; j++)
- {
- String s1 = constructFloatingLabel(selectedSeries, j, false);
- paintFloatingLabel(g, rectangle, selectedSeries, j, s1, font, fontmetrics);
- }
- }
- }
- }
- public void setMultiColorOn(boolean flag)
- {
- multiColorOn = flag;
- super.hasChanged = true;
- autoRepaint();
- }
- private void paintBars(Graphics g, Rectangle rectangle)
- {
- int i = getSeriesCount();
- int j = getSampleCount();
- if(rectangle.width < 0 || rectangle.height < 0)
- return;
- boolean flag = is3DModeOn();
- if(flag)
- g.setClip((rectangle.x - super.depth3dPoint.x) + 1, rectangle.y + 1, (rectangle.width + super.depth3dPoint.x) - 1, rectangle.height - super.depth3dPoint.y - 1);
- else
- if(super.parentChart != null && super.parentChart.is3DModeOn())
- g.setClip((rectangle.x + 1) - super.parentChart.depth3dPoint.x, (rectangle.y + 1) - super.parentChart.depth3dPoint.y, rectangle.width - 1, rectangle.height - 1);
- else
- g.setClip(rectangle.x + 1, rectangle.y + 1, rectangle.width - 1, rectangle.height - 1);
- if(super.gridAlignment == 1)
- {
- if(barType == 0)
- {
- for(int k = 0; k < j; k++)
- {
- for(int i2 = 0; i2 < i; i2++)
- paintBar(g, i2, k);
- }
- } else
- {
- for(int l = 0; l < j; l++)
- {
- for(int j2 = i - 1; j2 >= 0; j2--)
- if(getSampleValue(j2, l) < 0.0D)
- paintBar(g, j2, l);
- }
- for(int i1 = 0; i1 < j; i1++)
- {
- for(int k2 = 0; k2 < i; k2++)
- if(getSampleValue(k2, i1) >= 0.0D)
- paintBar(g, k2, i1);
- }
- }
- } else
- if(barType == 0)
- {
- for(int j1 = j - 1; j1 >= 0; j1--)
- {
- for(int l2 = i - 1; l2 >= 0; l2--)
- paintBar(g, l2, j1);
- }
- } else
- {
- for(int k1 = j - 1; k1 >= 0; k1--)
- {
- for(int i3 = i - 1; i3 >= 0; i3--)
- if(getSampleValue(i3, k1) < 0.0D)
- paintBar(g, i3, k1);
- }
- for(int l1 = j - 1; l1 >= 0; l1--)
- {
- for(int j3 = 0; j3 < i; j3++)
- if(getSampleValue(j3, l1) >= 0.0D)
- paintBar(g, j3, l1);
- }
- }
- if(flag)
- {
- g.setColor(getBackground());
- Polygon polygon = new Polygon();
- polygon.addPoint(rectangle.x + rectangle.width, rectangle.y + rectangle.height);
- polygon.addPoint(rectangle.x + rectangle.width, ((rectangle.y + rectangle.height) - super.depth3dPoint.y) + 1);
- polygon.addPoint((rectangle.x + rectangle.width) - super.depth3dPoint.x - 1, ((rectangle.y + rectangle.height) - super.depth3dPoint.y) + 1);
- g.fillPolygon(polygon);
- g.setColor(getChartForeground());
- g.drawLine(rectangle.x + rectangle.width, rectangle.y + rectangle.height, (rectangle.x + rectangle.width) - super.depth3dPoint.x, (rectangle.y + rectangle.height) - super.depth3dPoint.y);
- polygon.xpoints[0] = rectangle.x;
- polygon.ypoints[0] = rectangle.y;
- polygon.xpoints[1] = rectangle.x - super.depth3dPoint.x;
- polygon.ypoints[1] = rectangle.y;
- polygon.xpoints[2] = rectangle.x - super.depth3dPoint.x;
- polygon.ypoints[2] = rectangle.y - super.depth3dPoint.y;
- g.setColor(getBackground());
- g.fillPolygon(polygon);
- g.setColor(getChartForeground());
- g.drawLine(rectangle.x, rectangle.y, rectangle.x - super.depth3dPoint.x, rectangle.y - super.depth3dPoint.y);
- }
- }
- public void setValueLabelStyle(int i)
- {
- switch(i)
- {
- case 0: // ' '
- case 1: // ' 01'
- case 2: // ' 02'
- valueLabelStyle = i;
- super.hasChanged = true;
- autoRepaint();
- break;
- default:
- throw new IllegalArgumentException("Invalid valueLabelStyle: " + i);
- }
- }
- public int getValueLabelStyle()
- {
- return valueLabelStyle;
- }
- public boolean isMultiColorOn()
- {
- return multiColorOn;
- }
- public boolean isBarOutlineOn()
- {
- return barOutlineOn;
- }
- public ChartSample checkSelection(Point point)
- {
- ChartSample chartsample = null;
- int i = getSeriesCount();
- if(isLegendOn() && super.legendBounds != null)
- {
- for(int j = 0; j < super.legendBounds.length; j++)
- {
- if(super.legendBounds[j] == null || !super.legendBounds[j].contains(point))
- continue;
- if(i > 1 || barType == 1 || super.multiSeriesOn)
- {
- chartsample = new ChartSample(-1);
- chartsample.setSeries(j);
- } else
- {
- chartsample = getSample(0, j);
- }
- break;
- }
- }
- if(chartsample == null && barBounds != null)
- {
- for(int k = getSampleCount(); k != 0;)
- {
- int l = super.gridAlignment != 0 ? k - 1 : getSampleCount() - k;
- k--;
- for(int i1 = getSeriesCount(); i1 != 0;)
- {
- int j1 = super.gridAlignment != 0 ? i1 - 1 : getSeriesCount() - i1;
- j1 = barType != 1 ? j1 : i1 - 1;
- i1--;
- Rectangle rectangle = barBounds[j1][l];
- if(rectangle != null && rectangle != null)
- {
- Rectangle rectangle1 = rectangle;
- if(barType != 1 || getSeriesCount() <= 1)
- if(super.gridAlignment == 1 && rectangle1.height < 3)
- {
- rectangle1.y -= 3 - rectangle1.height;
- rectangle1.height = 6;
- } else
- if(super.gridAlignment == 0 && rectangle1.width < 3)
- {
- rectangle1.x -= 3 - rectangle1.width;
- rectangle1.width = 6;
- }
- if(rectangle1.contains(point))
- return getSample(j1, l);
- if(is3DModeOn())
- {
- if(super.gridAlignment != 1 || barType != 1 || getSampleValues(j1)[l] > 0.0D || j1 == 0)
- {
- Polygon polygon = new Polygon();
- polygon.addPoint(rectangle.x, rectangle.y);
- polygon.addPoint(polygon.xpoints[0] + super.depth3dPoint.x, polygon.ypoints[0] + super.depth3dPoint.y);
- polygon.addPoint(polygon.xpoints[1] + rectangle.width, polygon.ypoints[1]);
- polygon.addPoint(rectangle.x + rectangle.width, rectangle.y);
- if(polygon.contains(point))
- return getSample(j1, l);
- }
- if(super.gridAlignment != 0 || barType != 1 || getSampleValues(j1)[l] > 0.0D || j1 == 0)
- {
- Polygon polygon1 = new Polygon();
- polygon1.addPoint((rectangle.x + rectangle.width) - 1, rectangle.y);
- polygon1.addPoint(rectangle.x + super.depth3dPoint.x + rectangle.width, rectangle.y + super.depth3dPoint.y);
- polygon1.addPoint(rectangle.x + super.depth3dPoint.x + rectangle.width, rectangle.y + super.depth3dPoint.y + rectangle.height);
- polygon1.addPoint((rectangle.x + rectangle.width) - 1, rectangle.y + rectangle.height);
- if(polygon1.contains(point))
- return getSample(j1, l);
- }
- }
- }
- }
- }
- }
- return chartsample;
- }
- protected void renderData(Graphics g, Rectangle rectangle, Rectangle rectangle1)
- {
- paintBars(g, rectangle);
- if(is3DModeOn())
- {
- for(int i = super.rangeOn.length - 1; i >= 0; i--)
- paint3DZeroDivider(g, rectangle, i);
- if(isRangeOn(1))
- paint3DEdges(super.og, rectangle);
- }
- paintValueLabels(g, rectangle);
- }
- public void reset()
- {
- super.reset();
- multiColorOn = false;
- super.barLabelStyle = 0;
- valueLabelStyle = 0;
- barOutlineOn = true;
- autoLabelSpacingOn = false;
- barWidthFraction = 0.40000000000000002D;
- barType = 0;
- super.multiSeriesOn = false;
- barWidthFraction = 0.40000000000000002D;
- selectedSeries = -1;
- selectedSample = -1;
- barOutlineColor = null;
- }
- public BarChart()
- {
- this(1);
- }
- public BarChart(int i)
- {
- this(i, 100D);
- }
- public BarChart(int i, double d)
- {
- this(i, d, 0.0D);
- }
- public BarChart(int i, double d, double d1)
- {
- this(1, i, d, d1);
- }
- public BarChart(int i, int j, double d, double d1)
- {
- super(j);
- super.chartType = "bar";
- setAutomaticRepaintOn(false);
- setSeriesCount(i);
- super.upperRange[0] = super.currentUpperRange[0] = d;
- super.lowerRange[0] = super.currentLowerRange[0] = d1;
- mousePosition = new Point();
- setAutomaticRepaintOn(true);
- }
- public boolean isBarLabelsOn()
- {
- return super.sampleLabelsOn;
- }
- public boolean isAutoLabelSpacingOn()
- {
- return autoLabelSpacingOn;
- }
- public void setMultiSeriesOn(boolean flag)
- {
- super.multiSeriesOn = flag;
- super.hasChanged = true;
- autoRepaint();
- }
- private String constructFloatingLabel(int i, int j, boolean flag)
- {
- if(i < 0 || i >= getSeriesCount() || j < 0 || j >= getSampleCount())
- return "";
- String s = "";
- if(super.sampleLabelsOn && (super.barLabelStyle == 1 || super.barLabelStyle == 2))
- if(getSeriesCount() == 1)
- {
- if(getSampleLabel(j) != null)
- s += getSampleLabel(j);
- } else
- {
- String s1 = getSeriesLabel(i);
- if(flag && s1 != null)
- if(s1.endsWith("n"))
- s += s1;
- else
- s += s1 + " : ";
- if(getSampleLabel(j) != null)
- s += getSampleLabel(j);
- }
- if(isValueLabelsOn() && valueLabelStyle == 2)
- {
- String s2 = getLabel("valueLabelPrefix_" + i);
- if(s2 == null)
- s2 = getLabel("valueLabelPrefix");
- String s3 = getLabel("valueLabelPostfix_" + i);
- if(s3 == null)
- s3 = getLabel("valueLabelPostfix");
- if(s.length() > 0)
- {
- String s4 = formatNumber(getSampleValue(i, j), getSampleDecimalCount(i));
- s4 = s2 == null ? s4 : s2 + s4;
- s4 = s3 == null ? s4 : s4 + s3;
- if(s.endsWith("n"))
- s += s4;
- else
- s = s + " : " + s4;
- } else
- {
- s = formatNumber(getSampleValue(i, j), getSampleDecimalCount(i));
- s = s2 == null ? s : s2 + s;
- s = s3 == null ? s : s + s3;
- }
- }
- return s;
- }
- private void paintValueLabels(Graphics g, Rectangle rectangle)
- {
- g.setClip(0, 0, 32767, 32767);
- int i = getSampleCount();
- int j = getSeriesCount();
- if(i == 0 || j == 0 || valueLabelStyle == 2)
- return;
- Font font = getFont("valueLabelFont");
- getSize();
- g.setFont(font);
- FontMetrics fontmetrics = g.getFontMetrics();
- boolean flag = is3DModeOn();
- int k = rectangle.y;
- int l = (k + rectangle.height) - (flag ? super.depth3dPoint.y : 0);
- int i1 = rectangle.x - (flag ? super.depth3dPoint.x : 0);
- int j1 = rectangle.x + rectangle.width;
- getChartBackground();
- int k1 = getLabelAngle("valueLabelAngle");
- int l1 = fontmetrics.getHeight();
- int i2 = fontmetrics.getDescent();
- int j2 = fontmetrics.getAscent();
- if(valueLabelStyle == 0 && j > 1 && barType == 1)
- {
- if(!isValueLabelsOn(0))
- return;
- int k2 = getSampleDecimalCount(0);
- String s = getLabel("valueLabelPrefix");
- String s1 = getLabel("valueLabelPostfix");
- for(int j3 = 0; j3 < i; j3++)
- {
- double d = 0.0D;
- double d2 = 0.0D;
- boolean flag1 = false;
- for(int l3 = 0; l3 < j; l3++)
- {
- ChartSample chartsample1 = getSample(l3, j3);
- if(chartsample1 != null && chartsample1.value != null)
- {
- flag1 = true;
- double d3 = chartsample1.getFloatValue();
- if(d3 >= 0.0D)
- d += d3;
- else
- d2 += d3;
- }
- }
- if(flag1)
- {
- String s5 = formatNumber(d, k2);
- s5 = s == null ? s5 : s + s5;
- s5 = s1 == null ? s5 : s5 + s1;
- Dimension dimension1 = getLabelSize(s5, font);
- Dimension dimension3 = getAngledLabelSize(dimension1, k1);
- int i4 = fontmetrics.stringWidth(s5);
- String s6 = formatNumber(d2, k2);
- s6 = s == null ? s6 : s + s6;
- s6 = s1 == null ? s6 : s6 + s1;
- Dimension dimension4 = getLabelSize(s6, font);
- Dimension dimension5 = getAngledLabelSize(dimension4, k1);
- int l4 = fontmetrics.stringWidth(s6);
- Rectangle rectangle2 = barBounds[0][j3];
- Rectangle rectangle3 = barBounds[0][j3];
- for(int i5 = 0; i5 < barBounds.length; i5++)
- {
- Rectangle rectangle4 = barBounds[i5][j3];
- if(rectangle4 != null)
- if(super.gridAlignment == 1)
- {
- if(rectangle4.y < rectangle2.y)
- rectangle2 = rectangle4;
- if(rectangle4.y + rectangle4.height > rectangle3.y + rectangle3.height)
- rectangle3 = rectangle4;
- } else
- {
- if(rectangle4.x + rectangle4.width > rectangle2.x + rectangle2.width)
- rectangle2 = rectangle4;
- if(rectangle4.x < rectangle3.x)
- rectangle3 = rectangle4;
- }
- }
- int j5 = (rectangle2.x + rectangle2.width / 2) - dimension3.width / 2;
- int k5 = rectangle2.y - 2;
- if(k1 % 180 != 0)
- k5 -= dimension3.height;
- int l5 = (rectangle3.x + rectangle3.width / 2) - dimension5.width / 2;
- int i6 = (rectangle3.y + rectangle3.height + l1) - i2;
- if(k1 % 180 != 0)
- i6 = rectangle3.y + rectangle3.height + 2;
- if(super.gridAlignment == 0)
- {
- j5 = rectangle2.x + rectangle2.width + 2;
- k5 = ((rectangle2.y + rectangle2.height / 2 + l1 / 2) - i2) + 1;
- l5 = rectangle3.x - l4 - 1;
- i6 = k5;
- }
- if(flag)
- if(super.gridAlignment == 1)
- {
- j5 += super.depth3dPoint.x;
- k5 += super.depth3dPoint.y;
- } else
- {
- j5 += super.depth3dPoint.x;
- k5 += super.depth3dPoint.y;
- }
- if(super.gridAlignment == 1)
- {
- if(k1 % 180 == 0)
- {
- k5 = Math.max(k5, rectangle.y - 2);
- k5 = Math.min((rectangle.y + rectangle.height) - 2, k5);
- i6 = Math.max((rectangle.y + j2) - (flag ? super.depth3dPoint.y : 0), i6);
- i6 = Math.min((rectangle.y + rectangle.height + j2) - (flag ? super.depth3dPoint.y : 0), i6);
- } else
- {
- k5 = Math.max(k5, rectangle.y - dimension3.height - 2);
- k5 = Math.min(k5, (rectangle.y + rectangle.height) - dimension3.height - 2);
- i6 = Math.min(i6, (rectangle.y + rectangle.height + 2) - (flag ? super.depth3dPoint.y : 0));
- i6 = Math.max(i6, (rectangle.y + 2) - (flag ? super.depth3dPoint.y : 0));
- }
- } else
- {
- j5 = Math.min(rectangle.x + rectangle.width + 2, j5);
- j5 = Math.max(rectangle.x + 2, j5);
- l5 = Math.max(rectangle.x - l4 - 1 - (flag ? super.depth3dPoint.x : 0), l5);
- l5 = Math.min((rectangle.x + rectangle.width) - l4 - 1 - (flag ? super.depth3dPoint.x : 0), l5);
- }
- boolean flag3 = true;
- boolean flag4 = true;
- if(super.gridAlignment == 1)
- {
- if(j5 + i4 / 2 < i1 - 3 || j5 + i4 / 2 > j1 + 3)
- flag3 = false;
- if(l5 + l4 / 2 < i1 - 3 || l5 + l4 / 2 > j1 + 3)
- flag4 = false;
- } else
- {
- if(k5 - l1 / 2 < k - 3 || k5 - l1 / 2 > l)
- flag3 = false;
- if(i6 - l1 / 2 < k - 3 || i6 - l1 / 2 > l)
- flag4 = false;
- }
- g.setColor(getForeground());
- if(d >= 0.0D && super.upperRange[0] > 0.0D && flag3 && (d != 0.0D || d2 >= 0.0D))
- paintLabel(g, s5, j5, k5, dimension1, 0, super.gridAlignment != 1 ? 0 : k1);
- if(d2 < 0.0D && super.lowerRange[0] < 0.0D && flag4)
- paintLabel(g, s6, l5, i6, dimension4, 0, super.gridAlignment != 1 ? 0 : k1);
- }
- }
- } else
- if(valueLabelStyle == 0 || valueLabelStyle == 1)
- {
- for(int l2 = 0; l2 < i; l2++)
- {
- for(int i3 = 0; i3 < j; i3++)
- {
- ChartSample chartsample = getSample(i3, l2);
- if(chartsample != null && chartsample.value != null && !chartsample.value.isNaN() && isValueLabelsOn(i3))
- {
- String s2 = getLabel("valueLabelPrefix_" + i3);
- if(s2 == null)
- s2 = getLabel("valueLabelPrefix");
- String s3 = getLabel("valueLabelPostfix_" + i3);
- if(s3 == null)
- s3 = getLabel("valueLabelPostfix");
- double d1 = chartsample.getFloatValue();
- int k3 = getSampleDecimalCount(i3);
- String s4 = formatNumber(d1, k3);
- s4 = s2 == null ? s4 : s2 + s4;
- s4 = s3 == null ? s4 : s4 + s3;
- Dimension dimension = getLabelSize(s4, font);
- Dimension dimension2 = getAngledLabelSize(dimension, k1);
- Rectangle rectangle1 = barBounds[i3][l2];
- int j4 = 0;
- int k4 = 0;
- boolean flag2 = true;
- if(valueLabelStyle == 0)
- {
- if(super.gridAlignment == 1)
- {
- j4 = (rectangle1.x + rectangle1.width / 2) - dimension2.width / 2;
- if(d1 >= 0.0D)
- {
- if(k1 % 180 == 0)
- {
- k4 = rectangle1.y - 2;
- k4 = Math.max(k - 2, k4);
- k4 = Math.min(l - 1, k4);
- } else
- {
- k4 = rectangle1.y - 2 - dimension2.height;
- k4 = Math.max(k4, k - dimension2.height - 2);
- k4 = Math.min(k4, l - dimension2.height - 2);
- }
- if(k1 % 180 > 0 && k1 % 180 < 90)
- j4 = ((rectangle1.x + rectangle1.width) - dimension2.width) + 1;
- else
- if(k1 % 180 > 90)
- j4 = rectangle1.x - 1;
- if(flag && j == 1)
- {
- k4 += super.depth3dPoint.y;
- j4 += super.depth3dPoint.x;
- if(k1 % 180 == 0)
- k4 = Math.max(k - 2, k4);
- else
- k4 = Math.max(k - dimension2.height - 2, k4);
- }
- } else
- {
- if(k1 % 180 == 0)
- {
- k4 = rectangle1.y + rectangle1.height + j2;
- k4 = Math.min(l + j2, k4);
- if(flag)
- k4 = Math.max((k - super.depth3dPoint.y) + j2, k4);
- else
- k4 = Math.max(k + j2, k4);
- } else
- {
- k4 = rectangle1.y + rectangle1.height + 3;
- k4 = Math.min(l + 3, k4);
- if(flag)
- k4 = Math.max((k - super.depth3dPoint.y) + 2, k4);
- else
- k4 = Math.max(k + 2, k4);
- }
- if(k1 % 180 > 0 && k1 % 180 < 90)
- j4 = rectangle1.x - 1;
- else
- if(k1 % 180 > 90)
- j4 = ((rectangle1.x + rectangle1.width) - dimension2.width) + 1;
- }
- } else
- {
- if(d1 >= 0.0D)
- {
- j4 = rectangle1.x + rectangle1.width + 3;
- j4 = Math.min(rectangle.x + rectangle.width + 3, j4);
- j4 = Math.max(i1 + 3, j4);
- } else
- {
- j4 = rectangle1.x - dimension.width - 3;
- j4 = Math.max(i1 - dimension.width - 3, j4);
- j4 = Math.min((i1 + rectangle.width) - dimension.width - 3, j4);
- }
- k4 = ((rectangle1.y + rectangle1.height / 2 + l1 / 2) - i2) + 1;
- if(flag && j == 1 && d1 >= 0.0D)
- {
- k4 += super.depth3dPoint.y;
- j4 += super.depth3dPoint.x;
- j4 = Math.min(rectangle.x + rectangle.width + 3, j4);
- }
- }
- } else
- if(super.gridAlignment == 1)
- {
- j4 = ((rectangle1.x + rectangle1.width / 2) - dimension2.width / 2) + 1;
- if(d1 >= 0.0D)
- {
- if(k1 % 180 == 0)
- {
- k4 = rectangle1.y + fontmetrics.getAscent();
- k4 = Math.max(k4, (rectangle.y + dimension2.height) - 1);
- k4 = Math.min(k4, (rectangle.y + rectangle.height) - 2);
- } else
- {
- k4 = rectangle1.y + 3;
- k4 = Math.min(k4, (rectangle1.y + rectangle1.height) - dimension2.height - 2);
- k4 = Math.max(k4, rectangle.y + 3);
- }
- } else
- if(k1 % 180 == 0)
- {
- k4 = (rectangle1.y + rectangle1.height) - 2;
- k4 = Math.min(k4, (rectangle.y + rectangle.height) - 2 - (flag ? super.depth3dPoint.y : 0));
- k4 = Math.max(k4, (rectangle.y + dimension2.height) - 1);
- } else
- {
- k4 = (rectangle1.y + rectangle1.height) - dimension2.height - 2;
- k4 = Math.min(k4, (rectangle.y + rectangle.height) - dimension2.height - 2 - (flag ? super.depth3dPoint.y : 0));
- k4 = Math.max(k4, (rectangle.y + 3) - (flag ? super.depth3dPoint.y : 0));
- }
- if(barType == 1 && j > 1)
- flag2 = dimension2.height < rectangle1.height;
- } else
- {
- k4 = ((rectangle1.y + rectangle1.height / 2 + l1 / 2) - i2) + 1;
- if(d1 >= 0.0D)
- {
- j4 = (rectangle1.x + rectangle1.width) - dimension.width - 1;
- j4 = Math.max(j4, rectangle1.x + 2);
- j4 = Math.min(j4, (rectangle.x + rectangle.width) - dimension.width - 1);
- } else
- {
- j4 = rectangle1.x + 2;
- j4 = Math.max(j4, (rectangle.x + 2) - (flag ? super.depth3dPoint.x : 0));
- j4 = Math.min(j4, (rectangle.x + rectangle.width) - dimension.width - 1 - (flag ? super.depth3dPoint.x : 0));
- }
- if(barType == 1 && j > 1)
- flag2 = dimension2.width < rectangle1.width;
- }
- Object obj = null;
- if(valueLabelStyle == 0)
- {
- g.setColor(getForeground());
- Color color = getChartBackground();
- } else
- {
- Color color2 = getSampleColor(0);
- if(multiColorOn)
- if(j > 1 || barType == 1 || super.multiSeriesOn)
- color2 = getSampleColor(i3);
- else
- color2 = getSampleColor(l2);
- if((color2.getRed() + color2.getGreen() + color2.getBlue()) / 3 > 110)
- g.setColor(Color.black);
- else
- g.setColor(Color.white);
- Color color1 = color2;
- }
- if(super.gridAlignment == 1)
- {
- if(j4 + dimension2.width / 2 < i1 - 3 || j4 + dimension2.width / 2 > j1 + 3)
- flag2 = false;
- } else
- if(k4 - l1 / 2 < k - 3 || k4 - l1 / 2 > l)
- flag2 = false;
- if(flag2)
- paintLabel(g, s4, j4, k4, dimension, 0, super.gridAlignment != 1 ? 0 : k1);
- }
- }
- }
- }
- }
- public void setBarWidth(double d)
- {
- d = Math.max(0.0D, d);
- d = Math.min(1.0D, d);
- barWidthFraction = d;
- super.hasChanged = true;
- autoRepaint();
- }
- public double getBarWidth()
- {
- return barWidthFraction;
- }
- public void setBarLabelStyle(int i)
- {
- switch(i)
- {
- case 0: // ' '
- case 1: // ' 01'
- case 2: // ' 02'
- super.barLabelStyle = i;
- super.hasChanged = true;
- autoRepaint();
- break;
- default:
- throw new IllegalArgumentException("Invalid barLabelStyle: " + i);
- }
- }
- public int getBarLabelStyle()
- {
- return super.barLabelStyle;
- }
- public void render(Graphics g)
- {
- render(g, !isServletModeOn());
- }
- void render(Graphics g, boolean flag)
- {
- Rectangle rectangle = getGraphBounds();
- Rectangle rectangle1 = getDataBounds(rectangle);
- calculateChartData(rectangle, rectangle1);
- for(int i = 0; i < super.overlayCharts.size(); i++)
- {
- Chart chart = (Chart)super.overlayCharts.elementAt(i);
- if(chart != null && isOverlayChartOn(i))
- {
- Rectangle rectangle2 = new Rectangle(rectangle);
- Rectangle rectangle3 = new Rectangle(rectangle1);
- if(is3DModeOn())
- {
- rectangle2.x -= super.depth3dPoint.x;
- rectangle2.y -= super.depth3dPoint.y;
- rectangle3.x -= super.depth3dPoint.x;
- rectangle3.y -= super.depth3dPoint.y;
- }
- chart.calculateChartData(rectangle2, rectangle3);
- }
- }
- Dimension dimension = getSize();
- if(flag && super.offscreen == null)
- {
- super.offscreen = createImage(Math.max(1, dimension.width), Math.max(1, dimension.height));
- super.hasChanged = true;
- }
- if(!flag || super.hasChanged || super.offscreen == null)
- {
- if(!super.externalGraphicsOn && !flag)
- super.og = g;
- else
- if(flag || super.externalGraphicsOn)
- {
- if(!super.externalGraphicsOn && super.offscreen != null)
- super.og = super.offscreen.getGraphics();
- super.og.setColor(getBackground());
- super.og.fillRect(0, 0, dimension.width, dimension.height);
- }
- paintTitle(super.og, dimension);
- if(isLegendOn())
- paintLegend(super.og, rectangle, getLegendLabels());
- paintGrid(super.og, rectangle);
- paintBarLabels(super.og, rectangle);
- if(super.upperRange != super.lowerRange)
- {
- renderData(super.og, rectangle, rectangle1);
- for(int j = 0; j < super.overlayCharts.size(); j++)
- {
- Chart chart1 = (Chart)super.overlayCharts.elementAt(j);
- if(chart1 != null && isOverlayChartOn(j))
- {
- Rectangle rectangle4 = new Rectangle(rectangle);
- Rectangle rectangle5 = new Rectangle(rectangle1);
- rectangle4.x -= super.depth3dPoint.x;
- rectangle4.y -= super.depth3dPoint.y;
- rectangle5.x -= super.depth3dPoint.x;
- rectangle5.y -= super.depth3dPoint.y;
- if(chart1 instanceof LineChart)
- chart1.renderData(super.og, rectangle4, getLineChartBounds(rectangle5));
- else
- if(chart1 instanceof PieChart)
- chart1.renderData(super.og, rectangle4, rectangle5);
- else
- chart1.renderData(super.og, rectangle, rectangle1);
- }
- }
- }
- if(!super.externalGraphicsOn && super.og != g)
- super.og.dispose();
- super.hasChanged = false;
- }
- if((flag || super.externalGraphicsOn) && super.offscreen != null)
- g.drawImage(super.offscreen, 0, 0, this);
- paintFloatingLabels(g, rectangle);
- }
- private void paint3DBar(Graphics g, Rectangle rectangle, boolean flag, double d)
- {
- Polygon polygon = new Polygon();
- polygon.addPoint(rectangle.x, rectangle.y);
- polygon.addPoint(polygon.xpoints[0] + super.depth3dPoint.x, polygon.ypoints[0] + super.depth3dPoint.y);
- polygon.addPoint(polygon.xpoints[1] + rectangle.width, polygon.ypoints[1]);
- polygon.addPoint(rectangle.x + rectangle.width, rectangle.y);
- Polygon polygon1 = new Polygon();
- polygon1.addPoint(rectangle.x + rectangle.width, rectangle.y);
- polygon1.addPoint(polygon.xpoints[2], polygon.ypoints[2]);
- polygon1.addPoint(polygon.xpoints[2], polygon.ypoints[2] + rectangle.height);
- polygon1.addPoint(rectangle.x + rectangle.width, rectangle.y + rectangle.height);
- g.setColor(g.getColor().darker());
- g.fillPolygon(polygon);
- g.setColor(g.getColor().darker());
- g.fillPolygon(polygon1);
- if(barOutlineOn)
- {
- if(barOutlineColor != null)
- g.setColor(barOutlineColor);
- else
- g.setColor(getChartForeground());
- g.drawPolygon(polygon);
- g.drawPolygon(polygon1);
- if(flag)
- {
- g.drawLine(polygon1.xpoints[1] - 1, polygon1.ypoints[1] + 1, polygon1.xpoints[2] - 1, polygon1.ypoints[2]);
- g.drawLine(polygon.xpoints[1], polygon.ypoints[1] + 1, polygon.xpoints[2] - 1, polygon.ypoints[2] + 1);
- if(super.gridAlignment == 1)
- {
- g.drawLine(polygon1.xpoints[2] - 1, polygon1.ypoints[2], polygon1.xpoints[3] - 1, polygon1.ypoints[3]);
- g.drawLine(polygon.xpoints[0] + 1, polygon.ypoints[0], polygon.xpoints[1] + 1, polygon.ypoints[1]);
- if(rectangle.height != 0)
- g.drawLine(polygon1.xpoints[0], polygon1.ypoints[0] + 1, polygon1.xpoints[1], polygon1.ypoints[1] + 1);
- else
- g.drawLine(polygon.xpoints[3] - 1, polygon.ypoints[3] - 1, polygon.xpoints[0] + 1, polygon.ypoints[0] - 1);
- } else
- {
- g.drawLine(polygon1.xpoints[2], polygon1.ypoints[2] - 1, polygon1.xpoints[3], polygon1.ypoints[3] - 1);
- g.drawLine(polygon.xpoints[0], polygon.ypoints[0] + 1, polygon.xpoints[1], polygon.ypoints[1] + 1);
- if(rectangle.width != 0)
- g.drawLine(polygon.xpoints[2] - 1, polygon.ypoints[2], polygon.xpoints[3] - 1, polygon.ypoints[3]);
- else
- g.drawLine(polygon1.xpoints[3] + 1, polygon1.ypoints[3] - 1, polygon1.xpoints[0] + 1, polygon1.ypoints[0] + 1);
- }
- }
- } else
- if(flag)
- {
- if(barOutlineColor != null)
- g.setColor(barOutlineColor);
- else
- g.setColor(getChartForeground());
- g.drawPolygon(polygon);
- g.drawLine(polygon1.xpoints[1], polygon1.ypoints[1], polygon1.xpoints[2], polygon1.ypoints[2]);
- if(super.gridAlignment == 1)
- {
- g.drawLine(polygon1.xpoints[2], polygon1.ypoints[2], polygon1.xpoints[3], polygon1.ypoints[3]);
- } else
- {
- g.drawLine(polygon1.xpoints[2], polygon1.ypoints[2] - 1, polygon1.xpoints[3], polygon1.ypoints[3] - 1);
- g.drawLine(polygon1.xpoints[3] - 1, polygon1.ypoints[3] - 1, polygon1.xpoints[0] - 1, polygon1.ypoints[0]);
- }
- }
- }
- public int getValuePosition(double d)
- {
- return getValuePosition(0, d, getGraphBounds());
- }
- public void setBarOutlineOn(boolean flag)
- {
- barOutlineOn = flag;
- super.hasChanged = true;
- autoRepaint();
- }
- public boolean isMultiSeriesOn()
- {
- return super.multiSeriesOn;
- }
- private void paint3DZeroDivider(Graphics g, Rectangle rectangle, int i)
- {
- i = Math.min(super.rangeOn.length - 1, Math.max(0, i));
- if(!super.rangeOn[i])
- return;
- g.setColor(i != 0 ? getRangeColor(i) : getChartForeground());
- if(super.gridAlignment == 1)
- {
- int j = Math.max(super.zeroLine[i], rectangle.y);
- j = Math.min(j, rectangle.y + rectangle.height);
- int l = rectangle.x - super.depth3dPoint.x;
- int j1 = j - super.depth3dPoint.y;
- g.drawLine(l, j1, l + rectangle.width, j1);
- g.drawLine(l + rectangle.width, j1, rectangle.x + rectangle.width, j);
- } else
- {
- int k = Math.max(super.zeroLine[i], rectangle.x);
- k = Math.min(k, rectangle.x + rectangle.width);
- int i1 = rectangle.y - super.depth3dPoint.y;
- int k1 = k - super.depth3dPoint.x;
- g.drawLine(k1, i1, k1, i1 + rectangle.height);
- g.drawLine(k1, i1, k, rectangle.y);
- }
- }
- private Rectangle getLineChartBounds(Rectangle rectangle)
- {
- Rectangle rectangle1 = new Rectangle(rectangle);
- int i = barType != 1 ? getSeriesCount() : 1;
- if(barBounds != null && barBounds.length > 0 && barBounds[0] != null && barBounds[0].length > 0)
- {
- int j = (barBounds[0][0].x + (barBounds[0][0].width * i) / 2) - rectangle.x;
- rectangle1.x += j;
- rectangle1.width -= j * 2;
- }
- return rectangle1;
- }
- public Rectangle getGraphBounds()
- {
- if(!super.hasChanged && super.currentBounds != null)
- return super.currentBounds;
- Rectangle rectangle = super.getGraphBounds(getLegendLabels());
- Dimension dimension = getSize();
- int i = rectangle.x;
- int j = dimension.width - rectangle.width - rectangle.x;
- int k = rectangle.y;
- int l = dimension.height - rectangle.height - rectangle.y;
- for(int i1 = 0; i1 < super.rangeAdjusterOn.length; i1++)
- if(super.rangeAdjusterOn[i1])
- if(super.gridAlignment == 1)
- {
- if(super.rangeAdjusterPosition[i1] == 0)
- i += 6;
- else
- j += 6;
- } else
- if(super.rangeAdjusterPosition[i1] == 0)
- l += 6;
- else
- k += 6;
- if(super.sampleLabelsOn && (super.barLabelStyle == 0 || super.barLabelStyle == 2))
- {
- Font font = getFont("barLabelFont");
- FontMetrics fontmetrics = getFontMetrics(font);
- int k1 = getLabelAngle("barLabelAngle");
- if(super.gridAlignment == 1)
- {
- int k2 = 0;
- String as[] = getBarLabels();
- for(int l4 = 0; l4 < as.length; l4++)
- {
- Dimension dimension3 = getLabelSize(as[l4], font);
- Dimension dimension5 = getAngledLabelSize(dimension3, k1);
- k2 = Math.max(dimension5.height, k2);
- }
- l += k2;
- if(k1 % 180 == 0)
- l -= fontmetrics.getMaxDescent();
- } else
- {
- int l2 = 0;
- String as1[] = getBarLabels();
- for(int i5 = 0; i5 < as1.length; i5++)
- {
- Dimension dimension4 = getLabelSize(as1[i5], font);
- Dimension dimension6 = getAngledLabelSize(dimension4, k1);
- l2 = Math.max(l2, dimension6.width);
- }
- i += l2;
- }
- }
- boolean flag = false;
- for(int j1 = 0; j1 < super.rangeOn.length; j1++)
- flag = super.rangeOn[j1] ? true : flag;
- if(flag || super.rangeLabelsOn || super.targetsLabel.size() > 0)
- {
- FontMetrics fontmetrics1 = getFontMetrics(getFont("rangeLabelFont"));
- String s1 = getLabel("rangeLabelPrefix");
- String s2 = getLabel("rangeLabelPostfix");
- if(super.gridAlignment == 1)
- {
- int l3 = 0;
- int j5 = 0;
- for(Enumeration enumeration = super.targetsLabel.keys(); enumeration.hasMoreElements();)
- {
- String s8 = (String)enumeration.nextElement();
- String s13 = getTargetLabel(s8);
- if(s13 != null && s13.length() > 0)
- if(super.rangePosition[0] == 0)
- l3 = Math.max(l3, fontmetrics1.stringWidth(s13));
- else
- j5 = Math.max(j5, fontmetrics1.stringWidth(s13));
- }
- if(super.rangeLabelsOn && super.rangeOn[0])
- {
- int k5 = getRangeDecimalCount(0);
- String s9 = formatNumber(super.upperRange[0], k5);
- String s14 = formatNumber(super.lowerRange[0], k5);
- s9 = s1 == null ? s9 : s1 + s9;
- s14 = s1 == null ? s14 : s1 + s14;
- s9 = s2 == null ? s9 : s9 + s2;
- s14 = s2 == null ? s14 : s14 + s2;
- if(super.rangePosition[0] == 0)
- {
- l3 = Math.max(l3, fontmetrics1.stringWidth(s9));
- l3 = Math.max(l3, fontmetrics1.stringWidth(s14));
- } else
- {
- j5 = Math.max(j5, fontmetrics1.stringWidth(s9));
- j5 = Math.max(j5, fontmetrics1.stringWidth(s14));
- }
- }
- if(super.rangeOn[1])
- {
- int l5 = getRangeDecimalCount(1);
- String s10 = formatNumber(super.upperRange[1], l5);
- String s15 = formatNumber(super.lowerRange[1], l5);
- if(super.rangePosition[1] == 0)
- {
- l3 = Math.max(l3, fontmetrics1.stringWidth(s10));
- l3 = Math.max(l3, fontmetrics1.stringWidth(s15));
- } else
- {
- j5 = Math.max(j5, fontmetrics1.stringWidth(s10));
- j5 = Math.max(j5, fontmetrics1.stringWidth(s15));
- }
- }
- i += l3 + 2;
- j += j5 <= 0 ? 0 : j5 + 2;
- } else
- {
- if(super.targetsValue.size() > 0)
- k += fontmetrics1.getMaxAscent();
- if(super.rangeLabelsOn && super.rangeOn[0])
- {
- if(super.rangePosition[0] == 0)
- {
- l += fontmetrics1.getMaxAscent();
- if(super.targetsLabel.size() > 0)
- l += fontmetrics1.getHeight();
- } else
- {
- k += fontmetrics1.getMaxAscent();
- if(super.targetsLabel.size() > 0)
- k += fontmetrics1.getHeight();
- }
- int i4 = getRangeDecimalCount(0);
- String s4 = formatNumber(super.upperRange[0], i4);
- s4 = s1 == null ? s4 : s1 + s4;
- s4 = s2 == null ? s4 : s4 + s2;
- j = Math.max(j, fontmetrics1.stringWidth(s4) / 2 + 5);
- String s6 = formatNumber(super.lowerRange[0], i4);
- s6 = s1 == null ? s6 : s1 + s6;
- s6 = s2 == null ? s6 : s6 + s2;
- i = Math.max(i, fontmetrics1.stringWidth(s6) / 2 + 5);
- }
- if(super.rangeOn[1])
- {
- if(super.rangePosition[1] == 0)
- l += fontmetrics1.getMaxAscent();
- else
- k += fontmetrics1.getMaxAscent();
- int j4 = getRangeDecimalCount(1);
- String s5 = formatNumber(super.upperRange[1], j4);
- j = Math.max(j, fontmetrics1.stringWidth(s5) / 2 + 5);
- String s7 = formatNumber(super.lowerRange[1], j4);
- i = Math.max(i, fontmetrics1.stringWidth(s7) / 2 + 5);
- }
- }
- }
- if(isValueLabelsOn(0) && valueLabelStyle == 0)
- {
- Font font1 = getFont("valueLabelFont");
- FontMetrics fontmetrics2 = getFontMetrics(font1);
- int i3 = getSampleDecimalCount(0);
- if(super.gridAlignment == 1)
- {
- double d = getHighestValue(0);
- int i6 = getLabelAngle("valueLabelAngle");
- String s11 = formatNumber(d, i3);
- Dimension dimension8 = getLabelSize(s11, font1);
- Dimension dimension11 = getAngledLabelSize(dimension8, i6);
- k += dimension11.height - 4;
- double d5 = getLowestValue(0);
- if(d5 < 0.0D)
- {
- String s12 = formatNumber(d5, i3);
- Dimension dimension9 = getLabelSize(s12, font1);
- Dimension dimension12 = getAngledLabelSize(dimension9, i6);
- l += dimension12.height - 2;
- if(i6 % 180 == 0)
- l -= fontmetrics2.getDescent();
- }
- } else
- {
- double d1 = getHighestValue(0);
- double d4 = 0.0D;
- if(super.upperRange[0] - super.lowerRange[0] != 0.0D)
- d4 = (d1 - super.lowerRange[0]) / (super.upperRange[0] - super.lowerRange[0]);
- rectangle.x = i;
- rectangle.width = dimension.width - i - j;
- int j6 = (int)Math.round((double)rectangle.x + d4 * (double)rectangle.width);
- int k6 = fontmetrics2.stringWidth(formatNumber(d1, i3));
- j6 += k6;
- if(j6 > rectangle.x + rectangle.width)
- j += Math.min(j6 - rectangle.width - rectangle.x, k6);
- double d6 = getLowestValue(0);
- d4 = 0.0D;
- if(super.upperRange[0] - super.lowerRange[0] != 0.0D)
- d4 = (d6 - super.lowerRange[0]) / (super.upperRange[0] - super.lowerRange[0]);
- j6 = (int)Math.round((double)rectangle.x + d4 * (double)rectangle.width);
- k6 = fontmetrics2.stringWidth(formatNumber(d6, i3));
- j6 -= k6;
- if(j6 < rectangle.x)
- i += Math.min(rectangle.x - j6, k6 - 6 - (super.sampleScrollerOn ? 10 : 0));
- }
- }
- String s = getLabel("sampleAxisLabel");
- if(s != null)
- {
- int l1 = getLabelAngle("sampleAxisLabelAngle");
- l1 = super.gridAlignment != 0 ? 0 : l1;
- Font font2 = getFont("sampleAxisLabelFont");
- getFontMetrics(font2);
- Dimension dimension1 = getLabelSize(s, font2);
- Dimension dimension2 = getAngledLabelSize(dimension1, l1);
- if(super.gridAlignment == 1)
- l += dimension2.height + 3;
- else
- i += dimension2.width + 5;
- }
- int i2 = 0;
- do
- {
- String s3 = i2 != 0 ? getLabel("rangeAxisLabel_2") : getLabel("rangeAxisLabel");
- if(s3 != null && super.rangeOn[i2])
- {
- int k4 = i2 != 0 ? getLabelAngle("rangeAxisLabelAngle_2") : getLabelAngle("rangeAxisLabelAngle");
- k4 = super.gridAlignment != 1 ? 0 : k4;
- Font font3 = getFont("rangeAxisLabelFont");
- FontMetrics fontmetrics3 = getFontMetrics(font3);
- Dimension dimension7 = getLabelSize(s3, font3);
- Dimension dimension10 = getAngledLabelSize(dimension7, k4);
- if(super.gridAlignment == 1)
- {
- if(super.rangePosition[i2] == 0)
- i += dimension10.width + 20;
- else
- j += dimension10.width + 20;
- } else
- if(super.rangePosition[i2] == 0)
- l += (dimension10.height + 5) - (k4 % 360 != 0 ? 0 : fontmetrics3.getDescent());
- else
- k += dimension10.height + 5;
- }
- } while(++i2 < 2);
- if(is3DModeOn())
- if(super.depth3d >= 0)
- {
- l += super.depth3d;
- i += super.depth3d;
- } else
- {
- int j2 = Math.max(1, getSampleCount());
- if(barType == 0)
- j2 *= Math.max(1, getSeriesCount());
- if(super.gridAlignment == 1)
- {
- int j3 = 0;
- if((double)j2 + barWidthFraction * 1.25D > 0.0D)
- j3 = (int)(((double)rectangle.width * barWidthFraction * 1.25D) / ((double)j2 + barWidthFraction * 1.25D));
- i += j3;
- rectangle.width = dimension.width - i - j;
- double d2 = 0.0D;
- if(j2 > 0)
- d2 = (double)(rectangle.width / j2) * barWidthFraction;
- l += (int)Math.round(d2 / 1.25D);
- } else
- {
- int k3 = 0;
- if((double)(1.25F * (float)j2) + barWidthFraction * 0.75D > 0.0D)
- k3 = (int)(((double)rectangle.height * barWidthFraction * 0.75D) / ((double)(1.25F * (float)j2) + barWidthFraction * 0.75D));
- l += k3;
- rectangle.height = dimension.height - k - l;
- double d3 = (double)(rectangle.height / j2) * barWidthFraction;
- i += (int)Math.round(d3 * 1.25D * 0.75D);
- }
- }
- Insets insets = getGraphInsets();
- if(insets != null)
- {
- k = insets.top != -1 ? insets.top : k;
- i = insets.left != -1 ? insets.left : i;
- l = insets.bottom != -1 ? insets.bottom : l;
- j = insets.right != -1 ? insets.right : j;
- }
- rectangle.x = i;
- rectangle.width = dimension.width - i - j - 1;
- rectangle.y = k;
- rectangle.height = dimension.height - k - l - 1;
- super.currentBounds = rectangle;
- return rectangle;
- }
- public void setBarOutlineColor(Color color)
- {
- barOutlineColor = color;
- super.hasChanged = true;
- autoRepaint();
- }
- private void paintFloatingLabel(Graphics g, Rectangle rectangle, int i, int j, String s, Font font, FontMetrics fontmetrics)
- {
- if(i < 0 || i >= getSeriesCount() || j < 0 || j >= getSampleCount())
- return;
- Rectangle rectangle1 = barBounds[i][j];
- if(rectangle1 == null)
- return;
- if(super.gridAlignment == 1)
- {
- if(rectangle1.x + rectangle1.width < rectangle.x - super.depth3dPoint.x || rectangle1.x > rectangle.x + rectangle.width)
- return;
- if(rectangle1.y + rectangle1.height < rectangle.y || rectangle1.y > (rectangle.y + rectangle.height) - super.depth3dPoint.y)
- return;
- } else
- {
- if(rectangle1.y + rectangle1.height < rectangle.y || rectangle1.y > (rectangle.y + rectangle.height) - super.depth3dPoint.y)
- return;
- if(rectangle1.x + rectangle1.width < rectangle.x - super.depth3dPoint.x || rectangle1.x > rectangle.x + rectangle.width)
- return;
- }
- Dimension dimension = getLabelSize(s, font);
- int k = mousePosition.x + 3;
- if(super.gridAlignment == 1)
- k = ((rectangle1.x + rectangle1.width / 2) - dimension.width / 2) + 1;
- else
- if(mousePosition.x < 0)
- k = (rectangle1.x + rectangle1.width / 2) - dimension.width / 2;
- int l = (mousePosition.y - dimension.height) + fontmetrics.getAscent();
- if(super.gridAlignment == 0 || mousePosition.y < 0)
- l = ((rectangle1.y + rectangle1.height / 2) - dimension.height / 2) + fontmetrics.getAscent();
- if(barType == 1 && l - dimension.height / 2 < rectangle1.y)
- l = rectangle1.y + dimension.height / 2 + 1;
- else
- if(is3DModeOn() && super.depth3dPoint.y != 0 && super.gridAlignment == 1 && mousePosition.y < rectangle1.y && mousePosition.y >= 0)
- {
- k += (-super.depth3dPoint.x * (rectangle1.y - mousePosition.y)) / super.depth3dPoint.y;
- Rectangle rectangle2 = null;
- if(i < getSeriesCount() - 1)
- rectangle2 = barBounds[i + 1][j];
- else
- if(j < getSampleCount() - 1)
- rectangle2 = barBounds[0][j + 1];
- if(rectangle2 != null)
- {
- int i1 = (-super.depth3dPoint.x * (rectangle2.y - mousePosition.y)) / super.depth3dPoint.y;
- if(l >= rectangle2.y && k > rectangle2.x - 10)
- k = rectangle2.x - 10;
- else
- if(l < rectangle2.y && k > (rectangle2.x + i1) - 10)
- k = (rectangle2.x + i1) - 10;
- }
- }
- Dimension dimension1 = getSize();
- k = Math.max(k, 3);
- k = Math.min(k, dimension1.width - dimension.width - 3);
- l = Math.max(l, fontmetrics.getAscent() + 1);
- l = Math.min(l, ((dimension1.height - dimension.height) + fontmetrics.getAscent()) - 1);
- int j1 = fontmetrics.getHeight();
- int k1 = fontmetrics.getDescent();
- g.setColor(new Color(255, 255, 231));
- g.fillRect(k - 2, ((l - j1) + k1 * 2) - 2, dimension.width + 5, dimension.height);
- g.setColor(getChartForeground());
- if(getSeriesCount() == 1 && multiColorOn)
- g.setColor(getSampleColor(j).darker());
- else
- if(multiColorOn)
- g.setColor(getSampleColor(i).darker());
- g.drawRect(k - 3, ((l - j1) + k1 * 2) - 3, dimension.width + 5, dimension.height);
- g.setColor(Color.black);
- paintLabel(g, s, k, l, dimension, 0, 0);
- }
- public static final int SIDE_BY_SIDE_BARS = 0;
- public static final int STACKED_BARS = 1;
- public static final int VALUE_LABELS_OUTSIDE = 0;
- public static final int VALUE_LABELS_INSIDE = 1;
- public static final int VALUE_LABELS_FLOATING = 2;
- public static final int BAR_LABELS_BELOW = 0;
- public static final int BAR_LABELS_FLOATING = 1;
- public static final int BAR_LABELS_BELOW_AND_FLOATING = 2;
- private boolean multiColorOn;
- private int valueLabelStyle;
- private boolean barOutlineOn;
- private Color barOutlineColor;
- private boolean autoLabelSpacingOn;
- private double barWidthFraction;
- private int barType;
- private Rectangle barBounds[][];
- private int selectedSeries;
- private int selectedSample;
- private Point mousePosition;
- }