Many developers are already familiar with Visio or have enough experience with similar packages that we don't need to spend a lot of time reviewing how to produce simple diagrams. Since the balance of this chapter heavily depends on the reader's ability to interact with drawing shapes and lines, and use other Visio tools, we do need to spend a little time reviewing the basics of creating a simple flowchart diagram and doing some common tasks like saving, printing, etc. Let's start with a quick tour of the Visio environment.
The Visio EnvironmentFortunately, Visio follows most of the standard Windows UI rules in terms of how menus, pop-up menus, dialog boxes, and shortcut keys behave. For instance, you can right-click just about anything in a drawing and see a list of tasks you can perform relating to that object - changing properties, and copying for example. If you have Visio installed on a machine, now might be a good time to start the application. Otherwise, we'll try to provide enough screenshots to help point out useful items and make things clear. The main working view in Visio is very similar to the following. We use "very similar" because each user has quite a bit of control over such things as whether certain UI elements are visible, and where they are positioned. So, let's take a look at what we see when we start drawing in Visio. The screenshot below shows the basic look of the UI when we start a new Basic Flowchart diagram:
The first thing to notice is the familiar (dare we say 'comfortable'?) look and feel of the UI. The main menu is spread across the top of the form over the top of a number of toolbars, with the choice of which toolbars are visible up to you. In this screenshot, we have the Standard and Formatting toolbars visible. Obviously, the main portion of the UI is designed for drawing. The white page lined with horizontal and vertical grid lines represents, by default, a single printed page - this grid can be switched on or off, and a snap feature can be set so that objects snap onto the grid lines, and of course the grid line spacing can be adjusted. Visio calls this area the drawing page. It's size and orientation are entirely up to you via page properties found in File | Page Setup. Arranged vertically along the left side of the UI are groups of drawing shapes. Shapes and the lines that can connect them are the heart of any Visio drawing. Shapes can represent discrete, physical objects such as a piece of networking equipment or something more abstract like the relationship between types of data in a high-level database diagram. Shapes are also intelligent - we'll get into some of the more common shapes shipped with Visio shortly, and see examples of the shape intelligence. Shapes are organized into containers called stencils. In the screenshot above, there are three stencils - Basic Flowchart Shapes, Borders and Titles, and Backgrounds. Stencils are prearranged groups of shapes, generally oriented around a common theme or tasks that could include things as simple as basic flowcharting or as complicated as UML activity diagrams. When multiple stencils are open for a drawing, you can switch between them by clicking on their name bar in the stencil list. In the following screenshot, we've clicked on the Backgrounds stencil. Notice how the display has changed from our original screenshot.
One other quick comment about the basic Visio environment before we dig into shape and line details - Visio groups multiple pages together into one drawing using the Page Tab on the lower left of the main drawing window. Notice in our screenshots there exists one tab labeled Page-1. Visio gives us the ability to create multiple pages and store them in one drawing file. To add a new page either select Insert | New Page from the main menu or right-click on the Page Tab and select Insert Page. You'll see a dialog box for the new page that looks like the following screenshot.
Notice the highlighted page name. Pressing the OK button adds a new page to the drawing document named New Wrox Page. Also, notice that other page properties are available when you create the new drawing page. We won't review the details here, but you have the option of including many pages within a single drawing that all have different page properties - such as size, or orientation. With the addition of our new page, the drawing environment now looks like this:
There certainly is a multitude of properties, options, and functions related to the basic Visio drawing environment - more than a chapter of this scope could ever hope to cover. In the previous few pages we looked at a few of the most common drawing environment items that you'll most likely need to use. In the next section, we'll review working with the core components of any drawing - shapes and connectors.
ShapesShapes are merely drawings that represent something else. As we've already discussed, the things shapes represent can be as simple as a piece of equipment like a chair or as complex as some concept in a software design. Lines called connectors represent relationships between shapes. In Visio, there are many shapes available for your diagrams. At least in the author's experience, new Visio users spend a lot of time opening shapes and their stencils just to see what shapes are available for different drawing purposes. Using our simple flowchart example, let's look at how we get a shape onto the drawing page and what we can do with the shape once it's there. From the Basic Flowchart Shapes stencil, let's draw a Process shape. We don't really draw the shape on the form; we drag it from the stencil to the drawing page. Using the mouse, click on the Process shape - it's the first shape in the stencil in the first row. With the mouse button still clicked down, drag the Process shape onto the drawing page and position it somewhere in the middle of the page. It will look something like this:
Wow, a box! So what's the big deal about this? Well, as simple boxes go, it's not too exciting. However, what we're about to discover is that the simple box is actually a Process shape that has custom properties specific to that shape type. That means the shape has some intelligence. It knows what it was designed to do, what properties it can expose to the diagram builder and even rules about what other kinds of shapes it can be connected to. If you right-click on the Process shape (its border will display green handles when you've selected it) and select Properties from the pop-up menu, you'll see a dialog box like this:
Our little box has gotten smarter. Notice the Cost, Duration, and Resources boxes into which we can type information. That data will be saved with the shape. Since this is only a simple flowchart shape there really aren't that many properties, but the potential for building complicated shapes and properties that are domain-specific should be obvious. As we'll see in chapters throughout the book, these shape properties come in very handy for complicated software diagrams, such as UML diagrams. Let's examine a few other shape features before we move on. One of the most common tasks is putting some kind of text within the shape. The name or a short description of the process our shape represents would be appropriate here. If you highlight the shape - click on it to display a dashed green border with a number of small square handles - and type the words Process One, Visio will zoom in on the shape, and show a blinking cursor as you start to type. Depending on the size of your display and whether you have the Visio UI maximized, your application will now look something like this:
At this point we have a single shape on our drawing page and some custom data for that shape's Cost, Duration, and Resources. We also have some text inside the shape to identify it. To make the drawing useful at all we probably want to connect the shape to other shapes. Since our little example is a simple flowchart, let's create a flowchart consisting of four steps - Process One, Process Two, Process Three and Process Four. If we drag three more Process shapes onto the drawing page and give them the appropriate text, our drawing page will look like the following screenshot with a little shape repositioning. Notice too that the zoom factor in the upper right corner changed to 100%.
ConnectorsFrom the titles of our shapes, the order of this flowchart is clear, but to make it perfectly clear in other, more complicated drawings, we need lines. Lines are called connectors in Visio. On most stencils, including the Basic Flowchart Shapes stencil we've been using, there is a connector called the Dynamic Connector - it's very useful. Scroll down the stencil until you find it. In this stencil, it's in the second to last row in the middle column. Drag the connector onto the drawing page just like the shapes. Visio will draw a line with a couple of ninety degree breaks and an arrowhead at one end that looks like this (obviously, wherever you dropped the connector has an impact on what your Visio UI looks like):
To connect two shapes together using the Dynamic Connector, click on one end of the line with the mouse pointer and hold it down. Drag that end to one of the connection points on the shape. If you look closely at the shape Process One you'll notice four connection points - one on each side of the rectangle. If you drag the end of your connector to one of those connection points, it turns red and repositions the end of the line to be flush with one side of the shape. Once a connector line and the shape are associated this way, the end of the line is said to be glued to the shape. Here's what it looks like (you won't see the red color of the glued endpoint, but notice the slightly larger connection point now that that they've been glued):
The same process is repeated with the other end of the connector line to glue that end to the Process Two shape. Now we have two shapes with a single line connecting them. Even though it's an extremely simple diagram, there's no doubting what relationship exists between Process One and Process Two. Nor is there any confusion about what happens after Process One. If you repeat the same process with all the shapes, you'll get a diagram that looks something like this:
Since the shapes and their connectors are glued together, we can drag shapes all around the drawing page and their connectors will retain their relationships.
Again, this is a simple diagram, but the idea that Visio makes drawing complicated diagrams easy should be clear. Here are a few more comments about connectors before we continue. Firstly, you have quite a few options regarding the end points, size, and color of your connectors. In the drawing, right-click on one of the connector lines and select Format | Line. You'll see this dialog:
Using this dialog it's not only easy to change the beginning and end of the line - what kind of arrow, if any, but it's also easy to change the connector line pattern, thickness (Weight), and color as well as several other line properties. Additionally, depending on what type of connector you choose in your diagrams, Visio can smartly reroute how connections are drawn so the diagram looks its best. In other words, if you drop a shape in the middle of a group of connectors, those connectors will reroute themselves around the diagram automatically. For instance, dropping a tall process shape into the middle of our diagram we just used to illustrate glued connection points will have the following effect:
Notice how the connectors were automatically rerouted around the new shape. That's a handy feature and more times than not Visio does a good job at redrawing connector paths. Sometimes, however, it's necessary to tell Visio not to reroute when you move shapes around. To do that right-click on the connector for which you want to disable rerouting and select Never Reroute. Now Visio will allow other shapes to be drawn over top of your connector without moving it.
| |||||||||||||||||||||||||||||||||||