リストに従って線を引こうとしています。これが私のコードです。線が描画されているかどうかを確認するために「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
なぜその線を引いていないのか理解できませんでした。
編集: ここに私の Route クラスがあります
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);
}
ライナードローは
public void LinerDraw(Graphics2D g, Double td, Boolean checkSide)
そしてそれは呼んでいます
DrawSideTrack(g, startingY + 30, endingY + 30, td, Color.BLUE, false);