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