Beispiel #1
0
  private Component createPlayButtonPanel() {
    JPanel buttonJP = new JPanel();
    buttonJP.setBackground(new Color(0x8DB6CD));
    buttonJP.setSize(getSize().width, 50);
    buttonJP.setPreferredSize(buttonJP.getSize());
    buttonJP.setMaximumSize(buttonJP.getSize());
    buttonJP.setVisible(true);

    generatePlayButtonPanelContent(buttonJP);

    return buttonJP;
  }
  /**
   * Main PlamsidPanel constructor. A PlamsidPanel shows a Plasmid object and lives inside of a
   * JPanel. The size of the PlasmidPanel is determined from the size of the panel in which it
   * lives.
   *
   * @param p the Plasmid object
   * @param pan the JPanel that this PlasmidPanel lives in
   */
  public PlasmidPanel(org.autogene.core.bio.entities.Plasmid p, JPanel pan, Viewer parent) {
    homePanel = pan;
    home = parent;

    setSize(homePanel.getSize());
    setPreferredSize(homePanel.getSize());

    plasmid = p;
    initComponents();
    initCgview();
    addMouseListener(this);
    // addMouseMotionListener(this);

  }
Beispiel #3
0
  /** The main function for displaying the Life game area. */
  private void paintCanvas(Graphics g) {
    Dimension canvasSize = canvas.getSize();
    int xdelta = canvasSize.width / modelSize;
    if (xdelta == 0) {
      xdelta = 1;
    }
    int ydelta = canvasSize.height / modelSize;
    if (ydelta == 0) {
      ydelta = 1;
    }

    for (int x = 0; x < modelSize; ++x) {
      for (int y = 0; y < modelSize; ++y) {
        int age = theModel.getCell(x, y);
        // System.out.print("("+x+","+y+"): " + age);
        if (generationCount >= 10 && age > 0) {
          age = 1 + 10 * age / generationCount;
        }
        if (age >= 10) {
          age = 9;
        }
        Color c = (age > 0) ? colorMap[age - 1] : Color.black;
        // System.out.println(" " + age + " color: " + c);
        g.setColor(c);
        g.fillRect(x * xdelta, y * ydelta, xdelta, ydelta);
      }
    }
    Thread.yield();
  }
  private void resetRemainderProblems() {

    problemDisplays = new RemainderProblemDisplay[round.getNumProblems()];

    JPanel panel = new JPanel();
    panel.setMinimumSize(new Dimension(2, 2));
    panel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    for (int i = round.getNumProblems() / 4 + (round.getNumProblems() % 4 == 0 ? 0 : 1);
        i >= 0;
        i--) {
      panel.setSize(new Dimension(370, panel.getSize().height + 60));
    }
    panel.setLayout(new Layout(0, 4));

    for (int i = 0; i < round.getNumProblems(); i++) {
      RemainderProblemDisplay problem =
          new RemainderProblemDisplay(
              round.getProblem(i), round.getGenerator().getParam().charAt(0));
      problemDisplays[i] = problem;
      panel.add(problem);
    }
    panel.revalidate();
    problems.setPreferredSize(new Dimension(388, 360));
    problems.setViewportView(panel);
    problems.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    problems.revalidate();
  }
Beispiel #5
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
Beispiel #6
0
 public void move() {
   Graphics g = canvas.getGraphics();
   g.setColor(canvas.getBackground());
   g.fillOval(x, y, XSIZE, YSIZE);
   x += dx;
   y += dy;
   Dimension d = canvas.getSize();
   if (x < 0) {
     x = 0;
     dx = -dx;
   }
   if (x + XSIZE >= d.width) {
     x = d.width - XSIZE;
     dx = -dx;
   }
   if (y < 0) {
     y = 0;
     dy = -dy;
   }
   if (y + YSIZE >= d.height) {
     y = d.height - YSIZE;
     dy = -dy;
   }
   g.setColor(color);
   g.fillOval(x, y, XSIZE, YSIZE);
   g.dispose();
 }
 public OffscreenViewPanel(Vector cameras) {
   // init of camera array
   cams = new Camera[cameras.size()]; // array of Camera
   for (int nbcam = 0; nbcam < cameras.size(); nbcam++) {
     cams[nbcam] = (Camera) (cameras.get(nbcam));
   }
   // init other stuff
   panel.setBackground(Color.white);
   this.size = panel.getSize();
 }
        @Override
        public void focusGained(FocusEvent e) {
          if (e.getOppositeComponent() != null) {
            JTextField valueTextField = editorComponent.getTextField();
            DataEditorSettings settings = cell.getRow().getModel().getSettings();
            if (settings.getGeneralSettings().getSelectContentOnCellEdit().value()) {
              valueTextField.selectAll();
            }

            Rectangle rectangle = new Rectangle(mainPanel.getLocation(), mainPanel.getSize());
            parentForm.getColumnsPanel().scrollRectToVisible(rectangle);
          }
        }
Beispiel #9
0
  private void initComponents() {
    LoadScreen.Update("Locaties instellen", 10);

    lblTitle = new javax.swing.JLabel();
    Vraag = new javax.swing.JPanel();
    lblVraag = new javax.swing.JLabel();
    pbTime = new javax.swing.JProgressBar();
    Antwoorde = new javax.swing.JPanel();

    // setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setAlwaysOnTop(true);
    setUndecorated(true);
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    lblTitle.setText("{%TITLE}");
    getContentPane().add(lblTitle, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

    Vraag.setBackground(new Color(0, 0, 128));

    lblVraag.setFont(new java.awt.Font("DejaVu Sans", 1, 24)); // NOI18N
    lblVraag.setForeground(new Color(255, 255, 0));
    lblVraag.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    lblVraag.setVerticalAlignment(javax.swing.SwingConstants.TOP);
    lblVraag.setText("{%VRAAG}");
    lblVraag.setBorder(null);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    getContentPane()
        .add(Vraag, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 15, dim.width, 200));

    lblVraag.setLocation(0, 0);
    lblVraag.setSize(Vraag.getSize());
    lblVraag.setVisible(true);
    Vraag.setAlignmentX(javax.swing.SwingConstants.LEFT);
    Vraag.add(lblVraag);

    Antwoorde.setBackground(new java.awt.Color(200, 200, 100));
    Antwoorde.setLayout(new java.awt.GridLayout(3, 2, 5, 5));

    getContentPane()
        .add(
            Antwoorde,
            new org.netbeans.lib.awtextra.AbsoluteConstraints(0, dim.height - 300, dim.width, 300));

    // pack();

    // Vraag.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    this.setLocation(0, 0);
    this.setSize(dim);
  }
Beispiel #10
0
 public void Mostrar(JPanel p) {
   try {
     // se asigna a "url" el archivo de imagen seleccionado
     URL url = getObtener();
     // se lo coloca en memoria
     cargar_imagen(url);
     // se añade al contenedor
     p.add(new mipanel(Obtener_imagen_de_Buffer(), p.getSize()) {});
     p.setVisible(true);
     p.repaint();
   } catch (Exception ex) {
     Logger.getLogger(metodos.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Beispiel #11
0
 public Compiler(MainFrame mf, RussianPost rp, Configuration conf) {
   super(mf, rp, conf);
   JPanel p = mainframe.addGraphicsModule(this, MainFrame.BOTTOM, "Console");
   p.setLayout(new BorderLayout(0, 0));
   closed = false;
   console = new JTextPane();
   console.setSize(p.getSize());
   console.setFocusable(true);
   p.add(new JScrollPane(console));
   int show = -1;
   try {
     show = mainframe.addMenu("Window/Console", this, null);
   } catch (ConflictException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   SHOW = show;
   new Builder();
   new Launcher();
 }
Beispiel #12
0
 /* Metod que muestra una ventana de dialgo para añadir "archivo de imagen"
  *  en memoria  */
 public void Abrir_Dialogo(JPanel p) {
   JFileChooser fileChooser = new JFileChooser();
   fileChooser.setFileFilter(filter);
   int result = fileChooser.showOpenDialog(null);
   if (result == JFileChooser.APPROVE_OPTION) {
     try {
       // se asigna a "url" el archivo de imagen seleccionado
       setObtener(fileChooser.getSelectedFile().toURL());
       URL url = fileChooser.getSelectedFile().toURL();
       // se lo coloca en memoria
       cargar_imagen(url);
       // se añade al contenedor
       p.add(new mipanel(Obtener_imagen_de_Buffer(), p.getSize()) {});
       p.setVisible(true);
       p.repaint();
     } catch (IOException ex) {
       Logger.getLogger(metodos.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 }
  /** Move this ball. */
  public void move() {
    x += dx;
    y += dy;
    Dimension d = panel.getSize();
    if (x < 0) {
      x = 0;
      dx = -dx;
    } else if (x + BALL_DIAM >= d.width) {
      x = d.width - BALL_DIAM;
      dx = -dx;
    }

    if (y < 0) {
      y = 0;
      dy = -dy;
    } else if (y + BALL_DIAM >= d.height) {
      y = d.height - BALL_DIAM;
      dy = -dy;
    }
  }
 private void setOriginWindow(JPanel componentWindow) {
   this.owsize = componentWindow.getSize();
   this.owpos = componentWindow.getLocation();
 }
Beispiel #15
0
  public Dimension getPreferredSize() {

    int height = pane.getSize().height - 5;
    int width = pane.getSize().width;
    return new Dimension(width, height);
  }
// ----------------------------------------------------------------------------
Beispiel #17
0
  public Add() {
    super("Add Flight");

    base = new JPanel(null);
    base.setSize(270, 250);

    //        This part create the textField
    jFlightCode = new JTextField(10);
    jFlightCode.setBounds(150, 8, 100, 20);
    jPlaneCode = new JTextField(10);
    jPlaneCode.setBounds(150, 33, 100, 20);
    jPlaneName = new JTextField(10);
    jPlaneName.setBounds(150, 58, 100, 20);
    jDestination = new JTextField(10);
    jDestination.setBounds(150, 83, 100, 20);
    jFlightTime = new JTextField("YYYY-MM-DD HH:MM:SS");
    jFlightTime.setBounds(150, 108, 100, 20);
    jPrice = new JTextField(10);
    jPrice.setBounds(150, 108 + (33 - 8), 100, 20);

    //        This part create Label for text
    JLabel flightCode = new JLabel("Flight Code");
    flightCode.setBounds(8, 8, 100, 20);
    JLabel planeCode = new JLabel("Plane Code");
    planeCode.setBounds(8, 33, 100, 20);
    JLabel planeName = new JLabel("Plane Name");
    planeName.setBounds(8, 58, 120, 20);
    JLabel destination = new JLabel("Destination");
    destination.setBounds(8, 83, 100, 20);
    JLabel flightTime = new JLabel("Flight Time");
    flightTime.setBounds(8, 108, 100, 20);
    JLabel price = new JLabel("Price");
    price.setBounds(8, 108 + (33 - 8), 100, 20);

    base.add(flightCode);
    base.add(jFlightCode);
    base.add(planeCode);
    base.add(jPlaneCode);
    base.add(planeName);
    base.add(jPlaneName);
    base.add(destination);
    base.add(jDestination);
    base.add(flightTime);
    base.add(jFlightTime);
    base.add(jPrice);
    base.add(price);

    //        This part create the register button
    baccept = new JButton("Accept");
    baccept.setBounds(80 - 50, 195, 100, 20);
    bcancel = new JButton("Cancel");
    bcancel.setBounds(80 - 50 + 100 + 8, 195, 100, 20);
    bcancel.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
            new AdminPage();
          }
        });

    baccept.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (jFlightCode.getText().equalsIgnoreCase("")
                || jPlaneCode.getText().equalsIgnoreCase("")
                || jPlaneName.getText().equalsIgnoreCase("")
                || jDestination.getText().equalsIgnoreCase("")
                || jPrice.getText().equalsIgnoreCase("")
                || jFlightTime.getText().equalsIgnoreCase("")) {
              JOptionPane.showMessageDialog(null, "Data Cannot Be Blank!");
            } else {
              Flight f = new Flight();
              f.setFlightCode(jFlightCode.getText());
              f.setPlaneCode(jPlaneCode.getText());
              f.setPlaneName(jPlaneName.getText());
              f.setDestination(jDestination.getText());
              f.setFlightTime(jFlightTime.getText());
              f.setStatus("ready");
              f.setPrice(Integer.parseInt(jPrice.getText()));
              DataAccess.addFlight(f);
            }
          }
        });

    //        This part add the checkbox and button to the base
    base.add(bcancel);
    base.add(baccept);

    //        this part set the frame
    setResizable(false);
    setSize(base.getSize());
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
    add(base);
  }
  /**
   * setupPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;
    // remove all local enchantments

    Card c;
    /*
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.isLocalEnchantment())
        list.remove(i);
    }

    //add local enchantments to the permanents
    //put local enchantments "next to" the permanent they are enchanting
    //the inner for loop is backward so permanents with more than one local enchantments are in the right order
    Card ca[];
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.hasAttachedCards())
      {
        ca = c.getAttachedCards();
        for(int inner = ca.length - 1; 0 <= inner; inner--)
          list.add(i + 1, ca[inner]);
      }
    }
    */

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> manaPools = getManaPools(list);
      ArrayList<Card> enchantedLands = getEnchantedLands(list);
      ArrayList<Card> basicBlues = getBasics(list, Constant.Color.Blue);
      ArrayList<Card> basicReds = getBasics(list, Constant.Color.Red);
      ArrayList<Card> basicBlacks = getBasics(list, Constant.Color.Black);
      ArrayList<Card> basicGreens = getBasics(list, Constant.Color.Green);
      ArrayList<Card> basicWhites = getBasics(list, Constant.Color.White);
      ArrayList<Card> badlands = getNonBasicLand(list, "Badlands");
      ArrayList<Card> bayou = getNonBasicLand(list, "Bayou");
      ArrayList<Card> plateau = getNonBasicLand(list, "Plateau");
      ArrayList<Card> scrubland = getNonBasicLand(list, "Scrubland");
      ArrayList<Card> savannah = getNonBasicLand(list, "Savannah");
      ArrayList<Card> taiga = getNonBasicLand(list, "Taiga");
      ArrayList<Card> tropicalIsland = getNonBasicLand(list, "Tropical Island");
      ArrayList<Card> tundra = getNonBasicLand(list, "Tundra");
      ArrayList<Card> undergroundSea = getNonBasicLand(list, "Underground Sea");
      ArrayList<Card> volcanicIsland = getNonBasicLand(list, "Volcanic Island");

      ArrayList<Card> nonBasics = getNonBasics(list);

      ArrayList<Card> moxEmerald = getMoxen(list, "Mox Emerald");
      ArrayList<Card> moxJet = getMoxen(list, "Mox Jet");
      ArrayList<Card> moxPearl = getMoxen(list, "Mox Pearl");
      ArrayList<Card> moxRuby = getMoxen(list, "Mox Ruby");
      ArrayList<Card> moxSapphire = getMoxen(list, "Mox Sapphire");
      // ArrayList<Card> moxDiamond = getMoxen(list, "Mox Diamond");

      list = new ArrayList<Card>();
      list.addAll(manaPools);
      list.addAll(enchantedLands);
      list.addAll(basicBlues);
      list.addAll(basicReds);
      list.addAll(basicBlacks);
      list.addAll(basicGreens);
      list.addAll(basicWhites);
      list.addAll(badlands);
      list.addAll(bayou);
      list.addAll(plateau);
      list.addAll(scrubland);
      list.addAll(savannah);
      list.addAll(taiga);
      list.addAll(tropicalIsland);
      list.addAll(tundra);
      list.addAll(undergroundSea);
      list.addAll(volcanicIsland);

      list.addAll(nonBasics);

      list.addAll(moxEmerald);
      list.addAll(moxJet);
      list.addAll(moxPearl);
      list.addAll(moxRuby);
      list.addAll(moxSapphire);
      // list.addAll(moxDiamond);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEnchanted = false;
      Card prevCard = null;
      int nextXIfNotStacked = 0;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);

        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if (c.isAura() && c.isEnchanting() && !nextEnchanted) startANewStack = false;
        else if (c.isAura() && c.isEnchanting()) {
          startANewStack = true;
          nextEnchanted = false;
        }

        if (c.isLand() && c.isEnchanted()) {
          startANewStack = false;
          nextEnchanted = true;
        }

        // very hacky, but this is to ensure enchantment stacking occurs correctly when a land is
        // enchanted, and there are more lands of that same name

        else if ((prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && prevCard.isEnchanted()
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        /*
        if (c.getName().equals("Squirrel Nest")) {
            startANewStack = true;
            System.out.println("startANewStack: " + startANewStack);
        }
        */
        if (c.isAura() && c.isEnchanting() && prevCard != null && prevCard instanceof ManaPool)
          startANewStack = true;
        if (c instanceof ManaPool && prevCard instanceof ManaPool && prevCard.isSnow())
          startANewStack = false;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      // System.out.println("x:" + maxX + ", y:" + maxY);
      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        //        p.setSize(new Dimension(maxX, maxY));
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      // add all Cards in list to the GUI, add arrows to Local Enchantments
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        /*if(c.isLocalEnchantment())
          addPanel = getCardPanel(c, "<< " +c.getName());
        else
          addPanel = getCardPanel(c);
          */
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
  /**
   * setupNoLandPermPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;

    Card c;

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> planeswalkers = getPlaneswalkers(list);
      ArrayList<Card> equippedEnchantedCreatures =
          getEquippedEnchantedCreatures(
              list); // this will also fetch the equipment and/or enchantment
      ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list);
      ArrayList<Card> tokenCreatures = getTokenCreatures(list);

      // sort tokenCreatures by name (TODO: fix the warning message somehow)
      Collections.sort(
          tokenCreatures,
          new Comparator<Card>() {
            public int compare(Card c1, Card c2) {
              return c1.getName().compareTo(c2.getName());
            }
          });

      ArrayList<Card> artifacts = getNonCreatureArtifacts(list);
      ArrayList<Card> enchantments = getGlobalEnchantments(list);
      // ArrayList<Card> nonBasics = getNonBasics(list);

      list = new ArrayList<Card>();
      list.addAll(planeswalkers);
      list.addAll(equippedEnchantedCreatures);
      list.addAll(nonTokenCreatures);
      list.addAll(tokenCreatures);
      list.addAll(artifacts);
      list.addAll(enchantments);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEquippedEnchanted = false;
      int nextXIfNotStacked = 0;
      Card prevCard = null;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);
        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if ((c.isEquipment() || c.isAura())
            && (c.isEquipping() || c.isEnchanting())
            && !nextEquippedEnchanted) startANewStack = false;
        else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) {
          startANewStack = true;
          nextEquippedEnchanted = false;
        }

        if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) {
          startANewStack = false;
          nextEquippedEnchanted = true;
        }
        // very hacky, but this is to ensure equipment stacking occurs correctly when a token is
        // equipped/enchanted, and there are more tokens of that same name
        else if ((prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && (prevCard.isEquipped() || prevCard.isEnchanted())
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping()))
            && prevCard != null
            && prevCard.isPlaneswalker()) startANewStack = true;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()