Search in sources :

Example 26 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CraftingSynopsisPanelController method doChooseToons.

private void doChooseToons() {
    CharactersManager manager = CharactersManager.getInstance();
    List<CharacterFile> toons = manager.getAllToons();
    List<CharacterFile> selectedToons = _tableController.getToons();
    List<CharacterFile> newSelectedToons = CharactersChooserController.selectToons(_parent, toons, selectedToons);
    if (newSelectedToons != null) {
        _tableController.setToons(newSelectedToons);
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 27 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildRowHeaderColumn.

private TableColumnController<CraftingSynopsisItem, String> buildRowHeaderColumn() {
    CellDataProvider<CraftingSynopsisItem, String> cell = new CellDataProvider<CraftingSynopsisItem, String>() {

        @Override
        public String getData(CraftingSynopsisItem item) {
            CharacterFile character = item.getCharacter();
            String name = character.getName();
            return name;
        }
    };
    TableColumnController<CraftingSynopsisItem, String> column = new TableColumnController<CraftingSynopsisItem, String>("Name", String.class, cell);
    // Init widths
    column.setMinWidth(100);
    column.setPreferredWidth(150);
    column.setMaxWidth(300);
    // Header renderer
    JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = buildCharacterNameCellRenderer();
    column.setCellRenderer(renderer);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) GridBagLayout(java.awt.GridBagLayout) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 28 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CraftingSynopsisWindowController method dispose.

/**
 * Release all managed resources.
 */
@Override
public void dispose() {
    saveBoundsPreferences();
    super.dispose();
    if (_panelController != null) {
        Preferences preferences = Config.getInstance().getPreferences();
        TypedProperties props = preferences.getPreferences(CRAFTING_PREFERENCES_NAME);
        List<String> toonIds = new ArrayList<String>();
        for (CharacterFile toon : _panelController.getTableController().getToons()) {
            toonIds.add(toon.getIdentifier());
        }
        props.setStringList(TOON_NAME_PREFERENCE, toonIds);
        _panelController.dispose();
        _panelController = null;
    }
}
Also used : ArrayList(java.util.ArrayList) Preferences(delta.common.utils.misc.Preferences) TypedProperties(delta.common.utils.misc.TypedProperties) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 29 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CharacterLevelChartController method refresh.

/**
 * Refresh chart data from the underlying statistics.
 */
public void refresh() {
    XYSeriesCollection data = (XYSeriesCollection) _chart.getXYPlot().getDataset();
    List<CharacterFile> newToons = _stats.getToonsList();
    // Find added/removed toons
    ArrayList<Integer> indexesToRemove = new ArrayList<Integer>();
    HashSet<String> toonIDsToRemove = new HashSet<String>();
    for (String toonID : _toonID2SeriesIndex.keySet()) {
        CharacterFile foundToon = null;
        for (CharacterFile toon : newToons) {
            if (toonID.equals(toon.getIdentifier())) {
                foundToon = toon;
                break;
            }
        }
        if (foundToon != null) {
            newToons.remove(foundToon);
        } else {
            Integer index = _toonID2SeriesIndex.get(toonID);
            indexesToRemove.add(index);
            toonIDsToRemove.add(toonID);
        }
    }
    // Remove no more used toons
    for (String toonID : toonIDsToRemove) {
        _toonID2SeriesIndex.remove(toonID);
    }
    Collections.sort(indexesToRemove);
    for (int i = indexesToRemove.size() - 1; i >= 0; i--) {
        int index = indexesToRemove.get(i).intValue();
        data.removeSeries(index);
    }
    // Added new toons
    for (CharacterFile toon : newToons) {
        addSeriesForToon(data, toon);
        String toonID = toon.getIdentifier();
        setVisible(toonID, true);
    }
}
Also used : ArrayList(java.util.ArrayList) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) CharacterFile(delta.games.lotro.character.CharacterFile) Paint(java.awt.Paint) HashSet(java.util.HashSet)

Example 30 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class CharacterLevelChartController method createDataset.

private XYSeriesCollection createDataset() {
    XYSeriesCollection data = new XYSeriesCollection();
    List<CharacterFile> toons = _stats.getToonsList();
    for (CharacterFile toon : toons) {
        addSeriesForToon(data, toon);
    }
    return data;
}
Also used : XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) CharacterFile(delta.games.lotro.character.CharacterFile)

Aggregations

CharacterFile (delta.games.lotro.character.CharacterFile)42 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)13 ArrayList (java.util.ArrayList)11 CharactersManager (delta.games.lotro.character.CharactersManager)9 JPanel (javax.swing.JPanel)6 CharacterData (delta.games.lotro.character.CharacterData)5 CharacterLog (delta.games.lotro.character.log.CharacterLog)5 Preferences (delta.common.utils.misc.Preferences)4 TypedProperties (delta.common.utils.misc.TypedProperties)4 CraftingStatus (delta.games.lotro.character.crafting.CraftingStatus)3 CharacterEventType (delta.games.lotro.character.events.CharacterEventType)3 File (java.io.File)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)2 CharacterSummary (delta.games.lotro.character.CharacterSummary)2 ProfessionStatus (delta.games.lotro.character.crafting.ProfessionStatus)2 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)2 Profession (delta.games.lotro.lore.crafting.Profession)2 GridBagConstraints (java.awt.GridBagConstraints)2