chart.java
来自「一个完整的」· Java 代码 · 共 1,823 行 · 第 1/5 页
JAVA
1,823 行
{
String s2 = formatNumber(upperRange[i], rangeDecimalCount[i]);
String s3 = formatNumber(lowerRange[i], rangeDecimalCount[i]);
if(s != null && s.length() > 0)
{
s2 = s + s2;
s3 = s + s3;
}
if(s1 != null && s1.length() > 0)
{
s2 += s1;
s3 += s1;
}
int l = Math.max(fontmetrics.stringWidth(s2), fontmetrics.stringWidth(s3)) + 4;
j = (int)Math.round((double)rectangle.width / (double)l);
}
j = Math.min(maxValueLineCount, j);
int k = (int)Math.round((currentUpperRange[i] - currentLowerRange[i]) * Math.pow(10D, rangeDecimalCount[i]));
j = Math.min(j, k);
j = Math.max(1, j);
double d = (currentUpperRange[i] - currentLowerRange[i]) / (double)j;
d = Math.abs(d);
double d1 = d;
boolean flag = false;
for(double d2 = 9.9999999999999998E-013D; !flag && d2 < 100000000000000D; d2 *= 10D)
{
for(int i1 = 0; i1 < STEPS.length; i1++)
{
if(STEPS[i1] * d2 < d)
continue;
d1 = STEPS[i1] * d2;
flag = true;
break;
}
}
int j1 = 0;
if(i == 1)
{
int k1 = (int)(Math.abs(currentUpperRange[1] - currentLowerRange[1]) / d1 + 2D);
valueLines = new double[k1];
}
Color color = getRangeColor(i);
if(currentUpperRange[i] > 0.0D)
{
for(double d3 = Math.max(0.0D, currentLowerRange[i] - currentLowerRange[i] % d1); d3 < currentUpperRange[i]; d3 += d1)
if(d3 != 0.0D)
{
String s8 = !rangeLabelsOn && i <= 0 ? null : formatNumber(d3, rangeDecimalCount[i]);
if(i == 0)
{
if(s8 != null && s != null)
s8 = s + s8;
if(s8 != null && s1 != null)
s8 += s1;
}
if(i == 1 && valueLines != null)
valueLines[j1++] = d3;
paintGridLine(g, rectangle, d3, valueLinesColor, s8, color, i == 0 && valueLinesOn, false, i, 0);
}
}
if(currentLowerRange[i] < 0.0D)
{
for(double d4 = Math.min(0.0D, currentUpperRange[i] - currentUpperRange[i] % d1); d4 > currentLowerRange[i]; d4 -= d1)
if(d4 != 0.0D)
{
String s9 = !rangeLabelsOn && i <= 0 ? null : formatNumber(d4, rangeDecimalCount[i]);
if(i == 0)
{
if(s9 != null && s != null)
s9 = s + s9;
if(s9 != null && s1 != null)
s9 += s1;
}
if(i == 1 && valueLines != null)
valueLines[j1++] = d4;
paintGridLine(g, rectangle, d4, valueLinesColor, s9, color, i == 0 && valueLinesOn, false, i, 0);
}
}
if(rangeLabelsOn || i > 0)
{
String s4 = formatNumber(currentUpperRange[i], currentUpperRange[i] == 0.0D ? 0 : rangeDecimalCount[i]);
if(i == 0)
{
s4 = s == null ? s4 : s + s4;
s4 = s1 == null ? s4 : s4 + s1;
}
paintGridLine(g, rectangle, currentUpperRange[i], chartForeground, s4, color, i == 0, false, i, 0);
s4 = !rangeLabelsOn && i <= 0 ? null : formatNumber(currentLowerRange[i], currentLowerRange[i] == 0.0D ? 0 : rangeDecimalCount[i]);
if(i == 0)
{
s4 = s == null ? s4 : s + s4;
s4 = s1 == null ? s4 : s4 + s1;
}
paintGridLine(g, rectangle, currentLowerRange[i], chartForeground, s4, color, i == 0, false, i, 0);
}
if(rangeLabelsOn || i > 0)
{
String s5 = "0";
if(i == 0)
{
s5 = s == null ? s5 : s + s5;
s5 = s1 == null ? s5 : s5 + s1;
}
paintGridLine(g, rectangle, 0.0D, i != 0 ? color : chartForeground, s5, color, true, false, i, 0);
}
if(i == 0)
{
for(Enumeration enumeration = targetsLabel.keys(); enumeration.hasMoreElements();)
{
String s7 = (String)enumeration.nextElement();
String s10 = getTargetLabel(s7);
Double double1 = (Double)targetsValue.get(s7);
Color color2 = (Color)targetsColor.get(s7);
if(double1 != null)
paintGridLine(g, rectangle, double1.doubleValue(), color2, s10, color2, true, true, 0, 0);
}
}
if(defaultGridLines != null)
{
for(int l1 = 0; l1 < defaultGridLines.length; l1++)
paintGridLine(g, rectangle, defaultGridLines[l1], defaultGridLinesColor, null, null, true, false, 0, 1);
}
if(gridLines != null)
{
for(int i2 = 0; i2 < gridLines.length; i2++)
{
Color color1 = defaultGridLinesColor;
if(gridLineColors != null && gridLineColors.length > i2 && gridLineColors[i2] != null)
color1 = gridLineColors[i2];
paintGridLine(g, rectangle, gridLines[i2], color1, null, null, true, true, 0, 1);
}
}
String s6 = i != 0 ? getLabel("rangeAxisLabel_2") : getLabel("rangeAxisLabel");
if(s6 != null)
{
Font font = getFont("rangeAxisLabelFont");
g.setFont(font);
g.setColor(color);
FontMetrics fontmetrics1 = g.getFontMetrics();
int j2 = 0;
int k2 = 0;
int l2 = i != 0 ? getLabelAngle("rangeAxisLabelAngle_2") : getLabelAngle("rangeAxisLabelAngle");
l2 = gridAlignment != 1 ? 0 : l2;
Dimension dimension = getLabelSize(s6, font);
Dimension dimension1 = getAngledLabelSize(dimension, l2);
int i3 = getRangeWidth(i, true);
if(gridAlignment == 1)
{
if(rangePosition[i] == 0)
j2 = rectangle.x - dimension1.width - i3 - 15;
else
j2 = rectangle.x + rectangle.width + i3 + 15;
k2 = (rectangle.y + rectangle.height / 2) - dimension1.height / 2;
if(l2 % 180 == 0)
k2 += fontmetrics1.getAscent();
if(display3dOn && rangePosition[i] == 0)
{
k2 -= depth3dPoint.y;
j2 -= depth3dPoint.x;
}
} else
{
j2 = (rectangle.x + rectangle.width / 2) - dimension1.width / 2;
int j3 = getFontMetrics(getFont("rangeLabelFont")).getHeight();
if(rangePosition[i] == 0)
{
k2 = rectangle.y + rectangle.height + 5 + (rangeLabelsOn ? j3 : 0) + (l2 % 180 != 0 ? 0 : fontmetrics1.getMaxAscent() - 3);
if(rangeAdjusterOn[0] && rangeAdjusterPosition[0] == 0 || rangeAdjusterOn[1] && rangeAdjusterPosition[1] == 0)
k2 += 6;
} else
{
k2 = rectangle.y - 4 - (rangeLabelsOn ? j3 : 0);
if(rangeAdjusterOn[0] && rangeAdjusterPosition[0] == 0 || rangeAdjusterOn[1] && rangeAdjusterPosition[1] == 0)
k2 -= 10;
if(l2 % 180 != 0)
k2 -= dimension1.height - 5;
}
if(display3dOn && rangePosition[i] == 0)
{
k2 -= depth3dPoint.y;
j2 -= depth3dPoint.x;
}
}
paintLabel(g, s6, j2, k2, dimension, 0, l2);
}
}
public void set3DDepth(int i)
{
if(i >= -1 && i < 32767)
{
depth3d = i;
if(i >= 0)
{
depth3dPoint.x = depth3d;
depth3dPoint.y = -depth3d;
}
hasChanged = true;
autoRepaint();
}
}
public int get3DDepth()
{
return depth3d;
}
public static String getVersion()
{
return "2.6";
}
public void setVisibleSamples(int i, int j)
{
int k = getSampleCount();
j = j == -1 ? k : j;
i = Math.max(0, i);
i = Math.min(k - 1, i);
j = Math.max(1, j);
j = Math.min(k - i, j);
i = Math.min(k - j, i);
leftScrollerFactor = (double)i / (double)k;
rightScrollerFactor = (double)(k - j - i) / (double)k;
hasChanged = true;
autoRepaint();
}
public boolean isFloatingOnLegendOn()
{
return floatingOnLegendOn;
}
public boolean isRangeAdjusterOn(int i)
{
i = Math.min(rangeAdjusterOn.length - 1, Math.max(0, i));
return rangeAdjusterOn[i];
}
/**
* @deprecated Method isRangeAdjusterOn is deprecated
*/
public boolean isRangeAdjusterOn()
{
return isRangeAdjusterOn(0);
}
synchronized void setLowerRelativeRangeIndex(int i, double d)
{
i = Math.min(rangeOn.length - 1, Math.max(0, i));
double d1 = getLowestValue(i);
if(i == 0)
{
for(Enumeration enumeration = targetsValue.elements(); enumeration.hasMoreElements();)
d1 = Math.min(((Double)enumeration.nextElement()).doubleValue(), d1);
}
if(d1 < 0.0D)
setLowerRange(i, d1 * Math.abs(d));
else
setLowerRange(i, 0.0D);
}
public void setLabelAngle(String s, int i)
{
if(s != null && s.length() > 0)
{
i %= 360;
s = s.toLowerCase().trim();
labelAngles.put(s, new Integer(i));
angledLabelCache.clear();
hasChanged = true;
autoRepaint();
}
}
public int getLabelAngle(String s)
{
if(s != null)
{
s = s.toLowerCase().trim();
if(labelAngles.get(s) != null)
return ((Integer)labelAngles.get(s)).intValue();
}
return 0;
}
public Object[] getSelectedObjects()
{
int i = getSeriesCount();
int j = getSampleCount();
int k = 0;
for(int l = 0; l < i; l++)
{
for(int i1 = 0; i1 < j; i1++)
if(isSelected(l, i1))
k++;
}
if(k > 0)
{
Object aobj[] = new Object[k];
int j1 = 0;
for(int k1 = 0; k1 < i; k1++)
{
for(int l1 = 0; l1 < j; l1++)
if(isSelected(k1, l1) && j1 < aobj.length)
aobj[j1++] = getSample(k1, l1);
}
return aobj;
} else
{
return null;
}
}
void paint3DEdges(Graphics g, Rectangle rectangle)
{
Color color = getChartForeground();
Color color1 = new Color(color.getRed() / 2 + 128, color.getGreen() / 2 + 128, color.getBlue() / 2 + 128);
g.setColor(color1);
Polygon polygon = new Polygon();
polygon.addPoint((rectangle.x + rectangle.width) - depth3dPoint.x, rectangle.y - depth3dPoint.y);
polygon.addPoint((rectangle.x + rectangle.width) - depth3dPoint.x, (rectangle.y + rectangle.height) - depth3dPoint.y);
g.drawPolygon(polygon);
if(rangeOn[1] && valueLines != null)
{
int _tmp = depth3dPoint.y / valueLines.length;
for(int i = 0; i < valueLines.length; i++)
{
double d = (valueLines[i] - currentLowerRange[1]) / (currentUpperRange[1] - currentLowerRange[1]);
if(gridAlignment == 1)
{
int j = (int)Math.round((double)(rectangle.y + rectangle.height) - d * (double)rectangle.height - (double)depth3dPoint.y);
if(valueLines[i] != 0.0D && j > (rectangle.y - depth3dPoint.y) + 1)
g.drawLine((rectangle.x + rectangle.width) - depth3dPoint.x, j, ((rectangle.x + rectangle.width) - depth3dPoint.x) + 2, j - 2);
} else
{
int k = (int)Math.round((double)(rectangle.x + rectangle.width) - d * (double)rectangle.width);
k = (rectangle.x * 2 + rectangle.width) - k - depth3dPoint.x;
if(valueLines[i] != 0.0D && k < (rectangle.x + rectangle.width) - depth3dPoint.x)
g.drawLine(k - 1, rectangle.y - depth3dPoint.y, k + 2, rectangle.y - depth3dPoint.y - 2);
}
}
}
polygon.xpoints[1] = rectangle.x - depth3dPoint.x;
polygon.ypoints[1] = rectangle.y - depth3dPoint.y;
g.drawPolygon(polygon);
polygon.xpoints[1] = rectangle.x + rectangle.width;
polygon.ypoints[1] = rectangle.y;
g.drawPolygon(polygon);
}
public void setExternalGraphics(Graphics g, Image image)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?