| •1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
package com.github.weisj.jsvg.attributes.font; |
| 23 |
|
| 24 |
import java.util.Arrays; |
| 25 |
import java.util.Objects; |
| 26 |
|
| 27 |
import org.jetbrains.annotations.NotNull; |
| 28 |
import org.jetbrains.annotations.Nullable; |
| 29 |
|
| 30 |
import com.github.weisj.jsvg.geometry.size.Length; |
| 31 |
import com.github.weisj.jsvg.geometry.size.Percentage; |
| 32 |
import com.github.weisj.jsvg.nodes.prototype.Mutator; |
| 33 |
|
| 34 |
public final class AttributeFontSpec extends FontSpec implements Mutator<MeasurableFontSpec> { |
| 35 |
private final @Nullable FontSize size; |
| 36 |
private final @Nullable FontWeight weight; |
| 37 |
|
| 38 |
AttributeFontSpec(@NotNull String[] families, @Nullable FontStyle style, @Nullable Length sizeAdjust, |
| 39 |
@NotNull Percentage stretch, @Nullable FontSize size, @Nullable FontWeight weight) { |
| 40 |
super(families, style, sizeAdjust, stretch); |
| 41 |
this.size = size; |
| 42 |
this.weight = weight; |
| 43 |
} |
| 44 |
|
| 45 |
public @Nullable FontWeight weight() { |
| 46 |
return weight; |
| 47 |
} |
| 48 |
|
| 49 |
public @Nullable FontSize size() { |
| 50 |
return size; |
| 51 |
} |
| 52 |
|
| 53 |
@Override |
| 54 |
public @NotNull MeasurableFontSpec mutate(@NotNull MeasurableFontSpec element) { |
| 55 |
return element.derive(this); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public String toString() { |
| 60 |
return "AttributeFontSpec{" + |
| 61 |
"families=" + Arrays.toString(families) + |
| 62 |
", style=" + style + |
| 63 |
", weight=" + weight + |
| 64 |
", size=" + size + |
| 65 |
", sizeAdjust=" + sizeAdjust + |
| 66 |
", stretch=" + stretch + |
| 67 |
'}'; |
| 68 |
} |
| 69 |
|
| 70 |
@Override |
| 71 |
public boolean equals(Object o) { |
| 72 |
if (this == o) return true; |
| 73 |
if (!(o instanceof AttributeFontSpec)) return false; |
| 74 |
if (!super.equals(o)) return false; |
| 75 |
AttributeFontSpec fontSpec = (AttributeFontSpec) o; |
| 76 |
return Objects.equals(size, fontSpec.size) && Objects.equals(weight, fontSpec.weight); |
| 77 |
} |
| 78 |
|
| 79 |
@Override |
| 80 |
public int hashCode() { |
| 81 |
return Objects.hash(super.hashCode(), size, weight); |
| 82 |
} |
| 83 |
} |