| com.nodelab.view | ![]() |
com.nodelab.0.10051
Instance of Type
Inheriting from Graphical
Known subtypes are Ticker
| Type data | Value |
| org.uninode.Type.displayPattern | a {att:org.uninode.Node.type} |
| org.uninode.Resource.resourceType | |
| org.uninode.Resource.label | |
| org.uninode.Resource.resourceOf | List{} |
| org.uninode.Listable.resources | Reference[org.uninode.Listable.resources] of com.nodelab.view.Diagram |
| Attribute summary | Defined in | Uninode® Id | Properties | Default | |
| Reference[org.uninode.Listable.resources] | resources | Listable | org.uninode.0.2001 | type | |
| String | toString This is the display string. | Node | org.uninode.0.102 | ||
| Type | type The type of an object determines the behaviour and attributes of the object. | Node | org.uninode.0.101 | ||
| String | uri | Node | org.uninode.0.103 | ||
| String | label | Resource | org.uninode.0.2041 | type | |
| List[Type] | resourceOf | Resource | org.uninode.0.2042 | type | |
| Signature | resourceType This defines the type of resource. It can be 'view', 'adapter' or 'action' | Resource | org.uninode.0.2043 | type | |
| Script summary |
com.nodelab.0.10370import org.uninode.leaf.Graphics;
import org.uninode.leaf.Rectangle;
import org.uninode.leaf.Color;
import org.uninode.widget.*;
import org.edgescript.ScriptGenerationInfo;
import org.unizone.source.Source;
import com.nodelab.System;
import com.nodelab.Actor;
import com.nodelab.view.*;
/*
* DiagramLine
*/
/*
define DiagramLine(Scriptable) {
instance Source src;
instance Time t1;
instance Real v1;
instance Time t2;
instance Real v2;
constructor(Source src, Time t1, Real v1, Time t2, Real v2) {
instance src = src;
instance t1 = t1;
instance v1 = v1;
instance t2 = t2;
instance v2 = v2;
}
introspect Source source() {instance src}
introspect Time time1() {instance t1}
introspect Real value1() {instance v1}
introspect Time time2() {instance t2}
introspect Real value2() {instance v2}
Void draw(Graphics g, WidgetAxes axes, WidgetCondition cond) {
Object x1 = cond.coordinateFor(instance t1);
Object y1 = axes.coordinateFor(instance v1);
Object x2 = cond.coordinateFor(instance t2);
Object y2 = axes.coordinateFor(instance v2);
if (x1 != null && y1 != null && x2 != null && y2 != null)
g.drawLine(Int{x1}, Int{y1}, Int{x2}, Int{y2});
}
};
*/
/**
* ViewCalcD
*/
//Value[Signature] mouseType;
//Value[Boolean] partSensitive;
//Vector[DiagramLine] lines;
/*
constructor() {
Graphical:();
mouseType = new Value[Signature]('zoom');
partSensitive = new Value[Boolean](false);
partSensitive.addListener(void(){
changedHistory();
});
// lines = new Vector(DiagramLine);
}
*/
type Boolean isResourceOf(Listable node, Signature aspect) {
if (aspect == 'view') return true;
return false;
}
/*
introspect Vector[DiagramLine] lines() {
return .lines;
}
*/
/*
Color bkgdColor() {
Color.white;
}
*/
void designView(WidgetWorkspace ws) {
ws.setBackgroundColor(Color.white);
WidgetDiagram wd = new WidgetDiagram(this);
ws.addWidget(wd, new Place(1, 1).setWeight(1.0, 1.0, 'both'));
ws.addWidget(new WidgetHeader(ws), new Place(1, 0).setFill('horizontal'));
ws.addWidget(new WidgetDimension(wd), new Place(1, 2).setFill('horizontal').setPreferredSize(0, 16));
ws.addWidget(new WidgetActors(ws, scene), new Place(0, 3).setDimensions(3, 1).setFill('both'));
ws.addWidget(new WidgetSceneInfo(scene), new Place(0, 4).setDimensions(3, 1).setPreferredSize(0, 16).setFill('horizontal'));
// wd.prepareAxis();
}
void addAxis(WidgetWorkspace ws, WidgetDiagram wd, Int count) {
wd.removeAxis;
if (count >= 1) {
// if (dimensionAt(0).significantLow)
ws.addWidget(new WidgetAxes(wd, 0), new Place(0, 1).setWeight(0.0, 1.0, 'vertical'));
// else
// ws.addWidget(new WidgetAxes(ws, wd, 0), new Place(2, 1).setWeight(0.0, 1.0, 'vertical'));
}
if (count >= 2) {
// if (dimensionAt(0).significantLow)
ws.addWidget(new WidgetAxes(wd, 1), new Place(2, 1).setWeight(0.0, 1.0, 'vertical'));
// else
// ws.addWidget(new WidgetAxes(ws, wd, 1), new Place(0, 1).setWeight(0.0, 1.0, 'vertical'));
}
Int i = 2;
while (i < count) {
ws.addWidget(new WidgetAxes(wd, 0), new Place(i + 1, 1).setWeight(0.0, 1.0, 'vertical'));
i = i + 1;
}
}
void paint(Graphics g, PanelDiagram diagram, Rectangle bounds) {
diagram.prepareAxis();
diagram.dimension.paintGrid(g, bounds);
diagram.axesAt(0).paintGrid(g, bounds);
Real x = diagram.dimension.coordinateFor(diagram.dimension.focus);
g.setColor(Color.paleGreen);
g.drawLine(x, bounds.top, x, bounds.bottom);
Int actorIndex = actorCount() - 1;
while (actorIndex > -1) {
Actor actor = getActor(actorIndex);
PanelAxes axes = diagram.axesFor(actor);
actor.diagramPainter.draw(g, actor, axes, diagram.dimension);
actorIndex = actorIndex - 1;
}
}
/*
void dragMouse(Int downX, Int downY, Int upX, Int upY) {
Condition cond = conditionAt(0);
if (instance mouseType.value != 'line'' '
!cond.class().subclassOf(ConditionHistory)) {
ViewDiagram:dragMouse(downX, downY, upX, upY);
return;
}
Source src = partAt(0).source;
Axes axes = axesFor(partAt(0));
Time t1 = Time{cond.stepAt(downX)};
Real v1 = axes.valueAt(downY);
Time t2 = Time{cond.stepAt(upX)};
Real v2 = axes.valueAt(upY);
instance lines.add(new DiagramLine(src, t1, v1, t2, v2));
changedVisual();
}
*/
void designEditor(WidgetWorkspace ws) {
/*
ws.addRadioButton(new Place(0, 0),
"zoom", instance mouseType, 'zoom', "Mouse Type");
ws.addRadioButton(new Place(1, 0),
"line", instance mouseType, 'line', "Mouse Type");
ws.addButton(new Place(2, 0).setPadding(2, 2),
"-Lines", "Remove lines").addListener(Void(){
instance lines = new List(DiagramLine);
changedVisual()});
ws.addButton(new Place(3, 0).setPadding(2, 2),
"-Last", "Remove last line").addListener(Void(){
instance lines.removeLast();
changedVisual()});
*/
WidgetButton b = new WidgetButton("Add", "Add source");
b.addListener(void(){
Listable mix = System.getMix(0);
if (mix.type.isSubtypeOf(Source)) addSource(Source{mix});
});
ws.addWidget(b, new Place(4, 0).setPadding(2, 2));
// changedHistory()});
// ws.addCheckbox(new Place(5, 0), "Part sensitive", instance partSensitive,
// "Display active part only");
}
void generateScript(ScriptGenerationInfo info) {
if (!info.hasId(this)) {
info.addImportType(type);
String id = info.createId(this, "view");
info.append(type.fullName + " " + id + " = new " + type.fullName + "();
");
info.append(info.scriptId(scene) + ".setView(" + id + ");
");
Int actorIndex = 0;
while (actorIndex < actorCount()) {
Actor actor = getActor(actorIndex);
Axes axes = axesFor(actor);
String actorId = info.createId(actor, "actor");
String axesId = info.createId(axes, "axes");
info.append(actor.type.fullName + " " + actorId + " = " +
info.methodPrefix(this) + "getActor(" + actorIndex + ");
");
info.append(axes.type.fullName + " " + axesId + " = " +
info.methodPrefix(this) + "axesFor(" + actorId + ");
");
info.append(axesId + ".setTopBottomAdjustment(" +
axes.topAdjustment + ", " + axes.bottomAdjustment + ");
");
info.addImportType(actor.type);
info.addImportType(axes.type);
actorIndex = actorIndex + 1;
}
}
}
/*
Void addLine(Source src, String time1, Real value1, String time2, Real value2) {
instance lines.add(new DiagramLine(src, Time.fromString(time1), value1, Time.fromString(time2), value2));
}
String initScript(InstanceScriptInfo info) {
InstanceScriptInfo isi = info;
String prefix = info.methodPrefix(this);
String str = ViewDiagram:initScript(info);
instance lines.do(Void(DiagramLine line) {
str = str + " " + prefix + "addLine(" +
line.source().instanceScript(isi) + ", '" +
line.time1.dataString + "', " +
line.value1.toString + ", '" +
line.time2.dataString + "', " +
line.value2.toString + ");
";
});
str;
}
*/
String resourceString() {
if (actorCount > 0)
getActor(0).toString;
else
label;
}
|