« first day    last day (33 days later) » 

3:26 PM
Hi Mr
When you're online, please notify me.
 
 
3 hours later…
6:03 PM
@LanaM Back from the town.
 
Oh superbe
how was your day?
 
Well: two shops, two doctors, one meeting, some train riding...
 
that was a pretty busy day.
are you not tired?
 
One newspaper, 2 Sudoku, 1 crossword. Yes: busy.
Not particularly tired. Had a coffee a few hours ago ;-)
 
Can i ask you if you work?
 
6:06 PM
You mean whether I have a job? Not any more, just a little teaching-
 
So you worked as a software developer or something like that?
 
You could say that, although it was a little more, uh, sophisticated.
 
i see :)
Can i start bothering you?
;)
 
Go ahead.
 
:D
So i've been able to do the arrayList <Connection> with the two fields being NamedShape
 
6:11 PM
OK
 
But the thing is that when i detect the collisions with the line, it will first detect one collision (line collides with rectangle) which means that i will have a null value into my arraylist <connection>: con.add(0,( new Connection(new NamedShape(null,null), new NamedShape(nana1, f1)))); and then the second collision(line collides with rectangle) : con.add(0,(new Connection(new NamedShape(nana2, f2), new NamedShape(null,null)))); and when i run this, the arraylist "Connection" is of size 2,
meaning that it's not adding it to the same index but instead i'm having data into my arraylist "Connection" in index (0) and (1)
Should i post a question so that you can see clearly what i mean?
 
A 'new NamedShape(null, null)` doesn't make sense: nothing being written within no shape??
 
i wanted it to be replaced by the second collision, that is it ignored the "null" value and replace the data.
I can't leave it blank too, it doesn't work. That's why i put null there.
 
If you have one "ID"+Ellipse and one "Student"+Rectangle to form two NamedShapes you have one Connection connecting these two.
What do you mean by "collision"? Things don't "collide" here now, do they?
List<NamedShape> shapes = new ArrayList<>();
shapes.add( new NamedShape( "Humpty-Dumpty",
new Ellipse2D.Double( x, y, w, h ) ) );
shapes.add( new NamedShape( "John Doe",
new Rectangle2D.Double( u, v, a, b ) ) );
List<Connection> conns = ...;
conns.add( new Connection( shapes.get(0), shapes.get(1) ) );
This is the basic mechanism. (You may have to use a more flexible approach when you know how to extract that data from the DB.)
 
6:28 PM
In fact i have two IF Statement, one IF statement check if the line collides with the Ellipse and another IF statement that checks if the line connects with Rectangle. So inside each if statement, for e.g for Ellipse, it will retrieve the shape index that collides with the rectangle. In the other If statement it will retrieve another shape index that collides with rectangle. So now am stuck, i have two indexes;
One for ellipse, one for rectangle both in different if statement and i can't like those two indexes. Do you want me to send my code somewhere so that you can see what's wrong?
 
Did you read what I wrote? You should not have two Connection objects.
 
i can't link those two indexes**
this is not good then?
public class Connection {
private NamedShape namedShape1;
private NamedShape namedShape2;
public Connection(NamedShape namedShape1,NamedShape namedShape2){
this.namedShape1 = namedShape1;
this.namedShape2 = namedShape2;
}

public NamedShape getNamedShape1(){
return namedShape1;
}
public NamedShape getNamedShape2(){
return namedShape2;
}

public void setNamedShape1(){
this.namedShape1 = namedShape1;
}

public void setNamedShape2(){
this.namedShape2 = namedShape2;
}
}
 
Of course it is fine. It combines two references to NamedShapes, just like one line connects two shapes with text in them.
 
<You should not have two Connection objects> I can't understand this.
 
How many lines are there between the Ellipse and the Rectangle?
 
6:34 PM
Only one!
and the start of the line detect a shape and the end of the line detect another shape
 
We have decided to call this "line" a Connection. One line, one Connection.
 
My way of adding data to the ArrayList "Connection" is not the right way? con.add(0,(new Connection(new NamedShape(nana2, f2), new NamedShape(null,null))));
 
These ends aren't "detectives" ;-) They are attached to whatever you set in the constructor of class Connection.
Ask yourself this: What does a new NamedShape(null, null) mean? The Shape of this NamedShape is NOTHING, the text String is NOTHING. So, NOTHING drawn around NOTHING...?
 
yes, it doesn't make sense
:(
Can i just post my code and may be you can understand why i put the null value although it doesn't make sense to put the null value.
 
So, a line (Connection) connecting two NamedShapes needs two decently constructed NamedShapes in its constructor.
I may not understand a code along these lines. Can you describe what you want to do?
What do you want to represent?
 
6:47 PM
Ok. So i already have my shapes. It detects connection between shapes, ok that's fine. I want to add the two shape that connects along with its name to the ArrayList<Connection>.
That's all what i'm trying to do.
 
List<Connection> conns = ...;
conns.add( new Connection( shapes.get(0), shapes.get(1) ) );
You have your shapes in the ArrayList<NamedShape>. They may not be at index 0 and 1, but essentially they must be somewhere in that list.
I have no idea how your overall construction process is meant to proceed, so I can't really say "do this" or "do that".
 
7:07 PM
Please see at if (currentAction == 3) {
this is where i have trouble with the indexes.
I can't reach them.
If the collisions ==2 it must add the shape indexes for Ellipse and Rectangle but i can't reach the two indexes together to add them to my arraylist
That's where am stuck.
 
I don't think you should put the Shape resulting from a drawLine(...) into the List containing ellipses and rectangles. Now, assuming you have
Shape line = drawLine(...);
and the List<NamedShape> shapes you can write:
int iEll = -1;
int iRect = -1;
for( NamedShape ns: shapes ){
Shape s = ns.getShape();
if( s.intersects(...)){
I have to start over.
and the List<NamedShape> shapes you can write:
NamedShape ell = null;
NamedShape rect = null;
for( NamedShape ns: shapes ){
Shape s = ns.getShape();
if( s.intersects(...) ){ // intersects line
    if( s instanceof Ellipse2D ){
ell = ns;
} else {
}
}
Now, if ell and rect are both not null, you can
Connection conn = new Connection( ell, rect );
and add this to the List of Connections.
Makes sense?
rect = ns; // the missing statement after else
This editing isn't working too well...
The idea is to run through the list containing ellipses and rectangles and check whether a line intersects. If so, store the NamedShape. At the end, if you have a rectangle and an ellipse, you know the two shapes the line connects. (Although, this is not a good way to construct a graphic.)
You should check, when you define one end point of a line (by clicking on MB1) into which bounding rectangle the point falls: => 1st shape. Same for the second point (again, MB1) => 2nd shape. Now create Connection with both shapes. - Don't keep the line. You can always draw the line between the mid points of any two shapes.
 
7:29 PM
I do understand everything that you've posted. Am editing my codes and see if it works with this new logic.
 
OK. I'll retire. I'll be around tomorrow, so if something comes up, you can ask me.
good night, cu
 
7:44 PM
Thank you sir :)
Good night
take care
 
 
1 hour later…
8:55 PM
Sir, i've been able to do it :D thank you so much, now it's printing size 1 meaning that 2 data are added into the arrayList.
But i would liked to get the content of this arraylist "Connection" now.
 

« first day    last day (33 days later) »