File size: 6,635 Bytes
233f6d4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | Clazz.declarePackage ("J.shape");
Clazz.load (["J.shape.Shape", "java.util.Hashtable"], "J.shape.TextShape", ["JU.P3", "$.PT", "JU.C", "$.Logger"], function () {
c$ = Clazz.decorateAsClass (function () {
this.objects = null;
this.currentObject = null;
this.currentFont = null;
this.currentColor = null;
this.currentBgColor = null;
this.currentTranslucentLevel = 0;
this.currentBgTranslucentLevel = 0;
this.thisID = null;
this.isHover = false;
this.isAll = false;
Clazz.instantialize (this, arguments);
}, J.shape, "TextShape", J.shape.Shape);
Clazz.prepareFields (c$, function () {
this.objects = new java.util.Hashtable ();
});
Clazz.defineMethod (c$, "setPropTS",
function (propertyName, value, bsSelected) {
if ("text" === propertyName) {
var text = value;
if (this.currentObject != null) {
this.currentObject.setText (text);
} else if (this.isAll) {
for (var t, $t = this.objects.values ().iterator (); $t.hasNext () && ((t = $t.next ()) || true);) t.setText (text);
}return;
}if ("font" === propertyName) {
this.currentFont = value;
if (this.currentObject != null) {
this.currentObject.setFont (this.currentFont, true);
this.currentObject.setFontScale (0);
} else if (this.isAll) {
for (var t, $t = this.objects.values ().iterator (); $t.hasNext () && ((t = $t.next ()) || true);) t.setFont (this.currentFont, true);
}return;
}if ("allOff" === propertyName) {
this.currentObject = null;
this.isAll = true;
this.objects = new java.util.Hashtable ();
return;
}if ("delete" === propertyName) {
if (this.currentObject != null) {
this.objects.remove (this.currentObject.target);
this.currentObject = null;
} else if (this.isAll || this.thisID != null) {
var e = this.objects.values ().iterator ();
while (e.hasNext ()) {
var text = e.next ();
if (this.isAll || JU.PT.isMatch (text.target.toUpperCase (), this.thisID, true, true)) {
e.remove ();
}}
}return;
}if ("off" === propertyName) {
if (this.isAll) {
this.objects = new java.util.Hashtable ();
this.isAll = false;
this.currentObject = null;
}if (this.currentObject == null) {
return;
}this.objects.remove (this.currentObject.target);
this.currentObject = null;
return;
}if ("model" === propertyName) {
var modelIndex = (value).intValue ();
if (this.currentObject != null) {
this.currentObject.modelIndex = modelIndex;
} else if (this.isAll) {
for (var t, $t = this.objects.values ().iterator (); $t.hasNext () && ((t = $t.next ()) || true);) t.modelIndex = modelIndex;
}return;
}if ("align" === propertyName) {
var align = value;
if (this.currentObject != null) {
if (!this.currentObject.setAlignmentLCR (align)) JU.Logger.error ("unrecognized align:" + align);
} else if (this.isAll) {
for (var obj, $obj = this.objects.values ().iterator (); $obj.hasNext () && ((obj = $obj.next ()) || true);) obj.setAlignmentLCR (align);
}return;
}if ("bgcolor" === propertyName) {
this.currentBgColor = value;
if (this.currentObject != null) {
this.currentObject.bgcolix = JU.C.getColixO (value);
} else if (this.isAll) {
var e = this.objects.values ().iterator ();
while (e.hasNext ()) {
e.next ().bgcolix = JU.C.getColixO (value);
}
}return;
}if ("color" === propertyName) {
this.currentColor = value;
if (this.currentObject != null) {
this.currentObject.colix = JU.C.getColixO (value);
} else if (this.isAll || this.thisID != null) {
var e = this.objects.values ().iterator ();
while (e.hasNext ()) {
var text = e.next ();
if (this.isAll || JU.PT.isMatch (text.target.toUpperCase (), this.thisID, true, true)) {
text.colix = JU.C.getColixO (value);
}}
}return;
}if ("target" === propertyName) {
var target = value;
this.isAll = target.equals ("all");
if (this.isAll || target.equals ("none")) {
this.currentObject = null;
}return;
}var isBackground;
if ((isBackground = ("bgtranslucency" === propertyName)) || "translucency" === propertyName) {
var isTranslucent = ("translucent" === value);
if (isBackground) this.currentBgTranslucentLevel = (isTranslucent ? this.translucentLevel : 0);
else this.currentTranslucentLevel = (isTranslucent ? this.translucentLevel : 0);
if (this.currentObject != null) {
this.currentObject.setTranslucent (this.translucentLevel, isBackground);
} else if (this.isAll) {
var e = this.objects.values ().iterator ();
while (e.hasNext ()) {
e.next ().setTranslucent (this.translucentLevel, isBackground);
}
}return;
}if (propertyName === "deleteModelAtoms") {
var modelIndex = ((value)[2])[0];
var e = this.objects.values ().iterator ();
while (e.hasNext ()) {
var text = e.next ();
if (text.modelIndex == modelIndex) {
e.remove ();
} else if (text.modelIndex > modelIndex) {
text.modelIndex--;
}}
return;
}this.setPropS (propertyName, value, bsSelected);
}, "~S,~O,JU.BS");
Clazz.overrideMethod (c$, "getShapeState",
function () {
return null;
});
Clazz.overrideMethod (c$, "initModelSet",
function () {
this.currentObject = null;
this.isAll = false;
});
Clazz.overrideMethod (c$, "setModelVisibilityFlags",
function (bsModels) {
if (!this.isHover) for (var t, $t = this.objects.values ().iterator (); $t.hasNext () && ((t = $t.next ()) || true);) t.visible = (t.modelIndex < 0 || bsModels.get (t.modelIndex));
}, "JU.BS");
Clazz.overrideMethod (c$, "checkObjectClicked",
function (x, y, modifiers, bsVisible, drawPicking) {
if (this.isHover || modifiers == 0) return null;
var isAntialiased = this.vwr.antialiased;
for (var obj, $obj = this.objects.values ().iterator (); $obj.hasNext () && ((obj = $obj.next ()) || true);) {
if (obj.checkObjectClicked (isAntialiased, x, y, bsVisible)) {
if (obj.script != null) this.vwr.evalStringQuiet (obj.script);
var map = new java.util.Hashtable ();
map.put ("pt", (obj.xyz == null ? new JU.P3 () : obj.xyz));
var modelIndex = obj.modelIndex;
if (modelIndex < 0) modelIndex = 0;
map.put ("modelIndex", Integer.$valueOf (modelIndex));
map.put ("model", this.vwr.getModelNumberDotted (modelIndex));
map.put ("id", obj.target);
map.put ("type", "echo");
return map;
}}
return null;
}, "~N,~N,~N,JU.BS,~B");
Clazz.overrideMethod (c$, "checkObjectHovered",
function (x, y, bsVisible) {
if (this.isHover) return false;
var haveScripts = false;
var isAntialiased = this.vwr.antialiased;
for (var obj, $obj = this.objects.values ().iterator (); $obj.hasNext () && ((obj = $obj.next ()) || true);) {
if (obj.script != null) {
haveScripts = true;
if (obj.checkObjectClicked (isAntialiased, x, y, bsVisible)) {
this.vwr.setCursor (12);
return true;
}}}
if (haveScripts) this.vwr.setCursor (0);
return false;
}, "~N,~N,JU.BS");
});
|