[fix] Merged duplicate class-instance 'finset' property with parent's 'component' property.

This commit is contained in:
Daniel_M_Williams 2020-04-05 10:33:50 -04:00
parent 644404b070
commit 24ae797959

View File

@ -69,7 +69,6 @@ public class FreeformFinSetConfig extends FinSetConfig {
private static final Logger log = LoggerFactory.getLogger(FreeformFinSetConfig.class); private static final Logger log = LoggerFactory.getLogger(FreeformFinSetConfig.class);
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private final FreeformFinSet finset;
private JTable table = null; private JTable table = null;
private FinPointTableModel tableModel = null; private FinPointTableModel tableModel = null;
@ -80,7 +79,6 @@ public class FreeformFinSetConfig extends FinSetConfig {
public FreeformFinSetConfig(OpenRocketDocument d, RocketComponent component) { public FreeformFinSetConfig(OpenRocketDocument d, RocketComponent component) {
super(d, component); super(d, component);
this.finset = (FreeformFinSet) component;
//// General and General properties //// General and General properties
tabbedPane.insertTab(trans.get("FreeformFinSetCfg.tab.General"), null, generalPane(), trans.get("FreeformFinSetCfg.tab.ttip.General"), 0); tabbedPane.insertTab(trans.get("FreeformFinSetCfg.tab.General"), null, generalPane(), trans.get("FreeformFinSetCfg.tab.ttip.General"), 0);
@ -205,7 +203,8 @@ public class FreeformFinSetConfig extends FinSetConfig {
// edit fin points directly here // edit fin points directly here
private JPanel shapePane() { private JPanel shapePane() {
JPanel panel = new JPanel(null); JPanel panel = new JPanel(null);
final FreeformFinSet finset = (FreeformFinSet)component;
// Create the figure // Create the figure
figure = new FinPointFigure(finset); figure = new FinPointFigure(finset);
@ -324,6 +323,8 @@ public class FreeformFinSetConfig extends FinSetConfig {
private void importImage() { private void importImage() {
final FreeformFinSet finset = (FreeformFinSet)component;
JFileChooser chooser = new JFileChooser(); JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(FileHelper.getImageFileFilter()); chooser.setFileFilter(FileHelper.getImageFileFilter());
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@ -394,6 +395,8 @@ public class FreeformFinSetConfig extends FinSetConfig {
public void mousePressed(MouseEvent event) { public void mousePressed(MouseEvent event) {
int mods = event.getModifiersEx(); int mods = event.getModifiersEx();
final FreeformFinSet finset = (FreeformFinSet)component;
final int pressIndex = getPoint(event); final int pressIndex = getPoint(event);
if ( pressIndex >= 0) { if ( pressIndex >= 0) {
dragIndex = pressIndex; dragIndex = pressIndex;
@ -423,6 +426,8 @@ public class FreeformFinSetConfig extends FinSetConfig {
} }
Point2D.Double point = getCoordinates(event); Point2D.Double point = getCoordinates(event);
final FreeformFinSet finset = (FreeformFinSet)component;
finset.setPoint(dragIndex, point.x, point.y); finset.setPoint(dragIndex, point.x, point.y);
updateFields(); updateFields();
@ -443,6 +448,7 @@ public class FreeformFinSetConfig extends FinSetConfig {
// if ctrl+click, delete point // if ctrl+click, delete point
try { try {
Point2D.Double point = getCoordinates(event); Point2D.Double point = getCoordinates(event);
final FreeformFinSet finset = (FreeformFinSet)component;
finset.removePoint(clickIndex); finset.removePoint(clickIndex);
} catch (IllegalFinPointException ignore) { } catch (IllegalFinPointException ignore) {
log.error("Ignoring IllegalFinPointException while dragging, dragIndex=" + dragIndex + ". This is likely an internal error."); log.error("Ignoring IllegalFinPointException while dragging, dragIndex=" + dragIndex + ". This is likely an internal error.");
@ -527,12 +533,12 @@ public class FreeformFinSetConfig extends FinSetConfig {
@Override @Override
public int getRowCount() { public int getRowCount() {
return finset.getPointCount(); return ((FreeformFinSet)component).getPointCount();
} }
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
return Columns.values()[columnIndex].getValue(finset, rowIndex); return Columns.values()[columnIndex].getValue( (FreeformFinSet)component, rowIndex);
} }
@Override @Override
@ -553,7 +559,9 @@ public class FreeformFinSetConfig extends FinSetConfig {
public void setValueAt(Object o, int rowIndex, int columnIndex) { public void setValueAt(Object o, int rowIndex, int columnIndex) {
if (!(o instanceof String)) if (!(o instanceof String))
return; return;
final FreeformFinSet finset = (FreeformFinSet)component;
// bounds check that indices are valid // bounds check that indices are valid
if (rowIndex < 0 || rowIndex >= finset.getFinPoints().length || columnIndex < 0 || columnIndex >= Columns.values().length) { if (rowIndex < 0 || rowIndex >= finset.getFinPoints().length || columnIndex < 0 || columnIndex >= Columns.values().length) {
throw new IllegalArgumentException("Index out of bounds, row=" + rowIndex + " column=" + columnIndex + " fin point count=" + finset.getFinPoints().length); throw new IllegalArgumentException("Index out of bounds, row=" + rowIndex + " column=" + columnIndex + " fin point count=" + finset.getFinPoints().length);