Minor optimizations to drawing code to reduce errors and improve drawing

speed.
dev
sigonasr2 8 years ago
parent 70af0725b0
commit 674f7979c6
  1. 14
      .externalToolBuilders/Makejar.launch
  2. 10
      .project
  3. 6
      projectBuilder.xml
  4. BIN
      sigIRCv2.jar
  5. 17
      src/sig/MyPanel.java
  6. 13
      src/sig/ScrollingText.java
  7. 21
      src/sig/TwitchEmote.java
  8. 1
      src/sig/sigIRC.java

@ -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,6 +10,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/Makejar.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>

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

Binary file not shown.

@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
@ -40,11 +41,19 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
super.paintComponent(g);
// Draw Text
//int counter=18;
for (TwitchEmote e : sigIRC.twitchemoticons) {
e.draw(g);
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
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) {
m.draw(g);

@ -140,14 +140,25 @@ public class ScrollingText {
return true;
}
public boolean isActive() {
return isAlive;
}
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.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);
}
}
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() {
if (x-shadowSize>0) {
return Math.min((int)x-shadowSize, sigIRC.panel.getWidth());

@ -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) {
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 (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.pack();
f.setVisible(true);
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,panel.getHeight()/2);
}

Loading…
Cancel
Save