RadaeePDF.com :: Topic: changing stroke dynamically (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: changing stroke dynamically

changing stroke dynamically 3 weeks 1 day ago #13147

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();
}
The administrator has disabled public write access.

changing stroke dynamically 3 weeks 21 hours ago #13148

  • Davide
  • Davide's Avatar
  • OFFLINE
  • Moderator
  • Posts: 717
  • Thank you received: 56
  • Karma: 16
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
Last Edit: 3 weeks 21 hours ago by Davide.
The administrator has disabled public write access.
Powered by Kunena Forum