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

📄 linechart.java

📁 一个完整的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov  Date: 2002-12-03 18:42:54
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   LineChart.java

package cn.com.fcsoft.chart;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.io.PrintStream;
import java.util.*;

// Referenced classes of package com.objectplanet.chart:
//            Chart, ChartSample, PieChart

public class LineChart extends Chart
{

    public void setSampleHighlightStyle(int i, int j, int k)
    {
        sampleHighlightSize[i] = Math.max(0, k);
        sampleHighlightStyle[i] = j;
        super.hasChanged = true;
        autoRepaint();
    }

    public int getSampleHighlightStyle(int i)
    {
        try
        {
            return sampleHighlightStyle[i];
        }
        catch(IndexOutOfBoundsException _ex)
        {
            throw new IllegalArgumentException("Invalid series: " + i);
        }
    }

    public boolean isSampleLabelsOn()
    {
        return super.sampleLabelsOn;
    }

    public void setAutoLabelSpacingOn(boolean flag)
    {
        autoLabelSpacingOn = flag;
        super.hasChanged = true;
        autoRepaint();
    }

    public void setStackedOn(boolean flag)
    {
        stackedOn = flag;
        super.hasChanged = true;
        autoRepaint();
    }

    public void setConnectedLinesOn(int i, boolean flag)
    {
        if(i >= 0 && i < connectedLinesOn.length)
            connectedLinesOn[i] = flag;
        else
        if(i == -1)
        {
            for(int j = 0; j < connectedLinesOn.length; j++)
                connectedLinesOn[j] = 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 |= super.sampleLabelsOn && sampleLabelStyle == 2;
            flag |= seriesLabelsOn;
            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 String[] getLegendLabels()
    {
        if(super.legendLabels != null)
            return super.legendLabels;
        else
            return getSeriesLabels();
    }

    private void paintSampleLabels(Graphics g, Rectangle rectangle, Rectangle rectangle1)
    {
        String as[] = getSampleLabels();
        if(as == null)
            return;
        Font font = getFont("sampleLabelFont");
        g.setFont(font);
        FontMetrics fontmetrics = g.getFontMetrics();
        int i = getSampleCount();
        double d = rectangle1.width;
        if(i > 1)
            d = (float)rectangle1.width / (float)(i - 1);
        int j = rectangle1.y + rectangle1.height;
        double d1 = rectangle1.x;
        int k = rectangle.x;
        int l = rectangle.x + rectangle.width;
        if(is3DModeOn())
        {
            j -= super.depth3dPoint.y;
            d1 -= super.depth3dPoint.x;
            k -= super.depth3dPoint.x;
            l -= super.depth3dPoint.x;
        }
        if(super.sampleScrollerOn)
            j += 10;
        Color color = getChartForeground();
        int i1 = getLabelAngle("sampleLabelAngle");
        double d2 = 0.0D;
        for(int j1 = 0; j1 < as.length; j1++)
        {
            if(as[j1] != null && as[j1].length() > 0 && d1 >= (double)k && d1 <= (double)(l + 1))
            {
                Color color1 = getSampleLabelColor(j1);
                if(color1 == null)
                    color1 = getForeground();
                String s = as[j1];
                Dimension dimension = getLabelSize(s, font);
                Dimension dimension1 = getAngledLabelSize(dimension, i1);
                int k1 = j + 8;
                if(i1 % 180 == 0)
                    k1 += fontmetrics.getMaxAscent() - 4;
                double d3 = 0.0D;
                if(i1 % 180 == 0)
                    d3 = d1 - (double)(dimension1.width / 2);
                else
                if(i1 % 360 > 90 && i1 % 360 < 180 || i1 % 360 > 270)
                    d3 = (d1 - (double)dimension1.width) + (double)(fontmetrics.getAscent() / 2);
                else
                    d3 = d1 - (double)(fontmetrics.getAscent() / 2);
                g.setColor(color);
                if(autoLabelSpacingOn)
                {
                    if(s != null && s.trim().length() > 0 && (d3 > d2 || j1 == 0))
                    {
                        g.drawLine((int)Math.round(d1), j, (int)Math.round(d1), j + 3);
                        g.setColor(color1);
                        paintLabel(g, s, (int)Math.round(d3), k1, dimension, 0, i1);
                        d2 = d3 + (double)dimension1.width;
                    }
                } else
                if(s != null && s.trim().length() > 0)
                {
                    g.drawLine((int)Math.round(d1), j, (int)Math.round(d1), j + 3);
                    g.setColor(color1);
                    paintLabel(g, s, (int)Math.round(d3), k1, dimension, 0, i1);
                }
            }
            d1 += d;
        }

    }

    public void setSampleLabelStyle(int i)
    {
        sampleLabelStyle = i;
        super.hasChanged = true;
        autoRepaint();
    }

    public int getSampleLabelStyle()
    {
        return sampleLabelStyle;
    }

    public void setSeriesLineOn(boolean flag)
    {
        for(int i = 0; i < seriesLinesOn.length; i++)
            seriesLinesOn[i] = flag;

        super.hasChanged = true;
        autoRepaint();
    }

    public void setSeriesLineOn(int i, boolean flag)
    {
        seriesLinesOn[i] = flag;
        super.hasChanged = true;
        autoRepaint();
    }

    private void paintSampleHighlight(Graphics g, int i, int j, int k, Color color)
    {
        java.awt.Shape shape = g.getClip();
        g.setClip(0, 0, 32767, 32767);
        String s = getLegendImage(i);
        Dimension dimension = getImageSize(s);
        if(s != null && dimension.width > 0 && dimension.height > 0)
        {
            Image image = (Image)super.images.get(s);
            if(image != null)
                g.drawImage(image, j - dimension.width / 2, k - dimension.height / 2, this);
        } else
        {
            int l = 6;
            if(i >= 0 && i < sampleHighlightSize.length)
                l = sampleHighlightSize[i];
            int i1 = 0;
            if(i >= 0 && i < sampleHighlightStyle.length)
                i1 = sampleHighlightStyle[i];
            Color color1 = getChartBackground();
            g.setColor(color);
            switch(i1)
            {
            default:
                break;

            case 0: // '\0'
                g.drawOval(j - l / 2, k - l / 2, l, l);
                break;

            case 2: // '\002'
                g.fillOval(j - l / 2, k - l / 2, l + 1, l + 1);
                break;

            case 1: // '\001'
                g.setColor(color1);
                g.fillOval(j - l / 2, k - l / 2, l + 1, l + 1);
                g.setColor(color);
                g.drawOval(j - l / 2, k - l / 2, l, l);
                break;

            case 3: // '\003'
                g.drawRect(j - l / 2, k - l / 2, l, l);
                break;

            case 5: // '\005'
                g.fillRect(j - l / 2, k - l / 2, l + 1, l + 1);
                break;

            case 4: // '\004'
                g.setColor(color1);
                g.fillRect(j - l / 2, k - l / 2, l + 1, l + 1);
                g.setColor(color);
                g.drawRect(j - l / 2, k - l / 2, l, l);
                break;

            case 6: // '\006'
            case 7: // '\007'
            case 8: // '\b'
                int ai[] = new int[4];
                ai[0] = ai[2] = j;
                ai[1] = j + l / 2;
                ai[3] = j - l / 2;
                int ai1[] = new int[4];
                ai1[0] = k - l / 2;
                ai1[2] = k + l / 2;
                ai1[1] = ai1[3] = k;
                if(i1 == 7)
                {
                    g.setColor(color1);
                    g.fillPolygon(ai, ai1, 4);
                } else
                if(i1 == 8)
                {
                    g.setColor(color);
                    g.fillPolygon(ai, ai1, 4);
                }
                g.setColor(color);
                g.drawPolygon(ai, ai1, 4);
                break;
            }
        }
        g.setClip(shape);
    }

    double getHighestValue(int i)
    {
        if(stackedOn)
            return getMaxValue(-2);
        else
            return super.getHighestValue(i);
    }

    public double getMaxValue(int i)
    {
        if(i >= -1 || !stackedOn)
            return super.getMaxValue(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;
    }

    protected void calculateChartData(Rectangle rectangle, Rectangle rectangle1)
    {
        calculateZeroLines(rectangle);
        if(is3DModeOn())
            if(super.depth3d > -1)
            {
                super.depth3dPoint.x = super.depth3d;
                super.depth3dPoint.y = -super.depth3d;
            } else
            {
                int i = Math.max(getSampleCount(), 20);
                int j = getSeriesCount();
                if(j > 1 && !stackedOn)
                {
                    i /= j;
                    i = Math.max(i, 4);
                }
                double d = (double)rectangle.width / (double)i;
                super.depth3dPoint.x = (int)Math.round(d * 1.25D);
                super.depth3dPoint.y = (int)Math.round(-d / 1.25D);
            }
    }

    private void paintFloatingLabels(Graphics g, Rectangle rectangle)
    {
        boolean flag = isValueLabelsOn(-1) && valueLabelStyle == 2;
        flag |= super.sampleLabelsOn && sampleLabelStyle == 2;
        flag |= seriesLabelsOn;
        if(flag)
        {
            Font font = getFont("floatingLabelFont");
            g.setFont(font);
            FontMetrics fontmetrics = g.getFontMetrics();
            if(selectedSample >= 0 && selectedSeries >= 0)
            {
                ChartSample chartsample = getSample(selectedSeries, selectedSample);
                if(chartsample != null && chartsample.value != null && !chartsample.value.isNaN())
                {
                    String s = constructFloatingLabel(selectedSeries, selectedSample, seriesLabelsOn);
                    paintFloatingLabel(g, rectangle, selectedSeries, selectedSample, s, font, fontmetrics);
                }
            } else
            if(selectedSeries >= 0 && isFloatingOnLegendOn())
            {
                int i = getSampleCount();
                for(int j = 0; j < i; j++)
                {
                    ChartSample chartsample1 = getSample(selectedSeries, j);
                    if(chartsample1 != null && chartsample1.value != null && !chartsample1.value.isNaN())
                    {
                        String s1 = constructFloatingLabel(selectedSeries, j, false);
                        paintFloatingLabel(g, rectangle, selectedSeries, j, s1, font, fontmetrics);
                    }
                }

            }
        }
    }

    public boolean isSeriesLineOn(int i)
    {
        return seriesLinesOn[i];

⌨️ 快捷键说明

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