Closed andrewdurkiewicz closed 6 years ago
If he means draw as in create the graphic
I don't know. I'll think on this.
If he means a method to simply add the icon to DrawPanelTwo,
I think our best option is to optimize and re implement the code in:
public void drop(DropTargetDropEvent dtde)
into the respective classes draw method. Then, it can notify it's observers.
@cody i have to go to work I get off at 11 and if i dont work tomorrow ill pull an all nighter till i finish Can you or @aztcole basically explain how the observer and observable work? I've been looking them up all over the web and I don't understand. But if you give me dumbed down version I may be able to implement it correctly. Right now my issue is just not understanding how it works
ok i made an example
@CodyRoberson @aztcole i got it i think can you guys tell me if i did the same thing again or did it right
merging now
@CodyRoberson plz pull now i have work in 20 min so asap thx
did you see the pushed code. i think i did it. Im not done but now the rest will be easy
@CodyRoberson look at my branch i have to go but for some reason when i try to loop through your array "to reprint it" it prints three of the same type. I don't think its me. I think its actually like this in memory. in DataHandler to be exact
then after adding another:
Maybe I am not looping correctly
okay. cool, thanks for your hard work. Am taking a look rn.
havent pushed yet. its on my latest branch too late to delete other. will do tonight. pushing then going.
@CodyRoberson update?
mmm just planning the design, also I have no idea why the string type stays the same sorry. I'm just going to re-design the DraggableIcon structure and related sub classes.
did you get it working?
just got off work. working on it now i figured out how to use eclipse debugger. I think there is a point where we make a comparison (i.e if(x == y);, where we are actually putting (i.e. if(x=y);) effectively redefining x as y. i had this issue with my last homework in 310
but its not in my code. Which means something is wrong with DataHandler. When looking at the heap, it seeps that it is literally changing the value of it. Though, let me test a bit more to find the exact location
DataHandler can't possible be at fault though, when it comes to holding onto the icons and arrows, it doesn't have any conditionals, just getters and setters.
@CodyRoberson Can you explain this in line 88 in DataHandler
IconRecord =temp.get(0); ArrowRecord = temp.get(1);
is get a built in function for ArrayList or is a function you made?
I think you are right. I maybe changed something and broke it. But, its redefining it on repaint.
so when you make an object output stream, you can only use one object. Therefore the root of the tree is needed so to speak. So both array lists are packed into another single array list.
When the object is imported, it becomes an array list of those array lists
temp.get(0) is just the first list temp.get(1) is the second
like putting files into a zip folder
but, you are redefining it there. Can we test this?
how do you mean? these functions are isolated from the rest of the program since they are called to load and save the diagram ONLY from the file menu.
I'm dumb. Please ignore. Give me a bit. I'll find it. I think, you may be redefining then adding.
Yeah. Very good job on this btw
thx, also only load does redefining, and that wipes out the whole thing. I don't see any connection to the problem of types tho.
No, I agree.
im going to make a void to print of whats in the array before and after. See if its in this
what branch are you working on rn?
Pushing now Only cleaned up the whitespace
OMG observable is an interface. Its just called subject
@CodyRoberson Help me think through this. Do I want to know as an observer when something is added, that I need to update my list of all objects, or of the added object. See, it may be better to store the relationships in an ArrayList of nodes. Where nodes have private starting icons, ending icons and arrows. We add this as observable and update on changes. What do you think?
Honestly dude, Im thinking about making another branch. Ill delete after due date. Its just i like this idea to the point where i need to restart from where we were
just typing up the best explanation that i can
The observer basically presides over the observable objects that are added to it.
ex:
addObserver(/*observer object here*/)
When an observable object that belongs to an observer changes in some way that we want to let everyone know, we call these methods:
setChanged(); notifyObservers();
the observer then runs it's update method where Observable o
is a reference to the object that notified the observer. From there, the update method can do whatever with that.
Does what i'm doing make any sense to you here? Does it sound like a good idea?
I know the errors exist but, this would work. I'm sure of it
wait, why are you trying to do what i"m assigned?
I had no clue. I am making a lot of progress. want to see what I got?
of course :)
`package gui;
import java.util.ArrayList;
public class Nodes{
public ArrayList
DraggableIcon start;
DraggableIcon end;
DrawArrow arrow;
public Nodes() {
}
public Nodes(DraggableIcon st){
this.start = st;
}
public Nodes(DraggableIcon st, DraggableIcon e, DrawArrow a) {
this.start = st;
this.end = e;
arrow = a;
}
public void addSingle(Nodes addthis) {
n.add(addthis);
}
public void addConnect(Nodes addthis) {
n.add(addthis);
}
}`
basically, this allows us to add an observer. this is why i'm doing it. see, this class is to extend observable then the textarea implements observer
I cant fix the github syntax on it
nice
@andrewdurkiewicz
I noticed that you added your node to dragGestureRecognized, make sure to verify that the n object doesn't get deleted when this method call ends, because it might invalidate the observable ovject public void dragGestureRecognized(DragGestureEvent dge) {
}
wait your up? btw i got it all working..
everything
check my push
From B in the assignment:
The way I have it now, iconCircle and iconSquare extend DraggableIcon. I have no clue how Draw would be used in this case. Any Ideas?