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 unit = "0x";
|
||||||
private String expression = "x";
|
private String expression = "x";
|
||||||
private String byteExpression = "x";
|
private String byteExpression = "x";
|
||||||
private String format = "#";
|
private String format = "#.##";
|
||||||
private double coarseIncrement = 2;
|
private double coarseIncrement = 2;
|
||||||
private double fineIncrement = 1;
|
private double fineIncrement = 1;
|
||||||
private double min = 0.0;
|
private double min = 0.0;
|
||||||
private double max = 0.0;
|
private double max = 0.0;
|
||||||
private Table table;
|
|
||||||
|
|
||||||
public Scale() {
|
public Scale() {
|
||||||
}
|
}
|
||||||
|
@ -142,11 +141,75 @@ public class Scale implements Serializable {
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Table getTable() {
|
@Override
|
||||||
return table;
|
public boolean equals(Object other) {
|
||||||
}
|
try {
|
||||||
|
if(null == other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTable(Table table) {
|
if(other == this) {
|
||||||
this.table = table;
|
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 {
|
public void setScaleByName(String scaleName) throws NameNotFoundException {
|
||||||
for(Scale scale : scales) {
|
for(Scale scale : scales) {
|
||||||
if(scale.getName().equalsIgnoreCase(scaleName)) {
|
if(scale.getName().equalsIgnoreCase(scaleName)) {
|
||||||
if(!getCurrentScale().equals(scale)) {
|
Scale currentScale = getCurrentScale();
|
||||||
|
if(currentScale == null || !currentScale.equals(scale)) {
|
||||||
this.setCurrentScale(scale);
|
this.setCurrentScale(scale);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -375,7 +375,7 @@ public class Table2D extends Table {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentScale(Scale curScale) {
|
public void setCurrentScale(Scale curScale) {
|
||||||
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
|
if(SettingsManager.getSettings().isScaleHeadersAndData() && !axis.isStaticDataTable()) {
|
||||||
try {
|
try {
|
||||||
this.axis.setScaleByName(curScale.getName());
|
this.axis.setScaleByName(curScale.getName());
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
|
|
|
@ -916,20 +916,24 @@ public class Table3D extends Table {
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentScale(Scale curScale) {
|
public void setCurrentScale(Scale curScale) {
|
||||||
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
|
if(SettingsManager.getSettings().isScaleHeadersAndData()) {
|
||||||
try {
|
if(!xAxis.isStaticDataTable()) {
|
||||||
this.xAxis.setScaleByName(curScale.getName());
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
try {
|
try {
|
||||||
this.xAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
this.xAxis.setScaleByName(curScale.getName());
|
||||||
} catch (NameNotFoundException e1) {
|
} catch (NameNotFoundException e) {
|
||||||
|
try {
|
||||||
|
this.xAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||||
|
} catch (NameNotFoundException e1) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
if(!yAxis.isStaticDataTable()) {
|
||||||
this.yAxis.setScaleByName(curScale.getName());
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
try {
|
try {
|
||||||
this.yAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
this.yAxis.setScaleByName(curScale.getName());
|
||||||
} catch (NameNotFoundException e1) {
|
} catch (NameNotFoundException e) {
|
||||||
|
try {
|
||||||
|
this.yAxis.setScaleByName(SettingsManager.getSettings().getDefaultScale());
|
||||||
|
} catch (NameNotFoundException e1) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue