From 674f7979c68ecdb67957e221f07bd5946a27098d Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 3 Apr 2017 11:45:46 -0500 Subject: [PATCH] Minor optimizations to drawing code to reduce errors and improve drawing speed. --- .externalToolBuilders/Makejar.launch | 14 ++++++++++++++ .project | 10 ++++++++++ projectBuilder.xml | 6 ++++++ sigIRCv2.jar | Bin 0 -> 350 bytes src/sig/MyPanel.java | 17 +++++++++++++---- src/sig/ScrollingText.java | 13 ++++++++++++- src/sig/TwitchEmote.java | 23 +++++++++++++++++++---- src/sig/sigIRC.java | 1 - 8 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 .externalToolBuilders/Makejar.launch create mode 100644 projectBuilder.xml create mode 100644 sigIRCv2.jar diff --git a/.externalToolBuilders/Makejar.launch b/.externalToolBuilders/Makejar.launch new file mode 100644 index 0000000..1d6d52a --- /dev/null +++ b/.externalToolBuilders/Makejar.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/.project b/.project index 79e646c..2251988 100644 --- a/.project +++ b/.project @@ -10,6 +10,16 @@ + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/Makejar.launch + + + org.eclipse.jdt.core.javanature diff --git a/projectBuilder.xml b/projectBuilder.xml new file mode 100644 index 0000000..682fdab --- /dev/null +++ b/projectBuilder.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/sigIRCv2.jar b/sigIRCv2.jar new file mode 100644 index 0000000000000000000000000000000000000000..ba08ee080763f946f8291983368b6347fb2eef5f GIT binary patch literal 350 zcmWIWW@h1HVBlb2IJmCKivbC6GO#fCx`sIFdiuHP|2xIN5CB!m!EgYmwA@-jGzzFZ z9f(DM5U$kM(a+P(H8@1i*Nu@u04xtO6{HpfKKq_I?c=ShcahgySL@uF^P7VVt{6Xf zT6D%)s8Gkl=bT3i}?$0};XQIkL2LX(Sw zMCW|&=K9nv0 && y0) { + return true; + } + return false; + } + public int FindLeftMostCornerInDisplay() { if (x-shadowSize>0) { return Math.min((int)x-shadowSize, sigIRC.panel.getWidth()); diff --git a/src/sig/TwitchEmote.java b/src/sig/TwitchEmote.java index 4ea39e0..4d1805d 100644 --- a/src/sig/TwitchEmote.java +++ b/src/sig/TwitchEmote.java @@ -6,6 +6,7 @@ public class TwitchEmote { int x=0; //X Offset int y=0; //Y Offset ScrollingText text; + boolean active=true; public TwitchEmote(Emoticon emote, ScrollingText textref, int x, int y) { this.emote=emote; @@ -19,9 +20,10 @@ public class TwitchEmote { sigIRC.panel.repaint( Math.max(x,0), Math.max(y, 0), - Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth())+1, - Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight())+1); - if (x+emote.getImage().getWidth()<0) { + Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth()), + Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight())); + if (x+emote.getImage().getWidth()<0 || text==null || !text.isActive()) { + active=false; return false; } else { return true; @@ -29,6 +31,19 @@ public class TwitchEmote { } public void draw(Graphics g) { - g.drawImage(emote.getImage(), (int)(text.getX()+x), (int)(text.getY()+y), sigIRC.panel); + if (WithinBounds((int)(text.getX()+x), (int)(text.getY()+y), emote.getImage().getWidth(), emote.getImage().getHeight())) { + g.drawImage(emote.getImage(), (int)(text.getX()+x), (int)(text.getY()+y), sigIRC.panel); + } + } + + public boolean isActive() { + return active; + } + + private boolean WithinBounds(double x, double y, double w, double h) { + if (x0 && y0) { + return true; + } + return false; } } diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java index 10b280c..f92e328 100644 --- a/src/sig/sigIRC.java +++ b/src/sig/sigIRC.java @@ -266,7 +266,6 @@ public class sigIRC{ f.add(sigIRC.panel); f.pack(); f.setVisible(true); - button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,panel.getHeight()/2); }