Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Node template bindings and node data

$
0
0

@STM wrote:

I have the following node template

Node template
$$(go.Node, 'Vertical',
	{selectable: true, selectionAdorned: false}, // removing adornment
	new go.Binding('location', 'loc', go.Point.parse).makeTwoWay(go.Point.stringify),// stores the location of node, and renders at the same postion if the model is loaded
	$$(go.Panel, 'Auto',
		$$(go.Shape, 'RoundedRectangle', // to show the node selected
			{fill: '#c9c9c9', strokeWidth: 0, opacity: 0.5},
			new go.Binding('visible', 'isSelected').ofObject()
		),
		$$(go.Panel, 'Vertical',
			$$(go.Shape,
				{
					cursor: 'pointer',
					portId: '', // this whole panel acts as the only port for the node
					fill: 'transparent',
					figure: 'Circle',
					height: 20,
					width: 20
				},
				new go.Binding("fill", "color"),
				new go.Binding("figure", "shape"),
				new go.Binding("height", "height"),
				new go.Binding("width", "width")
			),
			//properties must be in a specific order in order to render correctly across all browsers: "font-style font-variant font-weight font-size font-family"
			$$(go.TextBlock, {
					margin: 4,
					width: 100,
					textAlign: 'center',
					font: "italic bold 14pt Arial  ",
					stroke: "red",
					isUnderline: true
				}, // node name
				new go.Binding('text', 'name').makeTwoWay(),
				new go.Binding("textAlign", "textAlign"),
				new go.Binding("font", "combinedFontStyle"),
				new go.Binding("stroke", "stroke"),
				new go.Binding("isUnderline", "isUnderline"),
			)
		)
	)
);

Please note the bindings list.
I have the following node styles that should be applied to node( Some bindings are not added yet )

Node style list

height
width
color
shape
stroke color,
stroke size,
stroke type(solid, dashed)
font color,
font family.
font size,
font style(bold, italic, underline),
text angle

All the above mentioned styles can be changed run time by user.

So my question is can I define something like node common styles ? As to apply these styles on the node I need to pass these many styles in the node data, which is very ugly and redundant.
Do we have a cleaner way to handle this ?

But the catch here is when I select a particular node I need all the data combined ( basic node data + common styles )

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles