瀏覽代碼

mol-theme: truncate too long entry names

David Sehnal 5 年之前
父節點
當前提交
f45edbc4f0
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/mol-theme/label.ts

+ 3 - 1
src/mol-theme/label.ts

@@ -149,7 +149,9 @@ export function elementLabel(location: StructureElement.Location, options: Parti
 function _elementLabel(location: StructureElement.Location, granularity: LabelGranularity = 'element', hidePrefix = false): string[] {
 function _elementLabel(location: StructureElement.Location, granularity: LabelGranularity = 'element', hidePrefix = false): string[] {
     const label: string[] = [];
     const label: string[] = [];
     if (!hidePrefix) {
     if (!hidePrefix) {
-        label.push(`<small>${location.unit.model.entry}</small>`) // entry
+        let entry = location.unit.model.entry;
+        if (entry.length > 30) entry = entry.substr(0, 27) + '...';
+        label.push(`<small>${entry}</small>`) // entry
         if (granularity !== 'structure') {
         if (granularity !== 'structure') {
             label.push(`<small>Model ${location.unit.model.modelNum}</small>`) // model
             label.push(`<small>Model ${location.unit.model.modelNum}</small>`) // model
             label.push(`<small>Instance ${location.unit.conformation.operator.name}</small>`) // instance
             label.push(`<small>Instance ${location.unit.conformation.operator.name}</small>`) // instance