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.

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