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.

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