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

📄 lineplot.java

📁 这是一个十分有用的java图形工具包
💻 JAVA
字号:
/*
 * Created on 2003-5-5
 *
 * To change this generated comment go to 
 * Window>Preferences>Java>Code Generation>Code Template
 */
package net.turbochen.graph;

import java.awt.Graphics;
import java.awt.Color;
import java.util.*;
/**
 * @author Administrator
 */
public class LinePlot extends Plot
{

    protected Color lineColor;


    public LinePlot(DataSeries ds,XAxis xaxis, YAxis yaxis)
    {
        dataSeries = new ArrayList();
        this.addDataSeries(ds);
        this.xAxis = xaxis;
        this.yAxis = yaxis;
        lineColor = Color.BLUE;
    }
    
    /* (non-Javadoc)
     * @see net.turbochen.graph.Plot#draw(java.awt.Graphics, net.turbochen.graph.DataSeries, int)
     */
    public void draw(Graphics g, DataSeries ds, int index)
    {
        if ( ds == null ) return;

        g.setColor(lineColor);
        double[] x = new double[ds.size()];
        double[] y = new double[ds.size()];
        int[] xPoints = new int[ds.size()];
        int[] yPoints = new int[ds.size()];
        for ( int i = 0; i< ds.size(); i++ )
        {
            x[i] = ((Double)ds.getXData(i)).doubleValue();
            y[i] = ((Double)ds.getYData(i)).doubleValue();
            xPoints[i] = xAxis.getScale().getScreenCoordinate(x[i]);
            yPoints[i] = yAxis.getScale().getScreenCoordinate(y[i]);
            g.fillOval(xPoints[i]-3, yPoints[i]-3, 6, 6);
        }
        g.drawPolyline(xPoints, yPoints, xPoints.length);
        
    }

    /**
     * @return Color
     */
    public Color getLineColor()
    {
        return lineColor;
    }

    /**
     * Sets the lineColor.
     * @param lineColor The lineColor to set
     */
    public void setLineColor(Color lineColor)
    {
        this.lineColor = lineColor;
    }

}

⌨️ 快捷键说明

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