Neat Trick with Graphics Sizing/Spacing
May 2nd, 2012One of the best parts of using Archestra graphics in your application is the ability to freely resize the vector based graphics with no apparent loss in resolution. The other nice thing is that as you update the size of the graphic in the design tools the graphic follows suit and grows or shrinks as necessary anywhere it is laid down. This may be fine if you have an item in free space with no connections or other items close by. This causes a big problem though if you are laying down graphics in tight quarters and can’t afford for things to wiggle around.
Example:
Let’s start with a simple pump graphic.
Then let’s lay it down on a process graphic with process lines connected
Note on the left hand side that my pump is actually an embedded symbol.
Now, say we want to go back and add some decoration to this pump. Maybe a piece of text under the pump. It’s important to remember that when Archestra looks at the size of the graphic it looks at the extents of all elements. If you go outside those extents Archestra thinks you want to make the graphic bigger. As such, when making the graphic bigger, Archestra will expand the graphic in all directions equally from the origin i.e. the middle. It’s pretty easy to see on this example.
Note the 2 shifts. First, the obvious one. The graphic grew up and down. The up growth is easy because you see the separation from the blue lines. The down growth isn’t easy because I don’t have a marker. Also, note that the graphic grew to the left and right.
So how do we fix this problem. Very simple. You have to think back to the extents concept. When you draw your graphic, think about the biggest it could possibly be, including text and other symbol decorations. Let’s try that with our pump example.
I’ve gone a little overboard but I’ve basically set up some boundaries. Now I lay it down on my target graphic, lining up my process lines.
Now, I go back and add that text I had before.
Notice that nothing moved around, nothing grew, nothing shrunk. The reason is that by drawing the box before I laid the graphic down I established the extents or bounds of the graphic. Now I can do anything I want inside the boundary without changing the “apparent” size.
The word “apparent” is key to making all this work. Drawing this ugly rectangle works for design time but would look awful at runtime. Easy way to handle this.
Set the Visible Runtime Behavior property to False. Now, you can see the rectangle during design time but it will disappear during runtime. Also, if you like you could make the rectangle really really light gray so it’s not distracting during design time.
Hope this little tidbit helps someone!
- Andy

