0

我正在尝试根据列表绘制线条。这是我的代码。我添加了一个“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];

这里画法

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);
4

0 回答 0