What do I do if I need more than 4 input settings?

a_edwall

Active member
Joined
May 22, 2019
Posts
28
Likes
7
I see there are constants "PERIOD - PERIOD4". But I need 6 inputs. What do I do? I have the same problem with METHOD and perhaps another one. But if I solve the period instance, then the others can probably work in the same manner.

periods.addRow(new IntegerDescriptor(Inputs.PERIOD, get("SMA Period"), 50, 1, 999, 1));
periods.addRow(new IntegerDescriptor(Inputs.PERIOD2, get("Sto K Period"), 5, 1, 999, 1));
periods.addRow(new IntegerDescriptor(Inputs.PERIOD3, get("Sto K Full Period"), 2, 1, 999, 1));
periods.addRow(new IntegerDescriptor(Inputs.PERIOD4, get("Sto D Period"), 3, 1, 999, 1));
periods.addRow(new IntegerDescriptor(Inputs.PERIOD5, get("Period 1"), 5, 1, 9999, 1));
periods.addRow(new IntegerDescriptor(Inputs.PERIOD6, get("Period 2"), 20, 1, 9999, 1));


Thank you.
 

Spin

Well-known member
Joined
May 22, 2019
Posts
480
Likes
192
Yes, one does indeed hit that 'constants'-limit fast. But the solution is -thankfully- rather easy :)

Simply define your own 'constant' at the beginning of your class:
Java:
 final static String TOP_PATH = "topPath";
 final static String TOP_IND = "topInd";
 final static String MIDDLE_PATH = "middlePath";
 final static String MIDDLE_IND = "middleInd";
 final static String BOTTOM_PATH = "bottomPath";
 final static String BOTTOM_IND = "bottomInd";

And use those (in initialize):
Java:
SettingGroup group = new SettingGroup("Display");
        tab.addGroup(group);
        group.addRow(new PathDescriptor(TOP_PATH, "Upper Line", defaults.getPurple(), 1.0f, null, true, true, true));
        group.addRow(new IndicatorDescriptor(TOP_IND, "Upper Ind", defaults.getPurple(), null, false, false, true));
        group.addRow(new PathDescriptor(MIDDLE_PATH, "Middle Line", defaults.getPurple(), 1.0f, null, true, true, true));
        group.addRow(new IndicatorDescriptor(MIDDLE_IND, "Middle Ind", defaults.getPurple(), null, false, false, true));
        group.addRow(new PathDescriptor(BOTTOM_PATH, "Upper Line", defaults.getPurple(), 1.0f, null, true, true, true));
        group.addRow(new IndicatorDescriptor(BOTTOM_IND, "Lower Ind", defaults.getPurple(), null, false, false, true));

Looks neat, no ? ;)

1630468979464.png
 
Top