This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Multiple instance events anim develop #230
Closed
ChrisEberleSchool
wants to merge
16
commits into
xspanger3770:develop
from
ChrisEberleSchool:multiple-instance-events-anim-develop
Closed
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
de56d73
- animation instances fix
ChrisEberleSchool acc95df
- fixed issue
ChrisEberleSchool 849b37d
- multiple instanced events fixed
ChrisEberleSchool 28ce970
- closing flag reset
ChrisEberleSchool 7640e76
- all issues resolved!
ChrisEberleSchool 7aa2a29
Merge pull request #252 from xspanger3770/develop
xspanger3770 f70548a
Merge pull request #253 from xspanger3770/main
xspanger3770 7993194
update general info in README.md
xspanger3770 4ac8264
Merge pull request #254 from xspanger3770/readme
xspanger3770 44086f7
Merge branch 'xspanger3770:main' into multiple-instance-events-anim-d…
ChrisEberleSchool 6ce4fa5
- update branch to get ready for new changes
ChrisEberleSchool f7ecda4
revert readme
ChrisEberleSchool c81c321
- using UUID of archived quakes to handle instances
ChrisEberleSchool f2b3102
- BugFix final commit
ChrisEberleSchool ae52079
- removed unneccessary imports
ChrisEberleSchool 00c58a9
- using contains method instead of isOpened method
ChrisEberleSchool File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,18 @@ | |
import java.util.Locale; | ||
import java.util.stream.Collectors; | ||
|
||
import java.awt.event.WindowAdapter; | ||
import java.awt.event.WindowEvent; | ||
import java.util.ArrayList; | ||
import java.util.UUID; | ||
|
||
public class EarthquakeListPanel extends JPanel { | ||
private double scroll = 0; | ||
protected int mouseY = -999; | ||
|
||
// Holds the list of currently opened archived quakes | ||
private ArrayList<UUID> openedQuakes = new ArrayList<UUID>(); | ||
|
||
public static final DecimalFormat f1d = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH)); | ||
private static final int cell_height = 50; | ||
|
||
|
@@ -65,6 +73,8 @@ public EarthquakeListPanel(Frame parent, List<ArchivedQuake> archivedQuakes) { | |
} | ||
}); | ||
|
||
|
||
|
||
addMouseListener(new MouseAdapter() { | ||
@Override | ||
public void mousePressed(MouseEvent e) { | ||
|
@@ -77,15 +87,34 @@ public void mousePressed(MouseEvent e) { | |
|
||
ArchivedQuake quake = filtered.get(i); | ||
|
||
UUID quakeUuid = quake.getUuid(); | ||
|
||
if (quake != null && e.getButton() == MouseEvent.BUTTON3 && !isMouseInGoUpRect) { | ||
quake.setWrong(!quake.isWrong()); | ||
} | ||
|
||
if(e.getButton() == MouseEvent.BUTTON1) { | ||
if(isMouseInGoUpRect) { | ||
scroll = 0; | ||
}else if (quake != null ) { | ||
new ArchivedQuakeUI(parent, quake).setVisible(true); | ||
} | ||
else if (quake != null && !isOpened(quakeUuid) ) { | ||
// Create Instance of quakeUi panel | ||
ArchivedQuakeUI quakeUi = new ArchivedQuakeUI(parent, quake); | ||
// set the panel to be visible | ||
quakeUi.setVisible(true); | ||
// add the quake to the list of opened panels | ||
openedQuakes.add(quakeUuid); | ||
|
||
// When quake panel is closed, remove quake from the ArrayList of openedQuakes | ||
quakeUi.addWindowListener(new WindowAdapter() { | ||
@Override | ||
public void windowClosing(WindowEvent e) { | ||
openedQuakes.remove(quakeUuid); | ||
} | ||
public void windowClosed(WindowEvent e) { | ||
openedQuakes.remove(quakeUuid); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
|
@@ -109,6 +138,23 @@ public void mouseMoved(MouseEvent e) { | |
}); | ||
} | ||
|
||
/** | ||
* @author Chris Eberle | ||
* @param UUID of an archived quake | ||
* @return boolean representing whether a quakepanel is open | ||
* | ||
* Compares the inputed id with all id's stored in openedquakes list | ||
*/ | ||
private boolean isOpened(UUID id) { | ||
// loop through openedquakes | ||
for( UUID i: openedQuakes) { | ||
if( i == id) { | ||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to use the ArrayList builtin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just replaced my isOpened method with contains! It isn't a huge optimization given how small the openedQuakes ArrayList will be but nonetheless makes the code cleaner so great catch! |
||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void paint(Graphics gr) { | ||
super.paint(gr); | ||
|
@@ -237,4 +283,4 @@ public void paint(Graphics gr) { | |
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to remove the uuid twice on closing and closed event?
is there a case where 1 of these events doesnt do what it is supposed to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty much for redundancy, I did research and I found it is best to include both! Essentially I could just use windowClosing and it would pretty much cover all cases but I'm pretty sure there are some cases that it wont cover that windowClosed will cover
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, just wanted to know the reason around it.