Template Canvas Help

7.8.5

Reaching out to anyone that might shed some light on my project. I currently have a custom SVG of a map that is set on a Template Canvas in which I am changing the map dimensions by way of a mouse scroll using the MouseWheelListener() in the event handler of the main screen using the internalFrameActivated.

from javax.swing import SwingUtilities
from javax.swing import JScrollPane
from java.awt.event import MouseWheelEvent
from java.awt.event import MouseWheelListener

class DebugMouseWheelListener(MouseWheelListener):
	def mouseWheelMoved(self, event):
		mouse = event.getWheelRotation()
		if mouse == 1 and event.isControlDown():
			system.tag.write("District Map Tags/Map Width",1500)
			system.tag.write("District Map Tags/Map Height",1200)
		elif mouse == -1 and event.isControlDown():
			system.tag.write("District Map Tags/Map Width",3500)
			system.tag.write("District Map Tags/Map Height",3000)
			
			

event.source.rootContainer.addMouseWheelListener(DebugMouseWheelListener())


scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, system.gui.getParentWindow(event).getComponentForPath('Root Container.Template Canvas').getComponents()[2].getComponents()[0])

scrollPane.getVerticalScrollBar().setUnitIncrement(300) #scroll amount for wheel and arrows
scrollPane.getVerticalScrollBar().setBlockIncrement(300) #scroll amount clicking on scrollbar itself
scrollPane.getHorizontalScrollBar().setUnitIncrement(300) 
scrollPane.getHorizontalScrollBar().setBlockIncrement(300) 


system.gui.getParentWindow(event).getComponentForPath('Root Container.Template Canvas').templates

I have two questions and am still a noob on this scripting stuff:

  1. My MouseWheelListener only works on the rootContainer due to my script below, I want this to work when my cursor is on the Template Canvas. Would I add in a getComponent("Template Canvas’) before the addMouseWheelListener, I tried .rootContainer.templateCanvas but it didnt work.

event.source.rootContainer.addMouseWheelListener(DebugMouseWheelListener())

  1. My client is larger than my viewpoint, How do I set where the JViewport starts. “I’m currently reading this”

This is my default start:

I would like this to be my default start or even dynamically set the JViewport based on my cursor screen coordinates.

Any thoughts or advice of where I should be looking is much appreciated. Thanks

I am trying to figure out the same thing. I have a layout and when I specify a certain portion of my layout via a dropdown component, I want to set the JViewport to that area of the layout. Did you ever figure this out? I am very very new to java and cant figure out how to set it. I am running my current code in the initialize template script.