📄 linechart.java
字号:
public void setSampleHighlightOn(int i, int j, boolean flag)
{
try
{
sampleHighlightOn[i][j] = flag;
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid series or index: " + i + ", " + j);
}
super.hasChanged = true;
autoRepaint();
}
public int getSampleHighlightSize(int i)
{
try
{
return sampleHighlightSize[i];
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid series: " + i);
}
}
protected void checkDataIntegrity()
{
super.checkDataIntegrity();
int i = getSeriesCount();
int j = getSampleCount();
int k = sampleHighlightOn.length;
int l = k <= 0 ? 0 : sampleHighlightOn[0].length;
if(i != k || j != l)
{
boolean aflag[][] = new boolean[i][j];
for(int j1 = 0; j1 < i; j1++)
{
for(int l1 = 0; l1 < j; l1++)
if(j1 < k && l1 < l)
aflag[j1][l1] = sampleHighlightOn[j1][l1];
}
sampleHighlightOn = aflag;
int ai[] = new int[i];
int ai1[] = new int[i];
boolean aflag1[] = new boolean[i];
boolean aflag2[] = new boolean[i];
int ai2[] = new int[i];
for(int i2 = 0; i2 < i; i2++)
if(i2 < k)
{
ai[i2] = sampleHighlightStyle[i2];
ai1[i2] = sampleHighlightSize[i2];
aflag1[i2] = seriesLinesOn[i2];
aflag2[i2] = connectedLinesOn[i2];
ai2[i2] = lineWidth[i2];
} else
{
ai1[i2] = 6;
aflag1[i2] = true;
ai2[i2] = 2;
}
sampleHighlightStyle = ai;
sampleHighlightSize = ai1;
seriesLinesOn = aflag1;
connectedLinesOn = aflag2;
lineWidth = ai2;
}
samplePosition = new Point[i][j];
for(int i1 = 0; i1 < samplePosition.length; i1++)
{
for(int k1 = 0; k1 < samplePosition[i1].length; k1++)
samplePosition[i1][k1] = new Point();
}
if(lastSelectedLine >= i)
lastSelectedLine = -1;
}
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.rangeAdjusterPosition[i1] == 0)
i += 6;
else
j += 6;
if(super.sampleLabelsOn && getSampleCount() > 0 && sampleLabelStyle != 2)
{
Font font = getFont("sampleLabelFont");
FontMetrics fontmetrics = getFontMetrics(font);
int k1 = 0;
int j2 = getLabelAngle("sampleLabelAngle");
String as[] = getSampleLabels();
for(int k3 = 0; k3 < as.length; k3++)
{
Dimension dimension2 = getLabelSize(as[k3], font);
Dimension dimension5 = getAngledLabelSize(dimension2, j2);
k1 = Math.max(dimension5.height, k1);
}
l += k1 + 3;
if(j2 % 180 == 0)
l -= fontmetrics.getMaxDescent();
String s4 = getSampleLabel(getSampleCount() - 1);
int j4 = 0;
if(s4 != null)
{
Dimension dimension6 = getLabelSize(s4, font);
Dimension dimension8 = getAngledLabelSize(dimension6, j2);
j4 = dimension8.width / 2 - 5;
}
int i5 = 0;
if(isLegendOn() && getLegendPosition() == 1)
i5 = super.legend.width;
if(j4 > i5)
j += j4 - i5;
}
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");
int l2 = 0;
int l3 = 0;
for(Enumeration enumeration = super.targetsLabel.keys(); enumeration.hasMoreElements();)
{
String s5 = (String)enumeration.nextElement();
String s8 = getTargetLabel(s5);
if(s8 != null && s8.length() > 0)
if(super.rangePosition[0] == 0)
l2 = Math.max(l2, fontmetrics1.stringWidth(s8));
else
l3 = Math.max(l3, fontmetrics1.stringWidth(s8));
}
if(super.rangeLabelsOn && super.rangeOn[0])
{
int k4 = getRangeDecimalCount(0);
String s6 = formatNumber(super.upperRange[0], k4);
String s9 = formatNumber(super.lowerRange[0], k4);
s6 = s1 == null ? s6 : s1 + s6;
s9 = s1 == null ? s9 : s1 + s9;
s6 = s2 == null ? s6 : s6 + s2;
s9 = s2 == null ? s9 : s9 + s2;
if(super.rangePosition[0] == 0)
{
l2 = Math.max(l2, fontmetrics1.stringWidth(s6));
l2 = Math.max(l2, fontmetrics1.stringWidth(s9));
} else
{
l3 = Math.max(l3, fontmetrics1.stringWidth(s6));
l3 = Math.max(l3, fontmetrics1.stringWidth(s9));
}
}
if(super.rangeOn[1])
{
int l4 = getRangeDecimalCount(1);
String s7 = formatNumber(super.upperRange[1], l4);
String s10 = formatNumber(super.lowerRange[1], l4);
if(super.rangePosition[1] == 0)
{
l2 = Math.max(l2, fontmetrics1.stringWidth(s7));
l2 = Math.max(l2, fontmetrics1.stringWidth(s10));
} else
{
l3 = Math.max(l3, fontmetrics1.stringWidth(s7));
l3 = Math.max(l3, fontmetrics1.stringWidth(s10));
}
}
i += l2 + 2;
j += l3 <= 0 ? 0 : l3 + 2;
}
String s = getLabel("sampleAxisLabel");
if(s != null)
{
Font font1 = getFont("sampleAxisLabelFont");
FontMetrics fontmetrics2 = getFontMetrics(font1);
int i3 = getLabelAngle("sampleAxisLabelAngle");
Dimension dimension1 = getLabelSize(s, font1);
Dimension dimension3 = getAngledLabelSize(dimension1, i3);
l += dimension3.height + 3;
if(i3 % 180 == 0)
l -= fontmetrics2.getDescent();
}
int l1 = 0;
do
{
String s3 = l1 != 0 ? getLabel("rangeAxisLabel_2") : getLabel("rangeAxisLabel");
if(s3 != null)
{
Font font2 = getFont("rangeAxisLabelFont");
getFontMetrics(font2);
int i4 = l1 != 0 ? getLabelAngle("rangeAxisLabelAngle_2") : getLabelAngle("rangeAxisLabelAngle");
Dimension dimension4 = getLabelSize(s3, font2);
Dimension dimension7 = getAngledLabelSize(dimension4, i4);
if(super.rangePosition[l1] == 0)
i += dimension7.width + 20;
else
j += dimension7.width + 20;
}
} while(++l1 < 2);
if(is3DModeOn())
if(super.depth3d > -1)
{
i += super.depth3dPoint.x;
l -= super.depth3dPoint.y;
} else
{
int i2 = Math.max(20, getSampleCount());
int k2 = getSeriesCount();
if(k2 > 1 && !stackedOn)
{
i2 /= k2;
i2 = Math.max(i2, 4);
}
int j3 = (int)(((float)rectangle.width * 1.25F) / ((float)i2 + 1.25F));
i += j3;
rectangle.width = dimension.width - i - j;
double d = rectangle.width / i2;
l += (int)Math.round(d / 1.25D);
}
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;
}
private void paint3DLine(Graphics g, int i, int j, int k, int l, int i1, Color color,
boolean flag, boolean flag1)
{
int ai[] = new int[4];
int ai1[] = new int[4];
int j1 = stackedOn ? 1 : Math.max(1, getSeriesCount());
int k1 = (int)Math.round((double)super.depth3dPoint.x / (double)j1);
int l1 = (int)Math.round((double)super.depth3dPoint.y / (double)j1);
ai[0] = i;
ai1[0] = j;
ai[1] = i + k1;
ai1[1] = j + l1;
ai[2] = ai[1] + (k - i);
ai1[2] = l + l1;
ai[3] = k;
ai1[3] = l;
Color color1 = color.darker();
if(flag)
{
double d = 0.0D;
if(ai[1] - ai[0] != 0)
d = (double)(j - l) / (double)(k - i);
if(d > 0.68999999999999995D)
g.setColor(color1);
else
g.setColor(color);
g.fillPolygon(ai, ai1, 4);
g.setColor(color1);
g.drawLine(ai[0], ai1[0], ai[1], ai1[1]);
g.drawLine(ai[1], ai1[1], ai[2], ai1[2]);
g.drawLine(ai[2], ai1[2], ai[3], ai1[3]);
}
if(flag1)
{
ai[0] = ai[3];
ai1[0] = ai1[3];
ai[1] = ai[2];
ai1[1] = ai1[2];
ai[2] = ai[2];
ai1[2] = i1 + l1;
ai[3] = ai[0];
ai1[3] = i1;
g.setColor(color);
g.fillPolygon(ai, ai1, 4);
g.setColor(color1);
g.drawLine(ai[0], ai1[0], ai[1], ai1[1]);
g.drawLine(ai[1], ai1[1], ai[2], ai1[2]);
g.drawLine(ai[2], ai1[2], ai[3], ai1[3]);
g.drawLine(ai[3], ai1[3], ai[0], ai1[0]);
}
}
private void paint3DZeroDivider(Graphics g, Rectangle rectangle, int i)
{
i = Math.min(super.rangeOn.length - 1, Math.max(0, i));
if(super.rangeOn[i])
{
int j = Math.max(super.zeroLine[i], rectangle.y);
j = Math.min(j, rectangle.y + rectangle.height);
int k = rectangle.x - super.depth3dPoint.x;
int l = j - super.depth3dPoint.y;
g.setColor(i != 0 ? getRangeColor(i) : getChartForeground());
g.drawLine(k, l, k + rectangle.width, l);
g.drawLine(k + rectangle.width, l, rectangle.x + rectangle.width, j);
}
}
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;
Point point = null;
if(samplePosition != null && i < samplePosition.length && samplePosition[i] != null && j <= samplePosition[i].length)
point = samplePosition[i][j];
if(point == null)
return;
int k = 0;
if(is3DModeOn())
if(stackedOn)
{
k = -super.depth3d;
} else
{
double d = (double)super.depth3dPoint.x / (double)getSeriesCount();
k = (int)Math.round(d * (double)i) - super.depth3dPoint.x;
}
if(point.x < rectangle.x || point.x > (rectangle.x + rectangle.width) - k)
return;
if(point.y < rectangle.y || point.y > (is3DModeOn() ? (rectangle.y + rectangle.height) - super.depth3dPoint.y : rectangle.y + rectangle.height))
{
return;
} else
{
Dimension dimension = getLabelSize(s, font);
int l = (point.x - dimension.width / 2) + k;
int i1 = ((point.y - dimension.height) + fontmetrics.getAscent()) - 3;
Dimension dimension1 = getSize();
l = Math.max(l, 3);
l = Math.min(l, dimension1.width - dimension.width - 3);
i1 = Math.max(i1, fontmetrics.getAscent());
i1 = Math.min(i1, ((dimension1.height - dimension.height) + fontmetrics.getAscent()) - 1);
int j1 = fontmetrics.getHeight();
int k1 = fontmetrics.getDescent();
g.setColor(new Color(255, 255, 231));
g.fillRect(l - 2, ((i1 - j1) + k1 * 2) - 2, dimension.width + 5, dimension.height);
g.setColor(getChartForeground());
g.setColor(getSampleColor(i).darker());
g.drawRect(l - 3, ((i1 - j1) + k1 * 2) - 3, dimension.width + 5, dimension.height);
g.setColor(Color.black);
paintLabel(g, s, l, i1, dimension, 0, 0);
return;
}
}
public void setSampleHighlightStyle(int i, int j)
{
for(int k = 0; k < sampleHighlightStyle.length; k++)
setSampleHighlightStyle(k, i, j);
}
public static final int SAMPLE_HIGHLIGHT_CIRCLE = 0;
public static final int SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE = 1;
public static final int SAMPLE_HIGHLIGHT_CIRCLE_FILLED = 2;
public static final int SAMPLE_HIGHLIGHT_SQUARE = 3;
public static final int SAMPLE_HIGHLIGHT_SQUARE_OPAQUE = 4;
public static final int SAMPLE_HIGHLIGHT_SQUARE_FILLED = 5;
public static final int SAMPLE_HIGHLIGHT_DIAMOND = 6;
public static final int SAMPLE_HIGHLIGHT_DIAMOND_OPAQUE = 7;
public static final int SAMPLE_HIGHLIGHT_DIAMOND_FILLED = 8;
public static final int VALUE_LABELS_OUTSIDE_POINT = 0;
public static final int VALUE_LABELS_AT_POINT = 1;
public static final int FLOATING = 2;
public static final int BELOW = 3;
private int valueLabelStyle;
private int sampleLabelStyle;
private boolean seriesLabelsOn;
private boolean autoLabelSpacingOn;
private int lineWidth[];
private boolean stackedOn;
private boolean sampleHighlightOn[][];
private int sampleHighlightStyle[];
private int sampleHighlightSize[];
private boolean seriesLinesOn[];
private boolean connectedLinesOn[];
private String highlightImages[];
private Point samplePosition[][];
private int selectedSeries;
private int selectedSample;
private Point mousePosition;
private int lastSelectedLine;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -