| •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.view; |
| 23 |
|
| 24 |
import java.awt.geom.Point2D; |
| 25 |
import java.awt.geom.Rectangle2D; |
| 26 |
|
| 27 |
import org.jetbrains.annotations.NotNull; |
| 28 |
|
| 29 |
import com.github.weisj.jsvg.geometry.size.Length; |
| 30 |
|
| 31 |
public final class ViewBox extends Rectangle2D.Float { |
| 32 |
|
| 33 |
public ViewBox(float @NotNull [] viewBox) { |
| 34 |
super(viewBox[0], viewBox[1], viewBox[2], viewBox[3]); |
| 35 |
} |
| 36 |
|
| 37 |
public ViewBox(float x, float y, float w, float h) { |
| 38 |
super(x, y, w, h); |
| 39 |
} |
| 40 |
|
| 41 |
public ViewBox(float w, float h) { |
| 42 |
this(0, 0, w, h); |
| 43 |
} |
| 44 |
|
| 45 |
public ViewBox(@NotNull FloatSize size) { |
| 46 |
this(size.width, size.height); |
| 47 |
} |
| 48 |
|
| 49 |
public ViewBox(@NotNull Point2D location, @NotNull FloatSize size) { |
| 50 |
this((float) location.getX(), (float) location.getY(), size.width, size.height); |
| 51 |
} |
| 52 |
|
| 53 |
public ViewBox(@NotNull Rectangle2D bounds) { |
| 54 |
this((float) bounds.getX(), (float) bounds.getY(), (float) bounds.getWidth(), (float) bounds.getHeight()); |
| 55 |
} |
| 56 |
|
| 57 |
public void setSize(@NotNull FloatSize size) { |
| 58 |
this.width = size.width; |
| 59 |
this.height = size.height; |
| 60 |
} |
| 61 |
|
| 62 |
public @NotNull FloatSize size() { |
| 63 |
return new FloatSize(width, height); |
| 64 |
} |
| 65 |
|
| 66 |
public @NotNull Point2D.Float location() { |
| 67 |
return new Point2D.Float(x, y); |
| 68 |
} |
| 69 |
|
| 70 |
public boolean hasSpecifiedX() { |
| 71 |
return Length.isSpecified(x); |
| 72 |
} |
| 73 |
|
| 74 |
public boolean hasSpecifiedY() { |
| 75 |
return Length.isSpecified(y); |
| 76 |
} |
| 77 |
|
| 78 |
public boolean hasSpecifiedWidth() { |
| 79 |
return Length.isSpecified(width); |
| 80 |
} |
| 81 |
|
| 82 |
public boolean hasSpecifiedHeight() { |
| 83 |
return Length.isSpecified(height); |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public @NotNull String toString() { |
| 88 |
return "ViewBox[" + x + "," + y + "," + width + "," + height + "]"; |
| 89 |
} |
| 90 |
} |