iink SDK on Device

Answered

Customize smart guide

Is it possible to programmatically show the smart guide suggestions after candidates have been exported?


Also, is it possible to trigger the on click of the smart guide programmatically? Thank you!


Best Answer

Dear Victor,


thank you for the update.


Proceeding as explained above, there is no reason it would not work.


Let's say you want to get the candidates on a long press event.


The first thing to do consists in getting the coordinates of the point, and transform these:


  @Override
public void onLongPress(MotionEvent event)
{
final float x = event.getX();
final float y = event.getY();

Transform transform = editor.getRenderer().getViewTransform();
transform.invert();
Point transformedPoint = transform.apply(x, y);
  ...



Then, you can export as JIIX:

String JIIX = editor.export_(null, MimeType.JIIX);


In your JIIX, you can then get the bounding boxes, and find if your transformedPoint is inside of one. If so, you can then get the other word candidates.

The easier is that you refer to SmartGuideView.java class (mainly the onClick function), in which you will see how the selected candidate replaces the default one.

Best regards,

Olivier


Dear Viktor,


currently, the question is more what do you want to develop?


Indeed, the smartGuide is dedicated to one thing, display the word candidates while in interactive mode.


I guess that after conversion, you want to select one word (e.g.with long press action) that was converted, and get the possible other candiates?


In that case, you can proceed as follows:

-When longPress is detected, you get the x and y  coordinates of the press

-You export as JIIX

-Use the invert transform to get the coordinates in mm of the x and y coordinates of your long press

-Parse the bounding boxes of the JIIX to get the word that is below your long press

-Parse the node to get the other candidates


If this doesn't help, feel free to provide us with your specification, so that we can think of another solution.


Best regards,


Olivier



Hi, Olivier!

Thank you for your quick response.

What I actually want to do is to be able to replicate the behaviour of the smart guide where if I tap a word then I tap one of the word's candidates, the original word is replaced by the candidate in the smart guide. I want to do this programmatically through a different component like a list.

Would this be possible?

Answer

Dear Victor,


thank you for the update.


Proceeding as explained above, there is no reason it would not work.


Let's say you want to get the candidates on a long press event.


The first thing to do consists in getting the coordinates of the point, and transform these:


  @Override
public void onLongPress(MotionEvent event)
{
final float x = event.getX();
final float y = event.getY();

Transform transform = editor.getRenderer().getViewTransform();
transform.invert();
Point transformedPoint = transform.apply(x, y);
  ...



Then, you can export as JIIX:

String JIIX = editor.export_(null, MimeType.JIIX);


In your JIIX, you can then get the bounding boxes, and find if your transformedPoint is inside of one. If so, you can then get the other word candidates.

The easier is that you refer to SmartGuideView.java class (mainly the onClick function), in which you will see how the selected candidate replaces the default one.

Best regards,

Olivier


1 person likes this

Thank you so much, Olivier! You've solved my problem. 

Dear Viktor,


thank you for the update, I am glad I was of help.


Feel free to contact us if you have any other question.


Best regards,


Olivier