From a9dfdf184d92ef7ac2193344eba791b6e0faaa58 Mon Sep 17 00:00:00 2001 From: Stefan Dollase Date: Mon, 15 Feb 2016 19:40:17 +0100 Subject: [PATCH] replaced all occurrences: biome color profile -> biome profile This enables us to store more biome related information in the profiles in the future. I also changed the default biome profiles directory name back to 'biome' to keep backwards compatibility with Amidst v3.7. --- {biome-color-profiles => biome}/default.json | 0 {biome-color-profiles => biome}/test.json | 0 src/main/java/amidst/AmidstSettings.java | 8 ++-- src/main/java/amidst/Application.java | 13 +++--- .../java/amidst/CommandLineParameters.java | 4 +- .../colorprovider/BiomeColorProvider.java | 10 ++--- .../amidst/fragment/layer/LayerBuilder.java | 2 +- src/main/java/amidst/gui/main/Actions.java | 14 +++--- src/main/java/amidst/gui/main/MainWindow.java | 12 +++--- .../gui/main/menu/AmidstMenuBuilder.java | 18 ++++---- ...tory.java => BiomeProfileMenuFactory.java} | 41 +++++++++--------- .../gui/main/viewer/widget/BiomeWidget.java | 11 +++-- .../gui/main/viewer/widget/WidgetBuilder.java | 2 +- .../mojangapi/world/biome/BiomeColor.java | 2 +- .../BiomeColorProfileVisitor.java | 9 ---- .../BiomeColorJson.java | 2 +- .../BiomeProfile.java} | 12 +++--- .../BiomeProfileDirectory.java} | 43 +++++++++---------- .../BiomeProfileSelection.java} | 14 +++--- .../biomeprofile/BiomeProfileVisitor.java | 9 ++++ 20 files changed, 110 insertions(+), 116 deletions(-) rename {biome-color-profiles => biome}/default.json (100%) rename {biome-color-profiles => biome}/test.json (100%) rename src/main/java/amidst/gui/main/menu/{BiomeColorMenuFactory.java => BiomeProfileMenuFactory.java} (70%) delete mode 100644 src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileVisitor.java rename src/main/java/amidst/settings/{biomecolorprofile => biomeprofile}/BiomeColorJson.java (92%) rename src/main/java/amidst/settings/{biomecolorprofile/BiomeColorProfile.java => biomeprofile/BiomeProfile.java} (91%) rename src/main/java/amidst/settings/{biomecolorprofile/BiomeColorProfileDirectory.java => biomeprofile/BiomeProfileDirectory.java} (60%) rename src/main/java/amidst/settings/{biomecolorprofile/BiomeColorProfileSelection.java => biomeprofile/BiomeProfileSelection.java} (70%) create mode 100644 src/main/java/amidst/settings/biomeprofile/BiomeProfileVisitor.java diff --git a/biome-color-profiles/default.json b/biome/default.json similarity index 100% rename from biome-color-profiles/default.json rename to biome/default.json diff --git a/biome-color-profiles/test.json b/biome/test.json similarity index 100% rename from biome-color-profiles/test.json rename to biome/test.json diff --git a/src/main/java/amidst/AmidstSettings.java b/src/main/java/amidst/AmidstSettings.java index f3202e76..82146c39 100644 --- a/src/main/java/amidst/AmidstSettings.java +++ b/src/main/java/amidst/AmidstSettings.java @@ -9,8 +9,8 @@ import amidst.mojangapi.world.Dimension; import amidst.mojangapi.world.WorldType; import amidst.settings.Setting; import amidst.settings.Settings; -import amidst.settings.biomecolorprofile.BiomeColorProfile; -import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; +import amidst.settings.biomeprofile.BiomeProfile; +import amidst.settings.biomeprofile.BiomeProfileSelection; @ThreadSafe public class AmidstSettings { @@ -41,7 +41,7 @@ public class AmidstSettings { /** * This is not persisted. */ - public final BiomeColorProfileSelection biomeColorProfileSelection; + public final BiomeProfileSelection biomeProfileSelection; @CalledOnlyBy(AmidstThread.EDT) public AmidstSettings(Preferences preferences) { @@ -69,7 +69,7 @@ public class AmidstSettings { lastProfile = Settings.createString( preferences, "profile", ""); worldType = Settings.createString( preferences, "worldType", WorldType.PROMPT_EACH_TIME); - biomeColorProfileSelection = new BiomeColorProfileSelection(BiomeColorProfile.getDefaultProfile()); + biomeProfileSelection = new BiomeProfileSelection(BiomeProfile.getDefaultProfile()); // @formatter:on } } diff --git a/src/main/java/amidst/Application.java b/src/main/java/amidst/Application.java index c398c134..8fd2f14f 100644 --- a/src/main/java/amidst/Application.java +++ b/src/main/java/amidst/Application.java @@ -18,7 +18,7 @@ import amidst.mojangapi.minecraftinterface.local.LocalMinecraftInterfaceCreation import amidst.mojangapi.world.SeedHistoryLogger; import amidst.mojangapi.world.WorldBuilder; import amidst.mojangapi.world.player.PlayerInformationCacheImpl; -import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; +import amidst.settings.biomeprofile.BiomeProfileDirectory; import amidst.threading.ThreadMaster; @NotThreadSafe @@ -27,7 +27,7 @@ public class Application { private final AmidstMetaData metadata; private final AmidstSettings settings; private final MojangApi mojangApi; - private final BiomeColorProfileDirectory biomeColorProfileDirectory; + private final BiomeProfileDirectory biomeProfileDirectory; private final ViewerFacadeBuilder viewerFacadeBuilder; private final ThreadMaster threadMaster; @@ -42,7 +42,7 @@ public class Application { this.metadata = metadata; this.settings = createSettings(); this.mojangApi = createMojangApi(); - this.biomeColorProfileDirectory = createBiomeColorProfileDirectory(); + this.biomeProfileDirectory = createBiomeProfileDirectory(); this.viewerFacadeBuilder = createViewerFacadeBuilder(); this.threadMaster = createThreadMaster(); } @@ -63,9 +63,8 @@ public class Application { } @CalledOnlyBy(AmidstThread.EDT) - private BiomeColorProfileDirectory createBiomeColorProfileDirectory() { - return BiomeColorProfileDirectory - .create(parameters.biomeColorProfilesDirectory); + private BiomeProfileDirectory createBiomeProfileDirectory() { + return BiomeProfileDirectory.create(parameters.biomeProfilesDirectory); } @CalledOnlyBy(AmidstThread.EDT) @@ -103,7 +102,7 @@ public class Application { @CalledOnlyBy(AmidstThread.EDT) public void displayMainWindow() { setMainWindow(new MainWindow(this, metadata, settings, mojangApi, - biomeColorProfileDirectory, viewerFacadeBuilder, threadMaster)); + biomeProfileDirectory, viewerFacadeBuilder, threadMaster)); setProfileSelectWindow(null); } diff --git a/src/main/java/amidst/CommandLineParameters.java b/src/main/java/amidst/CommandLineParameters.java index d12fb356..acae3882 100644 --- a/src/main/java/amidst/CommandLineParameters.java +++ b/src/main/java/amidst/CommandLineParameters.java @@ -23,8 +23,8 @@ public class CommandLineParameters { @Option(name = "-mcjson", usage = "location of the minecraft json file", metaVar = "", depends = { "-mcjar" }) public volatile String minecraftJsonFile; - @Option(name = "-biome-color-profiles", usage = "location of the biome color profile directory", metaVar = "") - public volatile String biomeColorProfilesDirectory; + @Option(name = "-biome-profiles", usage = "location of the biome profile directory", metaVar = "") + public volatile String biomeProfilesDirectory; @Option(name = "-history", usage = "location of the seed history file", metaVar = "") public volatile String historyFile; diff --git a/src/main/java/amidst/fragment/colorprovider/BiomeColorProvider.java b/src/main/java/amidst/fragment/colorprovider/BiomeColorProvider.java index a272bb8e..de79a2e3 100644 --- a/src/main/java/amidst/fragment/colorprovider/BiomeColorProvider.java +++ b/src/main/java/amidst/fragment/colorprovider/BiomeColorProvider.java @@ -5,17 +5,17 @@ import amidst.fragment.Fragment; import amidst.gui.main.viewer.BiomeSelection; import amidst.mojangapi.world.Dimension; import amidst.mojangapi.world.biome.BiomeColor; -import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; +import amidst.settings.biomeprofile.BiomeProfileSelection; @ThreadSafe public class BiomeColorProvider implements ColorProvider { private final BiomeSelection biomeSelection; - private final BiomeColorProfileSelection biomeColorProfileSelection; + private final BiomeProfileSelection biomeProfileSelection; public BiomeColorProvider(BiomeSelection biomeSelection, - BiomeColorProfileSelection biomeColorProfileSelection) { + BiomeProfileSelection biomeProfileSelection) { this.biomeSelection = biomeSelection; - this.biomeColorProfileSelection = biomeColorProfileSelection; + this.biomeProfileSelection = biomeProfileSelection; } @Override @@ -33,6 +33,6 @@ public class BiomeColorProvider implements ColorProvider { } private BiomeColor getBiomeColor(int biomeIndex) { - return biomeColorProfileSelection.getBiomeColorOrUnknown(biomeIndex); + return biomeProfileSelection.getBiomeColorOrUnknown(biomeIndex); } } diff --git a/src/main/java/amidst/fragment/layer/LayerBuilder.java b/src/main/java/amidst/fragment/layer/LayerBuilder.java index 76d184c3..cb2e25ad 100644 --- a/src/main/java/amidst/fragment/layer/LayerBuilder.java +++ b/src/main/java/amidst/fragment/layer/LayerBuilder.java @@ -124,7 +124,7 @@ public class LayerBuilder { new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading), new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()), new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()), - new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeColorProfileSelection), new TheEndColorProvider())), + new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())), new ImageLoader( declarations.get(LayerIds.SLIME), Resolution.CHUNK, new SlimeColorProvider(world.getSlimeChunkOracle())), new WorldIconLoader( declarations.get(LayerIds.SPAWN), world.getSpawnProducer()), new WorldIconLoader( declarations.get(LayerIds.STRONGHOLD), world.getStrongholdProducer()), diff --git a/src/main/java/amidst/gui/main/Actions.java b/src/main/java/amidst/gui/main/Actions.java index 1079d458..25c02bb6 100644 --- a/src/main/java/amidst/gui/main/Actions.java +++ b/src/main/java/amidst/gui/main/Actions.java @@ -28,8 +28,8 @@ import amidst.mojangapi.world.coordinates.CoordinatesInWorld; import amidst.mojangapi.world.icon.WorldIcon; import amidst.mojangapi.world.player.Player; import amidst.mojangapi.world.player.PlayerCoordinates; -import amidst.settings.biomecolorprofile.BiomeColorProfile; -import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; +import amidst.settings.biomeprofile.BiomeProfile; +import amidst.settings.biomeprofile.BiomeProfileSelection; import amidst.threading.WorkerExecutor; @NotThreadSafe @@ -38,19 +38,19 @@ public class Actions { private final MojangApi mojangApi; private final MainWindow mainWindow; private final AtomicReference viewerFacade; - private final BiomeColorProfileSelection biomeColorProfileSelection; + private final BiomeProfileSelection biomeProfileSelection; private final WorkerExecutor workerExecutor; @CalledOnlyBy(AmidstThread.EDT) public Actions(Application application, MojangApi mojangApi, MainWindow mainWindow, AtomicReference viewerFacade, - BiomeColorProfileSelection biomeColorProfileSelection, + BiomeProfileSelection biomeProfileSelection, WorkerExecutor workerExecutor) { this.application = application; this.mojangApi = mojangApi; this.mainWindow = mainWindow; this.viewerFacade = viewerFacade; - this.biomeColorProfileSelection = biomeColorProfileSelection; + this.biomeProfileSelection = biomeProfileSelection; this.workerExecutor = workerExecutor; } @@ -224,8 +224,8 @@ public class Actions { } @CalledOnlyBy(AmidstThread.EDT) - public void selectBiomeColorProfile(BiomeColorProfile profile) { - biomeColorProfileSelection.set(profile); + public void selectBiomeProfile(BiomeProfile profile) { + biomeProfileSelection.set(profile); ViewerFacade viewerFacade = this.viewerFacade.get(); if (viewerFacade != null) { viewerFacade.reloadBackgroundLayer(); diff --git a/src/main/java/amidst/gui/main/MainWindow.java b/src/main/java/amidst/gui/main/MainWindow.java index c0f990a2..e925b2ec 100644 --- a/src/main/java/amidst/gui/main/MainWindow.java +++ b/src/main/java/amidst/gui/main/MainWindow.java @@ -32,7 +32,7 @@ import amidst.mojangapi.world.WorldSeed; import amidst.mojangapi.world.WorldType; import amidst.mojangapi.world.player.MovablePlayerList; import amidst.mojangapi.world.player.WorldPlayerType; -import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; +import amidst.settings.biomeprofile.BiomeProfileDirectory; import amidst.threading.ThreadMaster; @NotThreadSafe @@ -41,7 +41,7 @@ public class MainWindow { private final AmidstMetaData metadata; private final AmidstSettings settings; private final MojangApi mojangApi; - private final BiomeColorProfileDirectory biomeColorProfileDirectory; + private final BiomeProfileDirectory biomeProfileDirectory; private final ViewerFacadeBuilder viewerFacadeBuilder; private final ThreadMaster threadMaster; @@ -55,13 +55,13 @@ public class MainWindow { @CalledOnlyBy(AmidstThread.EDT) public MainWindow(Application application, AmidstMetaData metadata, AmidstSettings settings, MojangApi mojangApi, - BiomeColorProfileDirectory biomeColorProfileDirectory, + BiomeProfileDirectory biomeProfileDirectory, ViewerFacadeBuilder viewerFacadeBuilder, ThreadMaster threadMaster) { this.application = application; this.metadata = metadata; this.settings = settings; this.mojangApi = mojangApi; - this.biomeColorProfileDirectory = biomeColorProfileDirectory; + this.biomeProfileDirectory = biomeProfileDirectory; this.viewerFacadeBuilder = viewerFacadeBuilder; this.threadMaster = threadMaster; this.frame = createFrame(); @@ -104,14 +104,14 @@ public class MainWindow { @CalledOnlyBy(AmidstThread.EDT) private Actions createActions() { return new Actions(application, mojangApi, this, viewerFacade, - settings.biomeColorProfileSelection, + settings.biomeProfileSelection, threadMaster.getWorkerExecutor()); } @CalledOnlyBy(AmidstThread.EDT) private AmidstMenu createMenuBar() { AmidstMenu menuBar = new AmidstMenuBuilder(settings, actions, - biomeColorProfileDirectory).construct(); + biomeProfileDirectory).construct(); frame.setJMenuBar(menuBar.getMenuBar()); return menuBar; } diff --git a/src/main/java/amidst/gui/main/menu/AmidstMenuBuilder.java b/src/main/java/amidst/gui/main/menu/AmidstMenuBuilder.java index 119b7c0f..b9d395e7 100644 --- a/src/main/java/amidst/gui/main/menu/AmidstMenuBuilder.java +++ b/src/main/java/amidst/gui/main/menu/AmidstMenuBuilder.java @@ -10,13 +10,13 @@ import amidst.AmidstSettings; import amidst.documentation.NotThreadSafe; import amidst.gui.main.Actions; import amidst.mojangapi.world.WorldType; -import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; +import amidst.settings.biomeprofile.BiomeProfileDirectory; @NotThreadSafe public class AmidstMenuBuilder { private final AmidstSettings settings; private final Actions actions; - private final BiomeColorProfileDirectory biomeColorProfileDirectory; + private final BiomeProfileDirectory biomeProfileDirectory; private final JMenuBar menuBar; private JMenu worldMenu; private JMenuItem savePlayerLocationsMenu; @@ -24,10 +24,10 @@ public class AmidstMenuBuilder { private LayersMenu layersMenu; public AmidstMenuBuilder(AmidstSettings settings, Actions actions, - BiomeColorProfileDirectory biomeColorProfileDirectory) { + BiomeProfileDirectory biomeProfileDirectory) { this.settings = settings; this.actions = actions; - this.biomeColorProfileDirectory = biomeColorProfileDirectory; + this.biomeProfileDirectory = biomeProfileDirectory; this.menuBar = createMenuBar(); } @@ -95,8 +95,8 @@ public class AmidstMenuBuilder { JMenu result = new JMenu("Settings"); result.setMnemonic(KeyEvent.VK_S); result.add(create_Settings_DefaultWorldType()); - if (biomeColorProfileDirectory.isValid()) { - result.add(create_Settings_BiomeColor()); + if (biomeProfileDirectory.isValid()) { + result.add(create_Settings_BiomeProfile()); } result.addSeparator(); // @formatter:off @@ -118,9 +118,9 @@ public class AmidstMenuBuilder { return result; } - private JMenu create_Settings_BiomeColor() { - JMenu result = new JMenu("Biome color profile"); - new BiomeColorMenuFactory(result, actions, biomeColorProfileDirectory); + private JMenu create_Settings_BiomeProfile() { + JMenu result = new JMenu("Biome profile"); + new BiomeProfileMenuFactory(result, actions, biomeProfileDirectory); return result; } diff --git a/src/main/java/amidst/gui/main/menu/BiomeColorMenuFactory.java b/src/main/java/amidst/gui/main/menu/BiomeProfileMenuFactory.java similarity index 70% rename from src/main/java/amidst/gui/main/menu/BiomeColorMenuFactory.java rename to src/main/java/amidst/gui/main/menu/BiomeProfileMenuFactory.java index 06c6c1dc..75a2e41c 100644 --- a/src/main/java/amidst/gui/main/menu/BiomeColorMenuFactory.java +++ b/src/main/java/amidst/gui/main/menu/BiomeProfileMenuFactory.java @@ -15,15 +15,14 @@ import javax.swing.KeyStroke; import amidst.documentation.NotThreadSafe; import amidst.gui.main.Actions; import amidst.logging.Log; -import amidst.settings.biomecolorprofile.BiomeColorProfile; -import amidst.settings.biomecolorprofile.BiomeColorProfileDirectory; -import amidst.settings.biomecolorprofile.BiomeColorProfileVisitor; +import amidst.settings.biomeprofile.BiomeProfile; +import amidst.settings.biomeprofile.BiomeProfileDirectory; +import amidst.settings.biomeprofile.BiomeProfileVisitor; @NotThreadSafe -public class BiomeColorMenuFactory { +public class BiomeProfileMenuFactory { @NotThreadSafe - private static class BiomeColorProfileVisitorImpl implements - BiomeColorProfileVisitor { + private static class BiomeProfileVisitorImpl implements BiomeProfileVisitor { private final List allCheckBoxes = new ArrayList(); private final List menuStack = new ArrayList(); private ActionListener firstListener; @@ -31,7 +30,7 @@ public class BiomeColorMenuFactory { private final Actions actions; - private BiomeColorProfileVisitorImpl(JMenu parentMenu, Actions actions) { + private BiomeProfileVisitorImpl(JMenu parentMenu, Actions actions) { this.actions = actions; menuStack.add(parentMenu); } @@ -48,7 +47,7 @@ public class BiomeColorMenuFactory { } @Override - public void visitProfile(BiomeColorProfile profile) { + public void visitProfile(BiomeProfile profile) { JCheckBoxMenuItem checkBox = createCheckBox(profile); allCheckBoxes.add(checkBox); getLastMenu().add(checkBox); @@ -67,7 +66,7 @@ public class BiomeColorMenuFactory { menuStack.remove(menuStack.size() - 1); } - private JCheckBoxMenuItem createCheckBox(BiomeColorProfile profile) { + private JCheckBoxMenuItem createCheckBox(BiomeProfile profile) { JCheckBoxMenuItem result = new JCheckBoxMenuItem(profile.getName()); tryCreateKeyboardShortcut(profile.getShortcut(), result); result.addActionListener(createListener(profile, result)); @@ -87,7 +86,7 @@ public class BiomeColorMenuFactory { } } - private ActionListener createListener(final BiomeColorProfile profile, + private ActionListener createListener(final BiomeProfile profile, final JCheckBoxMenuItem selectedCheckBox) { ActionListener result = new ActionListener() { @Override @@ -96,7 +95,7 @@ public class BiomeColorMenuFactory { checkBox.setSelected(false); } selectedCheckBox.setSelected(true); - actions.selectBiomeColorProfile(profile); + actions.selectBiomeProfile(profile); } }; if (firstListener == null) { @@ -114,35 +113,35 @@ public class BiomeColorMenuFactory { private final JMenu parentMenu; private final Actions actions; - private final BiomeColorProfileDirectory biomeColorProfileDirectory; + private final BiomeProfileDirectory biomeProfileDirectory; - public BiomeColorMenuFactory(JMenu parentMenu, Actions actions, - BiomeColorProfileDirectory biomeColorProfileDirectory) { + public BiomeProfileMenuFactory(JMenu parentMenu, Actions actions, + BiomeProfileDirectory biomeProfileDirectory) { this.parentMenu = parentMenu; this.actions = actions; - this.biomeColorProfileDirectory = biomeColorProfileDirectory; - Log.i("Checking for additional biome color profiles."); + this.biomeProfileDirectory = biomeProfileDirectory; + Log.i("Checking for additional biome profiles."); initParentMenu(); } private void initParentMenu() { parentMenu.removeAll(); - biomeColorProfileDirectory.saveDefaultProfileIfNecessary(); - BiomeColorProfileVisitorImpl visitor = new BiomeColorProfileVisitorImpl( + biomeProfileDirectory.saveDefaultProfileIfNecessary(); + BiomeProfileVisitorImpl visitor = new BiomeProfileVisitorImpl( parentMenu, actions); - biomeColorProfileDirectory.visitProfiles(visitor); + biomeProfileDirectory.visitProfiles(visitor); parentMenu.add(createReloadMenuItem()); visitor.selectFirstProfile(); } private JMenuItem createReloadMenuItem() { - final JMenuItem result = new JMenuItem("Reload biome color profiles"); + final JMenuItem result = new JMenuItem("Reload biome profiles"); result.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK)); result.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg) { - Log.i("Reloading additional biome color profiles."); + Log.i("Reloading additional biome profiles."); initParentMenu(); } }); diff --git a/src/main/java/amidst/gui/main/viewer/widget/BiomeWidget.java b/src/main/java/amidst/gui/main/viewer/widget/BiomeWidget.java index af5124ca..1bb09d89 100644 --- a/src/main/java/amidst/gui/main/viewer/widget/BiomeWidget.java +++ b/src/main/java/amidst/gui/main/viewer/widget/BiomeWidget.java @@ -15,7 +15,7 @@ import amidst.fragment.layer.LayerReloader; import amidst.gui.main.viewer.BiomeSelection; import amidst.mojangapi.world.biome.Biome; import amidst.mojangapi.world.biome.BiomeColor; -import amidst.settings.biomecolorprofile.BiomeColorProfileSelection; +import amidst.settings.biomeprofile.BiomeProfileSelection; @NotThreadSafe public class BiomeWidget extends Widget { @@ -33,7 +33,7 @@ public class BiomeWidget extends Widget { private final BiomeSelection biomeSelection; private final LayerReloader layerReloader; - private final BiomeColorProfileSelection biomeColorProfileSelection; + private final BiomeProfileSelection biomeProfileSelection; private List biomes = new ArrayList(); private int maxNameWidth = 0; @@ -54,11 +54,11 @@ public class BiomeWidget extends Widget { @CalledOnlyBy(AmidstThread.EDT) public BiomeWidget(CornerAnchorPoint anchor, BiomeSelection biomeSelection, LayerReloader layerReloader, - BiomeColorProfileSelection biomeColorProfileSelection) { + BiomeProfileSelection biomeProfileSelection) { super(anchor); this.biomeSelection = biomeSelection; this.layerReloader = layerReloader; - this.biomeColorProfileSelection = biomeColorProfileSelection; + this.biomeProfileSelection = biomeProfileSelection; setWidth(250); setHeight(400); setY(100); @@ -217,8 +217,7 @@ public class BiomeWidget extends Widget { @CalledOnlyBy(AmidstThread.EDT) private BiomeColor getBiomeColorOrUnknown(Biome biome) { - return biomeColorProfileSelection.getBiomeColorOrUnknown(biome - .getIndex()); + return biomeProfileSelection.getBiomeColorOrUnknown(biome.getIndex()); } @CalledOnlyBy(AmidstThread.EDT) diff --git a/src/main/java/amidst/gui/main/viewer/widget/WidgetBuilder.java b/src/main/java/amidst/gui/main/viewer/widget/WidgetBuilder.java index 36162a8f..dba6704f 100644 --- a/src/main/java/amidst/gui/main/viewer/widget/WidgetBuilder.java +++ b/src/main/java/amidst/gui/main/viewer/widget/WidgetBuilder.java @@ -63,7 +63,7 @@ public class WidgetBuilder { new DebugWidget( CornerAnchorPoint.BOTTOM_RIGHT, graph, fragmentManager, settings.showDebug, accelerationCounter), new CursorInformationWidget(CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension), new BiomeToggleWidget( CornerAnchorPoint.BOTTOM_RIGHT, biomeSelection, layerReloader), - new BiomeWidget( CornerAnchorPoint.NONE, biomeSelection, layerReloader, settings.biomeColorProfileSelection) + new BiomeWidget( CornerAnchorPoint.NONE, biomeSelection, layerReloader, settings.biomeProfileSelection) ); // @formatter:on } diff --git a/src/main/java/amidst/mojangapi/world/biome/BiomeColor.java b/src/main/java/amidst/mojangapi/world/biome/BiomeColor.java index d4fed7ae..85ec00a9 100644 --- a/src/main/java/amidst/mojangapi/world/biome/BiomeColor.java +++ b/src/main/java/amidst/mojangapi/world/biome/BiomeColor.java @@ -3,7 +3,7 @@ package amidst.mojangapi.world.biome; import java.awt.Color; import amidst.documentation.Immutable; -import amidst.settings.biomecolorprofile.BiomeColorJson; +import amidst.settings.biomeprofile.BiomeColorJson; @Immutable public class BiomeColor { diff --git a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileVisitor.java b/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileVisitor.java deleted file mode 100644 index 1ddd7be4..00000000 --- a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileVisitor.java +++ /dev/null @@ -1,9 +0,0 @@ -package amidst.settings.biomecolorprofile; - -public interface BiomeColorProfileVisitor { - void enterDirectory(String name); - - void visitProfile(BiomeColorProfile profile); - - void leaveDirectory(); -} diff --git a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorJson.java b/src/main/java/amidst/settings/biomeprofile/BiomeColorJson.java similarity index 92% rename from src/main/java/amidst/settings/biomecolorprofile/BiomeColorJson.java rename to src/main/java/amidst/settings/biomeprofile/BiomeColorJson.java index b4ce240b..7dc80a39 100644 --- a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorJson.java +++ b/src/main/java/amidst/settings/biomeprofile/BiomeColorJson.java @@ -1,4 +1,4 @@ -package amidst.settings.biomecolorprofile; +package amidst.settings.biomeprofile; import amidst.documentation.GsonConstructor; import amidst.documentation.Immutable; diff --git a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfile.java b/src/main/java/amidst/settings/biomeprofile/BiomeProfile.java similarity index 91% rename from src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfile.java rename to src/main/java/amidst/settings/biomeprofile/BiomeProfile.java index e830e732..89171f69 100644 --- a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfile.java +++ b/src/main/java/amidst/settings/biomeprofile/BiomeProfile.java @@ -1,4 +1,4 @@ -package amidst.settings.biomecolorprofile; +package amidst.settings.biomeprofile; import java.io.BufferedWriter; import java.io.File; @@ -18,7 +18,7 @@ import amidst.mojangapi.world.biome.Biome; import amidst.mojangapi.world.biome.BiomeColor; @Immutable -public class BiomeColorProfile { +public class BiomeProfile { private static Map createDefaultColorMap() { Map result = new HashMap(); for (Biome biome : Biome.allBiomes()) { @@ -28,11 +28,11 @@ public class BiomeColorProfile { return result; } - public static BiomeColorProfile getDefaultProfile() { + public static BiomeProfile getDefaultProfile() { return DEFAULT_PROFILE; } - private static final BiomeColorProfile DEFAULT_PROFILE = new BiomeColorProfile( + private static final BiomeProfile DEFAULT_PROFILE = new BiomeProfile( "default", null, createDefaultColorMap()); private volatile String name; @@ -40,10 +40,10 @@ public class BiomeColorProfile { private volatile Map colorMap; @GsonConstructor - public BiomeColorProfile() { + public BiomeProfile() { } - private BiomeColorProfile(String name, String shortcut, + private BiomeProfile(String name, String shortcut, Map colorMap) { this.name = name; this.shortcut = shortcut; diff --git a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileDirectory.java b/src/main/java/amidst/settings/biomeprofile/BiomeProfileDirectory.java similarity index 60% rename from src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileDirectory.java rename to src/main/java/amidst/settings/biomeprofile/BiomeProfileDirectory.java index 79694593..09d918ef 100644 --- a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileDirectory.java +++ b/src/main/java/amidst/settings/biomeprofile/BiomeProfileDirectory.java @@ -1,4 +1,4 @@ -package amidst.settings.biomecolorprofile; +package amidst.settings.biomeprofile; import java.io.BufferedReader; import java.io.File; @@ -13,11 +13,10 @@ import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; @Immutable -public class BiomeColorProfileDirectory { - public static BiomeColorProfileDirectory create(String root) { - BiomeColorProfileDirectory result = new BiomeColorProfileDirectory( - getRoot(root)); - Log.i("using biome color profiles at: '" + result.getRoot() + "'"); +public class BiomeProfileDirectory { + public static BiomeProfileDirectory create(String root) { + BiomeProfileDirectory result = new BiomeProfileDirectory(getRoot(root)); + Log.i("using biome profiles at: '" + result.getRoot() + "'"); return result; } @@ -29,14 +28,13 @@ public class BiomeColorProfileDirectory { } } - private static final File DEFAULT_ROOT_DIRECTORY = new File( - "biome-color-profiles"); + private static final File DEFAULT_ROOT_DIRECTORY = new File("biome"); private static final Gson GSON = new Gson(); private final File root; private final File defaultProfile; - public BiomeColorProfileDirectory(File root) { + public BiomeProfileDirectory(File root) { this.root = root; this.defaultProfile = new File(root, "default.json"); } @@ -55,29 +53,28 @@ public class BiomeColorProfileDirectory { public void saveDefaultProfileIfNecessary() { if (!isValid()) { - Log.i("Unable to find biome color profile directory."); + Log.i("Unable to find biome profile directory."); } else { - Log.i("Found biome color profile directory."); + Log.i("Found biome profile directory."); if (defaultProfile.isFile()) { - Log.i("Found default biome color profile."); - } else if (BiomeColorProfile.getDefaultProfile().save( - defaultProfile)) { - Log.i("Saved default biome color profile."); + Log.i("Found default biome profile."); + } else if (BiomeProfile.getDefaultProfile().save(defaultProfile)) { + Log.i("Saved default biome profile."); } else { - Log.i("Attempted to save default biome color profile, but encountered an error."); + Log.i("Attempted to save default biome profile, but encountered an error."); } } } - public void visitProfiles(BiomeColorProfileVisitor visitor) { + public void visitProfiles(BiomeProfileVisitor visitor) { visitProfiles(root, visitor); } - private void visitProfiles(File directory, BiomeColorProfileVisitor visitor) { + private void visitProfiles(File directory, BiomeProfileVisitor visitor) { boolean entered = false; for (File file : directory.listFiles()) { if (file.isFile()) { - BiomeColorProfile profile = createFromFile(file); + BiomeProfile profile = createFromFile(file); if (profile != null) { if (!entered) { entered = true; @@ -94,8 +91,8 @@ public class BiomeColorProfileDirectory { } } - private BiomeColorProfile createFromFile(File file) { - BiomeColorProfile profile = null; + private BiomeProfile createFromFile(File file) { + BiomeProfile profile = null; if (file.exists() && file.isFile()) { try { profile = readProfile(file); @@ -112,10 +109,10 @@ public class BiomeColorProfileDirectory { return profile; } - private BiomeColorProfile readProfile(File file) throws IOException, + private BiomeProfile readProfile(File file) throws IOException, JsonSyntaxException, JsonIOException { try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - return GSON.fromJson(reader, BiomeColorProfile.class); + return GSON.fromJson(reader, BiomeProfile.class); } } } diff --git a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileSelection.java b/src/main/java/amidst/settings/biomeprofile/BiomeProfileSelection.java similarity index 70% rename from src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileSelection.java rename to src/main/java/amidst/settings/biomeprofile/BiomeProfileSelection.java index c34c6819..c23006ed 100644 --- a/src/main/java/amidst/settings/biomecolorprofile/BiomeColorProfileSelection.java +++ b/src/main/java/amidst/settings/biomeprofile/BiomeProfileSelection.java @@ -1,4 +1,4 @@ -package amidst.settings.biomecolorprofile; +package amidst.settings.biomeprofile; import amidst.documentation.ThreadSafe; import amidst.logging.Log; @@ -6,11 +6,11 @@ import amidst.mojangapi.world.biome.BiomeColor; import amidst.mojangapi.world.biome.UnknownBiomeIndexException; @ThreadSafe -public class BiomeColorProfileSelection { +public class BiomeProfileSelection { private volatile BiomeColor[] biomeColors; - public BiomeColorProfileSelection(BiomeColorProfile biomeColorProfile) { - set(biomeColorProfile); + public BiomeProfileSelection(BiomeProfile biomeProfile) { + set(biomeProfile); } public BiomeColor getBiomeColorOrUnknown(int index) { @@ -35,8 +35,8 @@ public class BiomeColorProfileSelection { } } - public void set(BiomeColorProfile biomeColorProfile) { - this.biomeColors = biomeColorProfile.createBiomeColorArray(); - Log.i("Biome color profile activated."); + public void set(BiomeProfile biomeProfile) { + this.biomeColors = biomeProfile.createBiomeColorArray(); + Log.i("Biome profile activated: " + biomeProfile.getName()); } } diff --git a/src/main/java/amidst/settings/biomeprofile/BiomeProfileVisitor.java b/src/main/java/amidst/settings/biomeprofile/BiomeProfileVisitor.java new file mode 100644 index 00000000..0734f413 --- /dev/null +++ b/src/main/java/amidst/settings/biomeprofile/BiomeProfileVisitor.java @@ -0,0 +1,9 @@ +package amidst.settings.biomeprofile; + +public interface BiomeProfileVisitor { + void enterDirectory(String name); + + void visitProfile(BiomeProfile profile); + + void leaveDirectory(); +}