📄 barchart.java
字号:
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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -