Java Line2D没有绘图

时间:2013-09-16 04:42:43

标签: java line graphics2d

我正在尝试根据列表绘制线条。 这是我的代码。我添加了一个“if”来查看是否绘制了行

for(int m = 0; m < routecounter; m++){
         if(route[m] != null){
             if(route[m].routeType == 2){
                 if(route[m].xChange != 0){
                     System.out.println("xChange");
                     g.draw(new Line2D.Double(route[m].x1  - wellwide , routex[route[m].xChange ].y1, route[m].x1  - wellwide + routex[route[m].xChange].moveX, routex[route[m].xChange].y2));
                     g.draw(new Line2D.Double(route[m].x1  + wellwide , routex[route[m].xChange ].y1, route[m].x1  + wellwide + routex[route[m].xChange].moveX, routex[route[m].xChange].y2));

                 }


                 g.draw(new Line2D.Double(route[m].x1  - wellwide , route[m].y1, route[m].x1  - wellwide + route[m].moveX, route[m].y2));
                 g.draw(new Line2D.Double(route[m].x1  + wellwide , route[m].y1, route[m].x1  + wellwide + route[m].moveX, route[m].y2));

             } else if(route[m].routeType == 1){


                 if(route[m].x1 == 475){
                     g.draw(new Line2D.Double((route[m].x1 - wellwide), route[m].y1, (route[m].x1 - wellwide), route[m].y2));
                     g.draw(new Line2D.Double(route[m].x1  + wellwide, route[m].y1, route[m].x1  + wellwide , route[m].y2));
                     System.out.println(m + " DIDNT DRAW " + route[m].moveX + " X1: " + route[m].x1 + " X2: " + route[m].x2 + " Y1: " + route[m].y1 + " Y2: " + route[m].y2 + " wellwide : " + wellwide);
                 }else{
                     System.out.println("I AM : " + route[m].x1);
                 }

             }
         }
     }

控制台输出:

0 DIDNT DRAW 0.0 X1: 475.0 X2: 475.0 Y1: 301.42857142857144 Y2: 355.7142857142857 wellwide : 15.0
I AM : 509.7472422754954
I AM : 509.7472422754954

我无法理解为什么它没有绘制那条线。

修改 这是我的路线类

public class Route {
public Integer routeID;
public Integer routeType;
public Double x1;
public Double y1;
public Double x2;
public Double y2;
public Double moveX;
public Integer xChange = 0;

public Route(Integer routeID, Integer routeType, Double x1, Double y1, Double x2, Double y2, Double moveX){
    this.routeID = routeID;
    this.routeType = routeType;
    this.x1 = x1;
    this.y1 = y1;
    this.x2 = x2;
    this.y2 = y2;
    this.moveX = moveX;
}

}

这里是我如何创建路径数组

Route[] route = new Route[200];

这里是paint方法

public void paint(Graphics g){
     Graphics2D g2 = (Graphics2D) g;
     startPoint = 475.0;
     wellwide = 15.0;

     Double td = Double.parseDouble(wellinfo[0].totaldepth.trim());
     BackgroundDraw(g2, td);
     ScalaDraw(g2, td);
     WellInfoDraw(g2);
     HeadDraw(g2);

     LinerDraw(g2, td, false);

}   

LinerDraw是

public void LinerDraw(Graphics2D g, Double td, Boolean checkSide)

正在调用

DrawSideTrack(g, startingY + 30, endingY + 30, td, Color.BLUE, false);

0 个答案:

没有答案