فهرست منبع

avoid circular dependency

Alexander Rose 3 سال پیش
والد
کامیت
99b043a929

+ 3 - 2
src/mol-theme/color/element-symbol.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -12,7 +12,8 @@ import { ColorTheme } from '../color';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
-import { getAdjustedColorMap, getColorMapParams } from '../../mol-util/color/color';
+import { getAdjustedColorMap } from '../../mol-util/color/color';
+import { getColorMapParams } from '../../mol-util/color/params';
 import { ChainIdColorTheme, ChainIdColorThemeParams } from './chain-id';
 import { OperatorNameColorThemeParams, OperatorNameColorTheme } from './operator-name';
 

+ 2 - 1
src/mol-theme/color/molecule-type.ts

@@ -13,7 +13,8 @@ import { getElementMoleculeType } from '../../mol-model/structure/util';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
-import { getAdjustedColorMap, getColorMapParams } from '../../mol-util/color/color';
+import { getAdjustedColorMap } from '../../mol-util/color/color';
+import { getColorMapParams } from '../../mol-util/color/params';
 
 export const MoleculeTypeColors = ColorMap({
     water: 0x386cb0,

+ 3 - 2
src/mol-theme/color/residue-name.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -11,7 +11,8 @@ import { ColorTheme } from '../color';
 import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
-import { getAdjustedColorMap, getColorMapParams } from '../../mol-util/color/color';
+import { getAdjustedColorMap } from '../../mol-util/color/color';
+import { getColorMapParams } from '../../mol-util/color/params';
 
 // protein colors from Jmol http://jmol.sourceforge.net/jscolors/
 export const ResidueNameColors = ColorMap({

+ 2 - 1
src/mol-theme/color/secondary-structure.ts

@@ -14,7 +14,8 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition';
 import { ThemeDataContext } from '../theme';
 import { TableLegend } from '../../mol-util/legend';
 import { SecondaryStructureProvider, SecondaryStructureValue } from '../../mol-model-props/computed/secondary-structure';
-import { getAdjustedColorMap, getColorMapParams } from '../../mol-util/color/color';
+import { getAdjustedColorMap } from '../../mol-util/color/color';
+import { getColorMapParams } from '../../mol-util/color/params';
 import { CustomProperty } from '../../mol-model-props/common/custom-property';
 import { hash2 } from '../../mol-data/util';
 

+ 0 - 10
src/mol-util/color/color.ts

@@ -8,8 +8,6 @@ import { NumberArray } from '../../mol-util/type-helpers';
 import { Vec3 } from '../../mol-math/linear-algebra';
 import { Hcl } from './spaces/hcl';
 import { Lab } from './spaces/lab';
-import { ParamDefinition as PD } from '../../mol-util/param-definition';
-import { objectForEach } from '../object';
 
 /** RGB color triplet expressed as a single number */
 export type Color = { readonly '@type': 'color' } & number
@@ -176,13 +174,5 @@ export function getAdjustedColorMap<T extends { [k: string]: number }>(map: Colo
     return adjustedMap as ColorMap<T>;
 }
 
-export function getColorMapParams<T extends { [k: string]: number }>(map: ColorMap<T>) {
-    const colors: Record<string, PD.Color> = {};
-    objectForEach(map, (_, k) => {
-        colors[k] = PD.Color(map[k]);
-    });
-    return colors as { [k in keyof T]: PD.Color };
-}
-
 export type ColorSwatch = [string, Color][]
 export function ColorSwatch(l: [string, number][]) { return l as unknown as ColorSwatch; }

+ 17 - 0
src/mol-util/color/params.ts

@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { ParamDefinition as PD } from '../../mol-util/param-definition';
+import { objectForEach } from '../object';
+import { ColorMap } from './color';
+
+export function getColorMapParams<T extends { [k: string]: number }>(map: ColorMap<T>) {
+    const colors: Record<string, PD.Color> = {};
+    objectForEach(map, (_, k) => {
+        colors[k] = PD.Color(map[k]);
+    });
+    return colors as { [k in keyof T]: PD.Color };
+}