trackeditor: use inherited start heights when splitting segments
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9262 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
parent
65ace9cf15
commit
a99a804bd6
|
@ -652,17 +652,17 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
newShape.getLeft().setBarrierWidth(oldShape.getLeft().getBarrierWidth());
|
||||
newShape.getRight().setBarrierWidth(oldShape.getRight().getBarrierWidth());
|
||||
|
||||
double heightStart = oldShape.getHeightStart();
|
||||
double heightStart = oldShape.getValidHeightStart();
|
||||
|
||||
if (!Double.isNaN(heightStart) && !Double.isNaN(oldShape.getHeightEnd()))
|
||||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEnd())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEnd());
|
||||
double leftHeight = heightStart + (oldShape.getHeightEnd() - heightStart) * splitPoint;
|
||||
newShape.setHeightStart(leftHeight);
|
||||
oldShape.setHeightEnd(leftHeight);
|
||||
double splitHeight = heightStart + (oldShape.getHeightEnd() - heightStart) * splitPoint;
|
||||
newShape.setHeightStart(splitHeight);
|
||||
oldShape.setHeightEnd(splitHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(heightStart) && !Double.isNaN(oldShape.getHeightEndLeft()))
|
||||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEndLeft())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEndLeft());
|
||||
double leftHeight = heightStart + (oldShape.getHeightEndLeft() - heightStart) * splitPoint;
|
||||
|
@ -670,7 +670,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
oldShape.setHeightEndLeft(leftHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(heightStart) && !Double.isNaN(oldShape.getHeightEndRight()))
|
||||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEndRight())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEndRight());
|
||||
double leftHeight = heightStart + (oldShape.getHeightEndRight() - heightStart) * splitPoint;
|
||||
|
@ -678,41 +678,9 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
oldShape.setHeightEndRight(leftHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(oldShape.getHeightStartLeft()) && !Double.isNaN(oldShape.getHeightEndLeft()))
|
||||
{
|
||||
newShape.setHeightEndLeft(oldShape.getHeightEndLeft());
|
||||
double leftHeight = oldShape.getHeightStartLeft() + (oldShape.getHeightEndLeft() - oldShape.getHeightStartLeft()) * splitPoint;
|
||||
newShape.setHeightStartLeft(leftHeight);
|
||||
oldShape.setHeightEndLeft(leftHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(oldShape.getHeightStartLeft()) && !Double.isNaN(oldShape.getHeightEnd()))
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEnd());
|
||||
double leftHeight = oldShape.getHeightStartLeft() + (oldShape.getHeightEnd() - oldShape.getHeightStartLeft()) * splitPoint;
|
||||
newShape.setHeightStartLeft(leftHeight);
|
||||
oldShape.setHeightEndLeft(leftHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(oldShape.getHeightStartRight()) && !Double.isNaN(oldShape.getHeightEndRight()))
|
||||
{
|
||||
newShape.setHeightEndRight(oldShape.getHeightEndRight());
|
||||
double rightHeight = oldShape.getHeightStartRight() + (oldShape.getHeightEndRight() - oldShape.getHeightStartRight()) * splitPoint;
|
||||
newShape.setHeightStartRight(rightHeight);
|
||||
oldShape.setHeightEndRight(rightHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(oldShape.getHeightStartRight()) && !Double.isNaN(oldShape.getHeightEnd()))
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEnd());
|
||||
double rightHeight = oldShape.getHeightStartRight() + (oldShape.getHeightEnd() - oldShape.getHeightStartRight()) * splitPoint;
|
||||
newShape.setHeightStartRight(rightHeight);
|
||||
oldShape.setHeightEndRight(rightHeight);
|
||||
}
|
||||
|
||||
double bankingStart = getBankingStart(oldShape);
|
||||
|
||||
if (!Double.isNaN(bankingStart) && !Double.isNaN(oldShape.getBankingEnd()))
|
||||
if (!Double.isNaN(bankingStart) && oldShape.hasBankingEnd())
|
||||
{
|
||||
newShape.setBankingEnd(oldShape.getBankingEnd());
|
||||
double banking = bankingStart + (oldShape.getBankingEnd() - bankingStart) * splitPoint;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Properties
|
|||
private static Properties instance = new Properties();
|
||||
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
||||
public final String title = "sd2-trackeditor";
|
||||
public final String version = "1.4.8";
|
||||
public final String version = "1.4.9";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -377,6 +377,10 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightStart = heightStart;
|
||||
}
|
||||
public boolean hasHeightStart()
|
||||
{
|
||||
return !Double.isNaN(heightStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the heightStartLeft.
|
||||
|
@ -393,6 +397,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightStartLeft = heightStartLeft;
|
||||
}
|
||||
public boolean hasHeightStartLeft()
|
||||
{
|
||||
return !Double.isNaN(heightStartLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the heightStartRight.
|
||||
*/
|
||||
|
@ -408,6 +417,10 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightStartRight = heightStartRight;
|
||||
}
|
||||
public boolean hasHeightStartRight()
|
||||
{
|
||||
return !Double.isNaN(heightStartRight);
|
||||
}
|
||||
|
||||
public double getHeightEnd()
|
||||
{
|
||||
|
@ -417,6 +430,10 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightEnd = heightEnd;
|
||||
}
|
||||
public boolean hasHeightEnd()
|
||||
{
|
||||
return !Double.isNaN(heightEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the heightEndLeft.
|
||||
|
@ -433,6 +450,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightEndLeft = heightEndLeft;
|
||||
}
|
||||
public boolean hasHeightEndLeft()
|
||||
{
|
||||
return !Double.isNaN(heightEndLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the heightEndRight.
|
||||
*/
|
||||
|
@ -448,6 +470,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.heightEndRight = heightEndRight;
|
||||
}
|
||||
public boolean hasHeightEndRight()
|
||||
{
|
||||
return !Double.isNaN(heightEndRight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the grade.
|
||||
*/
|
||||
|
@ -478,6 +505,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.bankingStart = bankingStart;
|
||||
}
|
||||
public boolean hasBankingStart()
|
||||
{
|
||||
return !Double.isNaN(bankingStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the bankingEnd.
|
||||
*/
|
||||
|
@ -493,6 +525,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.bankingEnd = bankingEnd;
|
||||
}
|
||||
public boolean hasBankingEnd()
|
||||
{
|
||||
return !Double.isNaN(bankingEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profil.
|
||||
*/
|
||||
|
@ -523,6 +560,7 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilSteps = profilSteps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilStepsLength.
|
||||
*/
|
||||
|
@ -538,6 +576,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilStepsLength = profilStepsLength;
|
||||
}
|
||||
public boolean hasProfilStepsLength()
|
||||
{
|
||||
return !Double.isNaN(profilStepsLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilStartTangent.
|
||||
*/
|
||||
|
@ -553,6 +596,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilStartTangent = profilStartTangent;
|
||||
}
|
||||
public boolean hasProfilStartTangent()
|
||||
{
|
||||
return !Double.isNaN(profilStartTangent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilEndTangent.
|
||||
*/
|
||||
|
@ -568,6 +616,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilEndTangent = profilEndTangent;
|
||||
}
|
||||
public boolean hasProfilEndTangent()
|
||||
{
|
||||
return !Double.isNaN(profilEndTangent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilStartTangentLeft.
|
||||
*/
|
||||
|
@ -1731,7 +1784,110 @@ public class Segment implements Cloneable
|
|||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public double getValidHeightStart()
|
||||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStart())
|
||||
{
|
||||
return previous.heightStart;
|
||||
}
|
||||
else if (previous.hasHeightStartLeft() &&
|
||||
previous.hasHeightStartRight() &&
|
||||
previous.heightStartLeft == previous.heightStartRight)
|
||||
{
|
||||
return previous.heightStartLeft;
|
||||
}
|
||||
previous = previous.previousShape;
|
||||
if (previous == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (previous.hasHeightEnd())
|
||||
{
|
||||
return previous.heightEnd;
|
||||
}
|
||||
else if (previous.hasHeightEndLeft() &&
|
||||
previous.hasHeightEndRight() &&
|
||||
previous.heightEndLeft == previous.heightEndRight)
|
||||
{
|
||||
return previous.heightEnd;
|
||||
}
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
public double getValidHeightStartLeft()
|
||||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStartLeft())
|
||||
{
|
||||
return previous.heightStartLeft;
|
||||
}
|
||||
else if (previous.hasHeightStart())
|
||||
{
|
||||
return previous.heightStart;
|
||||
}
|
||||
previous = previous.previousShape;
|
||||
if (previous == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (previous.hasHeightEndLeft())
|
||||
{
|
||||
return previous.heightEndLeft;
|
||||
}
|
||||
else if (previous.hasHeightEnd())
|
||||
{
|
||||
return previous.heightEnd;
|
||||
}
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
public double getValidHeightStartRight()
|
||||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStartRight())
|
||||
{
|
||||
return previous.heightStartRight;
|
||||
}
|
||||
else if (previous.hasHeightStart())
|
||||
{
|
||||
return previous.heightStart;
|
||||
}
|
||||
previous = previous.previousShape;
|
||||
if (previous == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (previous.hasHeightEndRight())
|
||||
{
|
||||
return previous.heightEndRight;
|
||||
}
|
||||
else if (previous.hasHeightEnd())
|
||||
{
|
||||
return previous.heightEnd;
|
||||
}
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
public void inheritProperties(Segment previousShape)
|
||||
{
|
||||
setSurface(previousShape.getSurface());
|
||||
|
|
Loading…
Reference in New Issue