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 hat.buffer.Buffer;
29 import hat.ifacemapper.Schema;
30 
31 public interface Box extends Buffer {
32     int x1();
33 
34     int y1();
35 
36     void y1(int y1);
37 
38     void x1(int x1);
39 
40     int x2();
41 
42     int y2();
43 
44     void y2(int y2);
45 
46     void x2(int x2);
47 
48 
49     void width(int width);
50     void height(int height);
51     int width();
52     int height();
53     int area();
54     void area(int area);
55     Schema<Box> schema = Schema.of(Box.class, s ->
56             s.fields("x1", "y1", "x2", "y2", "width", "height", "area")
57     );
58 
59     static Box create(Accelerator accelerator, int x1, int y1, int x2, int y2) {
60         Box box = schema.allocate(accelerator);
61         box.x1(x1);
62         box.y1(y1);
63         box.x2(x2);
64         box.y2(y2);
65         box.width(x2-x1);
66         box.height(y2-y1);
67         box.area(box.width()* box.height());
68         return box;
69     }
70 }