Minor optimizations to drawing code to reduce errors and improve drawing
speed.
This commit is contained in:
parent
70af0725b0
commit
674f7979c6
14
.externalToolBuilders/Makejar.launch
Normal file
14
.externalToolBuilders/Makejar.launch
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||||
|
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||||
|
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${resource}"/>
|
||||||
|
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||||
|
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="sigIRCv2"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/sigIRCv2/projectBuilder.xml}"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||||
|
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/sigIRCv2}"/>
|
||||||
|
</launchConfiguration>
|
10
.project
10
.project
@ -10,6 +10,16 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
<dictionary>
|
||||||
|
<key>LaunchConfigHandle</key>
|
||||||
|
<value><project>/.externalToolBuilders/Makejar.launch</value>
|
||||||
|
</dictionary>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
6
projectBuilder.xml
Normal file
6
projectBuilder.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="sigIRCv2.makejar" default="makejar" basedir=".">
|
||||||
|
<target name ="makejar" description="Create a jar for the sigIRCv2 project">
|
||||||
|
<jar jarfile="sigIRCv2.jar" includes="*.class" basedir="bin"/>
|
||||||
|
</target>
|
||||||
|
</project>
|
BIN
sigIRCv2.jar
Normal file
BIN
sigIRCv2.jar
Normal file
Binary file not shown.
@ -4,6 +4,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@ -40,11 +41,19 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
// Draw Text
|
// Draw Text
|
||||||
//int counter=18;
|
//int counter=18;
|
||||||
for (TwitchEmote e : sigIRC.twitchemoticons) {
|
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
|
||||||
e.draw(g);
|
if (sigIRC.twitchemoticons.get(i).isActive()) {
|
||||||
|
sigIRC.twitchemoticons.get(i).draw(g);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i=0;i<sigIRC.textobj.size();i++) {
|
||||||
|
if (sigIRC.textobj.get(i).isActive()) {
|
||||||
|
sigIRC.textobj.get(i).draw(g);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
for (ScrollingText st : sigIRC.textobj) {
|
|
||||||
st.draw(g);
|
|
||||||
}
|
}
|
||||||
for (Module m : sigIRC.modules) {
|
for (Module m : sigIRC.modules) {
|
||||||
m.draw(g);
|
m.draw(g);
|
||||||
|
@ -140,14 +140,25 @@ public class ScrollingText {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isAlive;
|
||||||
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
if (isAlive) {
|
if (isAlive && WithinBounds(x,y,Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getWidth()),Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getHeight(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getHeight()))) {
|
||||||
//DrawUtils.drawTextFont(g, MyPanel.userFont, x+8, y+stringHeight-20, Color.GREEN, username);
|
//DrawUtils.drawTextFont(g, MyPanel.userFont, x+8, y+stringHeight-20, Color.GREEN, username);
|
||||||
DrawUtils.drawOutlineText(g, MyPanel.userFont, x+8, y+stringHeight-20, 2, userColor, Color.BLACK, username);
|
DrawUtils.drawOutlineText(g, MyPanel.userFont, x+8, y+stringHeight-20, 2, userColor, Color.BLACK, username);
|
||||||
DrawUtils.drawOutlineText(g, MyPanel.programFont, x, y+stringHeight, 2, Color.WHITE, Color.BLACK, message);
|
DrawUtils.drawOutlineText(g, MyPanel.programFont, x, y+stringHeight, 2, Color.WHITE, Color.BLACK, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean WithinBounds(double x, double y, double w, double h) {
|
||||||
|
if (x<sigIRC.panel.getWidth() && x+w>0 && y<sigIRC.panel.getHeight() && y+h>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int FindLeftMostCornerInDisplay() {
|
public int FindLeftMostCornerInDisplay() {
|
||||||
if (x-shadowSize>0) {
|
if (x-shadowSize>0) {
|
||||||
return Math.min((int)x-shadowSize, sigIRC.panel.getWidth());
|
return Math.min((int)x-shadowSize, sigIRC.panel.getWidth());
|
||||||
|
@ -6,6 +6,7 @@ public class TwitchEmote {
|
|||||||
int x=0; //X Offset
|
int x=0; //X Offset
|
||||||
int y=0; //Y Offset
|
int y=0; //Y Offset
|
||||||
ScrollingText text;
|
ScrollingText text;
|
||||||
|
boolean active=true;
|
||||||
|
|
||||||
public TwitchEmote(Emoticon emote, ScrollingText textref, int x, int y) {
|
public TwitchEmote(Emoticon emote, ScrollingText textref, int x, int y) {
|
||||||
this.emote=emote;
|
this.emote=emote;
|
||||||
@ -19,9 +20,10 @@ public class TwitchEmote {
|
|||||||
sigIRC.panel.repaint(
|
sigIRC.panel.repaint(
|
||||||
Math.max(x,0),
|
Math.max(x,0),
|
||||||
Math.max(y, 0),
|
Math.max(y, 0),
|
||||||
Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth())+1,
|
Math.min(sigIRC.panel.getWidth()-x,emote.getImage().getWidth()),
|
||||||
Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight())+1);
|
Math.min(sigIRC.panel.getHeight()-y,emote.getImage().getHeight()));
|
||||||
if (x+emote.getImage().getWidth()<0) {
|
if (x+emote.getImage().getWidth()<0 || text==null || !text.isActive()) {
|
||||||
|
active=false;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@ -29,6 +31,19 @@ public class TwitchEmote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
|
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);
|
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 (x<sigIRC.panel.getWidth() && x+w>0 && y<sigIRC.panel.getHeight() && y+h>0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -266,7 +266,6 @@ public class sigIRC{
|
|||||||
f.add(sigIRC.panel);
|
f.add(sigIRC.panel);
|
||||||
f.pack();
|
f.pack();
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
|
|
||||||
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,panel.getHeight()/2);
|
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,panel.getHeight()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user