📄 chart.java
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2002-12-03 18:40:24
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: Chart.java
package cn.com.fcsoft.chart;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.PrintStream;
import java.text.NumberFormat;
import java.util.*;
// Referenced classes of package com.objectplanet.chart:
// ChartData, Chart2, ChartSample
public abstract class Chart extends Component
implements ItemSelectable, Runnable
{
public boolean isValueLinesOn()
{
return valueLinesOn;
}
public void setDefaultGridLinesOn(boolean flag)
{
setDefaultGridLinesOn(flag, -1D, -1D);
}
public void setDefaultGridLinesOn(boolean flag, double d, double d1)
{
defaultGridLines = null;
if(flag)
{
if(d <= 0.0D && d1 > 0.0D)
d = d1;
if(d1 <= 0.0D)
{
int i = 0;
if(chartType.equals("bar"))
i = getSampleCount() - 1;
else
if(chartType.equals("line"))
i = getSampleCount() - 2;
double d2 = (rightSampleAxisRange - leftSampleAxisRange) / (double)(i + 1);
defaultGridLines = new double[i];
for(int l = 0; l < defaultGridLines.length; l++)
defaultGridLines[l] = leftSampleAxisRange + d2 * (double)(l + 1);
} else
{
int j = (int)Math.ceil((rightSampleAxisRange - d) / d1);
defaultGridLines = new double[j];
for(int k = 0; k < defaultGridLines.length; k++)
defaultGridLines[k] = d + d1 * (double)k;
}
}
hasChanged = true;
autoRepaint();
}
public void setRangeLabelsOn(boolean flag)
{
rangeLabelsOn = flag;
hasChanged = true;
autoRepaint();
}
public Image createImage(int i, int j)
{
i = Math.max(1, i);
j = Math.max(1, j);
Image image = super.createImage(i, j);
if(image == null)
{
Frame frame = new Frame();
frame.addNotify();
image = frame.createImage(i, j);
frame.dispose();
}
return image;
}
public void setTargetValueLine(String s, double d, Color color, int i)
{
if(color == null)
{
targetsLabel.remove(s);
targetsValue.remove(s);
targetsColor.remove(s);
targetsStyle.remove(s);
} else
{
targetsLabel.put(s, s);
targetsValue.put(s, new Double(d));
targetsColor.put(s, color);
targetsStyle.put(s, new Integer(i));
}
hasChanged = true;
autoRepaint();
}
public double getTargetValueLine(String s)
{
if(targetsValue.get(s) != null)
return ((Double)targetsValue.get(s)).doubleValue();
else
return 0.0D;
}
private int[] rotateImage(int ai[], int i, Dimension dimension, int j)
{
if(i % 360 == 0)
return ai;
if(i % 360 == 90)
{
int ai1[] = new int[ai.length];
for(int k = 0; k < dimension.height; k++)
{
for(int l1 = 0; l1 < dimension.width; l1++)
ai1[l1 * dimension.height + k] = ai[(dimension.width * dimension.height - dimension.width - k * dimension.width) + l1];
}
int l = dimension.width;
dimension.width = dimension.height;
dimension.height = l;
return ai1;
}
if(i % 360 == 180)
{
int ai2[] = new int[ai.length];
for(int i1 = 0; i1 < dimension.width; i1++)
{
for(int i2 = 0; i2 < dimension.height; i2++)
ai2[i2 * dimension.width + i1] = ai[dimension.width * dimension.height - 1 - i2 * dimension.width - i1];
}
return ai2;
}
if(i % 360 == 270)
{
int ai3[] = new int[ai.length];
for(int j1 = 0; j1 < dimension.height; j1++)
{
for(int j2 = 0; j2 < dimension.width; j2++)
ai3[j2 * dimension.height + j1] = ai[(j1 * dimension.width + dimension.width) - j2 - 1];
}
int k1 = dimension.width;
dimension.width = dimension.height;
dimension.height = k1;
return ai3;
}
i = -i;
double d = Math.sin((double)i * 0.017453292519943295D);
double d1 = Math.cos((double)i * 0.017453292519943295D);
double ad[] = new double[2];
Rectangle rectangle = new Rectangle(dimension);
getAngledBounds(d1, d, rectangle, ad);
int k2 = -rectangle.x;
int l2 = -rectangle.y;
int ai4[] = new int[rectangle.width * rectangle.height];
int ai5[] = new int[rectangle.width];
for(int i3 = 0; i3 < rectangle.height; i3++)
{
itransform(d1, d, 0 - k2, i3 - l2, ad);
double d2 = ad[0];
double d3 = ad[1];
itransform(d1, d, rectangle.width - k2, i3 - l2, ad);
double d4 = ad[0];
double d5 = ad[1];
double d6 = (d4 - d2) / (double)rectangle.width;
double d7 = (d5 - d3) / (double)rectangle.width;
for(int j3 = 0; j3 < rectangle.width; j3++)
{
int k3 = (int)Math.round(d2);
int l3 = (int)Math.round(d3);
if(k3 < 0 || l3 < 0 || k3 >= dimension.width || l3 >= dimension.height)
ai5[j3] = j & 0xffffff;
else
ai5[j3] = ai[l3 * dimension.width + k3];
d2 += d6;
d3 += d7;
}
System.arraycopy(ai5, 0, ai4, i3 * rectangle.width, ai5.length);
}
dimension.width = rectangle.width;
dimension.height = rectangle.height;
return ai4;
}
public void setLegendLabels(String as[])
{
if(as != null)
legendLabels = as;
else
legendLabels = null;
checkDataIntegrity();
labelSizeCache.clear();
hasChanged = true;
autoRepaint();
}
public String[] getLegendLabels()
{
if(legendLabels != null)
return legendLabels;
if(getSeriesCount() == 1)
return getSampleLabels();
else
return getSeriesLabels();
}
private void getColorPixels(Color acolor[], int ai[])
{
acolor[0] = Color.white;
if(acolor[0].equals(acolor[1]))
acolor[0] = Color.black;
Image image = createImage(2, 1);
if(image != null)
{
Graphics g = image.getGraphics();
g.setColor(acolor[0]);
g.drawLine(0, 0, 0, 0);
g.setColor(acolor[1]);
g.drawLine(1, 0, 1, 0);
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, 2, 1, ai, 0, 2);
pixelgrabber.startGrabbing();
pixelgrabber.getPixels();
if(ai[0] == ai[1])
acolor[0] = new Color(0x7fffff);
image.flush();
g.dispose();
}
}
public synchronized void setLowerRange(int i, double d)
{
i = Math.max(0, Math.min(1, i));
lowerRange[i] = d;
currentLowerRange[i] = Math.max(currentLowerRange[i], d);
if(!rangeAdjusterOn[i])
currentLowerRange[i] = d;
for(int j = 0; j < overlayCharts.size(); j++)
((Chart)overlayCharts.elementAt(j)).setLowerRange(i, d);
hasChanged = true;
autoRepaint();
}
public synchronized double getLowerRange(int i)
{
return (double)(long)lowerRange[Math.max(0, Math.min(1, i))];
}
public void setSeriesRange(int i, int j)
{
if(i >= 0 && i < getSeriesCount())
seriesRange[i] = Math.max(0, Math.min(rangeOn.length - 1, j));
hasChanged = true;
autoRepaint();
}
public int getSeriesRange(int i)
{
if(i >= 0 && i < getSeriesCount())
return seriesRange[i];
else
return 0;
}
public boolean is3DModeOn()
{
return display3dOn;
}
boolean isServletModeOn()
{
return servletModeOn;
}
/**
* @deprecated Method setLowerRange is deprecated
*/
public synchronized void setLowerRange(double d)
{
setLowerRange(0, d);
}
public void setChartForeground(Color color)
{
chartForeground = color;
hasChanged = true;
autoRepaint();
}
public void setGridLineColor(int i, Color color)
{
if(i >= maxGridLineCount || i < 0)
throw new IllegalArgumentException("Illegal vertical grid line index: " + i);
if(gridLineColors == null)
gridLineColors = new Color[i + 1];
if(i >= gridLineColors.length)
{
Color acolor[] = new Color[i + 1];
System.arraycopy(gridLineColors, 0, acolor, 0, gridLineColors.length);
gridLineColors = acolor;
}
gridLineColors[i] = color;
hasChanged = true;
autoRepaint();
}
public Color getGridLineColor(int i)
{
if(gridLineColors == null || i >= gridLineColors.length)
return getValueLinesColor();
else
return gridLineColors[i];
}
public Color getChartForeground()
{
return chartForeground;
}
/**
* @deprecated Method getLowerRange is deprecated
*/
public synchronized long getLowerRange()
{
return (long)getLowerRange(0);
}
public void autoRepaint()
{
if(automaticRepaintOn)
repaint();
}
private void paintRange(Graphics g, Rectangle rectangle, int i)
{
i = Math.max(0, Math.min(1, i));
if(!rangeOn[i])
return;
String s = getLabel("rangeLabelPrefix");
String s1 = getLabel("rangeLabelPostfix");
g.setFont(getFont("rangeLabelFont"));
FontMetrics fontmetrics = g.getFontMetrics();
int j = 0;
if(gridAlignment == 1)
{
j = (int)Math.round((double)rectangle.height / (double)fontmetrics.getHeight());
} else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -