Circle Annotation - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: Circle Annotation

Circle Annotation 3 years 2 months ago #9581

  • nwixsom
  • nwixsom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 0
How does one add a Circle Annotation? The Page.Annotation class does not seem to have an AddAnnotCircle. I'm aware of the AddAnnotEllipse but I'd like to use a real circle.

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

Circle Annotation 3 years 2 months ago #9589

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 18
  • Thank you received: 65
Hi,
I have made this code for you following this knowledgebase article .
You have to change the onTouchEllipse void of PDFReader class as following.
private boolean onTouchEllipse(MotionEvent event)
	{
		if( m_status == STA_ELLIPSE )
		{
			int len = 0;
			if( m_rects != null ) len = m_rects.length;
			int cur = 0;
			switch(event.getActionMasked())
			{
			case MotionEvent.ACTION_DOWN:
				float rects[] = new float[len + 4];
				for( cur = 0; cur < len; cur++ )
					rects[cur] = m_rects[cur];
				len += 4;
				rects[cur + 0] = event.getX();
				rects[cur + 1] = event.getY();
				rects[cur + 2] = event.getX();
				rects[cur + 3] = event.getY();
				m_rects = rects;
				break;
			case MotionEvent.ACTION_MOVE:
				float deltaMoveX = event.getX() - m_rects[len - 2];
				float deltaMoveY = event.getY() - m_rects[len - 1];
				m_rects[len - 2] = (deltaMoveX > deltaMoveY) ? event.getX() : m_rects[len - 2] + deltaMoveY;
				m_rects[len - 1] = (deltaMoveX < deltaMoveY) ? event.getY() : m_rects[len - 1] + deltaMoveX;
				break;
			case MotionEvent.ACTION_UP:
			case MotionEvent.ACTION_CANCEL:
				float deltaCancelX = event.getX() - m_rects[len - 2];
				float deltaCancelY = event.getY() - m_rects[len - 1];

				m_rects[len - 2] = (deltaCancelX > deltaCancelY) ? event.getX() : m_rects[len - 2] + deltaCancelY;
				m_rects[len - 1] = (deltaCancelX < deltaCancelY) ? event.getY() : m_rects[len - 1] + deltaCancelX;
				break;
			}
			invalidate();
			return true;
		}
		return false;
	}
The following user(s) said Thank You: nwixsom

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

Circle Annotation 3 years 2 months ago #9590

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 18
  • Thank you received: 65
Hi,
if you want to AddAnnotCircle programmatically, you should use AddAnnotEllipse and maintain the width equals to the height.

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

Circle Annotation 3 years 2 months ago #9591

  • nwixsom
  • nwixsom's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 12
  • Thank you received: 0
Thanks, that's pretty clever. Hadn't thought of that.

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

  • Page:
  • 1
Powered by Kunena Forum