Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TULIP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP
Commits
f1f1e80c
Commit
f1f1e80c
authored
Nov 04, 2015
by
Eric Tobias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with left and right space getters being out of range
parent
b2d45017
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
18 deletions
+49
-18
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
+49
-18
No files found.
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
View file @
f1f1e80c
...
@@ -59,8 +59,8 @@ public class SpatialMatrix {
...
@@ -59,8 +59,8 @@ public class SpatialMatrix {
* The object to add.
* The object to add.
*/
*/
public
synchronized
void
add
(
TangibleObject
object
)
{
public
synchronized
void
add
(
TangibleObject
object
)
{
horizontal
.
add
(
findHorizontalIndexFor
(
object
),
object
);
horizontal
.
add
(
findHorizontalIndexFor
(
object
,
false
),
object
);
vertical
.
add
(
findVerticalIndexFor
(
object
),
object
);
vertical
.
add
(
findVerticalIndexFor
(
object
,
false
),
object
);
}
}
/**
/**
...
@@ -113,10 +113,18 @@ public class SpatialMatrix {
...
@@ -113,10 +113,18 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* @return The index to add the element or the size of the list if the element should be added
* at the end.
* at the end.
*/
*/
private
synchronized
int
findHorizontalIndexFor
(
TangibleObject
object
)
{
private
synchronized
int
findHorizontalIndexFor
(
TangibleObject
object
,
boolean
strict
)
{
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
if
(
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
())
<=
0
)
{
int
comparisonResult
=
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
());
return
index
;
if
(
strict
)
{
if
(
comparisonResult
<
0
)
{
return
index
;
}
}
else
{
if
(
comparisonResult
<=
0
)
{
return
index
;
}
}
}
}
}
return
horizontal
.
size
();
return
horizontal
.
size
();
...
@@ -132,12 +140,20 @@ public class SpatialMatrix {
...
@@ -132,12 +140,20 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* @return The index to add the element or the size of the list if the element should be added
* at the end.
* at the end.
*/
*/
private
synchronized
int
findHorizontalIndexFor
(
int
objectId
)
{
private
synchronized
int
findHorizontalIndexFor
(
int
objectId
,
boolean
strict
)
{
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
if
(
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
())
<=
0
)
{
int
comparisonResult
=
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
());
return
index
;
if
(
strict
)
{
if
(
comparisonResult
<
0
)
{
return
index
;
}
}
else
{
if
(
comparisonResult
<=
0
)
{
return
index
;
}
}
}
}
}
return
horizontal
.
size
();
return
horizontal
.
size
();
...
@@ -154,10 +170,17 @@ public class SpatialMatrix {
...
@@ -154,10 +170,17 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* @return The index to add the element or the size of the list if the element should be added
* at the end.
* at the end.
*/
*/
private
synchronized
int
findVerticalIndexFor
(
TangibleObject
object
)
{
private
synchronized
int
findVerticalIndexFor
(
TangibleObject
object
,
boolean
strict
)
{
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
if
(
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
())
<=
0
)
{
int
comparisonResult
=
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
());
return
index
;
if
(
strict
)
{
if
(
comparisonResult
<
0
)
{
return
index
;
}
}
else
{
if
(
comparisonResult
<=
0
)
{
return
index
;
}
}
}
}
}
return
vertical
.
size
();
return
vertical
.
size
();
...
@@ -173,12 +196,20 @@ public class SpatialMatrix {
...
@@ -173,12 +196,20 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* @return The index to add the element or the size of the list if the element should be added
* at the end.
* at the end.
*/
*/
private
synchronized
int
findVerticalIndexFor
(
int
objectId
)
{
private
synchronized
int
findVerticalIndexFor
(
int
objectId
,
boolean
strict
)
{
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
if
(
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
())
<=
0
)
{
int
comparisonResult
=
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
());
return
index
;
if
(
strict
)
{
if
(
comparisonResult
<
0
)
{
return
index
;
}
}
else
{
if
(
comparisonResult
<=
0
)
{
return
index
;
}
}
}
}
}
return
vertical
.
size
();
return
vertical
.
size
();
...
@@ -200,7 +231,7 @@ public class SpatialMatrix {
...
@@ -200,7 +231,7 @@ public class SpatialMatrix {
* left of the given object.
* left of the given object.
*/
*/
public
synchronized
List
<
TangibleObject
>
leftOf
(
int
objectId
)
{
public
synchronized
List
<
TangibleObject
>
leftOf
(
int
objectId
)
{
int
index
=
findHorizontalIndexFor
(
objectId
);
int
index
=
findHorizontalIndexFor
(
objectId
,
false
);
return
new
ArrayList
<>(
horizontal
.
subList
(
0
,
index
));
return
new
ArrayList
<>(
horizontal
.
subList
(
0
,
index
));
}
}
...
@@ -220,7 +251,7 @@ public class SpatialMatrix {
...
@@ -220,7 +251,7 @@ public class SpatialMatrix {
* right of the given object.
* right of the given object.
*/
*/
public
synchronized
List
<
TangibleObject
>
rightOf
(
int
objectId
)
{
public
synchronized
List
<
TangibleObject
>
rightOf
(
int
objectId
)
{
int
index
=
findHorizontalIndexFor
(
objectId
)
+
1
;
int
index
=
findHorizontalIndexFor
(
objectId
,
true
)
;
return
new
ArrayList
<>(
horizontal
.
subList
(
index
,
horizontal
.
size
()));
return
new
ArrayList
<>(
horizontal
.
subList
(
index
,
horizontal
.
size
()));
}
}
...
@@ -240,7 +271,7 @@ public class SpatialMatrix {
...
@@ -240,7 +271,7 @@ public class SpatialMatrix {
* above the given object.
* above the given object.
*/
*/
public
synchronized
List
<
TangibleObject
>
above
(
int
objectId
)
{
public
synchronized
List
<
TangibleObject
>
above
(
int
objectId
)
{
int
index
=
findVerticalIndexFor
(
objectId
);
int
index
=
findVerticalIndexFor
(
objectId
,
false
);
return
new
ArrayList
<>(
vertical
.
subList
(
0
,
index
));
return
new
ArrayList
<>(
vertical
.
subList
(
0
,
index
));
}
}
...
@@ -260,7 +291,7 @@ public class SpatialMatrix {
...
@@ -260,7 +291,7 @@ public class SpatialMatrix {
* the given object.
* the given object.
*/
*/
public
synchronized
List
<
TangibleObject
>
below
(
int
objectId
)
{
public
synchronized
List
<
TangibleObject
>
below
(
int
objectId
)
{
int
index
=
findVerticalIndexFor
(
objectId
)
+
1
;
int
index
=
findVerticalIndexFor
(
objectId
,
true
)
;
return
new
ArrayList
<>(
vertical
.
subList
(
index
,
vertical
.
size
()));
return
new
ArrayList
<>(
vertical
.
subList
(
index
,
vertical
.
size
()));
}
}
...
...
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