andrewdurkiewicz / CSE360

Group Project
MIT License
1 stars 0 forks source link

Not sure how to implement the Draw() method #25

Closed andrewdurkiewicz closed 6 years ago

andrewdurkiewicz commented 6 years ago

From B in the assignment:

You should have a class Icon. Optionally you could have also a class IconSquare or IconCircle. This class should have the method that draw the icon on the screen. Please name this method draw(). You can add as many parameters as you need. You should have an object icon for each line draw on the screen

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?

CodyRoberson commented 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.

andrewdurkiewicz commented 6 years ago

@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

CodyRoberson commented 6 years ago

ok i made an example

andrewdurkiewicz commented 6 years ago

@CodyRoberson @aztcole i got it i think can you guys tell me if i did the same thing again or did it right

andrewdurkiewicz commented 6 years ago

merging now

andrewdurkiewicz commented 6 years ago

@CodyRoberson plz pull now i have work in 20 min so asap thx

CodyRoberson commented 6 years ago

example.zip

andrewdurkiewicz commented 6 years ago

did you see the pushed code. i think i did it. Im not done but now the rest will be easy

andrewdurkiewicz commented 6 years ago

@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 image

then after adding another: image

andrewdurkiewicz commented 6 years ago

Maybe I am not looping correctly

CodyRoberson commented 6 years ago

okay. cool, thanks for your hard work. Am taking a look rn.

andrewdurkiewicz commented 6 years ago

havent pushed yet. its on my latest branch too late to delete other. will do tonight. pushing then going.

andrewdurkiewicz commented 6 years ago

@CodyRoberson update?

CodyRoberson commented 6 years ago

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.

CodyRoberson commented 6 years ago

did you get it working?

andrewdurkiewicz commented 6 years ago

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

andrewdurkiewicz commented 6 years ago

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

CodyRoberson commented 6 years ago

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.

andrewdurkiewicz commented 6 years ago

@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?

andrewdurkiewicz commented 6 years ago

I think you are right. I maybe changed something and broke it. But, its redefining it on repaint.

CodyRoberson commented 6 years ago

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

CodyRoberson commented 6 years ago

like putting files into a zip folder

andrewdurkiewicz commented 6 years ago

but, you are redefining it there. Can we test this?

CodyRoberson commented 6 years ago

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.

andrewdurkiewicz commented 6 years ago

I'm dumb. Please ignore. Give me a bit. I'll find it. I think, you may be redefining then adding.

andrewdurkiewicz commented 6 years ago

Yeah. Very good job on this btw

CodyRoberson commented 6 years ago

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.

andrewdurkiewicz commented 6 years ago

No, I agree.

andrewdurkiewicz commented 6 years ago

im going to make a void to print of whats in the array before and after. See if its in this

CodyRoberson commented 6 years ago

what branch are you working on rn?

andrewdurkiewicz commented 6 years ago

https://github.com/andrewdurkiewicz/CSE360/tree/observerimplement

andrewdurkiewicz commented 6 years ago

Pushing now Only cleaned up the whitespace

andrewdurkiewicz commented 6 years ago

OMG observable is an interface. Its just called subject

andrewdurkiewicz commented 6 years ago

@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?

andrewdurkiewicz commented 6 years ago

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

CodyRoberson commented 6 years ago

just typing up the best explanation that i can

CodyRoberson commented 6 years ago

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.

andrewdurkiewicz commented 6 years ago

Does what i'm doing make any sense to you here? Does it sound like a good idea? image

andrewdurkiewicz commented 6 years ago

I know the errors exist but, this would work. I'm sure of it

CodyRoberson commented 6 years ago

wait, why are you trying to do what i"m assigned?

andrewdurkiewicz commented 6 years ago

I had no clue. I am making a lot of progress. want to see what I got?

CodyRoberson commented 6 years ago

of course :)

andrewdurkiewicz commented 6 years ago

`package gui;

import java.util.ArrayList;

public class Nodes{ public ArrayList n = new 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);
}

}`

andrewdurkiewicz commented 6 years ago

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

andrewdurkiewicz commented 6 years ago

I cant fix the github syntax on it

CodyRoberson commented 6 years ago

nice

CodyRoberson commented 6 years ago

@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) {

andrewdurkiewicz commented 6 years ago

wait your up? btw i got it all working..

andrewdurkiewicz commented 6 years ago

everything

andrewdurkiewicz commented 6 years ago

check my push