|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.sahits.game.graphic.display.util.OffsetCalculator
public final class OffsetCalculator
This helper class lets you calculate the relative offset in an overlayed image. This is needed if you place your image not at a fixed distance from the right border or the top. As with different screen resolutions you would like it to have it placed 150px to the left of the right border. What you actually want is not the offset of the image but a point within. Defining the image you know the relative location within the image, but you need to know the absolute position on the screen. This helper class lets you compute these coordinates.
| Field Summary | |
|---|---|
private int |
xOff
|
private int |
yOff
|
| Constructor Summary | |
|---|---|
OffsetCalculator(int xOff,
int yOff)
Initialize the offset of the image. |
|
| Method Summary | |
|---|---|
Point |
computeOffset(int relativeXOffset,
double xScale,
int relativeYOffset,
double yScale)
Compute the absolute offset of the point in the case that the relative offsets are scaled dynamically. |
Point |
computeOffset(int relativeXOffset,
int relativeYOffset)
Compute the absolute offset of the point |
int |
computeXOffset(int relativeXOffset)
Compute the absolute offset of the point X |
int |
computeXOffset(int relativeXOffset,
double xScale)
Compute the absolute offset of the point X in the case that the relative offset is scaled dynamically |
int |
computeYOffset(int relativeYOffset)
Compute the absolute offset of the point Y |
int |
computeYOffset(int relativeYOffset,
double yScale)
Compute the absolute offset of the point Y in the case that the relative offset is scaled dynamically |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final int xOff
private final int yOff
| Constructor Detail |
|---|
public OffsetCalculator(int xOff,
int yOff)
xOff - Offset in direction X (to the right)yOff - Offset in direction Y (down)| Method Detail |
|---|
public int computeXOffset(int relativeXOffset)
relativeXOffset - relative offset (in relation to the image) of X
public int computeYOffset(int relativeYOffset)
relativeYOffset - relative offset (in relation to the image) of Y
public Point computeOffset(int relativeXOffset,
int relativeYOffset)
relativeYOffset - relative offset (in relation to the image) of YrelativeYOffset - relative offset (in relation to the image) of Y
public int computeXOffset(int relativeXOffset,
double xScale)
relativeXOffset - relative offset (in relation to the image) of X
public int computeYOffset(int relativeYOffset,
double yScale)
relativeYOffset - relative offset (in relation to the image) of Y
public Point computeOffset(int relativeXOffset,
double xScale,
int relativeYOffset,
double yScale)
relativeYOffset - relative offset (in relation to the image) of YrelativeYOffset - relative offset (in relation to the image) of Y
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||