vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

774 lines
24 KiB

Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
Network: Fix handling of multi-fonts (#3486) * The next fix on Travis unit test failure This is the next escalation on the war against the Travis unit tests failing (which came into being by yours truly). By accident, I could recreate the unit test failure on my development machine. This led to a more directed effort to squash the bug. The insight here is that test `(window === undefined)` fails, but `(typeof window === 'undefined`)` succeeds. This undoubtedly has to do with the special status `window` has as a global object. Changes: - Added check on presence of `window` in `Canvas._requestNextFrame()`, fixed local source errors. - Added catch clause in `CanvasRendered._determinePixelRatio()` - small fix: raised timeout for the network `worldCup2014` unit test * Preliminary refactoring in utils.js * Added unit tests for extend routines, commenting and small fixes * More unit tests for extend routines * - Completed unit tests for extend routines in - Small fixes and cleanup in `util.js` - Removed `util.protoExtend()`, not used anywhere * Added unit tests for known font options * Interim save before trying out another proto chain strategy * Fixed problem in first example #3408 * Removed silly file that shouldn't be there * Added unit test for multi-fonts * Comment edits * Verufy unit tests, small adjustments for groups * Further work on getting unit tests to work. PARTS NEED TO BE CLEANED UP! * Further tweaks to get unit tests working * All unit tests passing * Fixes due to linting * Small edits * Removed prototype handling from font pile * Fixes during testing examples of #3408 * Added unit test for edge labels, small fixes * Added unit tests for shorthand string fonts; some tests still failing * All unit tests pass * Removed Label.parseOptions() * Completed shorthand font tests, code cleanup, fixed choosify for edges * Addressed review comments * Addressed review comments, cleanup
7 years ago
  1. let util = require('../../../../util');
  2. let ComponentUtil = require('./ComponentUtil').default;
  3. let LabelSplitter = require('./LabelSplitter').default;
  4. /**
  5. * List of special styles for multi-fonts
  6. * @private
  7. */
  8. const multiFontStyle = ['bold', 'ital', 'boldital', 'mono'];
  9. /**
  10. * A Label to be used for Nodes or Edges.
  11. */
  12. class Label {
  13. /**
  14. * @param {Object} body
  15. * @param {Object} options
  16. * @param {boolean} [edgelabel=false]
  17. */
  18. constructor(body, options, edgelabel = false) {
  19. this.body = body;
  20. this.pointToSelf = false;
  21. this.baseSize = undefined;
  22. this.fontOptions = {}; // instance variable containing the *instance-local* font options
  23. this.setOptions(options);
  24. this.size = {top: 0, left: 0, width: 0, height: 0, yLine: 0};
  25. this.isEdgeLabel = edgelabel;
  26. }
  27. /**
  28. * @param {Object} options the options of the parent Node-instance
  29. */
  30. setOptions(options) {
  31. this.elementOptions = options; // Reference to the options of the parent Node-instance
  32. this.initFontOptions(options.font);
  33. if (ComponentUtil.isValidLabel(options.label)) {
  34. this.labelDirty = true;
  35. } else {
  36. // Bad label! Change the option value to prevent bad stuff happening
  37. options.label = '';
  38. }
  39. if (options.font !== undefined && options.font !== null) { // font options can be deleted at various levels
  40. if (typeof options.font === 'string') {
  41. this.baseSize = this.fontOptions.size;
  42. }
  43. else if (typeof options.font === 'object') {
  44. let size = options.font.size;
  45. if (size !== undefined) {
  46. this.baseSize = size;
  47. }
  48. }
  49. }
  50. }
  51. /**
  52. * Init the font Options structure.
  53. *
  54. * Member fontOptions serves as an accumulator for the current font options.
  55. * As such, it needs to be completely separated from the node options.
  56. *
  57. * @param {Object} newFontOptions the new font options to process
  58. * @private
  59. */
  60. initFontOptions(newFontOptions) {
  61. // Prepare the multi-font option objects.
  62. // These will be filled in propagateFonts(), if required
  63. util.forEach(multiFontStyle, (style) => {
  64. this.fontOptions[style] = {};
  65. });
  66. // Handle shorthand option, if present
  67. if (Label.parseFontString(this.fontOptions, newFontOptions)) {
  68. this.fontOptions.vadjust = 0;
  69. return;
  70. }
  71. // Copy over the non-multifont options, if specified
  72. util.forEach(newFontOptions, (prop, n) => {
  73. if (prop !== undefined && prop !== null && typeof prop !== 'object') {
  74. this.fontOptions[n] = prop;
  75. }
  76. });
  77. }
  78. /**
  79. * If in-variable is a string, parse it as a font specifier.
  80. *
  81. * Note that following is not done here and have to be done after the call:
  82. * - No number conversion (size)
  83. * - Not all font options are set (vadjust, mod)
  84. *
  85. * @param {Object} outOptions out-parameter, object in which to store the parse results (if any)
  86. * @param {Object} inOptions font options to parse
  87. * @return {boolean} true if font parsed as string, false otherwise
  88. * @static
  89. */
  90. static parseFontString(outOptions, inOptions) {
  91. if (!inOptions || typeof inOptions !== 'string') return false;
  92. let newOptionsArray = inOptions.split(" ");
  93. outOptions.size = newOptionsArray[0].replace("px",'');
  94. outOptions.face = newOptionsArray[1];
  95. outOptions.color = newOptionsArray[2];
  96. return true;
  97. }
  98. /**
  99. * Set the width and height constraints based on 'nearest' value
  100. *
  101. * @param {Array} pile array of option objects to consider
  102. * @returns {object} the actual constraint values to use
  103. * @private
  104. */
  105. constrain(pile) {
  106. // NOTE: constrainWidth and constrainHeight never set!
  107. // NOTE: for edge labels, only 'maxWdt' set
  108. // Node labels can set all the fields
  109. let fontOptions = {
  110. constrainWidth: false,
  111. maxWdt: -1,
  112. minWdt: -1,
  113. constrainHeight: false,
  114. minHgt: -1,
  115. valign: 'middle',
  116. }
  117. let widthConstraint = util.topMost(pile, 'widthConstraint');
  118. if (typeof widthConstraint === 'number') {
  119. fontOptions.maxWdt = Number(widthConstraint);
  120. fontOptions.minWdt = Number(widthConstraint);
  121. } else if (typeof widthConstraint === 'object') {
  122. let widthConstraintMaximum = util.topMost(pile, ['widthConstraint', 'maximum']);
  123. if (typeof widthConstraintMaximum === 'number') {
  124. fontOptions.maxWdt = Number(widthConstraintMaximum);
  125. }
  126. let widthConstraintMinimum = util.topMost(pile, ['widthConstraint', 'minimum'])
  127. if (typeof widthConstraintMinimum === 'number') {
  128. fontOptions.minWdt = Number(widthConstraintMinimum);
  129. }
  130. }
  131. let heightConstraint = util.topMost(pile, 'heightConstraint');
  132. if (typeof heightConstraint === 'number') {
  133. fontOptions.minHgt = Number(heightConstraint);
  134. } else if (typeof heightConstraint === 'object') {
  135. let heightConstraintMinimum = util.topMost(pile, ['heightConstraint', 'minimum']);
  136. if (typeof heightConstraintMinimum === 'number') {
  137. fontOptions.minHgt = Number(heightConstraintMinimum);
  138. }
  139. let heightConstraintValign = util.topMost(pile, ['heightConstraint', 'valign']);
  140. if (typeof heightConstraintValign === 'string') {
  141. if ((heightConstraintValign === 'top')|| (heightConstraintValign === 'bottom')) {
  142. fontOptions.valign = heightConstraintValign;
  143. }
  144. }
  145. }
  146. return fontOptions;
  147. }
  148. /**
  149. * Set options and update internal state
  150. *
  151. * @param {Object} options options to set
  152. * @param {Array} pile array of option objects to consider for option 'chosen'
  153. */
  154. update(options, pile) {
  155. this.setOptions(options, true);
  156. this.propagateFonts(pile);
  157. util.deepExtend(this.fontOptions, this.constrain(pile));
  158. this.fontOptions.chooser = ComponentUtil.choosify('label', pile);
  159. }
  160. /**
  161. * When margins are set in an element, adjust sizes is called to remove them
  162. * from the width/height constraints. This must be done prior to label sizing.
  163. *
  164. * @param {{top: number, right: number, bottom: number, left: number}} margins
  165. */
  166. adjustSizes(margins) {
  167. let widthBias = (margins) ? (margins.right + margins.left) : 0;
  168. if (this.fontOptions.constrainWidth) {
  169. this.fontOptions.maxWdt -= widthBias;
  170. this.fontOptions.minWdt -= widthBias;
  171. }
  172. let heightBias = (margins) ? (margins.top + margins.bottom) : 0;
  173. if (this.fontOptions.constrainHeight) {
  174. this.fontOptions.minHgt -= heightBias;
  175. }
  176. }
  177. /////////////////////////////////////////////////////////
  178. // Methods for handling options piles
  179. // Eventually, these will be moved to a separate class
  180. /////////////////////////////////////////////////////////
  181. /**
  182. * Add the font members of the passed list of option objects to the pile.
  183. *
  184. * @param {Pile} dstPile pile of option objects add to
  185. * @param {Pile} srcPile pile of option objects to take font options from
  186. * @private
  187. */
  188. addFontOptionsToPile(dstPile, srcPile) {
  189. for (let i = 0; i < srcPile.length; ++i) {
  190. this.addFontToPile(dstPile, srcPile[i]);
  191. }
  192. }
  193. /**
  194. * Add given font option object to the list of objects (the 'pile') to consider for determining
  195. * multi-font option values.
  196. *
  197. * @param {Pile} pile pile of option objects to use
  198. * @param {object} options instance to add to pile
  199. * @private
  200. */
  201. addFontToPile(pile, options) {
  202. if (options === undefined) return;
  203. if (options.font === undefined || options.font === null) return;
  204. let item = options.font;
  205. pile.push(item);
  206. }
  207. /**
  208. * Collect all own-property values from the font pile that aren't multi-font option objectss.
  209. *
  210. * @param {Pile} pile pile of option objects to use
  211. * @returns {object} object with all current own basic font properties
  212. * @private
  213. */
  214. getBasicOptions(pile) {
  215. let ret = {};
  216. // Scans the whole pile to get all options present
  217. for (let n = 0; n < pile.length; ++n) {
  218. let fontOptions = pile[n];
  219. // Convert shorthand if necessary
  220. let tmpShorthand = {};
  221. if (Label.parseFontString(tmpShorthand, fontOptions)) {
  222. fontOptions = tmpShorthand;
  223. }
  224. util.forEach(fontOptions, (opt, name) => {
  225. if (opt === undefined) return; // multi-font option need not be present
  226. if (ret.hasOwnProperty(name)) return; // Keep first value we encounter
  227. if (multiFontStyle.indexOf(name) !== -1) {
  228. // Skip multi-font properties but we do need the structure
  229. ret[name] = {};
  230. } else {
  231. ret[name] = opt;
  232. }
  233. });
  234. }
  235. return ret;
  236. }
  237. /**
  238. * Return the value for given option for the given multi-font.
  239. *
  240. * All available option objects are trawled in the set order to construct the option values.
  241. *
  242. * ---------------------------------------------------------------------
  243. * ## Traversal of pile for multi-fonts
  244. *
  245. * The determination of multi-font option values is a special case, because any values not
  246. * present in the multi-font options should by definition be taken from the main font options,
  247. * i.e. from the current 'parent' object of the multi-font option.
  248. *
  249. * ### Search order for multi-fonts
  250. *
  251. * 'bold' used as example:
  252. *
  253. * - search in option group 'bold' in local properties
  254. * - search in main font option group in local properties
  255. *
  256. * ---------------------------------------------------------------------
  257. *
  258. * @param {Pile} pile pile of option objects to use
  259. * @param {MultiFontStyle} multiName sub path for the multi-font
  260. * @param {string} option the option to search for, for the given multi-font
  261. * @returns {string|number} the value for the given option
  262. * @private
  263. */
  264. getFontOption(pile, multiName, option) {
  265. let multiFont;
  266. // Search multi font in local properties
  267. for (let n = 0; n < pile.length; ++n) {
  268. let fontOptions = pile[n];
  269. if (fontOptions.hasOwnProperty(multiName)) {
  270. multiFont = fontOptions[multiName];
  271. if (multiFont === undefined || multiFont === null) continue;
  272. // Convert shorthand if necessary
  273. // TODO: inefficient to do this conversion every time; find a better way.
  274. let tmpShorthand = {};
  275. if (Label.parseFontString(tmpShorthand, multiFont)) {
  276. multiFont = tmpShorthand;
  277. }
  278. if (multiFont.hasOwnProperty(option)) {
  279. return multiFont[option];
  280. }
  281. }
  282. }
  283. // Option is not mentioned in the multi font options; take it from the parent font options.
  284. // These have already been converted with getBasicOptions(), so use the converted values.
  285. if (this.fontOptions.hasOwnProperty(option)) {
  286. return this.fontOptions[option];
  287. }
  288. // A value **must** be found; you should never get here.
  289. throw new Error("Did not find value for multi-font for property: '" + option + "'");
  290. }
  291. /**
  292. * Return all options values for the given multi-font.
  293. *
  294. * All available option objects are trawled in the set order to construct the option values.
  295. *
  296. * @param {Pile} pile pile of option objects to use
  297. * @param {MultiFontStyle} multiName sub path for the mod-font
  298. * @returns {MultiFontOptions}
  299. * @private
  300. */
  301. getFontOptions(pile, multiName) {
  302. let result = {};
  303. let optionNames = ['color', 'size', 'face', 'mod', 'vadjust']; // List of allowed options per multi-font
  304. for (let i = 0; i < optionNames.length; ++i) {
  305. let mod = optionNames[i];
  306. result[mod] = this.getFontOption(pile, multiName, mod);
  307. }
  308. return result;
  309. }
  310. /////////////////////////////////////////////////////////
  311. // End methods for handling options piles
  312. /////////////////////////////////////////////////////////
  313. /**
  314. * Collapse the font options for the multi-font to single objects, from
  315. * the chain of option objects passed (the 'pile').
  316. *
  317. * @param {Pile} pile sequence of option objects to consider.
  318. * First item in list assumed to be the newly set options.
  319. */
  320. propagateFonts(pile) {
  321. let fontPile = []; // sequence of font objects to consider, order important
  322. // Note that this.elementOptions is not used here.
  323. this.addFontOptionsToPile(fontPile, pile);
  324. this.fontOptions = this.getBasicOptions(fontPile);
  325. // We set multifont values even if multi === false, for consistency (things break otherwise)
  326. for (let i = 0; i < multiFontStyle.length; ++i) {
  327. let mod = multiFontStyle[i];
  328. let modOptions = this.fontOptions[mod];
  329. let tmpMultiFontOptions = this.getFontOptions(fontPile, mod);
  330. // Copy over found values
  331. util.forEach(tmpMultiFontOptions, (option, n) => {
  332. modOptions[n] = option;
  333. });
  334. modOptions.size = Number(modOptions.size);
  335. modOptions.vadjust = Number(modOptions.vadjust);
  336. }
  337. }
  338. /**
  339. * Main function. This is called from anything that wants to draw a label.
  340. * @param {CanvasRenderingContext2D} ctx
  341. * @param {number} x
  342. * @param {number} y
  343. * @param {boolean} selected
  344. * @param {boolean} hover
  345. * @param {string} [baseline='middle']
  346. */
  347. draw(ctx, x, y, selected, hover, baseline = 'middle') {
  348. // if no label, return
  349. if (this.elementOptions.label === undefined)
  350. return;
  351. // check if we have to render the label
  352. let viewFontSize = this.fontOptions.size * this.body.view.scale;
  353. if (this.elementOptions.label && viewFontSize < this.elementOptions.scaling.label.drawThreshold - 1)
  354. return;
  355. // This ensures that there will not be HUGE letters on screen
  356. // by setting an upper limit on the visible text size (regardless of zoomLevel)
  357. if (viewFontSize >= this.elementOptions.scaling.label.maxVisible) {
  358. viewFontSize = Number(this.elementOptions.scaling.label.maxVisible) / this.body.view.scale;
  359. }
  360. // update the size cache if required
  361. this.calculateLabelSize(ctx, selected, hover, x, y, baseline);
  362. this._drawBackground(ctx);
  363. this._drawText(ctx, x, this.size.yLine, baseline, viewFontSize);
  364. }
  365. /**
  366. * Draws the label background
  367. * @param {CanvasRenderingContext2D} ctx
  368. * @private
  369. */
  370. _drawBackground(ctx) {
  371. if (this.fontOptions.background !== undefined && this.fontOptions.background !== "none") {
  372. ctx.fillStyle = this.fontOptions.background;
  373. let size = this.getSize();
  374. ctx.fillRect(size.left, size.top, size.width, size.height);
  375. }
  376. }
  377. /**
  378. *
  379. * @param {CanvasRenderingContext2D} ctx
  380. * @param {number} x
  381. * @param {number} y
  382. * @param {string} [baseline='middle']
  383. * @param {number} viewFontSize
  384. * @private
  385. */
  386. _drawText(ctx, x, y, baseline = 'middle', viewFontSize) {
  387. [x, y] = this._setAlignment(ctx, x, y, baseline);
  388. ctx.textAlign = 'left';
  389. x = x - this.size.width / 2; // Shift label 1/2-distance to the left
  390. if ((this.fontOptions.valign) && (this.size.height > this.size.labelHeight)) {
  391. if (this.fontOptions.valign === 'top') {
  392. y -= (this.size.height - this.size.labelHeight) / 2;
  393. }
  394. if (this.fontOptions.valign === 'bottom') {
  395. y += (this.size.height - this.size.labelHeight) / 2;
  396. }
  397. }
  398. // draw the text
  399. for (let i = 0; i < this.lineCount; i++) {
  400. let line = this.lines[i];
  401. if (line && line.blocks) {
  402. let width = 0;
  403. if (this.isEdgeLabel || this.fontOptions.align === 'center') {
  404. width += (this.size.width - line.width) / 2
  405. } else if (this.fontOptions.align === 'right') {
  406. width += (this.size.width - line.width)
  407. }
  408. for (let j = 0; j < line.blocks.length; j++) {
  409. let block = line.blocks[j];
  410. ctx.font = block.font;
  411. let [fontColor, strokeColor] = this._getColor(block.color, viewFontSize, block.strokeColor);
  412. if (block.strokeWidth > 0) {
  413. ctx.lineWidth = block.strokeWidth;
  414. ctx.strokeStyle = strokeColor;
  415. ctx.lineJoin = 'round';
  416. }
  417. ctx.fillStyle = fontColor;
  418. if (block.strokeWidth > 0) {
  419. ctx.strokeText(block.text, x + width, y + block.vadjust);
  420. }
  421. ctx.fillText(block.text, x + width, y + block.vadjust);
  422. width += block.width;
  423. }
  424. y += line.height;
  425. }
  426. }
  427. }
  428. /**
  429. *
  430. * @param {CanvasRenderingContext2D} ctx
  431. * @param {number} x
  432. * @param {number} y
  433. * @param {string} baseline
  434. * @returns {Array.<number>}
  435. * @private
  436. */
  437. _setAlignment(ctx, x, y, baseline) {
  438. // check for label alignment (for edges)
  439. // TODO: make alignment for nodes
  440. if (this.isEdgeLabel && this.fontOptions.align !== 'horizontal' && this.pointToSelf === false) {
  441. x = 0;
  442. y = 0;
  443. let lineMargin = 2;
  444. if (this.fontOptions.align === 'top') {
  445. ctx.textBaseline = 'alphabetic';
  446. y -= 2 * lineMargin; // distance from edge, required because we use alphabetic. Alphabetic has less difference between browsers
  447. }
  448. else if (this.fontOptions.align === 'bottom') {
  449. ctx.textBaseline = 'hanging';
  450. y += 2 * lineMargin;// distance from edge, required because we use hanging. Hanging has less difference between browsers
  451. }
  452. else {
  453. ctx.textBaseline = 'middle';
  454. }
  455. }
  456. else {
  457. ctx.textBaseline = baseline;
  458. }
  459. return [x,y];
  460. }
  461. /**
  462. * fade in when relative scale is between threshold and threshold - 1.
  463. * If the relative scale would be smaller than threshold -1 the draw function would have returned before coming here.
  464. *
  465. * @param {string} color The font color to use
  466. * @param {number} viewFontSize
  467. * @param {string} initialStrokeColor
  468. * @returns {Array.<string>} An array containing the font color and stroke color
  469. * @private
  470. */
  471. _getColor(color, viewFontSize, initialStrokeColor) {
  472. let fontColor = color || '#000000';
  473. let strokeColor = initialStrokeColor || '#ffffff';
  474. if (viewFontSize <= this.elementOptions.scaling.label.drawThreshold) {
  475. let opacity = Math.max(0, Math.min(1, 1 - (this.elementOptions.scaling.label.drawThreshold - viewFontSize)));
  476. fontColor = util.overrideOpacity(fontColor, opacity);
  477. strokeColor = util.overrideOpacity(strokeColor, opacity);
  478. }
  479. return [fontColor, strokeColor];
  480. }
  481. /**
  482. *
  483. * @param {CanvasRenderingContext2D} ctx
  484. * @param {boolean} selected
  485. * @param {boolean} hover
  486. * @returns {{width: number, height: number}}
  487. */
  488. getTextSize(ctx, selected = false, hover = false) {
  489. this._processLabel(ctx, selected, hover);
  490. return {
  491. width: this.size.width,
  492. height: this.size.height,
  493. lineCount: this.lineCount
  494. };
  495. }
  496. /**
  497. * Get the current dimensions of the label
  498. *
  499. * @return {rect}
  500. */
  501. getSize() {
  502. let lineMargin = 2;
  503. let x = this.size.left; // default values which might be overridden below
  504. let y = this.size.top - 0.5*lineMargin; // idem
  505. if (this.isEdgeLabel) {
  506. const x2 = -this.size.width * 0.5;
  507. switch (this.fontOptions.align) {
  508. case 'middle':
  509. x = x2;
  510. y = -this.size.height * 0.5
  511. break;
  512. case 'top':
  513. x = x2;
  514. y = -(this.size.height + lineMargin);
  515. break;
  516. case 'bottom':
  517. x = x2;
  518. y = lineMargin;
  519. break;
  520. }
  521. }
  522. var ret = {
  523. left : x,
  524. top : y,
  525. width : this.size.width,
  526. height: this.size.height,
  527. };
  528. return ret;
  529. }
  530. /**
  531. *
  532. * @param {CanvasRenderingContext2D} ctx
  533. * @param {boolean} selected
  534. * @param {boolean} hover
  535. * @param {number} [x=0]
  536. * @param {number} [y=0]
  537. * @param {'middle'|'hanging'} [baseline='middle']
  538. */
  539. calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = 'middle') {
  540. this._processLabel(ctx, selected, hover);
  541. this.size.left = x - this.size.width * 0.5;
  542. this.size.top = y - this.size.height * 0.5;
  543. this.size.yLine = y + (1 - this.lineCount) * 0.5 * this.fontOptions.size;
  544. if (baseline === "hanging") {
  545. this.size.top += 0.5 * this.fontOptions.size;
  546. this.size.top += 4; // distance from node, required because we use hanging. Hanging has less difference between browsers
  547. this.size.yLine += 4; // distance from node
  548. }
  549. }
  550. /**
  551. *
  552. * @param {CanvasRenderingContext2D} ctx
  553. * @param {boolean} selected
  554. * @param {boolean} hover
  555. * @param {string} mod
  556. * @returns {{color, size, face, mod, vadjust, strokeWidth: *, strokeColor: (*|string|allOptions.edges.font.strokeColor|{string}|allOptions.nodes.font.strokeColor|Array)}}
  557. */
  558. getFormattingValues(ctx, selected, hover, mod) {
  559. let getValue = function(fontOptions, mod, option) {
  560. if (mod === "normal") {
  561. if (option === 'mod' ) return "";
  562. return fontOptions[option];
  563. }
  564. if (fontOptions[mod][option] !== undefined) { // Grumbl leaving out test on undefined equals false for ""
  565. return fontOptions[mod][option];
  566. } else {
  567. // Take from parent font option
  568. return fontOptions[option];
  569. }
  570. };
  571. let values = {
  572. color : getValue(this.fontOptions, mod, 'color' ),
  573. size : getValue(this.fontOptions, mod, 'size' ),
  574. face : getValue(this.fontOptions, mod, 'face' ),
  575. mod : getValue(this.fontOptions, mod, 'mod' ),
  576. vadjust: getValue(this.fontOptions, mod, 'vadjust'),
  577. strokeWidth: this.fontOptions.strokeWidth,
  578. strokeColor: this.fontOptions.strokeColor
  579. };
  580. if (selected || hover) {
  581. if (mod === "normal" && (this.fontOptions.chooser === true) && (this.elementOptions.labelHighlightBold)) {
  582. values.mod = 'bold';
  583. } else {
  584. if (typeof this.fontOptions.chooser === 'function') {
  585. this.fontOptions.chooser(values, this.elementOptions.id, selected, hover);
  586. }
  587. }
  588. }
  589. let fontString = "";
  590. if (values.mod !== undefined && values.mod !== "") { // safeguard for undefined - this happened
  591. fontString += values.mod + " ";
  592. }
  593. fontString += values.size + "px " + values.face;
  594. ctx.font = fontString.replace(/"/g, "");
  595. values.font = ctx.font;
  596. values.height = values.size;
  597. return values;
  598. }
  599. /**
  600. *
  601. * @param {boolean} selected
  602. * @param {boolean} hover
  603. * @returns {boolean}
  604. */
  605. differentState(selected, hover) {
  606. return ((selected !== this.selectedState) || (hover !== this.hoverState));
  607. }
  608. /**
  609. * This explodes the passed text into lines and determines the width, height and number of lines.
  610. *
  611. * @param {CanvasRenderingContext2D} ctx
  612. * @param {boolean} selected
  613. * @param {boolean} hover
  614. * @param {string} inText the text to explode
  615. * @returns {{width, height, lines}|*}
  616. * @private
  617. */
  618. _processLabelText(ctx, selected, hover, inText) {
  619. let splitter = new LabelSplitter(ctx, this, selected, hover);
  620. return splitter.process(inText);
  621. }
  622. /**
  623. * This explodes the label string into lines and sets the width, height and number of lines.
  624. * @param {CanvasRenderingContext2D} ctx
  625. * @param {boolean} selected
  626. * @param {boolean} hover
  627. * @private
  628. */
  629. _processLabel(ctx, selected, hover) {
  630. if(this.labelDirty === false && !this.differentState(selected,hover))
  631. return;
  632. let state = this._processLabelText(ctx, selected, hover, this.elementOptions.label);
  633. if ((this.fontOptions.minWdt > 0) && (state.width < this.fontOptions.minWdt)) {
  634. state.width = this.fontOptions.minWdt;
  635. }
  636. this.size.labelHeight =state.height;
  637. if ((this.fontOptions.minHgt > 0) && (state.height < this.fontOptions.minHgt)) {
  638. state.height = this.fontOptions.minHgt;
  639. }
  640. this.lines = state.lines;
  641. this.lineCount = state.lines.length;
  642. this.size.width = state.width;
  643. this.size.height = state.height;
  644. this.selectedState = selected;
  645. this.hoverState = hover;
  646. this.labelDirty = false;
  647. }
  648. /**
  649. * Check if this label is visible
  650. *
  651. * @return {boolean} true if this label will be show, false otherwise
  652. */
  653. visible() {
  654. if ((this.size.width === 0 || this.size.height === 0)
  655. || this.elementOptions.label === undefined) {
  656. return false; // nothing to display
  657. }
  658. let viewFontSize = this.fontOptions.size * this.body.view.scale;
  659. if (viewFontSize < this.elementOptions.scaling.label.drawThreshold - 1) {
  660. return false; // Too small or too far away to show
  661. }
  662. return true;
  663. }
  664. }
  665. export default Label;