Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Simple Example


A shape consists of at least a name and a SVG element. That is, every shape, at a minimum, has a name and a description:



<?xml version="1.0"?>

<shape xmlns="https://www.daa.com.au/~james/dia-shape-ns"
       xmlns:svg="https://www.w3.org/TR/2000/03/WD-SVG-
                 20000303/DTD/svg-20000303-stylable.dtd">
  <name>Sample - Minimal Shape</name>
  <svg:svg width="10" height="10">
    <svg:polygon points="0,0 10,0 5,10"/>
  </svg:svg>
</shape>

Image dia-sheet-sample-min-canvas3

You can place this in a subdirectory of your own dia shapes directory, perhaps called Sample as in  /.dia/shapes/Sample/minimal.shape. The actual filename in which the shape is stored (minimal.shape) is not so important--dia will find the file.

Now you need to create a sheet into which this shape is placed. Again, a sheet is specified using XML. This example is placed in the file  /.dia/sheets/Sample.sheet:



<?xml version="1.0" encoding="iso-8859-1"?>

<sheet xmlns="https://www.lysator.liu.se/~alla/dia/dia-sheet-ns">
  <name>Sample</name>
  <description>A collection of sample shapes.</description>
  <contents>
    <object name="Sample - Minimal Shape">
      <description>The most minimal of shapes</description>
    </object>
  </contents>
</sheet>

Now start up dia and you should see this new sheet, called Sample, containing a single button with a default icon.

Image dia-sheet-sample-min

You can now create a new canvas and add this shape to your canvas. Note that dia takes care of the resizing of the shape and the other characteristics.

The XML describing the shape begins with the usual xml meta element followed the actual shape element, identifying the appropriate XML namespaces (xmlns). The shape has a unique name used to identify the shape by dia. Next we have the actual SVG description of the shape which is 10 by 10 in size

Image dia-sheet-sample-min-canvas

(actually these are ignored by dia but are required by the SVG format), and consisting of a single polygon. The shape is a simple triangle (a polygon with three points) pointing downwards. The polygon is drawn from the top left corner (0,0) to the top right (10,0) then to the bottom middle (5,10) and then back to the top left to finish off the polygon.

The XML for the sheet then identifies this shape as belonging to the Sample sheet, which contains just one object, the Sample - Minimal Shape shape. The description for the object is used as the tooltip for the resulting button.

Copyright © 1995-2006 [email protected]

 
 
  Published under the terms fo the GNU General Public License Design by Interspire