1 /*
2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package heal;
26
27 import hat.Accelerator;
28 import optkl.ifacemapper.BoundSchema;
29 import optkl.ifacemapper.Buffer;
30 import optkl.ifacemapper.Schema;
31
32 public interface Box extends Buffer {
33 int x1();
34
35 int y1();
36
37 void y1(int y1);
38
39 void x1(int x1);
40
41 int x2();
42
43 int y2();
44
45 void y2(int y2);
46
47 void x2(int x2);
48
49
50 void width(int width);
51 void height(int height);
52 int width();
53 int height();
54 int area();
55 void area(int area);
56 Schema<Box> schema = Schema.of(Box.class, s ->
57 s.fields("x1", "y1", "x2", "y2", "width", "height", "area")
58 );
59
60 static Box create(Accelerator accelerator, int x1, int y1, int x2, int y2) {
61 Box box = BoundSchema.of(accelerator ,schema).allocate();
62 box.x1(x1);
63 box.y1(y1);
64 box.x2(x2);
65 box.y2(y2);
66 box.width(x2-x1);
67 box.height(y2-y1);
68 box.area(box.width()* box.height());
69 return box;
70 }
71 }