[Java] How to change attribute values in the Settings class --- seems setter methods are missing

Asked by manu

Hi,

I am coding Sikuli scripts under Java and I would like to change some parameters normally available through the Settings class such as ObserveScanRate, SlowMotionDelay and MoveMouseDelay.
Looking at your examples It seems pretty simple to be done under Python but I am struggling to do the same under Java.

Digging into the javadoc I haven't found any members method of the class Settings to update the parameters value, for example I would have expected a function like Settings.update("Parameter name", "new value")
So I have tried instead to instanciate a new Settings object and to access directly the members variables to affect them a new value but it does not work:

       public static Settings Stgs = new Settings() ;
       Settings.MoveMouseDelay = 3 ;

Then I get the compilation error: <identifier expected>

Could you please tell me what I should do to change the value of these parameters ?

Thanks for your great work on Sikuli guys !

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

The Settings class is "static", all attrbutes are class attributes.

so just saying:
Settings.MoveMouseDelay = 3 ;

is sufficient.

Revision history for this message
manu (udmanu5) said :
#2

Thanks for your answer,

Sorry my bad because in fact I already tried to use the class as static in the first place but it is not working neither (and I have just retried to be 100% sure).

I still get the same compilation error: <identifier expected> when "using Settings.MoveMouseDelay = 3 ;"

Thanks.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

sorry, I am not that Java expert.

This is the Settings class partly:

public class Settings {
   public static float WaitScanRate = 3f; // frames per second
...
   public static float MoveMouseDelay = 0.5f; // in seconds
...
}

It seems, that on the Java level, the Settings.Attributes are readonly and cannot be changed by a simple
Settings.Attribute = value (what is possible on the Python/Jython script level - which is conform to the Python definition, that does not know read-only class attributes).

It seems that a public setter method for each attribute is needed in class Settings to be able to change the value from Java code.

You should post a request bug.

Revision history for this message
manu (udmanu5) said :
#4

Thanks RaiMan, that solved my question.