-
Notifications
You must be signed in to change notification settings - Fork 45
New format for layout file #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9e362e0
Schema of new layout file
2863594
Implemented save a new layout schema
3639ddd
Implemented load a new layout schema
a47c2e0
Fixed some problems in new layout schema
1965632
Fixed some code review feedback in new layout schema
2c14807
Changed matcher method in DataURISchema
4b29500
Fixed load DataURISchema of image in old layout format
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,55 +44,19 @@ thin.core.AbstractTextGroup = function(element, layout) { | |
| goog.inherits(thin.core.AbstractTextGroup, thin.core.AbstractBoxGroup); | ||
|
|
||
|
|
||
| /** | ||
| * The latest fill applied to this element. | ||
| * @type {goog.graphics.Fill?} | ||
| * @protected | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.fill = null; | ||
|
|
||
|
|
||
| /** | ||
| * The latest stroke applied to this element. | ||
| * @type {goog.graphics.Stroke?} | ||
| * @private | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.stroke_ = null; | ||
|
|
||
|
|
||
| /** | ||
| * Sets the fill for this element. | ||
| * @param {goog.graphics.Fill?} fill The fill object. | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.setFill = function(fill) { | ||
| this.fill = fill; | ||
| this.getLayout().setElementFill(this, fill); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {goog.graphics.Fill?} fill The fill object. | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.getFill = function() { | ||
| return this.fill; | ||
| thin.core.AbstractTextGroup.prototype.setFillInternal = function() { | ||
| this.getLayout().setElementFill(this, this.fill); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * Sets the stroke for this element. | ||
| * @param {goog.graphics.Stroke?} stroke The stroke object. | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.setStroke = function(stroke) { | ||
| this.stroke_ = stroke; | ||
| this.getLayout().setElementStroke(this, stroke); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {goog.graphics.Stroke?} stroke The stroke object. | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.getStroke = function() { | ||
| return this.stroke_; | ||
| thin.core.AbstractTextGroup.prototype.setStrokeInternal = function() { | ||
| this.getLayout().setElementStroke(this, this.stroke_); | ||
| }; | ||
|
|
||
|
|
||
|
|
@@ -178,12 +142,29 @@ thin.core.AbstractTextGroup.prototype.setTextLineHeightRatio = function(ratio) { | |
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @deprecated See: https://github.com/thinreports/thinreports-editor/issues/38 | ||
| * @param {string|number} spacing | ||
| * @return {string} | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.convertKerningToDefaultInSince06 = function(spacing) { | ||
| if (isNaN(Number(spacing))) { | ||
| spacing = thin.core.TextStyle.DEFAULT_KERNING; | ||
| } | ||
|
|
||
| return spacing; | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @param {string} spacing | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.setKerning = function(spacing) { | ||
| var layout = this.getLayout(); | ||
| var element = this.getElement(); | ||
|
|
||
| spacing = this.convertKerningToDefaultInSince06(spacing); | ||
|
|
||
| if (thin.isExactlyEqual(spacing, thin.core.TextStyle.DEFAULT_KERNING)) { | ||
| layout.setElementAttributes(element, { | ||
| 'kerning': thin.core.TextStyle.DEFAULT_ELEMENT_KERNING, | ||
|
|
@@ -300,6 +281,15 @@ thin.core.AbstractTextGroup.prototype.getTextLineHeightRatio = function() { | |
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {string} | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.getTextLineHeight = function() { | ||
| return /** @type {string} */ (thin.getValIfNotDef(this.getLayout().getElementAttribute( | ||
| this.getElement(), 'x-line-height'), thin.core.TextStyle.DEFAULT_LINEHEIGHT)); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {string} | ||
| */ | ||
|
|
@@ -399,3 +389,190 @@ thin.core.AbstractTextGroup.prototype.disposeInternal = function() { | |
| delete this.fontStyle_; | ||
| delete this.textStyle_; | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {string} | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.getTextAnchorAsJSON = function() { | ||
| var textAlignAsJSON = ''; | ||
| var horizonAlignType = thin.core.TextStyle.HorizonAlignType; | ||
|
|
||
| // SVG: start, middle, end | ||
| // TLF: left, center, right | ||
| switch(this.getTextAnchor()) { | ||
| case horizonAlignType.MIDDLE: | ||
| textAlignAsJSON = 'center'; | ||
| break; | ||
| case horizonAlignType.END: | ||
| textAlignAsJSON = 'right'; | ||
| break; | ||
| default: | ||
| textAlignAsJSON = 'left'; | ||
| break; | ||
| } | ||
|
|
||
| return textAlignAsJSON; | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @param {string} textAlignFromJSON | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.setTextAnchorFromJSON = function(textAlignFromJSON) { | ||
| var anchor = ''; | ||
| var horizonAlignType = thin.core.TextStyle.HorizonAlignType; | ||
|
|
||
| // SVG: start, middle, end | ||
| // TLF: left, center, right | ||
| switch(textAlignFromJSON) { | ||
| case 'center': | ||
| anchor = horizonAlignType.MIDDLE; | ||
| break; | ||
| case 'right': | ||
| anchor = horizonAlignType.END; | ||
| break; | ||
| default: | ||
| anchor = horizonAlignType.START; | ||
| break; | ||
| } | ||
|
|
||
| this.setTextAnchor(anchor); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {string} | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.getVerticalAlignAsJSON = function() { | ||
| var verticalAlignAsJSON = ''; | ||
| var verticalAlignType = thin.core.TextStyle.VerticalAlignType; | ||
|
|
||
| // SVG: top, center, bottom | ||
| // TLF: top, middle, bottom | ||
| switch(this.getVerticalAlign()) { | ||
| case verticalAlignType.CENTER: | ||
| verticalAlignAsJSON = 'middle'; | ||
| break; | ||
| case verticalAlignType.BOTTOM: | ||
| verticalAlignAsJSON = verticalAlignType.BOTTOM; | ||
| break; | ||
| default: | ||
| verticalAlignAsJSON = verticalAlignType.TOP; | ||
| break; | ||
| } | ||
|
|
||
| return verticalAlignAsJSON; | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @param {string} verticalAlignFromJSON | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.setVerticalAlignFromJSON = function(verticalAlignFromJSON) { | ||
| var valign = ''; | ||
| var verticalAlignType = thin.core.TextStyle.VerticalAlignType; | ||
|
|
||
| // SVG: top, center, bottom | ||
| // TLF: top, middle, bottom | ||
| switch(verticalAlignFromJSON) { | ||
| case 'middle': | ||
| valign = verticalAlignType.CENTER; | ||
| break; | ||
| default: | ||
| valign = verticalAlignFromJSON; | ||
| break; | ||
| } | ||
|
|
||
| this.setVerticalAlign(valign); | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @return {Object} | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.asJSON = function() { | ||
| var object = this.asJSON_(); | ||
|
|
||
| var lineHeight = this.getTextLineHeight(); | ||
| var lineHeightRatio = this.getTextLineHeightRatio(); | ||
| if (!thin.isExactlyEqual(lineHeightRatio, thin.core.TextStyle.DEFAULT_LINEHEIGHT)) { | ||
| lineHeight = Number(lineHeight); | ||
| lineHeightRatio = Number(lineHeightRatio); | ||
| } | ||
|
|
||
| var letterSpecing = this.getKerning(); | ||
| if (!thin.isExactlyEqual(letterSpecing, thin.core.TextStyle.DEFAULT_KERNING)) { | ||
| letterSpecing = Number(letterSpecing); | ||
| } | ||
|
|
||
| goog.object.extend(object['style'], { | ||
| 'font-family': [ this.getFontFamily() ], | ||
| 'font-size': this.getFontSize(), | ||
| 'color': goog.object.get(object['style'], 'fill-color'), | ||
| 'text-align': this.getTextAnchorAsJSON(), | ||
| 'vertical-align': this.getVerticalAlignAsJSON(), | ||
| 'line-height': lineHeight, | ||
| 'line-height-ratio': lineHeightRatio, | ||
| 'letter-spacing': letterSpecing | ||
| }); | ||
| goog.object.extend(object['style'], this.fontStyle_.asJSON()); | ||
|
|
||
| goog.object.remove(object['style'], 'fill-color'); | ||
|
|
||
| return object; | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * @param {Object} attrs | ||
| */ | ||
| thin.core.AbstractTextGroup.prototype.update = function(attrs) { | ||
| this.update_(attrs); | ||
|
|
||
| goog.object.forEach(attrs, function(value, attr) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [chore] ここは if (attrs['font-family']) {
this.setFontFamily(attrs['font-family'][0]);
}
if (attrs['font-size']) {
this.setFontSize(attrs['font-size']);
}
// :でいいかなぁと思ったけど、このままでもいいかな。
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここは、このままにする。 |
||
| switch (attr) { | ||
| case 'font-family': | ||
| this.setFontFamily(value[0]); | ||
| break; | ||
| case 'font-size': | ||
| this.setFontSize(value); | ||
| break; | ||
| case 'color': | ||
| this.setFillColor(value); | ||
| break; | ||
| case 'text-align': | ||
| this.setTextAnchorFromJSON(value); | ||
| break; | ||
| case 'vertical-align': | ||
| this.setVerticalAlignFromJSON(value); | ||
| break; | ||
| case 'line-height-ratio': | ||
| this.setTextLineHeightRatio(value); | ||
| break; | ||
| case 'letter-spacing': | ||
| this.setKerning(value); | ||
| break; | ||
| case 'font-style': | ||
| goog.array.forEach(value, function(font_style) { | ||
| switch(font_style) { | ||
| case 'bold': | ||
| this.setFontBold(true); | ||
| break; | ||
| case 'italic': | ||
| this.setFontItalic(true); | ||
| break; | ||
| case 'linethrough': | ||
| this.setFontLinethrough(true); | ||
| break; | ||
| case 'underline': | ||
| this.setFontUnderline(true); | ||
| break; | ||
| } | ||
| }, this); | ||
| default: | ||
| // Do Nothing | ||
| break; | ||
| } | ||
| }, this); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
順番の仕様が曖昧なので、以下のようにしよう。 generator の方も修正する。
https://docs.google.com/spreadsheets/d/1iLqM1rdavuLLlbl_8xKODIIWZbHAE3D0A4AzhmK9_Pw/edit#gid=1893696187
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あい。Editorは大丈夫だと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ん?修正は必要だよね?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
再設定したらおかしくなることが判明。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそも順番が違うと思う。今のコードを見る限り、
[top, bottom, left, right]になってる気がする。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ですな。勘違いしていた。