Package xapc.gui

Source Code of xapc.gui.PalastPanel

package xapc.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.math.BigInteger;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.EtchedBorder;
import org.jgraph.JGraph;
import org.jgraph.graph.DefaultCellViewFactory;
import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.DefaultPort;
import org.jgraph.graph.GraphConstants;
import org.jgraph.graph.GraphLayoutCache;
import org.jgraph.graph.GraphModel;
import net.miginfocom.swing.MigLayout;
import xapc.core.Buildings;
import xapc.core.Creatures;
import xapc.core.IconLocations;
import xapc.core.Productions;

public class PalastPanel extends JTabbedPane
{
  private static final long serialVersionUID = -4704226685279784917L;
  private JPanel hordenCalculatorPanel = null;
  private JPanel heroPanel = null;
  private JPanel guardPanel = null;
  private JPanel resultPanel = null;
  private ArtefactsBoniToBuildings artefactsBoniToBuildings = new ArtefactsBoniToBuildings(this);
  private AngelsBoniToBuildings angelsBoniPanel = new AngelsBoniToBuildings(this);
  private JPanel techtreePanel = null;
  private final int graphCellWidth = 50;
  private final int graphCellHeight = 20;
  private JPanel buildingCalculatorPanel = null;
  private RessourcePanel ressourcePanel = null;
  private RessourcePanel ressourcePanelBuildings = null;
  private RessourcePanel ressourcePanelBuildingsTotalAllLevels = null;
  private XdKAndZSPanel xdkAndZSPanel = new XdKAndZSPanel(this);
  private Creatures creatures = new Creatures(true, this);
  private DragonsBoniToHorde dragonsBoni = new DragonsBoniToHorde(this);
  private JTextField jTextFieldAPWesen = new JTextField(22);
  private JTextField jTextFieldDefWesen = new JTextField(22);
  private JTextField jTextFieldHPWesen = new JTextField(22);
  private JTextField jTextFieldAPW�chter = new JTextField(13);
  private JTextField jTextFieldDefW�chter = new JTextField(13);
  private JTextField jTextFieldHPW�chter = new JTextField(13);
  private NumberFormat nf = NumberFormat.getNumberInstance();
  private String name = null;

  public PalastPanel(String nm)
  {
    super();
    name = nm;
    setOpaque(false);
    setFocusable(false);
    addTab("Horden", new ImageIcon(getClass().
      getClassLoader().getResource(IconLocations.KOBOLD)),
      getHordenCalculatorPanel());
    JPanel bPanel = new JPanel(new BorderLayout());
    bPanel.setOpaque(false);
    JPanel northPanel = new JPanel(new MigLayout("", "0[]0", "0[]0[]0[]0[]0"));
    northPanel.setOpaque(false);
    northPanel.add(getRessourcePanelBuildings(), "cell 0 0");
    northPanel.add(getRessourcePanelBuildingsTotalAllLevels(), "cell 0 1");
    northPanel.add(artefactsBoniToBuildings, "cell 0 2");
    northPanel.add(angelsBoniPanel, "cell 0 3");
    bPanel.add(northPanel, BorderLayout.NORTH);
    JScrollPane buildings = new JScrollPane(getBuildingCalculatorPanel());
    buildings.setOpaque(false);
    buildings.getHorizontalScrollBar().setUnitIncrement(10);
    buildings.getVerticalScrollBar().setUnitIncrement(10);
    bPanel.add(buildings, BorderLayout.CENTER);
    buildings.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
   
    addTab("Geb�ude", new ImageIcon(getClass().
      getClassLoader().getResource(IconLocations.BAUM_DES_LEBENS)),
      bPanel);
    addTab("XdK + ZS", new ImageIcon(getClass().
      getClassLoader().getResource(IconLocations.XHODOTORISCHER_KOKON)),
      xdkAndZSPanel);
    addTab("Techtree", new ImageIcon(getClass().
      getClassLoader().getResource(IconLocations.HELDENSTATUE)),
      getTechtreeGraph());
  }
 
  public String getPalastName()
  {
    return name;
  }
 
  private DefaultGraphCell createGraphCell(String text, int x, int y,
      int numPorts, String type)
    {
      DefaultGraphCell cell = new DefaultGraphCell(text);
      GraphConstants.setBounds(cell.getAttributes(),
        new Rectangle2D.Double(x, y, graphCellWidth, graphCellHeight));
      GraphConstants.setBorder(cell.getAttributes(), BorderFactory.createLineBorder(Color.black));
      GraphConstants.setOpaque(cell.getAttributes(), true);
     
      if(type.equals(Productions.BUILDING))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.cyan);
        cell.add(createPort(0, 0)); // lo
        cell.add(createPort(GraphConstants.PERMILLE/4, 0)); // zwischen lo und om
        cell.add(createPort(GraphConstants.PERMILLE/2, 0)); // om
        cell.add(createPort(Float.valueOf(GraphConstants.PERMILLE/(4F/3)), 0)); // zwischen om und ro
        cell.add(createPort(GraphConstants.PERMILLE, 0)); // ro
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/4)); // zwischen ro und rm
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/2)); // rm
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE/(4F/3))); // zwischen rm und ru
        cell.add(createPort(GraphConstants.PERMILLE, GraphConstants.PERMILLE)); // ru
        cell.add(createPort(GraphConstants.PERMILLE/(4F/3), GraphConstants.PERMILLE)); // zwischen um und ru
        cell.add(createPort(GraphConstants.PERMILLE/2, GraphConstants.PERMILLE));// um
        cell.add(createPort(GraphConstants.PERMILLE/4, GraphConstants.PERMILLE)); // zwischen lu und um
        cell.add(createPort(0, GraphConstants.PERMILLE));// lu
        cell.add(createPort(0, GraphConstants.PERMILLE/(4F/3))); // zwischen lu und lm
        cell.add(createPort(0, GraphConstants.PERMILLE/2));// lm
        cell.add(createPort(0, GraphConstants.PERMILLE/4)); // zwischen lm und lo
      }
      else if(type.equals(Productions.UNIT))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.orange);
        cell.add(new DefaultPort());
      }
      else if(type.equals(Productions.UNIT_BUILDING))
      {
        GraphConstants.setGradientColor(cell.getAttributes(),
          Color.cyan);
        cell.add(new DefaultPort());
      }
     
      return cell;
    }
   
    private DefaultPort createPort(float relX, float relY)
    {
      DefaultPort port = new DefaultPort();
      GraphConstants.setOffset(port.getAttributes(), new Point2D.Float(
        relX, relY));
     
      return port;
    }
   
    private DefaultEdge createGraphEdge(String text,
      List<Point2D> controlPoints, double lx, double ly)
    {
      DefaultEdge edge = new DefaultEdge();
      Object[] labels = {
        text
      };
      Point2D[] labelPositions = {
        new Point2D.Double(lx, ly)
      };
     
      GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_CLASSIC);
      GraphConstants.setEndFill(edge.getAttributes(), true);
      GraphConstants.setExtraLabelPositions(edge.getAttributes(),
        labelPositions);
      GraphConstants.setExtraLabels(edge.getAttributes(), labels);
      GraphConstants.setPoints(edge.getAttributes(), controlPoints);

      return edge;
    }
   
    private DefaultEdge createGraphEdge(String text, DefaultGraphCell source,
      DefaultGraphCell target, double lx, double ly)
    {
      DefaultEdge edge = new DefaultEdge();
      Object[] labels = {
        text
      };
     
      Point2D[] labelPositions = {
        new Point2D.Double(lx, ly)
      };
     
      GraphConstants.setLineEnd(edge.getAttributes(), GraphConstants.ARROW_CLASSIC);
      GraphConstants.setEndFill(edge.getAttributes(), true);
      GraphConstants.setExtraLabelPositions(edge.getAttributes(),
        labelPositions);
      GraphConstants.setExtraLabels(edge.getAttributes(), labels);
     
      edge.setSource(source.getChildAt(0));
      edge.setTarget(target.getChildAt(0));
     
      return edge;
    }
 
  private JPanel getTechtreeGraph()
  {
    if(techtreePanel == null)
    {
      techtreePanel = new JPanel(new BorderLayout());
      techtreePanel.setOpaque(false);
      GraphModel gmodel = new DefaultGraphModel();
      GraphLayoutCache gcache = new GraphLayoutCache(gmodel,
        new DefaultCellViewFactory());
      JGraph graphPanel = new JGraph(gmodel, gcache);
     
      DefaultGraphCell[] cells = new DefaultGraphCell[144];
     
      int i = 0;
      // buildings in building techtree
      DefaultGraphCell ks = createGraphCell("Ks", 315, 20, 1, Productions.BUILDING); // K�ruterschule
      DefaultGraphCell kh = createGraphCell("Kh", 315, 70, 2, Productions.BUILDING); // Kristallh�hle
      DefaultGraphCell ha = createGraphCell("Ha", 395, 70, 2, Productions.BUILDING); // Harzader
      DefaultGraphCell bdl = createGraphCell("BdL", 315, 120, 1, Productions.BUILDING); // Baum des Lebens
      DefaultGraphCell sw = createGraphCell("Sw", 395, 170, 1, Productions.BUILDING); // Steinwurzel
      DefaultGraphCell kb = createGraphCell("Kb", 315, 170, 1, Productions.BUILDING); // Kriegsbrunnen
      DefaultGraphCell ph = createGraphCell("Ph", 235, 120, 1, Productions.BUILDING); // Palasthof
      DefaultGraphCell xdk = createGraphCell("XdK", 235, 170, 1, Productions.BUILDING); // Xhodotorischer Kokon
      DefaultGraphCell kt = createGraphCell("Kt", 155, 170, 1, Productions.BUILDING); // Kristallturm
      DefaultGraphCell sm = createGraphCell("Sm", 75, 170, 1, Productions.BUILDING); // Steinmantel
      DefaultGraphCell ia = createGraphCell("IA", 475, 170, 1, Productions.BUILDING); // Irres Auge
      DefaultGraphCell zs = createGraphCell("Zs", 235, 220, 1, Productions.BUILDING); // Zuchtstation
      DefaultGraphCell kk = createGraphCell("KK", 235, 270, 1, Productions.BUILDING); // Kristallines Katapult
      DefaultGraphCell gg = createGraphCell("GG", 475, 45, 1, Productions.BUILDING); // Geheime Grotte
      DefaultGraphCell hs = createGraphCell("Hs", 155, 45, 1, Productions.BUILDING); // Heldenstatue
     
      // Units and buildings in units trees
      DefaultGraphCell bdlDRE = createGraphCell("BdL", 15, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsDRE = createGraphCell("Zs", 15, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell hsDRE = createGraphCell("Hs", 15, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell dre = createGraphCell("Dre", 85, 345, 1, Productions.UNIT);
     
      DefaultGraphCell zsEHW = createGraphCell("Zs", 15, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell ehw = createGraphCell("Ehw", 85, 405, 1, Productions.UNIT);
     
      DefaultGraphCell xdkKob = createGraphCell("XdK", 155, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kob = createGraphCell("Kob", 225, 315, 1, Productions.UNIT);
     
      DefaultGraphCell kbEIK = createGraphCell("Kb", 155, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkEIK = createGraphCell("XdK", 155, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell eik = createGraphCell("Eik", 225, 345, 1, Productions.UNIT);
     
      DefaultGraphCell phKDM = createGraphCell("Ph", 15, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkKDM = createGraphCell("XdK", 15, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kdm = createGraphCell("KdM", 85, 435, 1, Productions.UNIT);
     
      DefaultGraphCell bdlKRP = createGraphCell("BdL", 155, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkKRP = createGraphCell("XdK", 155, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbKRP = createGraphCell("Kb", 155, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell krp = createGraphCell("Krp", 225, 435, 1, Productions.UNIT);
     
      DefaultGraphCell phHYZ = createGraphCell("Ph", 295, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsHYZ = createGraphCell("Zs", 295, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell hyz = createGraphCell("HyZ", 365, 315, 1, Productions.UNIT);
     
      DefaultGraphCell phWIZ = createGraphCell("Ph", 295, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell zsWIZ = createGraphCell("Zs", 295, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell wiz = createGraphCell("WiZ", 365, 375, 1, Productions.UNIT);
     
      DefaultGraphCell phEBS = createGraphCell("Ph", 295, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkEBS = createGraphCell("Xdk", 295, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell ebs = createGraphCell("Ebs", 365, 435, 1, Productions.UNIT);
     
      DefaultGraphCell smAXZ = createGraphCell("Sm", 435, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkAXZ = createGraphCell("XdK", 435, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbAXZ = createGraphCell("Kb", 435, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell axz = createGraphCell("AxZ", 505, 345, 1, Productions.UNIT);
     
      DefaultGraphCell smDAZ = createGraphCell("Sm", 435, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell xdkDAZ = createGraphCell("XdK", 435, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell kbDAZ = createGraphCell("Kb", 435, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell daz = createGraphCell("Daz", 505, 435, 1, Productions.UNIT);
     
      DefaultGraphCell sihKB = createGraphCell("Kb", 575, 405, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihBDL = createGraphCell("BdL", 575, 435, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihSM = createGraphCell("Sm", 575, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sihZS = createGraphCell("Zs", 645, 465, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell sih = createGraphCell("SiH", 645, 435, 1, Productions.UNIT);
     
      DefaultGraphCell efmPH = createGraphCell("Ph", 575, 315, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmBDL = createGraphCell("BdL", 575, 345, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmKT = createGraphCell("Kt", 575, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efmXDK = createGraphCell("XdK", 645, 375, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell efm = createGraphCell("Efm", 645, 345, 1, Productions.UNIT);
     
      DefaultGraphCell fefPH = createGraphCell("Ph", 575, 225, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefKT = createGraphCell("Kt", 575, 255, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefZS = createGraphCell("Zs", 575, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fefBDL = createGraphCell("BdL", 645, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell fef = createGraphCell("Fef", 645, 255, 1, Productions.UNIT);
     
      DefaultGraphCell stfPH = createGraphCell("Ph", 575, 135, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfKB = createGraphCell("Kb", 575, 165, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfKT = createGraphCell("Kt", 575, 195, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stfZS = createGraphCell("Zs", 645, 195, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell stf = createGraphCell("Stf", 645, 165, 1, Productions.UNIT);
     
      DefaultGraphCell swbKB = createGraphCell("Kb", 575, 45, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swbBDL = createGraphCell("BdL", 575, 75, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swbZS = createGraphCell("Zs", 575, 105, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell swb = createGraphCell("SwB", 645, 75, 1, Productions.UNIT);
     
      DefaultGraphCell briPH = createGraphCell("Ph", 15, 255, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell briXDK = createGraphCell("XdK", 15, 285, 1, Productions.UNIT_BUILDING);
      DefaultGraphCell bri = createGraphCell("Bri", 85, 255, 1, Productions.UNIT);
     
      // cells of buildings
      cells[i++] = ks;
      cells[i++] = kh;
      cells[i++] = ha;
      cells[i++] = bdl;
      cells[i++] = sw;
      cells[i++] = kb;
      cells[i++] = ph;
      cells[i++] = xdk;
      cells[i++] = kt;
      cells[i++] = sm;
      cells[i++] = ia;
      cells[i++] = zs;
      cells[i++] = kk;
      cells[i++] = gg;
      cells[i++] = hs;
     
      // cells of units and buildings for units
      cells[i++] = bdlDRE;
      cells[i++] = zsDRE;
      cells[i++] = hsDRE;
      cells[i++] = dre;
      cells[i++] = zsEHW;
      cells[i++] = ehw;
      cells[i++] = xdkKob;
      cells[i++] = kob;
      cells[i++] = kbEIK;
      cells[i++] = xdkEIK;
      cells[i++] = eik;
      cells[i++] = phKDM;
      cells[i++] = xdkKDM;
      cells[i++] = kdm;
      cells[i++] = bdlKRP;
      cells[i++] = xdkKRP;
      cells[i++] = kbKRP;
      cells[i++] = krp;
      cells[i++] = zsHYZ;
      cells[i++] = phHYZ;
      cells[i++] = hyz;
      cells[i++] = phWIZ;
      cells[i++] = zsWIZ;
      cells[i++] = wiz;
      cells[i++] = phEBS;
      cells[i++] = xdkEBS;
      cells[i++] = ebs;
      cells[i++] = kbAXZ;
      cells[i++] = xdkAXZ;
      cells[i++] = smAXZ;
      cells[i++] = axz;
      cells[i++] = kbDAZ;
      cells[i++] = xdkDAZ;
      cells[i++] = smDAZ;
      cells[i++] = daz;
      cells[i++] = sih;
      cells[i++] = sihBDL;
      cells[i++] = sihKB;
      cells[i++] = sihSM;
      cells[i++] = sihZS;
      cells[i++] = efm;
      cells[i++] = efmBDL;
      cells[i++] = efmKT;
      cells[i++] = efmPH;
      cells[i++] = efmXDK;
      cells[i++] = fef;
      cells[i++] = fefBDL;
      cells[i++] = fefKT;
      cells[i++] = fefPH;
      cells[i++] = fefZS;
      cells[i++] = stf;
      cells[i++] = stfKB;
      cells[i++] = stfKT;
      cells[i++] = stfPH;
      cells[i++] = stfZS;
      cells[i++] = swb;
      cells[i++] = swbBDL;
      cells[i++] = swbKB;
      cells[i++] = swbZS;
      cells[i++] = bri;
      cells[i++] = briPH;
      cells[i++] = briXDK;
     
      // arrows
      cells[i++] = createGraphEdge("10", bdlDRE, dre, GraphConstants.PERMILLE * 0.2, -4);
      cells[i++] = createGraphEdge("5", zsDRE, dre, GraphConstants.PERMILLE * 0.2, -4);
      cells[i++] = createGraphEdge("1", hsDRE, dre, GraphConstants.PERMILLE * 0.3, -4);
      cells[i++] = createGraphEdge("1", zsEHW, ehw, GraphConstants.PERMILLE * 0.3, -4);
      cells[i++] = createGraphEdge("1", xdkKob, kob, GraphConstants.PERMILLE * 0.3, -4);
      cells[i++] = createGraphEdge("10", kbEIK, eik, GraphConstants.PERMILLE * 0.3, -4);
      cells[i++] = createGraphEdge("2", xdkEIK, eik, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("5", phKDM, kdm, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("1", xdkKDM, kdm, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("20", kbKRP, krp, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("3", xdkKRP, krp, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("15", bdlKRP, krp, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("15", phHYZ, hyz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("2", zsHYZ, hyz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("25", phWIZ, wiz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("3", zsWIZ, wiz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("35", phEBS, ebs, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("5", xdkEBS, ebs, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("30", kbAXZ, axz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("5", xdkAXZ, axz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("10", smAXZ, axz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("40", kbDAZ, daz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("7", xdkDAZ, daz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("15", smDAZ, daz, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("50", sihKB, sih, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("45", sihBDL, sih, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("25", sihSM, sih, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("15", sihZS, sih, GraphConstants.PERMILLE * 0.3, -15);
      cells[i++] = createGraphEdge("55", efmPH, efm, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("50", efmBDL, efm, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("10", efmKT, efm, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("14", efmXDK, efm, GraphConstants.PERMILLE * 0.3, -15);
      cells[i++] = createGraphEdge("20", fefPH, fef, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("5", fefKT, fef, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("4", fefZS, fef, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("20", fefBDL, fef, GraphConstants.PERMILLE * 0.3, -15);
      cells[i++] = createGraphEdge("15", stfPH, stf, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("15", stfKB, stf, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("10", stfKT, stf, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("5", stfZS, stf, GraphConstants.PERMILLE * 0.3, -15);
      cells[i++] = createGraphEdge("60", swbKB, swb, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("50", swbBDL, swb, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("20", swbZS, swb, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("45", briPH, bri, GraphConstants.PERMILLE * 0.3, -5);
      cells[i++] = createGraphEdge("8", briXDK, bri, GraphConstants.PERMILLE * 0.3, -5);
     
      // Kristallh�hle -> Heldenstatue
      List<Point2D> ctrPnts26 = new ArrayList<Point2D>();
      ctrPnts26.add(new Point2D.Double(315, 75));
      ctrPnts26.add(new Point2D.Double(295, 55));
      ctrPnts26.add(new Point2D.Double(205, 55));
      cells[i++] = createGraphEdge("2", ctrPnts26, GraphConstants.PERMILLE*0.2, 8);
     
      // Kristallh�hle -> Geheime Grotte
      List<Point2D> ctrPnts25 = new ArrayList<Point2D>();
      ctrPnts25.add(new Point2D.Double(365, 75));
      ctrPnts25.add(new Point2D.Double(385, 55));
      ctrPnts25.add(new Point2D.Double(475, 55));
      cells[i++] = createGraphEdge("2", ctrPnts25, GraphConstants.PERMILLE*0.2, -8);
     
      // Kristallturm -> Kristallines Katapult
      List<Point2D> ctrPnts24 = new ArrayList<Point2D>();
      ctrPnts24.add(new Point2D.Double(180, 190));
      ctrPnts24.add(new Point2D.Double(180, 280));
      ctrPnts24.add(new Point2D.Double(235, 280));
      cells[i++] = createGraphEdge("5", ctrPnts24, GraphConstants.PERMILLE*0.5, 8);
     
      // Palasthof -> Steinmantel
      List<Point2D> ctrPnts23 = new ArrayList<Point2D>();
      ctrPnts23.add(new Point2D.Double(235, 125));
      ctrPnts23.add(new Point2D.Double(100, 125));
      ctrPnts23.add(new Point2D.Double(100, 170));
      cells[i++] = createGraphEdge("5", ctrPnts23, GraphConstants.PERMILLE*0.85, -8);
     
      // Palasthof -> Kristallturm
      List<Point2D> ctrPnts22 = new ArrayList<Point2D>();
      ctrPnts22.add(new Point2D.Double(235, 130));
      ctrPnts22.add(new Point2D.Double(180, 130));
      ctrPnts22.add(new Point2D.Double(180, 170));
      cells[i++] = createGraphEdge("3", ctrPnts22, GraphConstants.PERMILLE*0.75, -8);
     
      // Palasthof -> Zuchtstation
      List<Point2D> ctrPnts21 = new ArrayList<Point2D>();
      ctrPnts21.add(new Point2D.Double(235, 135));
      ctrPnts21.add(new Point2D.Double(215, 155));
      ctrPnts21.add(new Point2D.Double(215, 230));
      ctrPnts21.add(new Point2D.Double(235, 230));
      cells[i++] = createGraphEdge("1", ctrPnts21, GraphConstants.PERMILLE*0.75, 8);
     
      // Kristallh�hle -> Kristallines Katapult
      List<Point2D> ctrPnts20 = new ArrayList<Point2D>();
      ctrPnts20.add(new Point2D.Double(315, 85));
      ctrPnts20.add(new Point2D.Double(305, 95));
      ctrPnts20.add(new Point2D.Double(305, 275));
      ctrPnts20.add(new Point2D.Double(285, 275));
      cells[i++] = createGraphEdge("15", ctrPnts20, GraphConstants.PERMILLE*0.85, -8);
     
      // Harzader -> Kristallines Katapult
      List<Point2D> ctrPnts19 = new ArrayList<Point2D>();
      ctrPnts19.add(new Point2D.Double(445, 80));
      ctrPnts19.add(new Point2D.Double(535, 80));
      ctrPnts19.add(new Point2D.Double(535, 285));
      ctrPnts19.add(new Point2D.Double(285, 285));
      cells[i++] = createGraphEdge("5", ctrPnts19, GraphConstants.PERMILLE/2, -8);
     
      // Steinwurzel -> Zuchtstation
      List<Point2D> ctrPnts18 = new ArrayList<Point2D>();
      ctrPnts18.add(new Point2D.Double(420, 190));
      ctrPnts18.add(new Point2D.Double(420, 230));
      ctrPnts18.add(new Point2D.Double(285, 230));
      cells[i++] = createGraphEdge("3", ctrPnts18, GraphConstants.PERMILLE/2, 8);
     
      // Steinwurzel -> Irres Auge
      List<Point2D> ctrPnts17 = new ArrayList<Point2D>();
      ctrPnts17.add(new Point2D.Double(445, 180));
      ctrPnts17.add(new Point2D.Double(475, 180));
      cells[i++] = createGraphEdge("1", ctrPnts17, GraphConstants.PERMILLE/2, -8);
     
      // Xhodotorischer Kokon -> Kriegsbrunnen
      List<Point2D> ctrPnts16 = new ArrayList<Point2D>();
      ctrPnts16.add(new Point2D.Double(285, 180));
      ctrPnts16.add(new Point2D.Double(315, 180));
      cells[i++] = createGraphEdge("5", ctrPnts16, GraphConstants.PERMILLE/4, -8);
     
      // Palasthof -> Xhodotorischer Kokon
      List<Point2D> ctrPnts15 = new ArrayList<Point2D>();
      ctrPnts15.add(new Point2D.Double(260, 140));
      ctrPnts15.add(new Point2D.Double(260, 170));
      cells[i++] = createGraphEdge("1", ctrPnts15, GraphConstants.PERMILLE/2, 8);
     
      // Kr�uterschule -> Kristallh�hle
      List<Point2D> ctrPnts2 = new ArrayList<Point2D>();
      ctrPnts2.add(new Point2D.Double(340, 40));
      ctrPnts2.add(new Point2D.Double(340, 70));
      cells[i++] = createGraphEdge("1", ctrPnts2, GraphConstants.PERMILLE/2, -8);
     
      // Kristallh�hle -> Baum des Lebens
      List<Point2D> ctrPnts4 = new ArrayList<Point2D>();
      ctrPnts4.add(new Point2D.Double(340, 90));
      ctrPnts4.add(new Point2D.Double(340, 120));
      cells[i++] = createGraphEdge("1", ctrPnts4, GraphConstants.PERMILLE/2, -8);
     
      // Baum des Lebens -> Steinwurzel
      List<Point2D> ctrPnts6 = new ArrayList<Point2D>();
      ctrPnts6.add(new Point2D.Double(365, 135));
      ctrPnts6.add(new Point2D.Double(420, 135));
      ctrPnts6.add(new Point2D.Double(420, 170));
      cells[i++] = createGraphEdge("3", ctrPnts6, GraphConstants.PERMILLE/2, 9);
     
      // Kristallh�hle -> Harzader
      List<Point2D> ctrPnts8 = new ArrayList<Point2D>();
      ctrPnts8.add(new Point2D.Double(365, 80));
      ctrPnts8.add(new Point2D.Double(395, 80));
      cells[i++] = createGraphEdge("10", ctrPnts8, GraphConstants.PERMILLE*0.7, 11);
     
      // Kr�uterschule -> Harzader
      List<Point2D> ctrPnts9 = new ArrayList<Point2D>();
      ctrPnts9.add(new Point2D.Double(365, 30));
      ctrPnts9.add(new Point2D.Double(420, 30));
      ctrPnts9.add(new Point2D.Double(420, 70));
      cells[i++] = createGraphEdge("15", ctrPnts9, GraphConstants.PERMILLE/2, -8);
     
      // Baum des Lebens -> Harzader
      List<Point2D> ctrPnts10 = new ArrayList<Point2D>();
      ctrPnts10.add(new Point2D.Double(365, 125));
      ctrPnts10.add(new Point2D.Double(420, 125));
      ctrPnts10.add(new Point2D.Double(420, 90));
      cells[i++] = createGraphEdge("10", ctrPnts10, GraphConstants.PERMILLE/2, -8);
     
      // Baum des Lebens -> Kriegsbrunnen
      List<Point2D> ctrPnts11 = new ArrayList<Point2D>();
      ctrPnts11.add(new Point2D.Double(340, 140));
      ctrPnts11.add(new Point2D.Double(340, 170));
      cells[i++] = createGraphEdge("5", ctrPnts11, GraphConstants.PERMILLE/2, -8);
     
      // Kr�uterschule -> Palasthof
      List<Point2D> ctrPnts12 = new ArrayList<Point2D>();
      ctrPnts12.add(new Point2D.Double(315, 25));
      ctrPnts12.add(new Point2D.Double(247.5, 25));
      ctrPnts12.add(new Point2D.Double(247.5, 120));
      cells[i++] = createGraphEdge("3", ctrPnts12, GraphConstants.PERMILLE/2, 8);
     
      // Kristallh�hle -> Palasthof
      List<Point2D> ctrPnts13 = new ArrayList<Point2D>();
      ctrPnts13.add(new Point2D.Double(315, 80));
      ctrPnts13.add(new Point2D.Double(272.5, 80));
      ctrPnts13.add(new Point2D.Double(272.5, 120));
      cells[i++] = createGraphEdge("3", ctrPnts13, GraphConstants.PERMILLE/2, 8);
     
      // Baum des Lebens -> Palasthof
      List<Point2D> ctrPnts14 = new ArrayList<Point2D>();
      ctrPnts14.add(new Point2D.Double(315, 130));
      ctrPnts14.add(new Point2D.Double(285, 130));
      cells[i++] = createGraphEdge("5", ctrPnts14, GraphConstants.PERMILLE*0.75, 9);
     
      // graph can't be modified
      graphPanel.getGraphLayoutCache().insert(cells);
      graphPanel.setOpaque(false);
      graphPanel.setEditable(false);
      graphPanel.setMoveable(false);
      graphPanel.setSelectionEnabled(false);
     
      techtreePanel.add(graphPanel, BorderLayout.CENTER);
     
      JPanel infoPanel = new JPanel();
      JTextArea ta = new JTextArea("Der Graph oben zeigt die Voraussetzungen f�r die jeweiligen Geb�ude. Die Zahl am Pfeil zeigt an, welche Stufe das Geb�ude zu Beginn\n" +
        "des Pfeils haben muss um das Geb�ude am Ende des Pfeils bauen zu k�nnen!\n\nCyan stellt Geb�ude dar, Orange Wesen.");
      ta.setFont(new JLabel().getFont());
      ta.setEditable(false);
      infoPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      infoPanel.setOpaque(false);
      ta.setOpaque(false);
      infoPanel.add(new JLabel(new ImageIcon(getClass().getClassLoader().getResource(IconLocations.INFO_ICON_48))));
      infoPanel.add(ta);
      techtreePanel.add(infoPanel, BorderLayout.SOUTH);
    }
   
    return techtreePanel;
  }
 
  public JPanel getBuildingCalculatorPanel()
  {
    if(buildingCalculatorPanel == null)
    {
      buildingCalculatorPanel = new JPanel(new MigLayout(
        "",
        "2[]2",
        "2[]2"));
      buildingCalculatorPanel.setOpaque(false);
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.BDL,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.BAUM_DES_LEBENS)), 0, 0, 0, 0, 0, 0, Productions.MANA, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.KS,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.KR�UTERSCHULE)), 0, 0, 0, 0, 0, 0, Productions.ESSENZEN, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.KH,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.KRISTALLH�HLE)), 0, 0, 0, 0, 0, 0, Productions.KRISTALL, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.SW,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.STEINWURZEL)), 0, 0, 0, 0, 0, 0, Productions.KRAFTSTEIN, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.HA,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.HARZADER)), 0, 0, 0, 0, 0, 0, Productions.GOLDHARZ, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.GG,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.GEHEIME_GROTTE)), 0, 0, 0, 0, 0, 0, Productions.GG_RAUM, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.IA,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.IRRES_AUGE)), 0, 0, 0, 0, 0, 0, null, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.KK,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.KRISTALLINES_KATAPULT)), 0, 0, 0, 0, 0, 0, null, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.KT,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.KRISTALLTURM)), 0, 0, 0, 0, 0, 0, null, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.SM,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.STEINMANTEL)), 0, 0, 0, 0, 0, 0, null, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.HS,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.HELDENSTATUE)), 0, 0, 0, 0, 0, 0, null, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.KB,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.KRIEGSBRUNNEN)), 0, 0, 0, 0, 0, 0, null, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.PH,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.PALASTHOF)), 0, 0, 0, 0, 0, 0, null, 1));
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.XDK,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.XHODOTORISCHER_KOKON)), 0, 0, 0, 0, 0, 0, Productions.GG_RAUM, 1), "wrap");
      buildingCalculatorPanel.add(new AbstractBuilding(this, Buildings.ZS,
        new ImageIcon(getClass().getClassLoader().getResource(
        IconLocations.ZUCHTSTATION)), 0, 0, 0, 0, 0, 0, null, 1));
    }
   
    return buildingCalculatorPanel;
  }
 
  protected RessourcePanel getRessourcePanelHords()
  {
    if(ressourcePanel == null)
    {
      ressourcePanel = new RessourcePanel();
      ressourcePanel.setOpaque(false);
    }
   
    return ressourcePanel;
  }
 
  protected RessourcePanel getRessourcePanelBuildings()
  {
    if(ressourcePanelBuildings == null)
    {
      ressourcePanelBuildings = new RessourcePanel(RessourcePanel.RESS_BUILDINGS);
      ressourcePanelBuildings.setOpaque(false);
    }
   
    return ressourcePanelBuildings;
  }
 
  protected RessourcePanel getRessourcePanelBuildingsTotalAllLevels()
  {
    if(ressourcePanelBuildingsTotalAllLevels == null)
    {
      ressourcePanelBuildingsTotalAllLevels = new RessourcePanel(RessourcePanel.RESS_BUILDINGS_TOTAL);
      ressourcePanelBuildingsTotalAllLevels.setOpaque(false);
    }
   
    return ressourcePanelBuildingsTotalAllLevels;
  }
 
  public JPanel getHeroPanel()
  {
    if(heroPanel == null)
    {
      heroPanel = new JPanel(new MigLayout(
        "",
        "0[]0",
        "0[]0"));
      heroPanel.setBorder(BorderFactory.createTitledBorder(
        BorderFactory.createLineBorder(Color.black), "Wesen"));
      heroPanel.setOpaque(false);
     
      int i = 0;
      heroPanel.add(creatures.DRACHENEIER, "cell 0 " + i++);
      heroPanel.add(creatures.EINHORNWAGEN, "cell 0 " + i++);
      heroPanel.add(creatures.KOBOLD, "cell 0 " + i++);
      heroPanel.add(creatures.EISKRIEGER, "cell 0 " + i++);
      heroPanel.add(creatures.KINDER_DER_MACHT, "cell 0 " + i++);
      heroPanel.add(creatures.HYSTERISCHE_ZENTAURIN, "cell 0 " + i++);
      heroPanel.add(creatures.KRIEGERPRIESTER, "cell 0 " + i++);
      heroPanel.add(creatures.WILDE_ZENTAUREN, "cell 0 " + i++);
      heroPanel.add(creatures.AXTSCHWINGENDE_ZWERGE, "cell 0 " + i++);
      heroPanel.add(creatures.ELFENBOGENSCH�TZEN, "cell 0 " + i++);
      heroPanel.add(creatures.DOPPELAXTZWERGE, "cell 0 " + i++);
      heroPanel.add(creatures.SINGENDE_HALBRIESEN, "cell 0 " + i++);
      heroPanel.add(creatures.STEINWERFENDE_BERGTROLLE, "cell 0 " + i++);
      heroPanel.add(creatures.BAUMRIESE, "cell 0 " + i++);
      heroPanel.add(creatures.ELFENMAGIER, "cell 0 " + i++);
      heroPanel.add(creatures.FEUERFEEN, "cell 0 " + i++);
      heroPanel.add(creatures.STURMFEEN, "cell 0 " + i++);
      heroPanel.add(getRessourcePanelHords(), "cell 0 " + i++);
    }
   
    return heroPanel;
  }
 
  public JPanel getGuardPanel()
  {
    if(guardPanel == null)
    {
      guardPanel = new JPanel(new MigLayout(
        "",
        "0[]0",
        "0[]0[bottom]0"));
      guardPanel.setBorder(BorderFactory.createTitledBorder(
        BorderFactory.createLineBorder(Color.black), "W�chter"));
      guardPanel.setOpaque(false);
     
      int i = 0;
      int j = 0;
      guardPanel.add(creatures.SALAMANDER, "cell " + j + " " + i++);
      guardPanel.add(creatures.WURZELWICHTE, "cell " + j + " " + i++);
      guardPanel.add(creatures.FLEISCHHUMMELN, "cell " + j + " " + i++);
      guardPanel.add(creatures.SKARABAEUS, "cell " + j + " " + i++);
      guardPanel.add(creatures.GNOME, "cell " + j + " " + i++);
      guardPanel.add(creatures.IRRLICHTER, "cell " + j + " " + i++);
      guardPanel.add(creatures.SKR�LINGE, "cell " + j + " " + i++);
      guardPanel.add(creatures.WARZENGIFTRATTEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.SYLPHEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.MIDGARSCHLANGEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.NYMPHEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.SCHLINGPFLANZEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.MEERJUNGFRAUEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.WERW�LFE, "cell " + j + " " + i++);
      guardPanel.add(creatures.GORGONEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.HARPIEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.WEISSADLER, "cell " + j + " " + i++);
      guardPanel.add(creatures.MORLOCKS, "cell " + j + " " + i++);
      guardPanel.add(creatures.RIESEN_MAROKSPINNEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.FEUERTEUFEL, "cell " + j + " " + i++);
      guardPanel.add(creatures.FENRISWOLF, "cell " + j + " " + i++);
      guardPanel.add(creatures.D�MON, "cell " + j + " " + i++);
      guardPanel.add(creatures.HORNGOLEMS, "cell " + j++ + " " + i++); i=0;
      guardPanel.add(creatures.SONNENPFERDE, "cell " + j + " " + i++);
      guardPanel.add(creatures.MINOTAUREN, "cell " + j + " " + i++);
      guardPanel.add(creatures.GREIFEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.BLUTALBEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.ZYKLOPEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.MANTIKOREN, "cell " + j + " " + i++);
      guardPanel.add(creatures.BEHEMOTH, "cell " + j + " " + i++);
      guardPanel.add(creatures.OGER, "cell " + j + " " + i++);
      guardPanel.add(creatures.SANDW�RMER, "cell " + j + " " + i++);
      guardPanel.add(creatures.TODESENGEL, "cell " + j + " " + i++);
      guardPanel.add(creatures.GOLDENE_SPHINX, "cell " + j + " " + i++);
      guardPanel.add(creatures.FEUERSTACHELDRACHEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.EISAUGENDRACHEN, "cell " + j + " " + i++);
      guardPanel.add(creatures.SCHLANGENHALSDRACHEN, "cell " + j + " " + i++);
    }
   
    return guardPanel;
  }
 
  private JPanel getResultPanel()
  {
    if(resultPanel == null)
    {
      resultPanel = new JPanel(new MigLayout(
        "",
        "0[]0",
        "0[]0"));
      resultPanel.setOpaque(false);
     
      JPanel results = new JPanel(new MigLayout(
        "",
        "5[]5",
        "2[]2"));
      results.setOpaque(false);
      results.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Berechnung"));
      results.add(new JLabel("Angr. We."), "cell 0 0");
      results.add(jTextFieldAPWesen, "cell 1 0");
      results.add(new JLabel("Angr. W�."), "cell 2 0");
      results.add(jTextFieldAPW�chter, "cell 3 0");
     
      results.add(new JLabel("Vert. We."), "cell 0 1");
      results.add(jTextFieldDefWesen, "cell 1 1");
      results.add(new JLabel("Vert. W�."), "cell 2 1");
      results.add(jTextFieldDefW�chter, "cell 3 1");
     
      results.add(new JLabel("Leb. We."), "cell 0 2");
      results.add(jTextFieldHPWesen, "cell 1 2");
      results.add(new JLabel("Leb. W�."), "cell 2 2");
      results.add(jTextFieldHPW�chter, "cell 3 2");
     
//      resultPanel.add(heroBonusPanel);
      resultPanel.add(results);
      resultPanel.add(dragonsBoni);
     
      jTextFieldAPWesen.setEditable(false);
      jTextFieldAPW�chter.setEditable(false);
      jTextFieldDefWesen.setEditable(false);
      jTextFieldDefW�chter.setEditable(false);
      jTextFieldHPWesen.setEditable(false);
      jTextFieldHPW�chter.setEditable(false);
    }
   
    return resultPanel;
  }
 
  private JPanel getHordenCalculatorPanel()
  {
    if(hordenCalculatorPanel == null)
    {
      hordenCalculatorPanel = new JPanel(new MigLayout(
        "",
        "0[]1[]0",
        "0[]0"));
      hordenCalculatorPanel.setOpaque(false);
      hordenCalculatorPanel.add(getHeroPanel());
      hordenCalculatorPanel.add(getGuardPanel());
      hordenCalculatorPanel.add(getResultPanel(), "south");
      hordenCalculatorPanel.setOpaque(false);
    }
   
    return hordenCalculatorPanel;
  }
 
  public DragonsBoniToHorde getDragonsBoniToHorde()
  {
    return dragonsBoni;
  }
 
  public AngelsBoniToBuildings getAngelsBoniToBuildings()
  {
    return angelsBoniPanel;
  }
 
  public ArtefactsBoniToBuildings getArtefactsBoniToBuildings()
  {
    return artefactsBoniToBuildings;
  }
 
  public XdKAndZSPanel getXdKAndZSPanel()
  {
    return xdkAndZSPanel;
  }
 
  protected void calculateHords()
  {
    calculateAP();
    calculateDef();
    calculateHP();
    calculateRessources();
    calculateCreatures();
  }
 
  protected void calculateBuildings()
  {
    calculateEachBuilding();
    calculateBuildingsRess();
    calculateBuildingsRessTotal();
  }
 
  private void calculateEachBuilding()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        for(Component c : getBuildingCalculatorPanel().getComponents())
        {
          if(c instanceof AbstractBuilding)
          {
            if(((AbstractBuilding)c).getName().equals(Buildings.BDL))
            {
              Integer cEss = Double.valueOf(kmRound(102 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(59 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(143.5 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pMan = Double.valueOf(kmRound(Math.pow(((AbstractBuilding)c).getLevel(), 1.1), 0)).intValue();
             
              Integer diffAngel = null;
              if(angelsBoniPanel.isManAngelActivated())
              {
                diffAngel = Long.valueOf(Math.round(Double.valueOf(pMan * 0.2))).intValue();
                pMan += diffAngel;
              }
             
              Integer diffArtefact = null;
              Double diffArtefactPerGMPercent = null;
              Integer diffArtefactPerGM = null;
              if(artefactsBoniToBuildings.isManaArtefactActivated())
              {
                double manaProdPercent = 0.05// 5% Manaproduktion
                if(artefactsBoniToBuildings.getLiga() > 10 &&
                  artefactsBoniToBuildings.getLiga() <= 60)
                {
                  manaProdPercent += (artefactsBoniToBuildings.getLiga() - 10) * 0.005;
                }
                else if(artefactsBoniToBuildings.getLiga() > 60)
                {
                  manaProdPercent = 0.3;
                }
               
                diffArtefact = Long.valueOf(Math.round(Double.valueOf(pMan * manaProdPercent))).intValue();
                if(artefactsBoniToBuildings.getNumGildMembers() == 0) diffArtefactPerGMPercent = 0.0;
                else diffArtefactPerGMPercent = manaProdPercent / artefactsBoniToBuildings.getNumGildMembers();
                diffArtefactPerGM = Long.valueOf(Math.round(Double.valueOf(diffArtefact * diffArtefactPerGMPercent))).intValue();
                pMan += diffArtefact;
              }
             
              if(diffAngel != null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdMana(nf.format(Long.valueOf(pMan.toString()).longValue()) +
                  " (" + diffAngel + ") [" + diffArtefact + " (" + diffArtefactPerGM + " pro Gildenmitglied)]");
              }
              else if(diffAngel != null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdMana(nf.format(Long.valueOf(pMan.toString()).longValue()) +
                  " (" + diffAngel + ")");
              }
              else if(diffAngel == null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdMana(nf.format(Long.valueOf(pMan.toString()).longValue()) +
                  " [" + diffArtefact + " (" + diffArtefactPerGM + " pro Gildenmitglied)]");
              }
              else if(diffAngel == null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdMana(nf.format(Long.valueOf(pMan.toString()).longValue()));
              }
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.KS))
            {
              Integer cEss = Double.valueOf(kmRound(24 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(14.2 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(86.1 * ((AbstractBuilding)c).getLevel(), 0) + 0.4).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pEss = Double.valueOf(kmRound(Math.pow(((AbstractBuilding)c).getLevel(), 1.96) + 3, 0)).intValue();

              Integer diffAngel = null;
              if(angelsBoniPanel.isEssAngelActivated())
              {
                diffAngel = Long.valueOf(Math.round(Double.valueOf(pEss * 0.2))).intValue();
                pEss += diffAngel;
              }
             
              Integer diffArtefact = null;
              if(artefactsBoniToBuildings.isEssAndKriArtefactActivated())
              {
                double essProdPercent = 0.05// 5% Manaproduktion
                if(artefactsBoniToBuildings.getLiga() > 10 &&
                  artefactsBoniToBuildings.getLiga() <= 60)
                {
                  essProdPercent += (artefactsBoniToBuildings.getLiga() - 10) * 0.005;
                }
                else if(artefactsBoniToBuildings.getLiga() > 60)
                {
                  essProdPercent = 0.3;
                }
               
                diffArtefact = Long.valueOf(Math.round(Double.valueOf(pEss * essProdPercent))).intValue();
                pEss += diffArtefact;
              }
             
              if(diffAngel != null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdEssenzen(nf.format(Long.valueOf(pEss.toString()).longValue()) +
                  " (" + diffAngel + ") [" + diffArtefact + "]");
              }
              else if(diffAngel != null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdEssenzen(nf.format(Long.valueOf(pEss.toString()).longValue()) +
                  " (" + diffAngel + ")");
              }
              else if(diffAngel == null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdEssenzen(nf.format(Long.valueOf(pEss.toString()).longValue()) +
                  " [" + diffArtefact + "]");
              }
              else if(diffAngel == null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdEssenzen(nf.format(Long.valueOf(pEss.toString()).longValue()));
              }
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.KH))
            {
              Integer cEss = Double.valueOf(kmRound(17.1 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(18.6 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(77.5 * ((AbstractBuilding)c).getLevel(), 0) + 0.4).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pKri = Double.valueOf(kmRound(0.83332 * Math.pow(((AbstractBuilding)c).getLevel(), 1.96) + 2.35, 0)).intValue();

              Integer diffAngel = null;
              if(angelsBoniPanel.isKriAngelActivated())
              {
                diffAngel = Long.valueOf(Math.round(Double.valueOf(pKri * 0.2))).intValue();
                pKri += diffAngel;
              }
             
              Integer diffArtefact = null;
              if(artefactsBoniToBuildings.isEssAndKriArtefactActivated())
              {
                double kriProdPercent = 0.05// 5% Manaproduktion
                if(artefactsBoniToBuildings.getLiga() > 10 &&
                  artefactsBoniToBuildings.getLiga() <= 60)
                {
                  kriProdPercent += (artefactsBoniToBuildings.getLiga() - 10) * 0.005;
                }
                else if(artefactsBoniToBuildings.getLiga() > 60)
                {
                  kriProdPercent = 0.3;
                }
               
                diffArtefact = Long.valueOf(Math.round(Double.valueOf(pKri * kriProdPercent))).intValue();
                pKri += diffArtefact;
              }
             
              if(diffAngel != null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdKristalle(nf.format(Long.valueOf(pKri.toString()).longValue()) +
                  " (" + diffAngel + ") [" + diffArtefact + "]");
              }
              else if(diffAngel != null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdKristalle(nf.format(Long.valueOf(pKri.toString()).longValue()) +
                  " (" + diffAngel + ")");
              }
              else if(diffAngel == null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdKristalle(nf.format(Long.valueOf(pKri.toString()).longValue()) +
                  " [" + diffArtefact + "]");
              }
              else if(diffAngel == null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdKristalle(nf.format(Long.valueOf(pKri.toString()).longValue()));
              }
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.SW))
            {
              Integer cEss = Double.valueOf(kmRound(68 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(158 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(229.625 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pKra = Double.valueOf(kmRound(0.625 * Math.pow(((AbstractBuilding)c).getLevel(), 1.96) + 1.5, 0)).intValue();

              Integer diffAngel = null;
              if(angelsBoniPanel.isKraAngelActivated())
              {
                diffAngel = Long.valueOf(Math.round(Double.valueOf(pKra * 0.2))).intValue();
                pKra += diffAngel;
              }
             
              Integer diffArtefact = null;
              if(artefactsBoniToBuildings.isKraAndGolArtefactActivated())
              {
                double kraProdPercent = 0.05// 5% Manaproduktion
                if(artefactsBoniToBuildings.getLiga() > 10 &&
                  artefactsBoniToBuildings.getLiga() <= 60)
                {
                  kraProdPercent += (artefactsBoniToBuildings.getLiga() - 10) * 0.005;
                }
                else if(artefactsBoniToBuildings.getLiga() > 60)
                {
                  kraProdPercent = 0.3;
                }
               
                diffArtefact = Long.valueOf(Math.round(Double.valueOf(pKra * kraProdPercent))).intValue();
                pKra += diffArtefact;
              }
             
              if(diffAngel != null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdKraftsteine(nf.format(Long.valueOf(pKra.toString()).longValue()) +
                  " (" + diffAngel + ") [" + diffArtefact + "]");
              }
              else if(diffAngel != null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdKraftsteine(nf.format(Long.valueOf(pKra.toString()).longValue()) +
                  " (" + diffAngel + ")");
              }
              else if(diffAngel == null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdKraftsteine(nf.format(Long.valueOf(pKra.toString()).longValue()) +
                  " [" + diffArtefact + "]");
              }
              else if(diffAngel == null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdKraftsteine(nf.format(Long.valueOf(pKra.toString()).longValue()));
              }
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.HA))
            {
              Integer cEss = Double.valueOf(kmRound(450 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(240 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(100 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(430.5 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pGol = Double.valueOf(kmRound(0.455 * Math.pow(((AbstractBuilding)c).getLevel(), 1.96) + 0.75, 0)).intValue();

              Integer diffAngel = null;
              if(angelsBoniPanel.isGolAngelActivated())
              {
                diffAngel = Long.valueOf(Math.round(Double.valueOf(pGol * 0.2))).intValue();
                pGol += diffAngel;
              }
             
              Integer diffArtefact = null;
              if(artefactsBoniToBuildings.isKraAndGolArtefactActivated())
              {
                double golProdPercent = 0.05// 5% Manaproduktion
                if(artefactsBoniToBuildings.getLiga() > 10 &&
                  artefactsBoniToBuildings.getLiga() <= 60)
                {
                  golProdPercent += (artefactsBoniToBuildings.getLiga() - 10) * 0.005;
                }
                else if(artefactsBoniToBuildings.getLiga() > 60)
                {
                  golProdPercent = 0.3;
                }
               
                diffArtefact = Long.valueOf(Math.round(Double.valueOf(pGol * golProdPercent))).intValue();
                pGol += diffArtefact;
              }
             
              if(diffAngel != null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdGoldharz(nf.format(Long.valueOf(pGol.toString()).longValue()) +
                  " (" + diffAngel + ") [" + diffArtefact + "]");
              }
              else if(diffAngel != null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdGoldharz(nf.format(Long.valueOf(pGol.toString()).longValue()) +
                  " (" + diffAngel + ")");
              }
              else if(diffAngel == null && diffArtefact != null)
              {
                ((AbstractBuilding)c).setProdGoldharz(nf.format(Long.valueOf(pGol.toString()).longValue()) +
                  " [" + diffArtefact + "]");
              }
              else if(diffAngel == null && diffArtefact == null)
              {
                ((AbstractBuilding)c).setProdGoldharz(nf.format(Long.valueOf(pGol.toString()).longValue()));
              }
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.GG))
            {
              Integer cEss = Double.valueOf(kmRound(243 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(223 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(172.2 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
             
              Integer pRaum = Double.valueOf(800 * Math.pow(((AbstractBuilding)c).getLevel(), 1.8)).intValue();
              ((AbstractBuilding)c).setProdGGRaum(nf.format(Long.valueOf(pRaum.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.IA))
            {
              Integer cEss = Double.valueOf(kmRound(823 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(1132 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(565 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cGol = Double.valueOf(kmRound(734 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(602.7 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.KK))
            {
              Integer cEss = Double.valueOf(kmRound(1500 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(1800 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(600 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cGol = Double.valueOf(kmRound(250 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(803.7 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.KT))
            {
              Integer cEss = Double.valueOf(kmRound(2022 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(3631 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(812 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(430.5 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.SM))
            {
              Integer cEss = Double.valueOf(kmRound(288 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(776 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(1431 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(258.3 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.HS))
            {
              Integer cEss = Double.valueOf(kmRound(1000 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(1000 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(700 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cGol = Double.valueOf(kmRound(900 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(258.3 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.KB))
            {
              Integer cEss = Double.valueOf(kmRound(844 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(775 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(350 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cGol = Double.valueOf(kmRound(550 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(574 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.PH))
            {
              Integer cEss = Double.valueOf(kmRound(734 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(896 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cKra = Double.valueOf(kmRound(651 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
             
              Integer cGol = Double.valueOf(kmRound(290 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
                       
              Integer cMan = Double.valueOf(kmRound(516.6 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.XDK))
            {
              Integer cEss = Double.valueOf(kmRound(58 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(21 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(157.85 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
            else if(((AbstractBuilding)c).getName().equals(Buildings.ZS))
            {
              Integer cEss = Double.valueOf(kmRound(58 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
             
              Integer cKri = Double.valueOf(kmRound(22 * (((AbstractBuilding)c).getLevel() * ((AbstractBuilding)c).getLevel()), 0)).intValue();
              ((AbstractBuilding)c).setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
             
              Integer cMan = Double.valueOf(kmRound(186.55 * ((AbstractBuilding)c).getLevel(), 0)).intValue();
              ((AbstractBuilding)c).setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
            }
          }
        }
      }
    });
  }
 
  private void calculateBuildingsRess()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        BigInteger essenzen = BigInteger.valueOf(0L);
        BigInteger kristalle = BigInteger.valueOf(0L);
        BigInteger kraftsteine = BigInteger.valueOf(0L);
        BigInteger goldharz = BigInteger.valueOf(0L);
        BigInteger mana = BigInteger.valueOf(0L);
       
        for(Component c : getBuildingCalculatorPanel().getComponents())
        {
          if(c instanceof AbstractBuilding)
          {
            essenzen = essenzen.add(new BigInteger(((AbstractBuilding)c).getEssenzen().toString()));
            kristalle = kristalle.add(new BigInteger(((AbstractBuilding)c).getKristallsplitter().toString()));
            kraftsteine = kraftsteine.add(new BigInteger(((AbstractBuilding)c).getKraftsteine().toString()));
            goldharz = goldharz.add(new BigInteger(((AbstractBuilding)c).getGoldharz().toString()));
            mana = mana.add(new BigInteger(((AbstractBuilding)c).getMana().toString()));
          }
        }
       
        getRessourcePanelBuildings().setEssenzen(nf.format(Long.valueOf(essenzen.toString()).longValue()));
        getRessourcePanelBuildings().setKristallsplitter(nf.format(Long.valueOf(kristalle.toString()).longValue()));
        getRessourcePanelBuildings().setKraftsteine(nf.format(Long.valueOf(kraftsteine.toString()).longValue()));
        getRessourcePanelBuildings().setGoldharz(nf.format(Long.valueOf(goldharz.toString()).longValue()));
        getRessourcePanelBuildings().setMana(nf.format(Long.valueOf(mana.toString()).longValue()));
      }
    });
  }
 
  private void calculateBuildingsRessTotal()
  {
    BigInteger cEss = BigInteger.valueOf(0L);
    BigInteger cKri = BigInteger.valueOf(0L);
    BigInteger cKra = BigInteger.valueOf(0L);
    BigInteger cGol = BigInteger.valueOf(0L);
    BigInteger cMan = BigInteger.valueOf(0L);
   
    for(Component c : getBuildingCalculatorPanel().getComponents()) // every building
    {
      if(c instanceof AbstractBuilding)
      {
        if(((AbstractBuilding)c).getName().equals(Buildings.BDL))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(102 * (i * i), 0)).intValue();
            Integer kr = Double.valueOf(kmRound(59 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(143.5 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kr.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.KS))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(24 * (i * i), 0)).intValue();             
            Integer kr = Double.valueOf(kmRound(14.2 * (i * i), 0)).intValue();             
            Integer ma = Double.valueOf(kmRound(86.1 * i, 0) + 0.4).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kr.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.KH))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(17.1 * (i * i), 0)).intValue();
            Integer kr = Double.valueOf(kmRound(18.6 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(77.5 * i, 0) + 0.4).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kr.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.SW))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(68 * (i * i), 0)).intValue();
            Integer kr = Double.valueOf(kmRound(158 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(229.625 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kr.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.HA))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(450 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(240 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(100 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(430.5 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.GG))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(243 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(223 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(172.2 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.IA))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(823 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(1132 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(565 * (i * i), 0)).intValue();
            Integer go = Double.valueOf(kmRound(734 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(602.7 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cGol = cGol.add(new BigInteger(go.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.KK))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(1500 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(1800 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(600 * (i * i), 0)).intValue();
            Integer go = Double.valueOf(kmRound(250 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(803.7 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cGol = cGol.add(new BigInteger(go.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.KT))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(2022 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(3631 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(812 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(430.5 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.SM))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(288 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(776 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(1431 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(258.3 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.HS))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(1000 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(1000 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(700 * (i * i), 0)).intValue();
            Integer go = Double.valueOf(kmRound(900 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(258.3 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cGol = cGol.add(new BigInteger(go.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.KB))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(844 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(775 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(350 * (i * i), 0)).intValue();
            Integer go = Double.valueOf(kmRound(550 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(574 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cGol = cGol.add(new BigInteger(go.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.PH))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(734 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(896 * (i * i), 0)).intValue();
            Integer kra = Double.valueOf(kmRound(651 * (i * i), 0)).intValue();
            Integer go = Double.valueOf(kmRound(290 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(516.6 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cKra = cKra.add(new BigInteger(kra.toString()));
            cGol = cGol.add(new BigInteger(go.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.XDK))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(58 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(21 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(157.85 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
        else if(((AbstractBuilding)c).getName().equals(Buildings.ZS))
        {
          int level = ((AbstractBuilding)c).getLevel();
          for(int i=0; i<=level; i++) // every level
          {
            Integer es = Double.valueOf(kmRound(58 * (i * i), 0)).intValue();
            Integer kri = Double.valueOf(kmRound(22 * (i * i), 0)).intValue();
            Integer ma = Double.valueOf(kmRound(186.55 * i, 0)).intValue();
            cEss = cEss.add(new BigInteger(es.toString()));
            cKri = cKri.add(new BigInteger(kri.toString()));
            cMan = cMan.add(new BigInteger(ma.toString()));
          }
        }
       
        getRessourcePanelBuildingsTotalAllLevels().setEssenzen(nf.format(Long.valueOf(cEss.toString()).longValue()));
        getRessourcePanelBuildingsTotalAllLevels().setKristallsplitter(nf.format(Long.valueOf(cKri.toString()).longValue()));
        getRessourcePanelBuildingsTotalAllLevels().setKraftsteine(nf.format(Long.valueOf(cKra.toString()).longValue()));
        getRessourcePanelBuildingsTotalAllLevels().setGoldharz(nf.format(Long.valueOf(cGol.toString()).longValue()));
        getRessourcePanelBuildingsTotalAllLevels().setMana(nf.format(Long.valueOf(cMan.toString()).longValue()));
      }
    }
  }
 
  public static double kmRound(double nr, int n)
  {
    return (Math.round(nr * Math.pow(10, n))) / Math.pow(10, n);
  }

  private void calculateAP()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        BigInteger apHero = BigInteger.valueOf(0L);
        for(Component c : getHeroPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            apHero = apHero.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
                new BigInteger(((AbstractCreature)c).getAngriff().toString())));
          }
        }
        if(dragonsBoni.isAttackDragonActivated())
        {
          BigInteger diff = apHero.divide(BigInteger.valueOf(10L));
          apHero = apHero.add(diff);
          jTextFieldAPWesen.setText(nf.format(Long.valueOf(
            apHero.toString()).longValue()) + " (" + nf.format(Long.valueOf(diff.toString())) + ")");
        }
        else
        {
          jTextFieldAPWesen.setText(nf.format(Long.valueOf(
            apHero.toString()).longValue()));
        }
     
        BigInteger apGuard = BigInteger.valueOf(0L);
        for(Component c : getGuardPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            apGuard = apGuard.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
                new BigInteger(((AbstractCreature)c).getAngriff().toString())));
          }
        }
        jTextFieldAPW�chter.setText(nf.format(Long.valueOf(
          apGuard.toString()).longValue()));
       
        if(apHero.compareTo(apGuard) == 1) // >
        {
          jTextFieldAPWesen.setBackground(Color.green);
        }
        else if(apHero.compareTo(apGuard) == -1) // <
        {
          jTextFieldAPWesen.setBackground(Color.red);
        }
        else if(apHero.compareTo(apGuard) == 0) // =
        {
          jTextFieldAPWesen.setBackground(Color.gray);
        }
      }
    });
  }
 
  private void calculateDef()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        BigInteger defHero = BigInteger.valueOf(0L);
        for(Component c : getHeroPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            defHero = defHero.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
                new BigInteger(((AbstractCreature)c).getVerteidigung().toString())));
          }
        }
        if(dragonsBoni.isDefDragonActivated())
        {
          BigInteger diff = defHero.divide(BigInteger.valueOf(10L));
          defHero = defHero.add(diff);
          jTextFieldDefWesen.setText(nf.format(Long.valueOf(
            defHero.toString()).longValue()) + " (" + nf.format(Long.valueOf(diff.toString())) + ")");
        }
        else
        {
          jTextFieldDefWesen.setText(nf.format(Long.valueOf(
            defHero.toString()).longValue()));
        }
     
        BigInteger defGuard = BigInteger.valueOf(0L);
        for(Component c : getGuardPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            defGuard = defGuard.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
                new BigInteger(((AbstractCreature)c).getVerteidigung().toString())));
          }
        }
        jTextFieldDefW�chter.setText(nf.format(Long.valueOf(
          defGuard.toString()).longValue()));
       
        if(defHero.compareTo(defGuard) == 1)
        {
          jTextFieldDefWesen.setBackground(Color.green);
        }
        else if(defHero.compareTo(defGuard) == -1)
        {
          jTextFieldDefWesen.setBackground(Color.red);
        }
        else if(defHero.compareTo(defGuard) == 0)
        {
          jTextFieldDefWesen.setBackground(Color.gray);
        }
      }
    });
  }
 
  private void calculateHP()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        BigInteger hpHero = BigInteger.valueOf(0L);
        for(Component c : getHeroPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            hpHero = hpHero.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
              new BigInteger(((AbstractCreature)c).getLeben().toString())));
          }
        }
        if(dragonsBoni.isLifeDragonActivated())
        {
          BigInteger diff = hpHero.divide(BigInteger.valueOf(10L));
          hpHero = hpHero.add(diff);
          jTextFieldHPWesen.setText(nf.format(Long.valueOf(
            hpHero.toString()).longValue()) + " (" + nf.format(Long.valueOf(diff.toString())) + ")");
        }
        else
        {
          jTextFieldHPWesen.setText(nf.format(Long.valueOf(
            hpHero.toString()).longValue()));
        }
     
        BigInteger hpGuard = BigInteger.valueOf(0L);
        for(Component c : getGuardPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            hpGuard = hpGuard.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
              new BigInteger(((AbstractCreature)c).getLeben().toString())));
          }
        }
        jTextFieldHPW�chter.setText(nf.format(Long.valueOf(
          hpGuard.toString()).longValue()));
       
        if(hpHero.compareTo(hpGuard) == 1// >
        {
          jTextFieldHPWesen.setBackground(Color.green);
        }
        else if(hpHero.compareTo(hpGuard) == -1) // <
        {
          jTextFieldHPWesen.setBackground(Color.red);
        }
        else if(hpHero.compareTo(hpGuard) == 0) // ==
        {
          jTextFieldHPWesen.setBackground(Color.gray);
        }
      }
    });
  }
 
  private void calculateRessources()
  {
    BigInteger essenzen = BigInteger.valueOf(0L);
    BigInteger kristallsplitter = BigInteger.valueOf(0L);
    BigInteger kraftsteine = BigInteger.valueOf(0L);
    BigInteger goldharz = BigInteger.valueOf(0L);
    BigInteger mana = BigInteger.valueOf(0L);
    BigInteger raum = BigInteger.valueOf(0L);
   
    for(Component c : getHeroPanel().getComponents())
    {
      if(c instanceof AbstractCreature)
      {
        essenzen = essenzen.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getEssenzen().toString())));
        kristallsplitter = kristallsplitter.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getKristallsplitter().toString())));
        kraftsteine = kraftsteine.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getKraftsteine().toString())));
        goldharz = goldharz.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getGoldharz().toString())));
        mana = mana.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getMana().toString())));
        raum = raum.add(new BigInteger(Integer.valueOf(((AbstractCreature)c).getNumCreatures()).toString()).multiply(
          new BigInteger(((AbstractCreature)c).getRaum().toString())));
      }
    }
   
    getRessourcePanelHords().setEssenzen(nf.format(Long.valueOf(essenzen.toString()).longValue()));
    getRessourcePanelHords().setKristallsplitter(nf.format(Long.valueOf(kristallsplitter.toString()).longValue()));
    getRessourcePanelHords().setKraftsteine(nf.format(Long.valueOf(kraftsteine.toString()).longValue()));
    getRessourcePanelHords().setGoldharz(nf.format(Long.valueOf(goldharz.toString()).longValue()));
    getRessourcePanelHords().setMana(nf.format(Long.valueOf(mana.toString()).longValue()));
    getRessourcePanelHords().setRaum(nf.format(Long.valueOf(raum.toString()).longValue()));
  }
 
  private void calculateCreatures()
  {
    SwingUtilities.invokeLater(new Runnable()
    { 
      @Override
      public void run()
      {
        BigInteger numHeroCeratures = BigInteger.valueOf(0L);
        for(Component c : getHeroPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            numHeroCeratures = numHeroCeratures.add(
              new BigInteger(Integer.valueOf(
              ((AbstractCreature)c).getNumCreatures()).
              toString()));
          }
        }
        getHeroPanel().setBorder(BorderFactory.createTitledBorder(
          BorderFactory.createLineBorder(Color.black), "Wesen - " +
          nf.format(Long.valueOf(numHeroCeratures.toString()).
          longValue())));
       
        BigInteger numGuardCeratures = BigInteger.valueOf(0L);
        for(Component c : getGuardPanel().getComponents())
        {
          if(c instanceof AbstractCreature)
          {
            numGuardCeratures = numGuardCeratures.add(
              new BigInteger(Integer.valueOf(
              ((AbstractCreature)c).getNumCreatures()).
              toString()));
          }
        }
        getGuardPanel().setBorder(BorderFactory.createTitledBorder(
          BorderFactory.createLineBorder(Color.black), "W�chter - " +
          nf.format(Long.valueOf(numGuardCeratures.toString()).
          longValue())));
      }
    });
  }
}
TOP

Related Classes of xapc.gui.PalastPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.