Using the Template Canvas as a work-around for Zoom

I have noticed several forum posts on similar topics:

But there has only been solutions to scrollbar incrementing. This is my solution to the "focus" or "Jump-to" issue....

from java.awt import Point
def TemplateCanvas_Focus():
	canvas = event.source.parent.parent.getComponent("Template Canvas")
	#### this is the java JScrollPane class... we can use any methods associated with JScrollPane here####
	scrollPane = canvas.getComponents()[2]
	####this is the java JSViewport class... we can use any methods associated with JViewport here####
	viewPort = scrollPane.getViewport()	
	
	if event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == 'Full Screen':
		setViewPositionX = 0
		setViewPositionY = 0
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '75%':
		setViewPositionX = 0
		setViewPositionY = 350
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '100%':
		setViewPositionX = 250
		setViewPositionY = 500
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '200%':
		setViewPositionX = 1000
		setViewPositionY = 1000
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == 'Max Zoom':
		setViewPositionX = 1500
		setViewPositionY = 1500
	
	
	viewPort.setViewPosition(Point(setViewPositionX,setViewPositionY))
1 Like