ChartData.java
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:20k
源码类别:
OA系统
开发平台:
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;
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid series: " + i);
- }
- catch(Exception _ex)
- {
- System.out.println("Internal error: ChartData.getSampleValues(serie)");
- }
- return null;
- }
- public synchronized void setSampleLabels(String as[])
- {
- for(int i = 0; i < sampleCount; i++)
- if(as == null)
- sampleLabels[i] = null;
- else
- if(i < as.length)
- sampleLabels[i] = as[i];
- else
- sampleLabels[i] = null;
- setIndividualSampleLabels();
- changedTime = System.currentTimeMillis();
- }
- public synchronized String[] getSampleLabels()
- {
- String as[] = new String[sampleCount];
- System.arraycopy(sampleLabels, 0, as, 0, sampleLabels.length);
- return as;
- }
- public boolean hasChangedSince(long l)
- {
- return changedTime >= l;
- }
- public synchronized void setSeriesCount(int i)
- {
- setDataCount(i, sampleCount);
- }
- public synchronized int getSeriesCount()
- {
- return seriesCount;
- }
- public double getMinValue(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.min(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.min(d, chartsample1.getFloatValue());
- flag1 = true;
- }
- }
- }
- }
- if(flag1)
- return d;
- else
- return 0.0D;
- }
- private void setDataCount(int i, int j)
- {
- if(seriesCount == i && sampleCount == j)
- return;
- seriesCount = Math.max(0, i);
- sampleCount = Math.max(0, j);
- ChartSample achartsample[][] = new ChartSample[seriesCount][sampleCount];
- for(int k = 0; k < achartsample.length; k++)
- if(k < data.length)
- {
- ChartSample achartsample1[] = achartsample[k];
- for(int i1 = 0; i1 < achartsample1.length; i1++)
- if(i1 < data[k].length)
- achartsample[k][i1] = data[k][i1];
- }
- data = achartsample;
- String as[] = new String[seriesCount];
- for(int l = 0; l < as.length; l++)
- if(l < seriesLabels.length)
- as[l] = seriesLabels[l];
- seriesLabels = as;
- String as1[] = new String[sampleCount];
- for(int j1 = 0; j1 < as1.length; j1++)
- if(j1 < sampleLabels.length)
- as1[j1] = sampleLabels[j1];
- sampleLabels = as1;
- changedTime = System.currentTimeMillis();
- }
- public String toString()
- {
- return "ChartData " + seriesCount + " series, " + sampleCount + " samples";
- }
- public ChartData(int i, int j)
- {
- seriesCount = Math.max(0, i);
- sampleCount = Math.max(0, j);
- data = new ChartSample[seriesCount][];
- for(int k = 0; k < data.length; k++)
- data[k] = new ChartSample[sampleCount];
- seriesLabels = new String[seriesCount];
- sampleLabels = new String[sampleCount];
- int l = Math.max(1, j) * Math.max(1, i);
- sampleLookup = new Hashtable(l);
- changedTime = System.currentTimeMillis();
- }
- public boolean isSelected(int i, int j)
- {
- if(i < -1 || i >= seriesCount)
- throw new IllegalArgumentException("Invalid series index: " + i);
- if(j < -1 || j >= sampleCount)
- throw new IllegalArgumentException("Invalid sample index: " + j);
- boolean flag = true;
- if(i == -1 && j == -1)
- {
- for(int k = 0; k < seriesCount; k++)
- {
- for(int j1 = 0; j1 < sampleCount; j1++)
- if(data[k] == null || data[k][j1] == null || !data[k][j1].isSelected())
- flag = false;
- }
- } else
- if(j == -1)
- {
- for(int l = 0; l < sampleCount; l++)
- if(data[i] != null && data[i][l] != null && !data[i][l].isSelected())
- flag = false;
- } else
- if(i == -1)
- {
- for(int i1 = 0; i1 < seriesCount; i1++)
- if(data[i1] != null && data[i1][j] != null && !data[i1][j].isSelected())
- flag = false;
- } else
- if(data[i] == null || data[i][j] == null || !data[i][j].isSelected())
- flag = false;
- return flag;
- }
- public synchronized void setSampleCount(int i)
- {
- setDataCount(seriesCount, i);
- }
- public synchronized int getSampleCount()
- {
- return sampleCount;
- }
- public synchronized void setSampleLabel(int i, String s)
- {
- try
- {
- sampleLabels[i] = s;
- for(int j = 0; j < seriesCount; j++)
- setIndividualSampleLabel(j, i);
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid index: " + i);
- }
- changedTime = System.currentTimeMillis();
- }
- public synchronized String getSampleLabel(int i)
- {
- try
- {
- return sampleLabels[i];
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid index: " + i);
- }
- }
- public synchronized void setSeriesLabels(String as[])
- {
- for(int i = 0; i < seriesCount; i++)
- if(as == null)
- seriesLabels[i] = null;
- else
- if(i < as.length)
- seriesLabels[i] = as[i];
- else
- seriesLabels[i] = null;
- setIndividualSampleLabels();
- changedTime = System.currentTimeMillis();
- }
- public synchronized String[] getSeriesLabels()
- {
- String as[] = new String[seriesCount];
- System.arraycopy(seriesLabels, 0, as, 0, as.length);
- return as;
- }
- private void setIndividualSampleLabels()
- {
- for(int i = 0; i < seriesCount; i++)
- {
- ChartSample achartsample[] = data[i];
- if(achartsample != null)
- {
- for(int j = 0; j < achartsample.length; j++)
- if(achartsample[j] != null)
- {
- String s = seriesLabels[i];
- String s1 = sampleLabels[j];
- if(s != null && s1 != null)
- achartsample[j].setLabel(s + " " + s1);
- else
- if(s != null)
- achartsample[j].setLabel(s);
- else
- if(s1 != null)
- achartsample[j].setLabel(s1);
- }
- }
- }
- }
- public void setSelection(int i, int j, boolean flag)
- {
- setSelection(i, j, flag, false);
- }
- void setSelection(int i, int j, boolean flag, boolean flag1)
- {
- if(flag1)
- setSelection(false);
- if(i == -1 && j == -1)
- {
- for(int k = 0; k < seriesCount; k++)
- {
- for(int j1 = 0; j1 < sampleCount; j1++)
- if(data[k] != null && data[k][j1] != null)
- data[k][j1].setSelection(flag);
- }
- } else
- if(i == -1)
- {
- for(int l = 0; l < sampleCount; l++)
- if(data[l] != null && j >= 0 && j < data[l].length && data[l][j] != null)
- data[l][j].setSelection(flag);
- } else
- if(j == -1)
- {
- for(int i1 = 0; i1 < sampleCount; i1++)
- if(i >= 0 && i < data.length && data[i] != null && data[i][i1] != null)
- data[i][i1].setSelection(flag);
- } else
- if(data != null && i >= 0 && i < data.length && data[i] != null && j >= 0 && j < data[i].length)
- data[i][j].setSelection(flag);
- changedTime = System.currentTimeMillis();
- }
- private void setSelection(boolean flag)
- {
- for(int i = 0; i < seriesCount; i++)
- {
- for(int j = 0; j < sampleCount; j++)
- if(data[i] != null && data[i][j] != null)
- data[i][j].setSelection(flag);
- }
- changedTime = System.currentTimeMillis();
- }
- public synchronized ChartSample getSample(int i, int j)
- {
- if(i < 0 || i >= data.length)
- throw new IllegalArgumentException("Invalid series: " + i);
- try
- {
- return data[i][j];
- }
- catch(IndexOutOfBoundsException _ex)
- {
- throw new IllegalArgumentException("Invalid index: " + j);
- }
- catch(NullPointerException _ex)
- {
- System.out.println("Internal error: getSample(serie, index");
- }
- return null;
- }
- private ChartSample data[][];
- private Hashtable sampleLookup;
- private String seriesLabels[];
- private String sampleLabels[];
- private int seriesCount;
- private int sampleCount;
- private long changedTime;
- }