Skip to content

Commit

Permalink
Added fontColor option to make changing the background color option v…
Browse files Browse the repository at this point in the history
…iable

Also cleaned up text layout in a few places.  The only thing tying us to a
dark background now is drawing fuzzy files
  • Loading branch information
rictic committed Oct 24, 2008
1 parent 155ef18 commit ccbb025
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 33 deletions.
1 change: 1 addition & 0 deletions defaults/code_swarm.config
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ShowDebug=false
Font=SansSerif
FontSize=10
BoldFontSize=14
FontColor=255,255,255

# Natural distance of files to people
EdgeLength=25
Expand Down
13 changes: 4 additions & 9 deletions src/CodeSwarmConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class CodeSwarmConfig {
public static final String TAKE_SNAPSHOTS_KEY = "TakeSnapshots";
/** R,G,B Determines the background color */
public static final String BACKGROUND_KEY = "Background";
/** R,G,B Determines the background color */
/** R,G,B Determines the default font color */
public static final String FONT_COLOR_KEY = "FontColor";
public static final String FONT_KEY = "Font";
/** R,G,B Determines the background color */
public static final String FONT_SIZE = "FontSize";
Expand Down Expand Up @@ -158,14 +159,8 @@ public String getStringProperty( String key ) {
return null;
}

/**
*
* @return Color
*/
public Color getBackground() {
if ( _background == null )
_background = stringToColor( getStringProperty(BACKGROUND_KEY) );
return _background;
public Color getColorProperty(String key) {
return stringToColor( getStringProperty(key) );
}


Expand Down
42 changes: 18 additions & 24 deletions src/code_swarm.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ public class code_swarm extends PApplet {
public static Utils utils = null;
public AvatarFetcher avatarFetcher;

private int fontColor;



/**
Expand Down Expand Up @@ -204,8 +206,9 @@ public void setup() {
drawFilesFuzzy = cfg.getBooleanProperty(CodeSwarmConfig.DRAW_FILES_FUZZY);
drawFilesJelly = cfg.getBooleanProperty(CodeSwarmConfig.DRAW_FILES_JELLY);

background = cfg.getBackground().getRGB();

background = cfg.getColorProperty(CodeSwarmConfig.BACKGROUND_KEY).getRGB();
fontColor = cfg.getColorProperty(CodeSwarmConfig.FONT_COLOR_KEY).getRGB();

// Ensure we have sane values.
EDGE_LIFE_INIT = cfg.getPositiveIntProperty(CodeSwarmConfig.EDGE_LIFE_KEY);
FILE_LIFE_INIT = cfg.getPositiveIntProperty(CodeSwarmConfig.FILE_LIFE_KEY);
Expand Down Expand Up @@ -391,6 +394,7 @@ public void draw() {
node.draw();
}


textFont(font);

// Show the physics engine name
Expand Down Expand Up @@ -474,11 +478,11 @@ public void drawPeopleNodesSharp() {
* Draw date in lower-right corner
*/
public void drawDate() {
fill(255);
fill(fontColor, 255);
String dateText = formatter.format(prevDate);
textAlign(RIGHT, BASELINE);
textSize(font.size);
text(dateText, width - 1, height - textDescent());
text(dateText, width - 3, height - (2 + textDescent()));
}

/**
Expand Down Expand Up @@ -508,39 +512,27 @@ public void drawHistory() {
}
}

/**
* Show the Loading screen.
*/

public void drawLoading() {
noStroke();
textFont(font, 20);
textAlign(LEFT, TOP);
fill(255, 200);
text(loadingMessage, 0, 0);
}

/**
* Show color codings
*/
public void drawLegend() {
noStroke();
fill(fontColor, 255);
textFont(font);
textAlign(LEFT, TOP);
fill(255, 200);
text("Legend:", 0, 0);
text("Legend:", 3, 3);
for (int i = 0; i < colorAssigner.tests.size(); i++) {
ColorTest t = colorAssigner.tests.get(i);
fill(t.c1, 200);
text(t.label, font.size, (i + 1) * font.size);
text(t.label, font.size, 3 + ((i + 1) * (font.size + 2)));
}
}

/**
* Show physics engine name
*/
public void drawEngine() {
fill(255);
fill(fontColor, 255);
textAlign(RIGHT, BASELINE);
textSize(10);
text(physicsEngineSelection, width-1, height - (textDescent() * 5));
Expand All @@ -554,7 +546,7 @@ public void drawHelp() {
noStroke();
textFont(font);
textAlign(LEFT, TOP);
fill(255, 200);
fill(fontColor, 200);
text("Help on keyboard commands:", 0, 10*line++);
text("space bar : pause", 0, 10*line++);
text(" a : show name halos", 0, 10*line++);
Expand All @@ -581,7 +573,7 @@ public void drawDebugData() {
noStroke();
textFont(font);
textAlign(LEFT, TOP);
fill(255, 200);
fill(fontColor, 200);
text("Nodes: " + nodes.size(), 0, 0);
text("People: " + people.size(), 0, 10);
text("Queue: " + eventsQueue.size(), 0, 20);
Expand All @@ -596,7 +588,7 @@ public void drawPopular() {
noStroke();
textFont(font);
textAlign(RIGHT, TOP);
fill(255, 200);
fill(fontColor, 200);
text("Popular Nodes (touches):", width-120, 0);
for (FileNode fn : nodes.values()) {
if (fn.qualifies()) {
Expand Down Expand Up @@ -1354,6 +1346,7 @@ public void draw() {
*/
if (showPopular) {
textAlign( CENTER, CENTER );
fill(fontColor, 200);
if (this.qualifies()) {
text(touches, mPosition.x, mPosition.y - (8 + (int)Math.sqrt(touches)));
}
Expand Down Expand Up @@ -1496,7 +1489,8 @@ public void draw() {
textFont(boldFont);
else
textFont(font);


fill(fontColor, life);
text(name, mPosition.x, mPosition.y+10);
if (icon != null){
colorMode(RGB);
Expand Down

0 comments on commit ccbb025

Please sign in to comment.