mirror of https://github.com/rusefi/RomRaider.git
Scaling Fixes:
- Set default scale format to #.## - Removed unused table reference from Scale.java. - Added checks for staticDataTable before setting the scale. - fix for NullPointerException when changing table scales.
This commit is contained in:
parent
1127b78879
commit
0b55ac2f52
|
@ -31,12 +31,11 @@ public class Scale implements Serializable {
|
|||
private String unit = "0x";
|
||||
private String expression = "x";
|
||||
private String byteExpression = "x";
|
||||
private String format = "#";
|
||||
private String format = "#.##";
|
||||
private double coarseIncrement = 2;
|
||||
private double fineIncrement = 1;
|
||||
private double min = 0.0;
|
||||
private double max = 0.0;
|
||||
private Table table;
|
||||
|
||||
public Scale() {
|
||||
}
|
||||
|
@ -142,11 +141,75 @@ public class Scale implements Serializable {
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
public Table getTable() {
|
||||
return table;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
try {
|
||||
if(null == other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setTable(Table table) {
|
||||
this.table = table;
|
||||
if(other == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!(other instanceof Scale)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Scale otherScale = (Scale)other;
|
||||
|
||||
if( (null == this.getName() && null == otherScale.getName())
|
||||
|| (this.getName().isEmpty() && otherScale.getName().isEmpty()) ) {
|
||||
;// Skip name compare if name is null or empty.
|
||||
} else {
|
||||
if(!this.getName().equalsIgnoreCase(otherScale.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.getUnit().equals(otherScale.getUnit()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.getExpression().equals(otherScale.getExpression()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.getByteExpression().equals(otherScale.getByteExpression()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!this.getFormat().equals(otherScale.getFormat()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getCoarseIncrement() != otherScale.getCoarseIncrement())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getFineIncrement() != otherScale.getFineIncrement())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getMin() != otherScale.getMin())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getMax() != otherScale.getMax())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch(Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1236,7 +1236,8 @@ public abstract class Table extends JPanel implements Serializable {
|
|||
public void setScaleByName(String scaleName) throws NameNotFoundException {
|
||||
for(Scale scale : scales) {
|
||||
if(scale.getName().equalsIgnoreCase(scaleName)) {
|
||||
if(!getCurrentScale().equals(scale)) {
|
||||
Scale currentScale = getCurrentScale();
|
||||
if(currentScale == null || !currentScale.equals(scale)) {
|
||||
this.setCurrentScale(scale);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -375,7 +375,7 @@ public class Table2D extends Table {
|
|||
|
||||
@Override
|
||||
public void setCurrentScale(Scale curScale) {
|
||||
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
|
||||
if(SettingsManager.getSettings().isScaleHeadersAndData() && !axis.isStaticDataTable()) {
|
||||
try {
|
||||
this.axis.setScaleByName(curScale.getName());
|
||||
} catch (NameNotFoundException e) {
|
||||
|
|
|
@ -916,20 +916,24 @@ public class Table3D extends Table {
|
|||
@Override
|
||||
public void setCurrentScale(Scale curScale) {
|
||||
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
|
||||
try {
|
||||
this.xAxis.setScaleByName(curScale.getName());
|
||||
} catch (NameNotFoundException e) {
|
||||
if(!xAxis.isStaticDataTable()) {
|
||||
try {
|
||||
this.xAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||
} catch (NameNotFoundException e1) {
|
||||
this.xAxis.setScaleByName(curScale.getName());
|
||||
} catch (NameNotFoundException e) {
|
||||
try {
|
||||
this.xAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||
} catch (NameNotFoundException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.yAxis.setScaleByName(curScale.getName());
|
||||
} catch (NameNotFoundException e) {
|
||||
if(!yAxis.isStaticDataTable()) {
|
||||
try {
|
||||
this.yAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||
} catch (NameNotFoundException e1) {
|
||||
this.yAxis.setScaleByName(curScale.getName());
|
||||
} catch (NameNotFoundException e) {
|
||||
try {
|
||||
this.yAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||
} catch (NameNotFoundException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue