# Designer visible window bounds

**URL:** <https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640>\
**Category:** Module Development\
**Tags:** vision\
**Created:** [May 23, 2025, 3:48pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640 "2025-05-23T15:48:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 3:48pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/1 "2025-05-23T15:48:26Z")

</div>

Is there anything built in that can give me the bounds of the currently visible window?

For example, the visible bounds for the below screenshot should be:  
[x=20, y=20, width=312, height=140]

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c086414ca1454b195251af17406cda32f6569a3.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 23, 2025, 4:02pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/2 "2025-05-23T16:02:34Z")

</div>

From a reference to the [`WindowWorkspace`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.48/com/inductiveautomation/factorypmi/designer/workspace/WindowWorkspace.html); from there you can call [`getSelectedDesignPanel`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.48/com/inductiveautomation/ignition/designer/designable/AbstractDesignableWorkspace.html#getSelectedDesignPanel()) (or use some other method to retrieve a [`DesignPanel`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.48/com/inductiveautomation/ignition/designer/designable/DesignPanel.html)), which is the outer `JScrollPane` that contains the 'rulers'; from there you should be able to retrieve underlying Swing bounds fairly easily.

I'm interested in what you want this information for, but purely out of curiosity.

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 4:12pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/3 "2025-05-23T16:12:12Z")

</div>

Thanks Paul, I'll check that out.

The reason I need this information is that when I use the `setClip()` method, Ignition wants to draw my components on top of the rulers and scroll bars.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/5/75291616bfef09424dbb45118dd8a74db16a9845.jpeg)

I want to try to fix this by limiting the clip to the visible bounds.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 23, 2025, 4:46pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/4 "2025-05-23T16:46:47Z")

</div>

Probably easier then to just `SwingUtilities.getAncestorOfClass(TopLevelContainer.class)`, to get the 'root' window or template your component is on (in designer _or_ client scope).

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 4:57pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/5 "2025-05-23T16:57:14Z")

</div>

That returns the `FPMIWindow`, from which I can use `getVisibleRect()`, but that doesn't give me what I'm looking for.

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 5:10pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/6 "2025-05-23T17:10:34Z")

</div>

I was able to get the `DesignPanel` via `SwingUtilities.getAncestorOfClass(ScrollPaneConstants.class,this)`. But how do I get the visible bounds from here? The `.getVisibleRect()` method does not give me what I need.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 23, 2025, 5:45pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/7 "2025-05-23T17:45:43Z")

</div>

I think you want `topLevelContainer.getVisibleRect()`, you just _also_ need to adjust your rectangle coordinate system, e.g. `javax.swing.SwingUtilities#convertRectangle`.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/1/91d2a7fa4b7d2699eb5b2cb0c7c013682fbc55b3.png)

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 8:08pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/8 "2025-05-23T20:08:19Z")

</div>

I see now that it works good when the window is scaled at 100%. Still can't figure out though how to get proper values on any other scale

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 23, 2025, 8:14pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/9 "2025-05-23T20:14:55Z")

</div>

Can you take a step back and describe what you're actually trying to do?  
Is there a reason you can't just have your component(s) paint within their own bounds? You get the clipping for free, then.

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 23, 2025, 8:59pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/10 "2025-05-23T20:59:57Z")

</div>

My components are built by extending `AbstractVisionShape`, which uses the window's bounds as its own bounds, and then has another property `boundingRect`, which is the actual bounds of the component.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 23, 2025, 10:18pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/11 "2025-05-23T22:18:45Z")

</div>

Can you extend `com.inductiveautomation.vision.api.client.components.shapes.PathBasedVisionShape` instead? I would essentially have to see your code and then reverse engineer `AbstractVisionShape` to give you specific advice on what to do, but my guess is that if you extend `PathBasedVisionShape` you'll basically get the right behavior "for free".

---

<div class="post-metadata">

**Author:** ![Mathias\_Melling](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mathias_melling/32/67682_2.png) [@Mathias\_Melling](https://forum.inductiveautomation.com/u/Mathias_Melling)\
**Post date:** [May 26, 2025, 1:30pm UTC](https://forum.inductiveautomation.com/t/designer-visible-window-bounds/106640/12 "2025-05-26T13:30:03Z")

</div>

I figured it out now. I didn't realize that the clip was set to something before I set it. Thanks for mentioning that the clipping is 'for free'.

> [@paul-griffith](#):
>
> You get the clipping for free

I still have to modify the clip for what I need to do, but I can simply capture the clip before I do that and then set it back to what it was.

```python
Shape originalClip = g.getClip();
g.clip(getShoulderArea());
g.drawImage(BHC.getImage(),backgroundTx,null);
g.setClip(originalClip);

```
