Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

changing stroke dynamically 6 years 5 months ago #13147

  • rohitgarg2990
  • rohitgarg2990's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 17
  • Thank you received: 0
I am trying to change stroke dynamically for which i have given some options which is working fine but when i hit "Confirm", it goes back to original stroke width. Can someone tell pls what's wrong? I am adding my stroke width dynamically via calling Draw method from Ink class.

public void OnDraw(Canvas canvas, float scrollx, float scrolly, float width)
{
m_paint.setStrokeWidth(width);
if(canvas == null) return;
if(m_method != 2)
{
m_path.reset();
m_path_append.reset();
path_idx = 0;
m_method = 2;
}
int index = path_idx;
int cnt = getNodeCount(hand);
int new_idx = 0;
while( index < cnt )
{
int op = getNode( hand, index, pt1 );
switch( op )
{
case 1:
m_path_cur.lineTo(pt1[0] + scrollx, pt1[1] + scrolly);
index++;
break;
case 2:
getNode( hand, index + 1, pt2 );
m_path_cur.quadTo(pt1[0] + scrollx, pt1[1] + scrolly, pt2[0] + scrollx, pt2[1] + scrolly);
index += 2;
break;
default:
m_path_append.reset();
m_path_append.addPath(m_path_cur);
new_idx = index;//last MoveTo
m_path_cur.moveTo(pt1[0] + scrollx, pt1[1] + scrolly);
index++;
break;
}
}
canvas.drawPath(m_path, m_paint);
//Redraw old lines with stored stroke width
/*if (strokeWidthMemory.size() > 0) {
for (Path p : strokeWidthMemory.keySet()) {
m_paint.setStrokeWidth(strokeWidthMemory.get(p));
canvas.drawPath(p, m_paint);
}
}*/
Log.v("printing size","ok"+strokeWidthMemory.size());
canvas.drawPath(m_path_cur, m_paint);
if(new_idx > path_idx)
{
path_idx = new_idx;
m_path.addPath(m_path_append);
strokeWidthMemory.put(m_path_append, m_paint.getStrokeWidth());
}
m_path_cur.reset();
}

Please Log in or Create an account to join the conversation.

changing stroke dynamically 6 years 5 months ago #13148

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
you are changing only the draw phase, not the annotation stroke itself, you can change stroke width for an already created annotation using this method :
annot.SetStrokeWidth(float width)

For more info check this : www.radaeepdf.com/documentation/javadocs...etStrokeWidth-float-

You have to change the stroke width even in the add phase, please check the AddAnnotRect, AddAnnotEllipse etc.. methods in PDFLayoutView
This thread will help you : www.radaeepdf.com/forum/Android-developm...roke-and-fill-colors

Please Log in or Create an account to join the conversation.

Last edit: by Davide.
  • Page:
  • 1
Powered by Kunena Forum