You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
5.3 KiB
116 lines
5.3 KiB
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>GoJS Shapes</title>
|
|
<meta name="description" content="All predefined GoJS Shape figures, displayed as Nodes with a name underneath." />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<!-- Copyright 1998-2019 by Northwoods Software Corporation. -->
|
|
|
|
<script src="../release/go.js"></script>
|
|
<script src="../extensions/figures.js"></script>
|
|
<script src="../assets/js/goSamples.js"></script> <!-- this is only for the GoJS Samples framework -->
|
|
<script id="code">
|
|
function init() {
|
|
if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this
|
|
var $ = go.GraphObject.make; // for conciseness in defining templates
|
|
|
|
myDiagram =
|
|
$(go.Diagram, "myDiagramDiv", // create the Diagram for the HTML DIV element
|
|
{
|
|
layout: $(go.GridLayout, { sorting: go.GridLayout.Forward }), // use a GridLayout
|
|
padding: new go.Margin(5, 5, 25, 5) // to see the names of shapes on the bottom row
|
|
});
|
|
|
|
function mouseEnter(e, obj) {
|
|
obj.isHighlighted = true;
|
|
};
|
|
|
|
function mouseLeave(e, obj) {
|
|
obj.isHighlighted = false;
|
|
};
|
|
|
|
// Names of the built in shapes, which we will color green instead of pink.
|
|
// The pinks shapes are instead defined in the "../extensions/figures.js" file.
|
|
var builtIn = ["Rectangle", "Square", "RoundedRectangle", "Border", "Ellipse", "Circle", "TriangleRight", "TriangleDown", "TriangleLeft", "TriangleUp", "Triangle", "Diamond", "LineH", "LineV", "None", "BarH", "BarV", "MinusLine", "PlusLine", "XLine"];
|
|
function isBuiltIn(shapeName) {
|
|
return builtIn.find(function(element) { return element.toLowerCase() === shapeName.toLowerCase() }) !== undefined;
|
|
}
|
|
|
|
|
|
myDiagram.nodeTemplate =
|
|
$(go.Node, "Vertical",
|
|
{
|
|
mouseEnter: mouseEnter,
|
|
mouseLeave: mouseLeave,
|
|
locationSpot: go.Spot.Center, // the location is the center of the Shape
|
|
locationObjectName: "SHAPE",
|
|
selectionAdorned: false, // no selection handle when selected
|
|
resizable: true, resizeObjectName: "SHAPE", // user can resize the Shape
|
|
rotatable: true, rotateObjectName: "SHAPE", // rotate the Shape without rotating the label
|
|
// don't re-layout when node changes size
|
|
layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized
|
|
},
|
|
new go.Binding("layerName", "isHighlighted", function(h) { return h ? "Foreground" : ""; }).ofObject(),
|
|
$(go.Shape,
|
|
{
|
|
name: "SHAPE", // named so that the above properties can refer to this GraphObject
|
|
width: 70, height: 70,
|
|
strokeWidth: 3
|
|
},
|
|
// Color the built in shapes green, and the figures.js shapes Pink
|
|
new go.Binding("fill", "key", function(k) {
|
|
return isBuiltIn(k) ? "palegreen" : "lightpink";
|
|
}),
|
|
new go.Binding("stroke", "key", function(k) {
|
|
return isBuiltIn(k) ? "darkgreen" : "#C2185B";
|
|
}),
|
|
// bind the Shape.figure to the figure name, which automatically gives the Shape a Geometry
|
|
new go.Binding("figure", "key")),
|
|
$(go.TextBlock, // the label
|
|
{
|
|
margin: 4,
|
|
font: "bold 18px sans-serif",
|
|
background: 'white'
|
|
},
|
|
new go.Binding("visible", "isHighlighted").ofObject(),
|
|
new go.Binding("text", "key"))
|
|
);
|
|
|
|
// initialize the model
|
|
myDiagram.model.nodeDataArray = go.Shape.getFigureGenerators().toArray();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
<div id="sample">
|
|
<div id="myDiagramDiv" style="border: solid 1px black; height:600px"></div>
|
|
<p>
|
|
This sample showcases all predefined <b>GoJS</b> figures.
|
|
This sample also makes use of <a href="../intro/highlighting.html">GoJS Highlighting</a> data bindings: Mouse-hover over a shape to see its name.
|
|
</p>
|
|
<p>
|
|
You can specify a predefined geometry for a <a>Shape</a> by setting its <a>Shape.figure</a>.
|
|
</p>
|
|
<p>
|
|
<strong>As of 2.0:</strong> In order to shrink the size of the GoJS library we no longer define most predefined figures in the library.
|
|
Instead, you can find all of their definitions in the <a href="../extensions/Figures.js" target="_blank">Figures.js</a> file.
|
|
You can load this file or simply load only those figures that you want to use by copying their definitions into your code.
|
|
</p>
|
|
<p>
|
|
A number of very common figures remain predefined in version 2.0.
|
|
The figures that remain in 2.0 are: <code>"Rectangle", "Square", "RoundedRectangle", "Border", "Ellipse", "Circle", "TriangleRight",
|
|
"TriangleDown", "TriangleLeft", "TriangleUp", "Triangle", "Diamond", "LineH", "LineV", "BarH", "BarV", "MinusLine", "PlusLine", "XLine"</code>.
|
|
These figures are filled green above, instead of pink.
|
|
</p>
|
|
<p>
|
|
With GoJS you can also define your own custom shapes with SVG-like path syntax, see the <a href="icons.html">SVG icons</a>
|
|
sample for examples or the <a href="../intro/geometry.html">Geometry Path Strings intro page</a> to learn more.
|
|
</p>
|
|
<p>
|
|
For predefined arrowheads, see the <a href="arrowheads.html">Arrowheads</a> sample.
|
|
</p>
|
|
</div>
|
|
</body>
|
|
</html>
|