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
e90a6339
Commit
e90a6339
authored
Oct 29, 2015
by
Eric Tobias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.1.2 - Added ShapeCorona and related builders.
parent
8c3c1a4d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
289 additions
and
9 deletions
+289
-9
TULIP/properties.properties
TULIP/properties.properties
+1
-1
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
+84
-7
TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java
...lu/list/itis/dkd/tui/space/SpatialPositioningManager.java
+1
-1
TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java
...P/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java
+77
-0
TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java
...dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java
+79
-0
TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java
...tis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java
+47
-0
No files found.
TULIP/properties.properties
View file @
e90a6339
# Properties for the Logger
logger.event.output.location
=
log.txt
logger.event.output.enabled
=
false
logger.level
=
SEVERE
logger.level
=
ALL
logger.event.configuration
=
logger.xml
# Widget IDs to be mapped
...
...
TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
View file @
e90a6339
...
...
@@ -17,9 +17,12 @@
package
lu.list.itis.dkd.tui.space
;
import
lu.list.itis.dkd.dbc.annotation.NonNullByDefault
;
import
lu.list.itis.dkd.tui.TangibleObjectManager
;
import
lu.list.itis.dkd.tui.adapter.TangibleObject
;
import
lu.list.itis.dkd.tui.widget.BaseWidget
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author Eric Tobias [eric.tobias@list.lu]
...
...
@@ -41,7 +44,7 @@ public class SpatialMatrix {
* @param object
* The object to add.
*/
public
void
add
(
TangibleObject
object
)
{
public
synchronized
void
add
(
TangibleObject
object
)
{
horizontal
.
add
(
findHorizontalIndexFor
(
object
),
object
);
vertical
.
add
(
findVerticalIndexFor
(
object
),
object
);
}
...
...
@@ -53,7 +56,7 @@ public class SpatialMatrix {
* @param object
* The object to remove.
*/
public
void
remove
(
TangibleObject
object
)
{
public
synchronized
void
remove
(
TangibleObject
object
)
{
horizontal
.
remove
(
object
);
vertical
.
remove
(
object
);
}
...
...
@@ -81,7 +84,7 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
private
int
findHorizontalIndexFor
(
TangibleObject
object
)
{
private
synchronized
int
findHorizontalIndexFor
(
TangibleObject
object
)
{
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
if
(
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
())
<=
0
)
{
return
index
;
...
...
@@ -90,6 +93,28 @@ public class SpatialMatrix {
return
horizontal
.
size
();
}
/**
* Method used to find the index of the first horizontal object whose x-axis coordinate is
* bigger than this object's. Returns the size of the horizontal list if no such element could
* be found.
*
* @param objectId
* The ID of the object to look up the insertion index for.
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
private
synchronized
int
findHorizontalIndexFor
(
int
objectId
)
{
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
for
(
int
index
=
0
;
index
<
horizontal
.
size
();
index
++)
{
if
(
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getX
(),
horizontal
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getX
())
<=
0
)
{
return
index
;
}
}
return
horizontal
.
size
();
}
/**
* Method used to find the index of the first horizontal object whose x-axis coordinate is
* bigger than this object's. Returns the size of the horizontal list if no such element could
...
...
@@ -100,7 +125,7 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
private
int
findVerticalIndexFor
(
TangibleObject
object
)
{
private
synchronized
int
findVerticalIndexFor
(
TangibleObject
object
)
{
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
if
(
Double
.
compare
(
object
.
getPosition
().
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
())
<=
0
)
{
return
index
;
...
...
@@ -109,14 +134,66 @@ public class SpatialMatrix {
return
vertical
.
size
();
}
public
void
printLists
()
{
/**
* Method used to find the index of the first horizontal object whose x-axis coordinate is
* bigger than this object's. Returns the size of the horizontal list if no such element could
* be found.
*
* @param objectId
* The ID of the object to look up the insertion index for.
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
private
synchronized
int
findVerticalIndexFor
(
int
objectId
)
{
BaseWidget
widget
=
TangibleObjectManager
.
getWidget
(
objectId
);
for
(
int
index
=
0
;
index
<
vertical
.
size
();
index
++)
{
if
(
Double
.
compare
(
widget
.
getPosition
(
objectId
).
toScreenCoordinates
().
getY
(),
vertical
.
get
(
index
).
getPosition
().
toScreenCoordinates
().
getY
())
<=
0
)
{
return
index
;
}
}
return
vertical
.
size
();
}
/**
* Method used to retrieve all {@link TangibleObject} instances to the left of the parameterized
* object (by ID). The method will return a new list build from the sublist of the horizontal
* space.<br />
* To determine whether something is "left", the method will make a sub-list of all elements
* with a lower index in the list than the parameterized object.
*
* @param objectId
* The object for which to retrieve all objects to the left of.
* @return A {@link List} of {@link TangibleObject} instances which are considered to be to the
* left of the given object.
*/
public
synchronized
List
<
TangibleObject
>
leftOf
(
int
objectId
)
{
int
index
=
findHorizontalIndexFor
(
objectId
);
return
new
ArrayList
<>(
horizontal
.
subList
(
index
,
horizontal
.
size
()));
}
public
synchronized
List
<
TangibleObject
>
rightOf
(
int
objectId
)
{
int
index
=
findHorizontalIndexFor
(
objectId
);
return
new
ArrayList
<>(
horizontal
.
subList
(
0
,
index
));
}
public
synchronized
List
<
TangibleObject
>
above
(
int
objectId
)
{
int
index
=
findVerticalIndexFor
(
objectId
);
return
new
ArrayList
<>(
vertical
.
subList
(
0
,
index
));
}
public
synchronized
List
<
TangibleObject
>
below
(
int
objectId
)
{
int
index
=
findHorizontalIndexFor
(
objectId
);
return
new
ArrayList
<>(
horizontal
.
subList
(
index
,
vertical
.
size
()));
}
String
printLists
()
{
StringBuilder
verticalBuilder
=
new
StringBuilder
();
StringBuilder
horizontalbuilder
=
new
StringBuilder
();
vertical
.
forEach
(
object
->
verticalBuilder
.
append
(
object
.
getObjectId
()
+
", "
));
//$NON-NLS-1$
horizontal
.
forEach
(
object
->
horizontalbuilder
.
append
(
object
.
getObjectId
()
+
", "
));
//$NON-NLS-1$
System
.
out
.
println
(
"Vertical : "
+
verticalBuilder
.
toString
());
//$NON-NLS-1$
System
.
out
.
println
(
"Horizontal : "
+
horizontalbuilder
.
toString
());
//$NON-NLS-1$
return
"Vertical : "
+
verticalBuilder
.
toString
()
+
"\n"
+
"Horizontal : "
+
horizontalbuilder
.
toString
();
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
\ No newline at end of file
TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java
View file @
e90a6339
...
...
@@ -107,6 +107,6 @@ public class SpatialPositioningManager implements SpatialEventListener {
logger
.
log
(
Level
.
SEVERE
,
"Spatial event type \""
+
event
.
getType
()
+
"\" not recognized!"
);
//$NON-NLS-1$ //$NON-NLS-2$
break
;
}
spatialMatrix
.
printLists
(
);
System
.
out
.
println
(
spatialMatrix
.
printLists
()
);
}
}
\ No newline at end of file
TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java
0 → 100644
View file @
e90a6339
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package
lu.list.itis.dkd.tui.widget.corona
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.corona.builder.BaseShapeCoronaBuilder
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.Graphics2D
;
import
java.awt.Stroke
;
import
java.awt.geom.AffineTransform
;
/**
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.1
* @version 2.1.2
*/
public
class
ShapeCorona
extends
Corona
{
private
Color
colour
=
Color
.
GRAY
;
private
int
borderWidth
=
20
;
/**
* Constructor building all fields and calling the implicit super constructor using a
* {@link BaseShapeCoronaBuilder} instance holding all values.
*
* @param builder
* The {@link BaseShapeCoronaBuilder} instance holding all values.
*/
public
ShapeCorona
(
BaseShapeCoronaBuilder
<?>
builder
)
{
super
(
builder
);
}
/** {@inheritDoc} */
@Override
public
void
paint
(
Graphics2D
canvas
)
{
if
(!
active
)
{
return
;
}
centre
.
toScreenCoordinates
();
if
(
initialTranslation
!=
null
)
{
initialTranslation
.
toScreenCoordinates
();
}
Point
drawAt
=
centre
.
add
(
initialTranslation
);
AffineTransform
transformation
=
new
AffineTransform
();
transformation
.
translate
(
drawAt
.
getX
(),
drawAt
.
getY
());
if
(
rotateWithHandle
)
{
transformation
.
rotate
(
drawAt
.
getAngle
());
}
Stroke
oldStroke
=
canvas
.
getStroke
();
canvas
.
setStroke
(
new
BasicStroke
(
borderWidth
));
canvas
.
draw
(
shape
);
canvas
.
setStroke
(
oldStroke
);
canvas
.
setPaint
(
colour
);
canvas
.
fill
(
transformation
.
createTransformedShape
(
shape
));
}
}
\ No newline at end of file
TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java
0 → 100644
View file @
e90a6339
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package
lu.list.itis.dkd.tui.widget.corona.builder
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.corona.Corona
;
import
lu.list.itis.dkd.tui.widget.corona.ShapeCorona
;
import
java.awt.Color
;
/**
* {@link CoronaBuilder} extension building {@link ShapeCorona} coronas.
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.1
* @version 2.1.2
* @param <B>
* The concrete builder.
*/
public
abstract
class
BaseShapeCoronaBuilder
<
B
extends
BaseShapeCoronaBuilder
<
B
>>
extends
CoronaBuilder
<
B
>
{
public
Color
colour
=
Color
.
GRAY
;
public
int
borderWidth
=
20
;
/**
* Constructor setting the centre of the corona.
*
* @param centre
* The centre of the corona, usually the centre of the handle.
*/
protected
BaseShapeCoronaBuilder
(
Point
centre
)
{
super
(
centre
);
}
/**
* Method for setting the colour of the shape drawn for this {@link Corona}.
*
* @param color
* The colour the shape should be filled with.
* @return An instance of this builder for chain calling.
*/
@SuppressWarnings
(
"unchecked"
)
public
B
withColor
(
Color
color
)
{
this
.
colour
=
color
;
return
(
B
)
this
;
}
/**
* Method for setting the width of the border to draw around the shape.
*
* @param width
* The width of the line to draw the border with.
* @return An instance of this builder for chain calling.
*/
@SuppressWarnings
(
"unchecked"
)
public
B
withBorderWidth
(
int
width
)
{
this
.
borderWidth
=
width
;
return
(
B
)
this
;
}
/** {@inheritDoc} */
@Override
public
abstract
ShapeCorona
build
();
}
\ No newline at end of file
TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java
0 → 100644
View file @
e90a6339
/**
* Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
*
* This file is part of TULIP.
*
* TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation, version 3 of the
* License.
*
* TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package
lu.list.itis.dkd.tui.widget.corona.builder
;
import
lu.list.itis.dkd.tui.utility.Point
;
import
lu.list.itis.dkd.tui.widget.corona.ShapeCorona
;
/**
* {@link ShapeCoronaBuilder} class used to construct a {@link ShapeCorona} corona by providing
* methods to set all parameters and permutations thereof.
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 2.1
* @version 2.1.2
*/
public
class
ShapeCoronaBuilder
extends
BaseShapeCoronaBuilder
<
ShapeCoronaBuilder
>
{
/**
* Constructor setting the centre of the corona.
*
* @param centre
* The centre of the corona, usually the centre of the handle.
*/
protected
ShapeCoronaBuilder
(
Point
centre
)
{
super
(
centre
);
}
/** {@inheritDoc} */
@Override
public
ShapeCorona
build
()
{
return
new
ShapeCorona
(
this
);
}
}
\ No newline at end of file
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