All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lightgraph.GraphLine Maven / Gradle / Ivy

The newest version!
package lightgraph;

import lightgraph.painters.GraphPainter;

import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.util.ArrayList;

/**
 * For drawing lines.
 * 
 * User: mbs207
 * Date: May 20, 2010
 * Time: 6:48:46 AM
 */
public abstract class GraphLine {
    double WIDTH = 1;
    abstract public void drawLine(ArrayList pts, GraphPainter painter);
    public double getLineWidth(){
        return WIDTH;
    }

    public void setLineWidth(double w){
        WIDTH = w;
    }


    /**
     * Default line implementation.
     *
     * @return solid line.
     */
    public static GraphLine solidLine(){
        return new GraphLine(){
            public void drawLine(ArrayList pts, GraphPainter painter){
                painter.setLineWidth(WIDTH);
                Path2D path = new Path2D.Double();
                if(pts.size()>0){
                    Point2D pt = pts.get(0);
                    path.moveTo(pt.getX(), pt.getY());
                    for(int i = 1; i pts, GraphPainter painter){
                painter.setLineWidth(WIDTH);
                painter.setDashes(dashes);
                Path2D path = new Path2D.Double();
                if(pts.size()>0){
                    Point2D pt = pts.get(0);
                    path.moveTo(pt.getX(), pt.getY());
                    for(int i = 1; i getLines(){
        ArrayList lines = new ArrayList();
        lines.add(solidLine());
        lines.add(shortDashes());
        lines.add(longDashes());
        lines.add(longShortDashes());
        lines.add(longShortShortDashes());
        return lines;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy