Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
TULIP
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
14
Issues
14
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP
Commits
d670fb8a
Commit
d670fb8a
authored
Jan 24, 2019
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added withinBounds method to Point class
Added static ZERO_BOUNDS to Bounds2D class
parent
39e79fcb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
19 deletions
+74
-19
Bounds2D.java
TULIP/src/lu/list/itis/dkd/tui/utility/Bounds2D.java
+2
-0
CameraCoordinates.java
...P/src/lu/list/itis/dkd/tui/utility/CameraCoordinates.java
+9
-2
CoordinateState.java
TULIP/src/lu/list/itis/dkd/tui/utility/CoordinateState.java
+20
-11
NormalizedCoordinates.java
...c/lu/list/itis/dkd/tui/utility/NormalizedCoordinates.java
+8
-0
Point.java
TULIP/src/lu/list/itis/dkd/tui/utility/Point.java
+11
-0
ScreenCoordinates.java
...P/src/lu/list/itis/dkd/tui/utility/ScreenCoordinates.java
+6
-0
TableCoordinates.java
TULIP/src/lu/list/itis/dkd/tui/utility/TableCoordinates.java
+13
-6
GraphCoordinates.java
...dkd/tui/utility/graph/forcedirected/GraphCoordinates.java
+5
-0
No files found.
TULIP/src/lu/list/itis/dkd/tui/utility/Bounds2D.java
View file @
d670fb8a
...
...
@@ -12,6 +12,8 @@ public class Bounds2D {
public
static
DecimalFormat
format
=
new
DecimalFormat
();
public
static
final
Bounds2D
ZERO_BOUNDS
=
new
Bounds2D
(
0
,
0
,
0
,
0
);
static
{
format
.
setDecimalSeparatorAlwaysShown
(
false
);
format
.
setMaximumFractionDigits
(
2
);
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/CameraCoordinates.java
View file @
d670fb8a
...
...
@@ -31,6 +31,9 @@ import lu.list.itis.dkd.dbc.annotation.NonNull;
* @version 2.3.0
*/
public
class
CameraCoordinates
extends
CoordinateState
{
private
static
final
Bounds2D
BOUNDS
=
new
Bounds2D
(
Calibration
.
getCameraLeft
(),
Calibration
.
getCameraTop
(),
Calibration
.
getTableWidth
(),
Calibration
.
getTableHeight
());
/**
* Constructing an instance with the provided points.
*
...
...
@@ -70,11 +73,15 @@ public class CameraCoordinates extends CoordinateState {
@Deprecated
public
void
toCamera
(
@NonNull
Point
context
)
{
/**
* The conversion is naught as the point's coordinates are already given in this reference
* scheme!
* The conversion is naught as the point's coordinates are already given in this reference scheme!
*/
}
@Override
public
boolean
withinBounds
(
Point
context
)
{
return
BOUNDS
.
includes
(
context
);
}
/** {@inheritDoc} */
@Override
public
Point
normalize
(
Point
context
)
{
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/CoordinateState.java
View file @
d670fb8a
...
...
@@ -32,8 +32,7 @@ import lu.list.itis.dkd.dbc.annotation.NonNull;
public
abstract
class
CoordinateState
{
/**
* normalizes the coordinates of a given point with the respect to its current coordinate
* system.
* normalizes the coordinates of a given point with the respect to its current coordinate system.
*
* @param context
* point to convert in given coordinate state
...
...
@@ -70,9 +69,9 @@ public abstract class CoordinateState {
}
/**
* Method used to transition coordinates from the current system to table coordinates. By
*
default, unless overridden, the method does nothing. This method is deprecated. Use
*
toCoordinates method
instead.
* Method used to transition coordinates from the current system to table coordinates. By
default,
*
unless overridden, the method does nothing. This method is deprecated. Use toCoordinates method
* instead.
*
* @param context
* The context of the state; the feature the state gives meaning.
...
...
@@ -82,9 +81,9 @@ public abstract class CoordinateState {
public
abstract
void
toTable
(
@NonNull
Point
context
);
/**
* Method used to transition coordinates from the current system to screen coordinates. By
*
default, unless overridden, the method does nothing. This method is deprecated. Use
*
toCoordinates method
instead.
* Method used to transition coordinates from the current system to screen coordinates. By
default,
*
unless overridden, the method does nothing. This method is deprecated. Use toCoordinates method
* instead.
*
* @param context
* The context of the state; the feature the state gives meaning.
...
...
@@ -94,9 +93,9 @@ public abstract class CoordinateState {
public
abstract
void
toScreen
(
@NonNull
Point
context
);
/**
* Method used to transition coordinates from the current system to camera coordinates. By
*
default, unless overridden, the method does nothing. This method is deprecated. Use
*
toCoordinates method
instead.
* Method used to transition coordinates from the current system to camera coordinates. By
default,
*
unless overridden, the method does nothing. This method is deprecated. Use toCoordinates method
* instead.
*
* @param context
* The context of the state; the feature the state gives meaning.
...
...
@@ -105,6 +104,16 @@ public abstract class CoordinateState {
@Deprecated
public
abstract
void
toCamera
(
@NonNull
Point
context
);
/**
* Checks whether the specified point is withing acceptable bounds.
*
* @param context
* @return <code>true</code> if specified point can be represented by this coordinate state,
* <code>false</code> otherwise
*/
public
abstract
boolean
withinBounds
(
Point
context
);
/**
* Method testing for equality.
*
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/NormalizedCoordinates.java
View file @
d670fb8a
...
...
@@ -33,6 +33,9 @@ import com.google.common.base.Preconditions;
* @version 2.3.0
*/
public
class
NormalizedCoordinates
extends
CoordinateState
{
private
static
final
Bounds2D
BOUNDS
=
new
Bounds2D
(
0
,
0
,
1
,
1
);
/**
* Constructing an instance with the provided points.
*
...
...
@@ -76,6 +79,11 @@ public class NormalizedCoordinates extends CoordinateState {
toCoordinates
(
context
,
CameraCoordinates
.
class
);
}
@Override
public
boolean
withinBounds
(
Point
context
)
{
return
BOUNDS
.
includes
(
context
);
}
/** {@inheritDoc} */
@Override
public
Point
normalize
(
Point
context
)
{
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/Point.java
View file @
d670fb8a
...
...
@@ -571,6 +571,17 @@ public class Point extends Float implements Comparable<Point>, KdComparator<Poin
return
comparison
;
}
/**
* Checks whether the specified point is within the acceptable bounds of its coordinate state.
*
* @return <code>true</code> if specified point can be represented by this coordinate state,
* <code>false</code> otherwise
*/
public
boolean
withinBounds
()
{
return
state
.
withinBounds
(
this
);
}
}
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/ScreenCoordinates.java
View file @
d670fb8a
...
...
@@ -86,6 +86,12 @@ public class ScreenCoordinates extends CoordinateState {
context
.
setState
(
new
CameraCoordinates
(
context
,
Calibration
.
screenToCameraX
(
context
.
x
),
Calibration
.
screenToCameraY
(
context
.
y
)));
}
@Override
public
boolean
withinBounds
(
Point
context
)
{
Bounds2D
currentBounds
=
(
bounds
==
null
)
?
FULL_SCREEN
:
bounds
;
return
currentBounds
.
includes
(
context
);
}
/** {@inheritDoc} */
@Override
public
Point
normalize
(
Point
context
)
{
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/TableCoordinates.java
View file @
d670fb8a
...
...
@@ -31,6 +31,9 @@ import lu.list.itis.dkd.dbc.annotation.NonNull;
* @version 2.3.0
*/
public
class
TableCoordinates
extends
CoordinateState
{
private
static
final
Bounds2D
BOUNDS
=
new
Bounds2D
(
0
,
0
,
Calibration
.
getTableWidth
(),
Calibration
.
getTableHeight
());
/**
* Constructing an instance with the provided points.
*
...
...
@@ -52,8 +55,7 @@ public class TableCoordinates extends CoordinateState {
@Deprecated
public
void
toTable
(
@NonNull
Point
context
)
{
/**
* The conversion is naught as the point's coordinates are already given in this reference
* scheme!
* The conversion is naught as the point's coordinates are already given in this reference scheme!
*/
}
...
...
@@ -75,11 +77,16 @@ public class TableCoordinates extends CoordinateState {
context
.
setState
(
new
CameraCoordinates
(
context
,
Calibration
.
tableToCameraX
(
context
.
x
),
Calibration
.
tableToCameraY
(
context
.
y
)));
}
@Override
public
boolean
withinBounds
(
Point
context
)
{
return
BOUNDS
.
includes
(
context
);
}
/** {@inheritDoc} */
@Override
public
Point
normalize
(
Point
context
)
{
double
normx
=
context
.
x
/
Calibration
.
getTable
Width
();
double
normy
=
context
.
y
/
Calibration
.
getTable
Height
();
double
normx
=
context
.
x
/
BOUNDS
.
get
Width
();
double
normy
=
context
.
y
/
BOUNDS
.
get
Height
();
return
new
Point
((
float
)
normx
,
(
float
)
normy
,
context
.
getAngle
(),
NormalizedCoordinates
.
class
);
}
...
...
@@ -90,8 +97,8 @@ public class TableCoordinates extends CoordinateState {
// Preconditions.checkArgument((normalized.x >= 0) && (normalized.x <= 1));
// Preconditions.checkArgument((normalized.y >= 0) && (normalized.y <= 1));
double
tblx
=
(
normalized
.
x
*
Calibration
.
getTable
Width
());
double
tbly
=
(
normalized
.
y
*
Calibration
.
getTable
Height
());
double
tblx
=
(
normalized
.
x
*
BOUNDS
.
get
Width
());
double
tbly
=
(
normalized
.
y
*
BOUNDS
.
get
Height
());
return
new
Point
((
float
)
tblx
,
(
float
)
tbly
,
normalized
.
getAngle
(),
this
.
getClass
());
}
...
...
TULIP/src/lu/list/itis/dkd/tui/utility/graph/forcedirected/GraphCoordinates.java
View file @
d670fb8a
...
...
@@ -91,6 +91,11 @@ public class GraphCoordinates extends CoordinateState {
toCoordinates
(
context
,
CameraCoordinates
.
class
);
}
@Override
public
boolean
withinBounds
(
Point
context
)
{
return
bounds
.
includes
(
context
);
}
@Override
public
Point
normalize
(
Point
context
)
{
double
normx
=
((
context
.
x
-
bounds
.
x1
)
/
bounds
.
getWidth
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment