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.

787 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 (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);
  375. this._drawText(ctx, x, this.size.yLine, baseline, viewFontSize);
  376. }
  377. /**
  378. * Draws the label background
  379. * @param {CanvasRenderingContext2D} ctx
  380. * @private
  381. */
  382. _drawBackground(ctx) {
  383. if (this.fontOptions.background !== undefined && this.fontOptions.background !== "none") {
  384. ctx.fillStyle = this.fontOptions.background;
  385. let size = this.getSize();
  386. ctx.fillRect(size.left, size.top, size.width, size.height);
  387. }
  388. }
  389. /**
  390. *
  391. * @param {CanvasRenderingContext2D} ctx
  392. * @param {number} x
  393. * @param {number} y
  394. * @param {string} [baseline='middle']
  395. * @param {number} viewFontSize
  396. * @private
  397. */
  398. _drawText(ctx, x, y, baseline = 'middle', viewFontSize) {
  399. [x, y] = this._setAlignment(ctx, x, y, baseline);
  400. ctx.textAlign = 'left';
  401. x = x - this.size.width / 2; // Shift label 1/2-distance to the left
  402. if ((this.fontOptions.valign) && (this.size.height > this.size.labelHeight)) {
  403. if (this.fontOptions.valign === 'top') {
  404. y -= (this.size.height - this.size.labelHeight) / 2;
  405. }
  406. if (this.fontOptions.valign === 'bottom') {
  407. y += (this.size.height - this.size.labelHeight) / 2;
  408. }
  409. }
  410. // draw the text
  411. for (let i = 0; i < this.lineCount; i++) {
  412. let line = this.lines[i];
  413. if (line && line.blocks) {
  414. let width = 0;
  415. if (this.isEdgeLabel || this.fontOptions.align === 'center') {
  416. width += (this.size.width - line.width) / 2
  417. } else if (this.fontOptions.align === 'right') {
  418. width += (this.size.width - line.width)
  419. }
  420. for (let j = 0; j < line.blocks.length; j++) {
  421. let block = line.blocks[j];
  422. ctx.font = block.font;
  423. let [fontColor, strokeColor] = this._getColor(block.color, viewFontSize, block.strokeColor);
  424. if (block.strokeWidth > 0) {
  425. ctx.lineWidth = block.strokeWidth;
  426. ctx.strokeStyle = strokeColor;
  427. ctx.lineJoin = 'round';
  428. }
  429. ctx.fillStyle = fontColor;
  430. if (block.strokeWidth > 0) {
  431. ctx.strokeText(block.text, x + width, y + block.vadjust);
  432. }
  433. ctx.fillText(block.text, x + width, y + block.vadjust);
  434. width += block.width;
  435. }
  436. y += line.height;
  437. }
  438. }
  439. }
  440. /**
  441. *
  442. * @param {CanvasRenderingContext2D} ctx
  443. * @param {number} x
  444. * @param {number} y
  445. * @param {string} baseline
  446. * @returns {Array.<number>}
  447. * @private
  448. */
  449. _setAlignment(ctx, x, y, baseline) {
  450. // check for label alignment (for edges)
  451. // TODO: make alignment for nodes
  452. if (this.isEdgeLabel && this.fontOptions.align !== 'horizontal' && this.pointToSelf === false) {
  453. x = 0;
  454. y = 0;
  455. let lineMargin = 2;
  456. if (this.fontOptions.align === 'top') {
  457. ctx.textBaseline = 'alphabetic';
  458. y -= 2 * lineMargin; // distance from edge, required because we use alphabetic. Alphabetic has less difference between browsers
  459. }
  460. else if (this.fontOptions.align === 'bottom') {
  461. ctx.textBaseline = 'hanging';
  462. y += 2 * lineMargin;// distance from edge, required because we use hanging. Hanging has less difference between browsers
  463. }
  464. else {
  465. ctx.textBaseline = 'middle';
  466. }
  467. }
  468. else {
  469. ctx.textBaseline = baseline;
  470. }
  471. return [x,y];
  472. }
  473. /**
  474. * fade in when relative scale is between threshold and threshold - 1.
  475. * If the relative scale would be smaller than threshold -1 the draw function would have returned before coming here.
  476. *
  477. * @param {string} color The font color to use
  478. * @param {number} viewFontSize
  479. * @param {string} initialStrokeColor
  480. * @returns {Array.<string>} An array containing the font color and stroke color
  481. * @private
  482. */
  483. _getColor(color, viewFontSize, initialStrokeColor) {
  484. let fontColor = color || '#000000';
  485. let strokeColor = initialStrokeColor || '#ffffff';
  486. if (viewFontSize <= this.elementOptions.scaling.label.drawThreshold) {
  487. let opacity = Math.max(0, Math.min(1, 1 - (this.elementOptions.scaling.label.drawThreshold - viewFontSize)));
  488. fontColor = util.overrideOpacity(fontColor, opacity);
  489. strokeColor = util.overrideOpacity(strokeColor, opacity);
  490. }
  491. return [fontColor, strokeColor];
  492. }
  493. /**
  494. *
  495. * @param {CanvasRenderingContext2D} ctx
  496. * @param {boolean} selected
  497. * @param {boolean} hover
  498. * @returns {{width: number, height: number}}
  499. */
  500. getTextSize(ctx, selected = false, hover = false) {
  501. this._processLabel(ctx, selected, hover);
  502. return {
  503. width: this.size.width,
  504. height: this.size.height,
  505. lineCount: this.lineCount
  506. };
  507. }
  508. /**
  509. * Get the current dimensions of the label
  510. *
  511. * @return {rect}
  512. */
  513. getSize() {
  514. let lineMargin = 2;
  515. let x = this.size.left; // default values which might be overridden below
  516. let y = this.size.top - 0.5*lineMargin; // idem
  517. if (this.isEdgeLabel) {
  518. const x2 = -this.size.width * 0.5;
  519. switch (this.fontOptions.align) {
  520. case 'middle':
  521. x = x2;
  522. y = -this.size.height * 0.5
  523. break;
  524. case 'top':
  525. x = x2;
  526. y = -(this.size.height + lineMargin);
  527. break;
  528. case 'bottom':
  529. x = x2;
  530. y = lineMargin;
  531. break;
  532. }
  533. }
  534. var ret = {
  535. left : x,
  536. top : y,
  537. width : this.size.width,
  538. height: this.size.height,
  539. };
  540. return ret;
  541. }
  542. /**
  543. *
  544. * @param {CanvasRenderingContext2D} ctx
  545. * @param {boolean} selected
  546. * @param {boolean} hover
  547. * @param {number} [x=0]
  548. * @param {number} [y=0]
  549. * @param {'middle'|'hanging'} [baseline='middle']
  550. */
  551. calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = 'middle') {
  552. this._processLabel(ctx, selected, hover);
  553. this.size.left = x - this.size.width * 0.5;
  554. this.size.top = y - this.size.height * 0.5;
  555. this.size.yLine = y + (1 - this.lineCount) * 0.5 * this.fontOptions.size;
  556. if (baseline === "hanging") {
  557. this.size.top += 0.5 * this.fontOptions.size;
  558. this.size.top += 4; // distance from node, required because we use hanging. Hanging has less difference between browsers
  559. this.size.yLine += 4; // distance from node
  560. }
  561. }
  562. /**
  563. *
  564. * @param {CanvasRenderingContext2D} ctx
  565. * @param {boolean} selected
  566. * @param {boolean} hover
  567. * @param {string} mod
  568. * @returns {{color, size, face, mod, vadjust, strokeWidth: *, strokeColor: (*|string|allOptions.edges.font.strokeColor|{string}|allOptions.nodes.font.strokeColor|Array)}}
  569. */
  570. getFormattingValues(ctx, selected, hover, mod) {
  571. let getValue = function(fontOptions, mod, option) {
  572. if (mod === "normal") {
  573. if (option === 'mod' ) return "";
  574. return fontOptions[option];
  575. }
  576. if (fontOptions[mod][option] !== undefined) { // Grumbl leaving out test on undefined equals false for ""
  577. return fontOptions[mod][option];
  578. } else {
  579. // Take from parent font option
  580. return fontOptions[option];
  581. }
  582. };
  583. let values = {
  584. color : getValue(this.fontOptions, mod, 'color' ),
  585. size : getValue(this.fontOptions, mod, 'size' ),
  586. face : getValue(this.fontOptions, mod, 'face' ),
  587. mod : getValue(this.fontOptions, mod, 'mod' ),
  588. vadjust: getValue(this.fontOptions, mod, 'vadjust'),
  589. strokeWidth: this.fontOptions.strokeWidth,
  590. strokeColor: this.fontOptions.strokeColor
  591. };
  592. if (selected || hover) {
  593. if (mod === "normal" && (this.fontOptions.chooser === true) && (this.elementOptions.labelHighlightBold)) {
  594. values.mod = 'bold';
  595. } else {
  596. if (typeof this.fontOptions.chooser === 'function') {
  597. this.fontOptions.chooser(values, this.elementOptions.id, selected, hover);
  598. }
  599. }
  600. }
  601. let fontString = "";
  602. if (values.mod !== undefined && values.mod !== "") { // safeguard for undefined - this happened
  603. fontString += values.mod + " ";
  604. }
  605. fontString += values.size + "px " + values.face;
  606. ctx.font = fontString.replace(/"/g, "");
  607. values.font = ctx.font;
  608. values.height = values.size;
  609. return values;
  610. }
  611. /**
  612. *
  613. * @param {boolean} selected
  614. * @param {boolean} hover
  615. * @returns {boolean}
  616. */
  617. differentState(selected, hover) {
  618. return ((selected !== this.selectedState) || (hover !== this.hoverState));
  619. }
  620. /**
  621. * This explodes the passed text into lines and determines the width, height and number of lines.
  622. *
  623. * @param {CanvasRenderingContext2D} ctx
  624. * @param {boolean} selected
  625. * @param {boolean} hover
  626. * @param {string} inText the text to explode
  627. * @returns {{width, height, lines}|*}
  628. * @private
  629. */
  630. _processLabelText(ctx, selected, hover, inText) {
  631. let splitter = new LabelSplitter(ctx, this, selected, hover);
  632. return splitter.process(inText);
  633. }
  634. /**
  635. * This explodes the label string into lines and sets the width, height and number of lines.
  636. * @param {CanvasRenderingContext2D} ctx
  637. * @param {boolean} selected
  638. * @param {boolean} hover
  639. * @private
  640. */
  641. _processLabel(ctx, selected, hover) {
  642. if(this.labelDirty === false && !this.differentState(selected,hover))
  643. return;
  644. let state = this._processLabelText(ctx, selected, hover, this.elementOptions.label);
  645. if ((this.fontOptions.minWdt > 0) && (state.width < this.fontOptions.minWdt)) {
  646. state.width = this.fontOptions.minWdt;
  647. }
  648. this.size.labelHeight =state.height;
  649. if ((this.fontOptions.minHgt > 0) && (state.height < this.fontOptions.minHgt)) {
  650. state.height = this.fontOptions.minHgt;
  651. }
  652. this.lines = state.lines;
  653. this.lineCount = state.lines.length;
  654. this.size.width = state.width;
  655. this.size.height = state.height;
  656. this.selectedState = selected;
  657. this.hoverState = hover;
  658. this.labelDirty = false;
  659. }
  660. /**
  661. * Check if this label is visible
  662. *
  663. * @return {boolean} true if this label will be show, false otherwise
  664. */
  665. visible() {
  666. if ((this.size.width === 0 || this.size.height === 0)
  667. || this.elementOptions.label === undefined) {
  668. return false; // nothing to display
  669. }
  670. let viewFontSize = this.fontOptions.size * this.body.view.scale;
  671. if (viewFontSize < this.elementOptions.scaling.label.drawThreshold - 1) {
  672. return false; // Too small or too far away to show
  673. }
  674. return true;
  675. }
  676. }
  677. export default Label;