Class AlchemyDialog.PlannerModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel
    Enclosing class:
    AlchemyDialog

    public static class AlchemyDialog.PlannerModel
    extends javax.swing.table.AbstractTableModel
    A model for the potion planning table.
    See Also:
    Serialized Form
    • Constructor Detail

      • PlannerModel

        public PlannerModel​(GameData data)
        Parameters:
        data -
    • Method Detail

      • addPotion

        public boolean addPotion​(AlchemyDialog.PlannerModel.PotionInfo potionInfo)
        Adds a potion. External use.
        Parameters:
        potionInfo -
        Returns:
        false if the potion was already in the model.
      • removeHerb

        public boolean removeHerb​(int row)
        Removes the herb of the specified row from the model.
      • removePotion

        public boolean removePotion​(int col)
        Removes the potion of the specified column from the model.
      • setData

        public void setData​(GameData data)
        Change the underlying data. Rests everything.
        Parameters:
        data -
      • resetProduction

        public void resetProduction()
        Set production to 0.
      • updateFromFactions

        public void updateFromFactions​(java.util.List<Faction> factions,
                                       java.util.List<Region> regions)
        Update stocks with items from units of specified factions in selected regions.
        Parameters:
        factions - Units are taken from these factions.
        regions - Only units from these regions will be considered.
      • updateFromRegions

        public void updateFromRegions​(java.util.List<Region> regions)
        Update stocks with region herbs in selected regions.
      • getColumnCount

        public int getColumnCount()
        See Also:
        TableModel.getColumnCount()
      • getRowCount

        public int getRowCount()
        See Also:
        TableModel.getRowCount()
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
        See Also:
        AbstractTableModel.getColumnName(int)
      • getColumnClass

        public java.lang.Class<?> getColumnClass​(int columnIndex)
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
        See Also:
        AbstractTableModel.getColumnClass(int)
      • getValueAt

        public java.lang.Object getValueAt​(int rowIndex,
                                           int columnIndex)
        Returns the value at the specified cell this is either a String or a subclass of AlchemyDialog.PlannerModel.ValueMarker. The table looks as follows: String (max possible) | null | null | MaxValue | ... String (remaining) | null | null | CurrentMaxValue | ... String (planned) | null | null | ProductionValue | ... HerbInfo (Herb1) | StockValue | RestValue | IngredientValue/null | ... HerbInfo (Herb2) | StockValue | RestValue | IngredientValue/null | ... ...
        See Also:
        TableModel.getValueAt(int, int)
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Only stock cells, production cells and ingredient cells are editable.
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.swing.table.AbstractTableModel
        See Also:
        AbstractTableModel.isCellEditable(int, int)
      • setValueAt

        public void setValueAt​(java.lang.Object aValue,
                               int rowIndex,
                               int columnIndex)
        Specified by:
        setValueAt in interface javax.swing.table.TableModel
        Overrides:
        setValueAt in class javax.swing.table.AbstractTableModel
        See Also:
        AbstractTableModel.setValueAt(java.lang.Object, int, int)