Debian Codegraph @

src/com/github/weisj/jsvg/view/ViewBox.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*
2 * MIT License
3 *
4 * Copyright (c) 2021-2025 Jannis Weis
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
7 * associated documentation files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
9 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all copies or
13 * substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
16 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 }