public abstract class Portal extends Object
Modifier and Type | Field and Description |
---|---|
boolean |
cursorInside
Was the cursor inside the portal or not last time it moved.
|
int |
h
Portal dimensions (height).
|
int |
w
Portal dimensions (width).
|
int |
x
Top-left x-coordinate of this portal (JPanel coordinates system).
|
int |
y
Top-left y-coordinate of this portal (JPanel coordinates system).
|
Constructor and Description |
---|
Portal() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
coordInside(int cx,
int cy)
detects whether the given point is inside this portal or not
|
int |
cursorInOut(int cx,
int cy)
Detects cursor entry/exit in/from the portal.
|
Dimension |
getDimensions() |
int[] |
getDistanceFromBorders(int cx,
int cy,
int[] res)
Computes the distance between a given point (typically the mouse cursor) and each of the four portal borders.
|
View |
getOwningView()
Get the view embedding this portal.
|
PortalListener |
getPortalListener()
Get the event handler for mouse and keyboard events occuring inside the portal (null if none)
|
boolean |
isVisible()
Tells wether this portal is currently visible or not.
|
void |
move(int dx,
int dy)
Move the portal inside the view (relative).
|
void |
moveTo(int x,
int y)
Move the portal inside the view (absolute).
|
abstract void |
paint(Graphics2D g2d,
int viewWidth,
int viewHeight) |
void |
resize(int dw,
int dh)
Set the portal's size (multiplication factor).
|
void |
setOwningView(View v)
CALLED INTERNALLY - NOT FOR PUBLIC USE
|
void |
setPortalListener(PortalListener peh)
Set an event handler for mouse and keyboard events occuring inside the portal.
|
void |
setVisible(boolean b)
Show/hide this portal.
|
void |
sizeTo(int w,
int h)
Set the portal's size (absolute value).
|
void |
updateDimensions() |
public int x
public int y
public int w
public int h
public boolean cursorInside
public void move(int dx, int dy)
dx
- x-offset (JPanel coordinates system)dy
- y-offset (JPanel coordinates system)public void moveTo(int x, int y)
x
- new x-coordinate (JPanel coordinates system)y
- new y-coordinate (JPanel coordinates system)public void resize(int dw, int dh)
public void sizeTo(int w, int h)
public Dimension getDimensions()
public void updateDimensions()
public void setOwningView(View v)
public View getOwningView()
public void setPortalListener(PortalListener peh)
public PortalListener getPortalListener()
public abstract boolean coordInside(int cx, int cy)
cx
- cursor x-coordinate (JPanel coordinates system)cy
- cursor y-coordinate (JPanel coordinates system)public int cursorInOut(int cx, int cy)
cx
- cursor x-coordinate (JPanel coordinates system)cy
- cursor y-coordinate (JPanel coordinates system)public int[] getDistanceFromBorders(int cx, int cy, int[] res)
In all four cases, the value is positive if the point is on the side of the border that potentially makes it belong to the inside of the portal (potentially because the point has to meet the requirement for all four borders to actually be inside the portal). The value is zero when the point is exactly above the border, and negative otherwise.
This method usually makes the hypothesis that the portal's shape is rectangular. If it is not, the portal's bounding box is considered. Subclasses willing to change this behaviour should be free to override this method.
cx
- horizontal cursor coordinate (JPanel)cy
- vertical cursor coordinate (JPanel)res
- the array to fill with information (to be initialized by client application)public void setVisible(boolean b)
public boolean isVisible()
public abstract void paint(Graphics2D g2d, int viewWidth, int viewHeight)
Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2015 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.