Crossfire JXClient, Trunk  R20561
Extent.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.gui.gui;
23 
24 import org.jetbrains.annotations.NotNull;
25 
31 public class Extent {
32 
36  @NotNull
37  private final Expression x;
38 
42  @NotNull
43  private final Expression y;
44 
48  @NotNull
49  private final Expression w;
50 
54  @NotNull
55  private final Expression h;
56 
64  public Extent(@NotNull final Expression x, @NotNull final Expression y, @NotNull final Expression w, @NotNull final Expression h) {
65  this.x = x;
66  this.y = y;
67  this.w = w;
68  this.h = h;
69  }
70 
79  public int getX(final int width, final int height, final int prefWidth, final int prefHeight) {
80  return x.evaluate(width, height, prefWidth, prefHeight);
81  }
82 
91  public int getY(final int width, final int height, final int prefWidth, final int prefHeight) {
92  return y.evaluate(width, height, prefWidth, prefHeight);
93  }
94 
103  public int getW(final int width, final int height, final int prefWidth, final int prefHeight) {
104  return w.evaluate(width, height, prefWidth, prefHeight);
105  }
106 
115  public int getH(final int width, final int height, final int prefWidth, final int prefHeight) {
116  return h.evaluate(width, height, prefWidth, prefHeight);
117  }
118 
119 }
Encapsulates the extent of a GUI element.
Definition: Extent.java:31
int evaluate(final int width, final int height, final int prefWidth, final int prefHeight)
Evaluates the expression into a constant.
Definition: Expression.java:97
final Expression h
The height.
Definition: Extent.java:55
final Expression y
The y coordinate.
Definition: Extent.java:43
An expression yielding an integer value derived from a screen resolution.
Definition: Expression.java:30
final Expression x
The x coordinate.
Definition: Extent.java:37
int getY(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the y coordinate.
Definition: Extent.java:91
int getW(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the width.
Definition: Extent.java:103
Extent(@NotNull final Expression x, @NotNull final Expression y, @NotNull final Expression w, @NotNull final Expression h)
Creates a new instance.
Definition: Extent.java:64
int getX(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the x coordinate.
Definition: Extent.java:79
int getH(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the height.
Definition: Extent.java:115