Skip to content

Commit

Permalink
Code refactoring (remove Vector und Hashtable, code formatting)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpatzwald committed Dec 4, 2021
1 parent 8efdd87 commit d35e854
Show file tree
Hide file tree
Showing 90 changed files with 6,235 additions and 5,682 deletions.
2 changes: 1 addition & 1 deletion wisim/doc/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------
The WiSim license.
Copyright (c) 2003 WiSim Development Team
Copyright (c) 2003-2021 WiSim Development Team
Document version 1.00, 28-05-2003
------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion wisim/doc/README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ******************************************************************** **
** Copyright notice **
** **
** (c) 2003 WiSim Development Team **
** (c) 2003-2021 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** **
** All rights reserved **
Expand Down
2 changes: 1 addition & 1 deletion wisim/src/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--/* *********************************************************************
** Copyright notice **
** **
** (c) 2003 WiSim Development Team **
** (c) 2003-2021 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** **
** All rights reserved **
Expand Down
168 changes: 87 additions & 81 deletions wisim/src/java/net/sourceforge/wisim/controller/IconGenerater.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ******************************************************************** **
** Copyright notice **
** **
** (c) 2003 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** (c) 2003-2021 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** **
** All rights reserved **
** **
Expand All @@ -21,103 +21,109 @@
** This copyright notice MUST APPEAR in all copies of the file! **
** ******************************************************************** */

/*
/*
* IconGenerater.java
*
* Created on 17. März 2003, 10:23
*/

package net.sourceforge.wisim.controller;

import java.awt.*;
import java.awt.image.*;
import javax.swing.*;

/** Erzeugt eine neue Instanz IconGenerater
/**
* Erzeugt eine neue Instanz IconGenerater
*
* @author benjamin.pasero
*/
public class IconGenerater {

private static Color darkgreen = new Color(51, 153, 51);
private static Color red = new Color(255, 0, 0);
private static Color orange = new Color(255, 153, 0);
private static Color darkgreenDither = new Color(51, 153, 51, 50);
private static Color redDither = new Color(255, 0, 0, 50);
private static Color orangeDither = new Color(255, 153, 0, 50);
private Image icon;
private Graphics g;
private int abstand;
private static final Color DARKGREEN = new Color(51, 153, 51);
private static final Color RED = new Color(255, 0, 0);
private static final Color ORANGE = new Color(255, 153, 0);
private static final Color DARKGREENDITHER = new Color(51, 153, 51, 50);
private static final Color REDDITHER = new Color(255, 0, 0, 50);
private static final Color ORANGEDITHER = new Color(255, 153, 0, 50);
private final Image icon;
private final Graphics g;
private final int abstand;

/** Creates a new instance of IconGenerater */
public IconGenerater() {
icon = new BufferedImage(83, 30, 2);
g = icon.getGraphics();
abstand = 12;
}
/**
* Creates a new instance of IconGenerater
*/
public IconGenerater() {
icon = new BufferedImage(83, 30, 2);
g = icon.getGraphics();
abstand = 12;
}

/** Erzeugt ein ImageIcon je nach Parameterangabe.
* @param type Der Typ gibt die Fabe der Rechtecke im ImageIcon an.
* 0 steht für grün, 1 für orange und 2 für rot.
* @param filledRects Steht für die Anzahl der gefüllten Rechtecke.
* @return ImageIcon Objekt bestehend aus 5 Rechtecken.
*/
public ImageIcon generateIcon(int type, int filledRects) {
int i = 0;
switch (type) {
/**
* Erzeugt ein ImageIcon je nach Parameterangabe.
*
* @param type Der Typ gibt die Fabe der Rechtecke im ImageIcon an. 0 steht
* für grün, 1 für orange und 2 für rot.
* @param filledRects Steht für die Anzahl der gefüllten Rechtecke.
* @return ImageIcon Objekt bestehend aus 5 Rechtecken.
*/
public ImageIcon generateIcon(int type, int filledRects) {
int i = 0;
switch (type) {

//Grünes Icon
case 0 :
g.setColor(darkgreen);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}
//Grünes Icon
case 0:
g.setColor(DARKGREEN);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}

i = filledRects + 1;
while (i <= 5) {
g.setColor(darkgreen);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(darkgreenDither);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;
i = filledRects + 1;
while (i <= 5) {
g.setColor(DARKGREEN);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(DARKGREENDITHER);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;

//Oranges Icon
case 1 :
g.setColor(orange);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}
//Oranges Icon
case 1:
g.setColor(ORANGE);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}

i = filledRects + 1;
while (i <= 5) {
g.setColor(orange);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(orangeDither);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;
i = filledRects + 1;
while (i <= 5) {
g.setColor(ORANGE);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(ORANGEDITHER);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;

//Rotes Icon
case 2 :
g.setColor(red);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}
//Rotes Icon
case 2:
g.setColor(RED);
while (i < filledRects) {
g.fillRect((abstand * (i + 1)), 11, 10, 10);
i++;
}

i = filledRects + 1;
while (i <= 5) {
g.setColor(red);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(redDither);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;
}
return new ImageIcon(icon);
}
}
i = filledRects + 1;
while (i <= 5) {
g.setColor(RED);
g.drawRect((abstand * i), 11, 9, 9);
g.setColor(REDDITHER);
g.fillRect((abstand * i), 11, 9, 9);
i++;
}
break;
}
return new ImageIcon(icon);
}
}
117 changes: 58 additions & 59 deletions wisim/src/java/net/sourceforge/wisim/controller/IconNode.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ******************************************************************** **
** Copyright notice **
** **
** (c) 2003 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** (c) 2003-2021 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** **
** All rights reserved **
** **
Expand All @@ -20,76 +20,75 @@
** **
** This copyright notice MUST APPEAR in all copies of the file! **
** ******************************************************************** */

package net.sourceforge.wisim.controller;

import javax.swing.*;
import javax.swing.tree.*;

/** Ein IconNode ist ein Element im JTree. Das IconNode kann ein eigenes
* Icon haben.
* Diese Klasse wurde von:
* http://www.codeguru.com/java/articles/187.shtml
* heruntergeladen.
/**
* Ein IconNode ist ein Element im JTree. Das IconNode kann ein eigenes Icon
* haben. Diese Klasse wurde von:
* http://www.codeguru.com/java/articles/187.shtml heruntergeladen.
*
* @version 1.0 01/12/99
*/
public class IconNode extends DefaultMutableTreeNode {

protected Icon icon;
protected String iconName;
protected Icon icon;
protected String iconName;

public IconNode() {
this(null);
}
public IconNode() {
this(null);
}

/**
* @param userObject
*/
public IconNode(Object userObject) {
this(userObject, true, null);
}
/**
* @param userObject
*/
public IconNode(Object userObject) {
this(userObject, true, null);
}

/**
* @param userObject
* @param allowsChildren
* @param icon
*/
public IconNode(Object userObject, boolean allowsChildren, Icon icon) {
super(userObject, allowsChildren);
this.icon = icon;
}
/**
* @param userObject
* @param allowsChildren
* @param icon
*/
public IconNode(Object userObject, boolean allowsChildren, Icon icon) {
super(userObject, allowsChildren);
this.icon = icon;
}

/**
* @param icon
*/
public void setIcon(Icon icon) {
this.icon = icon;
}
/**
* @param icon
*/
public void setIcon(Icon icon) {
this.icon = icon;
}

/**
* @return icon
*/
public Icon getIcon() {
return icon;
}
/**
* @return icon
*/
public Icon getIcon() {
return icon;
}

/**
* @return iconname
*/
public String getIconName() {
String str = userObject.toString();
int index = str.lastIndexOf(".");
if (index != -1) {
return str.substring(++index);
} else {
return iconName;
}
}
/**
* @return iconname
*/
public String getIconName() {
String str = userObject.toString();
int index = str.lastIndexOf(".");
if (index != -1) {
return str.substring(++index);
} else {
return iconName;
}
}

/**
* @param name
*/
public void setIconName(String name) {
iconName = name;
}
}
/**
* @param name
*/
public void setIconName(String name) {
iconName = name;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ******************************************************************** **
** Copyright notice **
** **
** (c) 2003 WiSim Development Team **
** (c) 2003-2021 WiSim Development Team **
** https://github.com/kpatzwald/WiSim **
** **
** All rights reserved **
Expand All @@ -23,8 +23,8 @@

package net.sourceforge.wisim.controller;

import java.util.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.tree.*;

Expand Down
Loading

0 comments on commit d35e854

Please sign in to comment.