📄 chartdata.java
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2002-12-03 18:42:21
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: ChartData.java
package cn.com.fcsoft.chart;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.Hashtable;
// Referenced classes of package com.objectplanet.chart:
// ChartSample
public class ChartData
implements Serializable
{
public synchronized ChartSample getSample(Object obj)
{
return (ChartSample)sampleLookup.get(obj);
}
public synchronized int appendSample(int i, ChartSample chartsample, boolean flag)
{
if(i < 0 || i >= seriesCount)
throw new IllegalArgumentException("Illegal serie: " + i);
changedTime = System.currentTimeMillis();
int j = -1;
for(int k = 0; k < sampleCount; k++)
{
ChartSample chartsample1 = data[i][k];
if(chartsample1 != null && chartsample1.value != null)
continue;
j = k;
break;
}
if(j >= 0)
{
setSample(i, j, chartsample);
return j;
}
if(flag)
{
int l = sampleCount;
setSampleCount(l + 1);
setSample(i, l, chartsample);
return l;
}
if(sampleCount > 0)
{
for(int i1 = 0; i1 < sampleLabels.length - 1; i1++)
sampleLabels[i1] = sampleLabels[i1 + 1];
for(int j1 = 0; j1 < data[i].length - 1; j1++)
data[i][j1] = data[i][j1 + 1];
setSample(i, sampleCount - 1, chartsample);
return sampleCount - 1;
} else
{
return -1;
}
}
public synchronized void setSample(int i, int j, ChartSample chartsample)
{
if(i < 0 || i >= data.length)
throw new IllegalArgumentException("Invalid series: " + i);
try
{
chartsample.setIndex(j);
chartsample.setSeries(i);
data[i][j] = chartsample;
if(chartsample.key == null)
chartsample.key = i + "." + j;
sampleLookup.put(chartsample.key, chartsample);
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid index: " + j);
}
catch(NullPointerException _ex)
{
System.out.println("Internal error: setSample(serie, index, sample) method");
}
setIndividualSampleLabel(i, j);
changedTime = System.currentTimeMillis();
}
public synchronized void setSeriesLabel(int i, String s)
{
try
{
seriesLabels[i] = s;
for(int j = 0; j < sampleCount; j++)
setIndividualSampleLabel(i, j);
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid series: " + i);
}
changedTime = System.currentTimeMillis();
}
public synchronized String getSeriesLabel(int i)
{
try
{
return seriesLabels[i];
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid series: " + i);
}
}
private void setIndividualSampleLabel(int i, int j)
{
try
{
ChartSample chartsample = data[i][j];
if(chartsample != null)
{
String s = seriesLabels[i];
String s1 = sampleLabels[j];
String s2 = "";
if(s != null && s1 != null)
s2 = s + " " + s1;
else
if(s != null)
s2 = s;
else
if(s1 != null)
s2 = s1;
chartsample.setLabel(s2);
}
}
catch(Exception _ex)
{
System.out.println("Internal error: ChartData.setIndividualSampleLabel(serie, sample)");
}
}
public double getMaxValue(int i)
{
boolean flag = i >= 0 && i < seriesCount;
boolean flag1 = false;
double d = -1.7976931348623157E+308D;
if(flag)
{
for(int j = 0; j < sampleCount; j++)
{
ChartSample chartsample = data[i][j];
if(chartsample != null && chartsample.value != null && !chartsample.value.isNaN())
{
d = Math.max(d, chartsample.getFloatValue());
flag1 = true;
}
}
} else
{
for(int k = 0; k < seriesCount; k++)
{
for(int l = 0; l < sampleCount; l++)
{
ChartSample chartsample1 = data[k][l];
if(chartsample1 != null && chartsample1.value != null && !chartsample1.value.isNaN())
{
d = Math.max(d, chartsample1.getFloatValue());
flag1 = true;
}
}
}
}
if(flag1)
return d;
else
return 0.0D;
}
public synchronized void setSampleValue(int i, int j, double d)
{
if(i < 0 || i >= data.length)
throw new IllegalArgumentException("Invalid series: " + i);
try
{
if(data[i][j] == null)
{
data[i][j] = new ChartSample(j);
data[i][j].setSeries(i);
data[i][j].key = i + "." + j;
sampleLookup.put(data[i][j].key, data[i][j]);
}
data[i][j].setValue(d);
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid index: " + j);
}
catch(NullPointerException _ex)
{
System.out.println("Internal error: setSampleValue(serie, index, value) method");
}
setIndividualSampleLabel(i, j);
changedTime = System.currentTimeMillis();
}
public synchronized double getSampleValue(int i, int j)
{
if(i < 0 || i >= data.length)
throw new IllegalArgumentException("Invalid series: " + i);
if(data[i] == null)
return 0.0D;
if(j < 0 || j >= data[i].length)
throw new IllegalArgumentException("Invalid index: " + j);
if(data[i][j] != null)
return data[i][j].getFloatValue();
else
return 0.0D;
}
public synchronized int appendSampleValue(int i, double d, boolean flag)
{
if(i < 0 || i >= seriesCount)
throw new IllegalArgumentException("Illegal serie: " + i);
changedTime = System.currentTimeMillis();
int j = -1;
for(int k = 0; k < sampleCount; k++)
{
ChartSample chartsample = data[i][k];
if(chartsample != null && chartsample.value != null)
continue;
j = k;
break;
}
if(j >= 0)
{
setSampleValue(i, j, d);
return j;
}
if(flag)
{
int l = sampleCount;
setSampleCount(l + 1);
setSampleValue(i, l, d);
return l;
}
if(sampleCount > 0)
{
double ad[] = getSampleValues(i);
for(int i1 = 0; i1 < ad.length - 1; i1++)
ad[i1] = ad[i1 + 1];
ad[ad.length - 1] = d;
setSampleValues(i, ad);
return ad.length - 1;
} else
{
return -1;
}
}
public synchronized void setSamples(int i, ChartSample achartsample[])
{
if(i < 0 || i >= data.length)
throw new IllegalArgumentException("Invalid series: " + i);
if(data[i] == null)
data[i] = new ChartSample[sampleCount];
for(int j = 0; j < sampleCount; j++)
if(achartsample != null && j < achartsample.length && achartsample[j] != null)
{
achartsample[j].setIndex(j);
achartsample[j].setSeries(i);
data[i][j] = achartsample[j];
if(achartsample[j].key == null)
achartsample[j].key = i + "." + j;
sampleLookup.put(achartsample[j].key, achartsample[j]);
} else
{
data[i][j] = null;
}
setIndividualSampleLabels();
changedTime = System.currentTimeMillis();
}
public synchronized ChartSample[] getSamples(int i)
{
try
{
return data[i];
}
catch(IndexOutOfBoundsException _ex)
{
throw new IllegalArgumentException("Invalid series: " + i);
}
}
public synchronized void setSampleValues(int i, double ad[])
{
if(i < 0 || i >= data.length)
throw new IllegalArgumentException("Invalid series: " + i);
if(data[i] == null)
data[i] = new ChartSample[sampleCount];
for(int j = 0; j < sampleCount; j++)
{
double d = 0.0D;
if(ad != null && j < ad.length)
d = ad[j];
if(data[i][j] == null)
{
data[i][j] = new ChartSample(j);
data[i][j].setSeries(i);
data[i][j].key = i + "." + j;
sampleLookup.put(data[i][j].key, data[i][j]);
}
if(j < ad.length)
data[i][j].setValue(d);
else
data[i][j].value = null;
}
setIndividualSampleLabels();
changedTime = System.currentTimeMillis();
}
public synchronized double[] getSampleValues(int i)
{
try
{
ChartSample achartsample[] = data[i];
double ad[] = new double[achartsample.length];
for(int j = 0; j < achartsample.length; j++)
if(achartsample[j] != null)
ad[j] = achartsample[j].getFloatValue();
return ad;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -