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

📄 barchart.java

📁 一个完整的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                            l3 -= super.sampleScrollerOn ? 10 : 0;
                            j3 = Math.min(j3, l3 - dimension2.width - 3);
                        }
                        paintLabel(g, as[j1], j3, l2, dimension, 1, j);
                    }
                }

        }
    }

    private void paintFloatingLabels(Graphics g, Rectangle rectangle)
    {
        boolean flag = valueLabelStyle == 2 || super.barLabelStyle == 1 || super.barLabelStyle == 2;
        if(flag && selectedSeries >= 0 && selectedSample >= -1)
        {
            Font font = getFont("floatingLabelFont");
            g.setFont(font);
            FontMetrics fontmetrics = g.getFontMetrics();
            if(selectedSample >= 0)
            {
                String s = constructFloatingLabel(selectedSeries, selectedSample, true);
                paintFloatingLabel(g, rectangle, selectedSeries, selectedSample, s, font, fontmetrics);
            } else
            if(isFloatingOnLegendOn())
            {
                int i = getSampleCount();
                for(int j = 0; j < i; j++)
                {
                    String s1 = constructFloatingLabel(selectedSeries, j, false);
                    paintFloatingLabel(g, rectangle, selectedSeries, j, s1, font, fontmetrics);
                }

            }
        }
    }

    public void setMultiColorOn(boolean flag)
    {
        multiColorOn = flag;
        super.hasChanged = true;
        autoRepaint();
    }

    private void paintBars(Graphics g, Rectangle rectangle)
    {
        int i = getSeriesCount();
        int j = getSampleCount();
        if(rectangle.width < 0 || rectangle.height < 0)
            return;
        boolean flag = is3DModeOn();
        if(flag)
            g.setClip((rectangle.x - super.depth3dPoint.x) + 1, rectangle.y + 1, (rectangle.width + super.depth3dPoint.x) - 1, rectangle.height - super.depth3dPoint.y - 1);
        else
        if(super.parentChart != null && super.parentChart.is3DModeOn())
            g.setClip((rectangle.x + 1) - super.parentChart.depth3dPoint.x, (rectangle.y + 1) - super.parentChart.depth3dPoint.y, rectangle.width - 1, rectangle.height - 1);
        else
            g.setClip(rectangle.x + 1, rectangle.y + 1, rectangle.width - 1, rectangle.height - 1);
        if(super.gridAlignment == 1)
        {
            if(barType == 0)
            {
                for(int k = 0; k < j; k++)
                {
                    for(int i2 = 0; i2 < i; i2++)
                        paintBar(g, i2, k);

                }

            } else
            {
                for(int l = 0; l < j; l++)
                {
                    for(int j2 = i - 1; j2 >= 0; j2--)
                        if(getSampleValue(j2, l) < 0.0D)
                            paintBar(g, j2, l);

                }

                for(int i1 = 0; i1 < j; i1++)
                {
                    for(int k2 = 0; k2 < i; k2++)
                        if(getSampleValue(k2, i1) >= 0.0D)
                            paintBar(g, k2, i1);

                }

            }
        } else
        if(barType == 0)
        {
            for(int j1 = j - 1; j1 >= 0; j1--)
            {
                for(int l2 = i - 1; l2 >= 0; l2--)
                    paintBar(g, l2, j1);

            }

        } else
        {
            for(int k1 = j - 1; k1 >= 0; k1--)
            {
                for(int i3 = i - 1; i3 >= 0; i3--)
                    if(getSampleValue(i3, k1) < 0.0D)
                        paintBar(g, i3, k1);

            }

            for(int l1 = j - 1; l1 >= 0; l1--)
            {
                for(int j3 = 0; j3 < i; j3++)
                    if(getSampleValue(j3, l1) >= 0.0D)
                        paintBar(g, j3, l1);

            }

        }
        if(flag)
        {
            g.setColor(getBackground());
            Polygon polygon = new Polygon();
            polygon.addPoint(rectangle.x + rectangle.width, rectangle.y + rectangle.height);
            polygon.addPoint(rectangle.x + rectangle.width, ((rectangle.y + rectangle.height) - super.depth3dPoint.y) + 1);
            polygon.addPoint((rectangle.x + rectangle.width) - super.depth3dPoint.x - 1, ((rectangle.y + rectangle.height) - super.depth3dPoint.y) + 1);
            g.fillPolygon(polygon);
            g.setColor(getChartForeground());
            g.drawLine(rectangle.x + rectangle.width, rectangle.y + rectangle.height, (rectangle.x + rectangle.width) - super.depth3dPoint.x, (rectangle.y + rectangle.height) - super.depth3dPoint.y);
            polygon.xpoints[0] = rectangle.x;
            polygon.ypoints[0] = rectangle.y;
            polygon.xpoints[1] = rectangle.x - super.depth3dPoint.x;
            polygon.ypoints[1] = rectangle.y;
            polygon.xpoints[2] = rectangle.x - super.depth3dPoint.x;
            polygon.ypoints[2] = rectangle.y - super.depth3dPoint.y;
            g.setColor(getBackground());
            g.fillPolygon(polygon);
            g.setColor(getChartForeground());
            g.drawLine(rectangle.x, rectangle.y, rectangle.x - super.depth3dPoint.x, rectangle.y - super.depth3dPoint.y);
        }
    }

    public void setValueLabelStyle(int i)
    {
        switch(i)
        {
        case 0: // '\0'
        case 1: // '\001'
        case 2: // '\002'
            valueLabelStyle = i;
            super.hasChanged = true;
            autoRepaint();
            break;

        default:
            throw new IllegalArgumentException("Invalid valueLabelStyle: " + i);
        }
    }

    public int getValueLabelStyle()
    {
        return valueLabelStyle;
    }

    public boolean isMultiColorOn()
    {
        return multiColorOn;
    }

    public boolean isBarOutlineOn()
    {
        return barOutlineOn;
    }

    public ChartSample checkSelection(Point point)
    {
        ChartSample chartsample = null;
        int i = getSeriesCount();
        if(isLegendOn() && super.legendBounds != null)
        {
            for(int j = 0; j < super.legendBounds.length; j++)
            {
                if(super.legendBounds[j] == null || !super.legendBounds[j].contains(point))
                    continue;
                if(i > 1 || barType == 1 || super.multiSeriesOn)
                {
                    chartsample = new ChartSample(-1);
                    chartsample.setSeries(j);
                } else
                {
                    chartsample = getSample(0, j);
                }
                break;
            }

        }
        if(chartsample == null && barBounds != null)
        {
            for(int k = getSampleCount(); k != 0;)
            {
                int l = super.gridAlignment != 0 ? k - 1 : getSampleCount() - k;
                k--;
                for(int i1 = getSeriesCount(); i1 != 0;)
                {
                    int j1 = super.gridAlignment != 0 ? i1 - 1 : getSeriesCount() - i1;
                    j1 = barType != 1 ? j1 : i1 - 1;
                    i1--;
                    Rectangle rectangle = barBounds[j1][l];
                    if(rectangle != null && rectangle != null)
                    {
                        Rectangle rectangle1 = rectangle;
                        if(barType != 1 || getSeriesCount() <= 1)
                            if(super.gridAlignment == 1 && rectangle1.height < 3)
                            {
                                rectangle1.y -= 3 - rectangle1.height;
                                rectangle1.height = 6;
                            } else
                            if(super.gridAlignment == 0 && rectangle1.width < 3)
                            {
                                rectangle1.x -= 3 - rectangle1.width;
                                rectangle1.width = 6;
                            }
                        if(rectangle1.contains(point))
                            return getSample(j1, l);
                        if(is3DModeOn())
                        {
                            if(super.gridAlignment != 1 || barType != 1 || getSampleValues(j1)[l] > 0.0D || j1 == 0)
                            {
                                Polygon polygon = new Polygon();
                                polygon.addPoint(rectangle.x, rectangle.y);
                                polygon.addPoint(polygon.xpoints[0] + super.depth3dPoint.x, polygon.ypoints[0] + super.depth3dPoint.y);
                                polygon.addPoint(polygon.xpoints[1] + rectangle.width, polygon.ypoints[1]);
                                polygon.addPoint(rectangle.x + rectangle.width, rectangle.y);
                                if(polygon.contains(point))
                                    return getSample(j1, l);
                            }
                            if(super.gridAlignment != 0 || barType != 1 || getSampleValues(j1)[l] > 0.0D || j1 == 0)
                            {
                                Polygon polygon1 = new Polygon();
                                polygon1.addPoint((rectangle.x + rectangle.width) - 1, rectangle.y);
                                polygon1.addPoint(rectangle.x + super.depth3dPoint.x + rectangle.width, rectangle.y + super.depth3dPoint.y);
                                polygon1.addPoint(rectangle.x + super.depth3dPoint.x + rectangle.width, rectangle.y + super.depth3dPoint.y + rectangle.height);
                                polygon1.addPoint((rectangle.x + rectangle.width) - 1, rectangle.y + rectangle.height);
                                if(polygon1.contains(point))
                                    return getSample(j1, l);
                            }
                        }
                    }
                }

            }

        }
        return chartsample;
    }

    protected void renderData(Graphics g, Rectangle rectangle, Rectangle rectangle1)
    {
        paintBars(g, rectangle);
        if(is3DModeOn())
        {
            for(int i = super.rangeOn.length - 1; i >= 0; i--)
                paint3DZeroDivider(g, rectangle, i);

            if(isRangeOn(1))
                paint3DEdges(super.og, rectangle);
        }
        paintValueLabels(g, rectangle);
    }

    public void reset()
    {
        super.reset();
        multiColorOn = false;
        super.barLabelStyle = 0;
        valueLabelStyle = 0;
        barOutlineOn = true;
        autoLabelSpacingOn = false;
        barWidthFraction = 0.40000000000000002D;
        barType = 0;
        super.multiSeriesOn = false;
        barWidthFraction = 0.40000000000000002D;
        selectedSeries = -1;
        selectedSample = -1;
        barOutlineColor = null;
    }

    public BarChart()
    {
        this(1);
    }

    public BarChart(int i)
    {
        this(i, 100D);
    }

    public BarChart(int i, double d)
    {
        this(i, d, 0.0D);
    }

    public BarChart(int i, double d, double d1)
    {
        this(1, i, d, d1);
    }

⌨️ 快捷键说明

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