src/tokenclustering/model/ClusteringAreaData.java
/**
     * Puts a token in this area in the given slot.
     * @param token The token to put.
     * @param slot The slot to put the token.
     * @return The token put or null if it was not possible.
     */
Puts a token in this area in the given slot.
@param token The token to put.
@param slot The slot to put the token.
@return The token put or null if it was not possible.
Puts a token in this area in the given slot . @param token The token to put . @param slot The slot to put the token . @return The token put or null if it was not possible .
public Token putToken(Token token, Slot slot) {
        if (this.getTokens().contains(token)) {
            return null;
        }
        ArrayList<Slot> slots = new ArrayList<Slot>();
        for (int i = slot.getX(); i < slot.getX() + token.getWidth(); i++) {
            for (int j = slot.getY(); j < slot.getY() + token.getHeight(); j++) {
                if (this.occupiedSlots.contains(new Slot(i, j))) {
                    return null;
                }
                slots.add(new Slot(i, j));
            }
        }
        this.occupiedSlots.addAll((Collection<? extends Slot>) slots.clone());
        this.freeSlots.removeAll((Collection<? extends Slot>) slots.clone());
        this.getTokens().add(token);
        token.setOccupiedSlots(slots);
        token.setUpperLeftSlot(slot);
        return token;
    }
public Token putToken ( Token token , Slot slot ) { if ( this . getTokens ( ) . contains ( token ) ) { return null ; } ArrayList < Slot > slots = new ArrayList < Slot > ( ) ; for ( int i = slot . getX ( ) ; i < slot . getX ( ) + token . getWidth ( ) ; i ++ ) { for ( int j = slot . getY ( ) ; j < slot . getY ( ) + token . getHeight ( ) ; j ++ ) { if ( this . occupiedSlots . contains ( new Slot ( i , j ) ) ) { return null ; } slots . add ( new Slot ( i , j ) ) ; } } this . occupiedSlots . addAll ( ( Collection < ? extends Slot > ) slots . clone ( ) ) ; this . freeSlots . removeAll ( ( Collection < ? extends Slot > ) slots . clone ( ) ) ; this . getTokens ( ) . add ( token ) ; token . setOccupiedSlots ( slots ) ; token . setUpperLeftSlot ( slot ) ; return token ; }
Puts a token in this area in the given slot.
Puts a token in this area in the given slot .