⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartdata.java

📁 一个完整的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        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;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -