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.

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