diff --git a/.gitattributes b/.gitattributes
index 5cb66ba39a4..96d9daec754 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -11113,8 +11113,6 @@ src/main/java/forge/view/editor/EditorTopLevel.java -text
src/main/java/forge/view/editor/package-info.java svneol=native#text/plain
src/main/java/forge/view/home/HomeTopLevel.java -text
src/main/java/forge/view/home/SplashFrame.java -text
-src/main/java/forge/view/home/SplashProgressComponent.java -text
-src/main/java/forge/view/home/SplashProgressModel.java -text
src/main/java/forge/view/home/StartButton.java -text
src/main/java/forge/view/home/SubButton.java -text
src/main/java/forge/view/home/ViewConstructed.java -text
@@ -11143,6 +11141,7 @@ src/main/java/forge/view/toolbox/FButton.java -text
src/main/java/forge/view/toolbox/FList.java -text
src/main/java/forge/view/toolbox/FOverlay.java -text
src/main/java/forge/view/toolbox/FPanel.java -text
+src/main/java/forge/view/toolbox/FProgressBar.java -text
src/main/java/forge/view/toolbox/FRoundedPanel.java -text
src/main/java/forge/view/toolbox/FScrollPane.java -text
src/main/java/forge/view/toolbox/FSkin.java -text
diff --git a/src/main/java/forge/CardReader.java b/src/main/java/forge/CardReader.java
index 3127b09c1e4..d91cc2ec2f3 100644
--- a/src/main/java/forge/CardReader.java
+++ b/src/main/java/forge/CardReader.java
@@ -38,8 +38,6 @@ import java.util.zip.ZipFile;
import net.slightlymagic.braids.util.UtilFunctions;
import net.slightlymagic.braids.util.generator.FindNonDirectoriesSkipDotDirectoriesGenerator;
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
-import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
-import net.slightlymagic.braids.util.progress_monitor.StderrProgressMonitor;
import com.google.code.jyield.Generator;
import com.google.code.jyield.YieldUtils;
@@ -49,7 +47,7 @@ import forge.card.CardRulesReader;
import forge.card.replacement.ReplacementHandler;
import forge.card.trigger.TriggerHandler;
import forge.error.ErrorViewer;
-import forge.view.FView;
+import forge.view.toolbox.FProgressBar;
/**
*
@@ -262,18 +260,7 @@ public class CardReader implements Runnable {
*/
protected final Card loadCardsUntilYouFind(final String cardName) {
Card result = null;
-
- // Try to retrieve card loading progress monitor model.
- // If no progress monitor present, output results to console.
- BraidsProgressMonitor monitor = null;
- final FView view = Singletons.getView();
- if (view != null) {
- monitor = view.getCardLoadingProgressMonitor();
- }
-
- if (monitor == null) {
- monitor = new StderrProgressMonitor(1, 0L);
- }
+ final FProgressBar barProgress = Singletons.getView().getProgressBar();
// Iterate through txt files or zip archive.
// Report relevant numbers to progress monitor model.
@@ -285,18 +272,19 @@ public class CardReader implements Runnable {
this.findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen);
}
- if (monitor != null) {
- monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining);
+ if (barProgress != null) {
+ barProgress.setMaximum((int) this.estimatedFilesRemaining);
+ barProgress.setDescription("Preloading card images: ");
}
for (final File cardTxtFile : this.findNonDirsIterable) {
if (!cardTxtFile.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) {
- monitor.incrementUnitsCompletedThisPhase(1L);
+ barProgress.increment();
continue;
}
result = this.loadCard(cardTxtFile);
- monitor.incrementUnitsCompletedThisPhase(1L);
+ barProgress.increment();
if ((cardName != null) && cardName.equals(result.getName())) {
break; // no thread leak here if entire card DB is loaded,
@@ -304,9 +292,8 @@ public class CardReader implements Runnable {
}
} // endfor
-
} else {
- monitor.setTotalUnitsThisPhase(this.estimatedFilesRemaining);
+ barProgress.setMaximum((int) this.estimatedFilesRemaining);
ZipEntry entry;
// zipEnum was initialized in the constructor.
@@ -314,18 +301,17 @@ public class CardReader implements Runnable {
entry = this.zipEnum.nextElement();
if (entry.isDirectory() || !entry.getName().endsWith(CardReader.CARD_FILE_DOT_EXTENSION)) {
- monitor.incrementUnitsCompletedThisPhase(1L);
+ barProgress.increment();
continue;
}
result = this.loadCard(entry);
- monitor.incrementUnitsCompletedThisPhase(1L);
+ barProgress.increment();
if ((cardName != null) && cardName.equals(result.getName())) {
break;
}
}
-
} // endif
return result;
diff --git a/src/main/java/forge/card/cardfactory/PreloadingCardFactory.java b/src/main/java/forge/card/cardfactory/PreloadingCardFactory.java
index b960b9826db..d61302c1ef2 100644
--- a/src/main/java/forge/card/cardfactory/PreloadingCardFactory.java
+++ b/src/main/java/forge/card/cardfactory/PreloadingCardFactory.java
@@ -22,14 +22,18 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import javax.swing.SwingUtilities;
+
import forge.AllZone;
import forge.Card;
import forge.CardReader;
+import forge.Singletons;
import forge.card.CardRules;
import forge.error.ErrorViewer;
import forge.item.CardDb;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
+import forge.view.toolbox.FProgressBar;
/**
*
@@ -76,12 +80,25 @@ public class PreloadingCardFactory extends AbstractCardFactory {
try {
this.readCards(file);
+ final FProgressBar barProgress = Singletons.getView().getProgressBar();
+ if (barProgress != null) {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ barProgress.reset();
+ barProgress.setDescription("Creating card objects: ");
+ }
+ });
+ }
+
// initialize CardList allCards
final Iterator it = this.getMap().keySet().iterator();
+ if (barProgress != null) { barProgress.setMaximum(this.getMap().size()); }
Card c;
while (it.hasNext()) {
c = this.getCard(it.next().toString(), AllZone.getHumanPlayer());
this.getAllCards().add(c);
+ if (barProgress != null) { barProgress.increment(); }
}
} catch (final Exception ex) {
ErrorViewer.showError(ex);
diff --git a/src/main/java/forge/control/home/ControlSettings.java b/src/main/java/forge/control/home/ControlSettings.java
index 6b2866b123c..3353c80eed5 100644
--- a/src/main/java/forge/control/home/ControlSettings.java
+++ b/src/main/java/forge/control/home/ControlSettings.java
@@ -147,10 +147,11 @@ public class ControlSettings {
});
}
- private void updateSkin() throws Exception {
+ private void updateSkin() {
String name = view.getLstChooseSkin().getSelectedValue().toString();
FSkin skin = new FSkin(name);
- skin.loadFontAndImages();
+
+ skin.loadFontsAndImages();
prefs.setSkin(name);
Singletons.getView().setSkin(skin);
diff --git a/src/main/java/forge/view/FView.java b/src/main/java/forge/view/FView.java
index 43cd3533e99..54b150fd7de 100644
--- a/src/main/java/forge/view/FView.java
+++ b/src/main/java/forge/view/FView.java
@@ -20,16 +20,15 @@ package forge.view;
import javax.swing.SwingUtilities;
import net.slightlymagic.braids.util.UtilFunctions;
-import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import forge.AllZone;
import forge.ComputerAIGeneral;
import forge.ComputerAIInput;
import forge.Constant;
import forge.control.FControl;
-import forge.error.ErrorViewer;
import forge.game.GameType;
import forge.view.home.SplashFrame;
import forge.view.toolbox.CardFaceSymbols;
+import forge.view.toolbox.FProgressBar;
import forge.view.toolbox.FSkin;
/**
@@ -39,6 +38,7 @@ import forge.view.toolbox.FSkin;
public class FView {
private transient SplashFrame splashFrame;
+ private FProgressBar barProgress = null;
private FSkin skin;
/**
@@ -55,7 +55,11 @@ public class FView {
UtilFunctions.invokeInEventDispatchThreadAndWait(new Runnable() {
@Override
public void run() {
- FView.this.splashFrame = new SplashFrame(FView.this.skin);
+ try {
+ FView.this.splashFrame = new SplashFrame(FView.this.skin);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
});
@@ -68,20 +72,21 @@ public class FView {
}
/**
- * Get the progress monitor for loading all cards at once.
+ * Allows singleton (global) access to a progress bar (which must be set first).
*
* @return a progress monitor having only one phase; may be null
*/
- public final BraidsProgressMonitor getCardLoadingProgressMonitor() {
- BraidsProgressMonitor result;
+ public final FProgressBar getProgressBar() {
+ return this.barProgress;
+ }
- if (this.splashFrame == null) {
- result = null;
- } else {
- result = this.splashFrame.getMonitorModel();
- }
-
- return result;
+ /**
+ * Sets a progress bar so it can be accessed via singletons.
+ *
+ * @param bar0 An FProgressBar object
+ */
+ public final void setProgressBar(FProgressBar bar0) {
+ this.barProgress = bar0;
}
/** @return FSkin */
@@ -89,10 +94,7 @@ public class FView {
return this.skin;
}
- /**
- * @param skin0
- * FSkin
- */
+ /** @param skin0 FSkin */
public void setSkin(final FSkin skin0) {
this.skin = skin0;
}
@@ -102,42 +104,39 @@ public class FView {
* for initial display.
*/
public final void initialize() {
- // For the following two blocks, check if user has cancelled
- // SplashFrame.
- // Note: Error thrown sometimes because log file cannot be accessed
- if (!this.splashFrame.getSplashHasBeenClosed()) {
- AllZone.getCardFactory(); // forces preloading of all cards
- }
+ this.setProgressBar(splashFrame.getProgressBar());
- if (!this.splashFrame.getSplashHasBeenClosed()) {
- try {
+ // Preloads all cards (using progress bar).
+ AllZone.getCardFactory();
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
- FView.this.skin.loadFontAndImages();
+ // Preloads skin components (using progress bar).
+ FView.this.skin.loadFontsAndImages();
- CardFaceSymbols.loadImages();
+ // Does not use progress bar, due to be deprecated in favor of skin.
+ CardFaceSymbols.loadImages();
- Constant.Runtime.setGameType(GameType.Constructed);
+ barProgress.setDescription("Creating display components.");
- final GuiTopLevel g = new GuiTopLevel();
- AllZone.setDisplay(g);
- g.getController().changeState(FControl.HOME_SCREEN);
- g.pack();
- g.setVisible(true);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
- FView.this.splashFrame.dispose();
- // Enable only one of the following two lines.
- // The second is useful for debugging.
- FView.this.splashFrame = null;
- // FView.this.splashFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- }
- });
- } catch (final Exception ex) {
- ErrorViewer.showError(ex);
+ // TODO there must be a better place for this. ////////////
+ Constant.Runtime.setGameType(GameType.Constructed);
+ AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
+ /////////////////////////////////////
+
+ final GuiTopLevel g = new GuiTopLevel();
+ AllZone.setDisplay(g);
+ g.getController().changeState(FControl.HOME_SCREEN);
+ g.pack();
+
+ FView.this.splashFrame.dispose();
+ FView.this.splashFrame = null;
+
+ barProgress.setDescription("Forge is ready to launch.");
+ g.setVisible(true);
}
- } // End if(splashHasBeenClosed) */
+ });
} // End FView()
}
diff --git a/src/main/java/forge/view/home/SplashFrame.java b/src/main/java/forge/view/home/SplashFrame.java
index c9d12dc4a70..26533106957 100644
--- a/src/main/java/forge/view/home/SplashFrame.java
+++ b/src/main/java/forge/view/home/SplashFrame.java
@@ -20,10 +20,11 @@ package forge.view.home;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
-import java.awt.Toolkit;
import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
import javax.swing.AbstractAction;
+import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@@ -33,10 +34,8 @@ import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.border.LineBorder;
-import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
+import forge.view.toolbox.FProgressBar;
import forge.view.toolbox.FSkin;
/**
@@ -44,8 +43,6 @@ import forge.view.toolbox.FSkin;
*/
@SuppressWarnings("serial")
public class SplashFrame extends JFrame {
-
- // Inits: Visual changes can be made here.
private static final int BAR_PADDING_X = 20;
private static final int BAR_PADDING_Y = 20;
private static final int BAR_HEIGHT = 57;
@@ -55,65 +52,57 @@ public class SplashFrame extends JFrame {
private static final int DISCLAIMER_FONT_SIZE = 9;
private static final Color DISCLAIMER_COLOR = Color.white;
- // private static final int CLOSEBTN_PADDING_X = 15;
private static final int CLOSEBTN_PADDING_Y = 15;
private static final int CLOSEBTN_SIDELENGTH = 15;
private static final Color CLOSEBTN_COLOR = new Color(215, 208, 188);
- private SplashProgressModel monitorModel = null;
- private SplashProgressComponent monitorView = null;
-
- private boolean splashHasBeenClosed = false;
+ private final FProgressBar barLoader;
/**
- *
* Create the frame; this must be called from an event
* dispatch thread.
- *
*
- * Throws
- *
- * @param skin
- * the skin {@link IllegalStateException} if not called from an
- * event dispatch thread.
+ * @param skin An FSkin object, must be passed here since it hasn't
+ * been set in the view yet.
+ * @throws Exception {@link IllegalStateException} if not called from an
+ * event dispatch thread.
*/
- public SplashFrame(final FSkin skin) {
+ public SplashFrame(final FSkin skin) throws Exception {
super();
if (!SwingUtilities.isEventDispatchThread()) {
- throw new IllegalStateException("SplashFrame() must be called from an event dispatch thread.");
+ throw new IllegalStateException(
+ "SplashFrame() must be called from an event dispatch thread.");
}
- this.setUndecorated(true);
-
- // Set preferred JFrame properties.
final ImageIcon bgIcon = skin.getIcon(FSkin.SkinProp.BG_SPLASH);
final int splashWidthPx = bgIcon.getIconWidth();
final int splashHeightPx = bgIcon.getIconHeight();
+ this.setUndecorated(true);
this.setMinimumSize(new Dimension(splashWidthPx, splashHeightPx));
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setIconImage(Toolkit.getDefaultToolkit().getImage("res/images/symbols-13/favicon.png"));
this.setTitle("Loading Forge...");
// Insert JPanel to hold content above background
- final JPanel contentPane = new JPanel();
- this.setContentPane(contentPane);
- contentPane.setLayout(null);
+ final JPanel pnlContent = new JPanel();
+ this.setContentPane(pnlContent);
+ pnlContent.setLayout(null);
// Add disclaimer
- final JLabel lblDisclaimer = new JLabel(
- "Forge is not affiliated in any way with Wizards of the Coast."
- + "
Forge is open source software, released under the GNU Public License.");
+ final JLabel lblDisclaimer = new JLabel(""
+ + "Forge is not affiliated in any way with Wizards of the Coast."
+ + "
Forge is open source software, released under"
+ + "the GNU Public License.");
lblDisclaimer.setBounds(0, SplashFrame.DISCLAIMER_TOP, splashWidthPx, SplashFrame.DISCLAIMER_HEIGHT);
lblDisclaimer.setFont(new Font("Tahoma", Font.PLAIN, SplashFrame.DISCLAIMER_FONT_SIZE));
lblDisclaimer.setHorizontalAlignment(SwingConstants.CENTER);
lblDisclaimer.setForeground(SplashFrame.DISCLAIMER_COLOR);
- contentPane.add(lblDisclaimer);
+ pnlContent.add(lblDisclaimer);
// Add close button
final JButton btnClose = new JButton("X");
@@ -124,10 +113,10 @@ public class SplashFrame extends JFrame {
btnClose.setOpaque(false);
btnClose.setBackground(new Color(0, 0, 0));
btnClose.setFocusPainted(false);
- contentPane.add(btnClose);
+ pnlContent.add(btnClose);
- // Action handler: button hover effect
- btnClose.addMouseListener(new java.awt.event.MouseAdapter() {
+ // Actions and listeners for close button (also mapped to ESC)
+ final MouseAdapter madClose = new MouseAdapter() {
@Override
public void mouseEntered(final java.awt.event.MouseEvent evt) {
btnClose.setBorder(BorderFactory.createLineBorder(Color.white));
@@ -139,104 +128,35 @@ public class SplashFrame extends JFrame {
btnClose.setBorder(BorderFactory.createLineBorder(SplashFrame.CLOSEBTN_COLOR));
btnClose.setForeground(SplashFrame.CLOSEBTN_COLOR);
}
- });
+ };
- // Action handler: button close
- btnClose.addActionListener(new CloseAction());
+ final Action actClose = new AbstractAction() {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ System.exit(0);
+ }
+ };
- // Action handler: esc key close
- contentPane.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escAction");
+ btnClose.addMouseListener(madClose);
+ btnClose.addActionListener(actClose);
+ pnlContent.getInputMap().put(KeyStroke.getKeyStroke("ESCAPE"), "escAction");
+ pnlContent.getActionMap().put("escAction", actClose);
- contentPane.getActionMap().put("escAction", new CloseAction());
-
- // Set UI to color splash bar filled/unfilled states with skin colors
- UIManager.put("ProgressBar.background", skin.getColor(FSkin.SkinProp.PRELOAD_EMPTY_BG));
- UIManager.put("ProgressBar.selectionBackground", skin.getColor(FSkin.SkinProp.PRELOAD_EMPTY_TXT));
- UIManager.put("ProgressBar.foreground", skin.getColor(FSkin.SkinProp.PRELOAD_FULL_BG));
- UIManager.put("ProgressBar.selectionForeground", skin.getColor(FSkin.SkinProp.PRELOAD_FULL_TXT));
- UIManager.put("ProgressBar.border", new LineBorder(skin.getColor(FSkin.SkinProp.CLR_THEME), 0));
-
- // Instantiate model and view and tie together.
- this.monitorModel = new SplashProgressModel();
- this.monitorView = new SplashProgressComponent();
-
- this.monitorModel.setCurrentView(this.monitorView);
- this.monitorView.setCurrentModel(this.monitorModel);
-
- // Add prog bar + message, bg image
- this.monitorView.displayUpdate("Assembling file list...");
- this.monitorView.setBounds(SplashFrame.BAR_PADDING_X, splashHeightPx - SplashFrame.BAR_PADDING_Y
+ barLoader = new FProgressBar();
+ barLoader.setString("Welcome to Forge.");
+ barLoader.setBounds(SplashFrame.BAR_PADDING_X, splashHeightPx - SplashFrame.BAR_PADDING_Y
- SplashFrame.BAR_HEIGHT, splashWidthPx - (2 * SplashFrame.BAR_PADDING_X), SplashFrame.BAR_HEIGHT);
- contentPane.add(this.monitorView);
+ pnlContent.add(barLoader);
- contentPane.setOpaque(false);
final JLabel bgLabel = new JLabel(bgIcon);
-
- // Do not pass Integer.MIN_VALUE directly here; it must be packaged in
- // an Integer instance. Otherwise, GUI components will not draw unless
- // moused over.
- this.getLayeredPane().add(bgLabel, Integer.valueOf(Integer.MIN_VALUE));
-
bgLabel.setBounds(0, 0, splashWidthPx, splashHeightPx);
+ pnlContent.add(bgLabel);
this.pack();
}
- /**
- * Getter for progress bar view.
- *
- * @return the SplashViewProgressMonitor progress bar used in the splash
- * frame.
- */
- public final SplashProgressComponent getMonitorView() {
- return this.monitorView;
+ /** @return FProgressBar The preloader. */
+ public final FProgressBar getProgressBar() {
+ return this.barLoader;
}
-
- /**
- * Getter for progress monitor model.
- *
- * @return the BraidsProgressMonitor model used in the splash frame.
- */
- public final BraidsProgressMonitor getMonitorModel() {
- return this.monitorModel;
- }
-
- /**
- * Returns state of splash frame, to determine if GUI should continue
- * loading.
- *
- * @return SplashHasBeenClosed boolean.
- */
- public final boolean getSplashHasBeenClosed() {
- return this.splashHasBeenClosed;
- }
-
- /**
- * Sets state of splash frame, to determine if GUI should continue loading.
- *
- * @param neoState
- * the new splash has been closed
- */
- public final void setSplashHasBeenClosed(final boolean neoState) {
- this.splashHasBeenClosed = neoState;
- }
-
- /**
- *
- * closeAction
- *
- * Closes the splash frame by toggling "has been closed" switch (to cancel
- * preloading) and dispose() (to discard JFrame).
- *
- * @param splashHasBeenClosed
- * boolean.
- */
- private class CloseAction extends AbstractAction {
- @Override
- public void actionPerformed(final ActionEvent e) {
- SplashFrame.this.setSplashHasBeenClosed(true);
- SplashFrame.this.dispose();
- }
- }
-
}
diff --git a/src/main/java/forge/view/home/SplashProgressComponent.java b/src/main/java/forge/view/home/SplashProgressComponent.java
deleted file mode 100644
index edce2e9f271..00000000000
--- a/src/main/java/forge/view/home/SplashProgressComponent.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.view.home;
-
-import javax.swing.JProgressBar;
-import javax.swing.SwingUtilities;
-
-import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
-import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
-
-/**
- * Swing component view, to be used with BaseProgressMonitor.
- *
- */
-@SuppressWarnings("serial")
-public class SplashProgressComponent extends JProgressBar {
- private BaseProgressMonitor currentModel;
- private double completed;
- private double total;
-
- /**
- * Constructor: Must be called from an event dispatch thread.
- *
- */
- public SplashProgressComponent() {
- super();
-
- if (!SwingUtilities.isEventDispatchThread()) {
- throw new IllegalStateException("must be called from within an event dispatch thread");
- }
-
- this.setString("");
- this.setStringPainted(true);
- }
-
- /**
- * Updates progress bar stripe and text with current state of model.
- *
- */
- public final void updateProgressBar() {
- // Update bar "stripe"
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- SplashProgressComponent.this.stripeUpdate();
- }
- });
-
- // Update bar message
- // Note: shouldUpdateUI() severely retards motion
- // of the preloader, so is temporarily disabled.
- // if (getCurrentModel().shouldUpdateUI()) {
- if ((this.getCurrentModel().getNumPhases() > 1)) {
- this.displayUpdate("Phase " + this.getCurrentModel().getCurrentPhase() + ". "
- // + getUnitsCompletedSoFarThisPhase() + " units processed. "
- // + "Overall: " + getTotalPercentCompleteAsString() +
- // "% complete, "
- + "Overall ETA in " + this.getCurrentModel().getRelativeETAAsString(true) + ".");
- } else {
- this.displayUpdate(
- // "Overall: " +
- this.getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
- // + "(" + getTotalPercentCompleteAsString() + "%); "
- + "ETA in " + this.getCurrentModel().getRelativeETAAsString(true) + ".");
- }
- // getCurrentModel().justUpdatedUI();
- // }
-
- if ((this.getCurrentModel().getCurrentPhase() == this.getCurrentModel().getNumPhases())
- && (this.getCurrentModel().getUnitsCompletedSoFarThisPhase() >= this.getCurrentModel()
- .getTotalUnitsThisPhase())) {
- this.displayUpdate("Done! Firing up the GUI...");
- }
- }
-
- /**
- * Shows the message inside the progress dialog; does not always work on all
- * platforms.
- *
- * @param message
- * the message to display
- */
- public final void displayUpdate(final String message) {
- final Runnable proc = new Runnable() {
- @Override
- public void run() {
- SplashProgressComponent.this.setString(message);
- SplashProgressComponent.this.getCurrentModel().justUpdatedUI();
- }
- };
-
- if (SwingUtilities.isEventDispatchThread()) {
- proc.run();
- } else {
- SwingUtilities.invokeLater(proc);
- }
- }
-
- /**
- * Moves the stripe inside the progress dialog.
- *
- */
- public final void stripeUpdate() {
- this.completed = this.getCurrentModel().getUnitsCompletedSoFarThisPhase();
- this.total = this.getCurrentModel().getTotalUnitsThisPhase();
-
- this.setValue((int) Math.round(((int) this.completed / this.total) * 100));
- }
-
- /**
- * Resets the stripe inside the progress dialog back to zero.
- *
- */
- public final void stripeReset() {
- this.setValue(0);
- }
-
- /**
- * Retrieves the model from which this component uses data.
- *
- * @param neoModel
- * the new current model
- */
- public final void setCurrentModel(final BaseProgressMonitor neoModel) {
- this.currentModel = neoModel;
- }
-
- /**
- * Sets model from which this component uses data.
- *
- * @return the current model
- */
- public final BraidsProgressMonitor getCurrentModel() {
- return this.currentModel;
- }
-}
diff --git a/src/main/java/forge/view/home/SplashProgressModel.java b/src/main/java/forge/view/home/SplashProgressModel.java
deleted file mode 100644
index 6b0017e5ac5..00000000000
--- a/src/main/java/forge/view/home/SplashProgressModel.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Forge: Play Magic: the Gathering.
- * Copyright (C) 2011 Forge Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package forge.view.home;
-
-import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
-
-/**
- * Creates an instance of BaseProgressMonitor that is used in the splash frame.
- *
- * Not all mutators notify the view yet.
- *
- */
-public class SplashProgressModel extends BaseProgressMonitor {
-
- private SplashProgressComponent currentView = null;
-
- /**
- * Constructor called with no arguments, indicating 1 phase and number of
- * phase units assumed to be 1 also (can be updated later).
- *
- */
- public SplashProgressModel() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#
- * incrementUnitsCompletedThisPhase(long)
- */
-
- /**
- * Increment units completed this phase.
- *
- * @param numUnits
- * long
- * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#incrementUnitsCompletedThisPhase(long)
- */
- @Override
- public final void incrementUnitsCompletedThisPhase(final long numUnits) {
- super.incrementUnitsCompletedThisPhase(numUnits);
- this.getCurrentView().updateProgressBar();
- }
-
- /**
- * Gets view from which data is sent for display.
- *
- * @return the current view
- */
- public final SplashProgressComponent getCurrentView() {
- return this.currentView;
- }
-
- /**
- * Sets view to which data is sent for display.
- *
- * @param neoView
- * the new current view
- */
- public final void setCurrentView(final SplashProgressComponent neoView) {
- this.currentView = neoView;
- }
-
-}
diff --git a/src/main/java/forge/view/toolbox/FProgressBar.java b/src/main/java/forge/view/toolbox/FProgressBar.java
new file mode 100644
index 00000000000..ffdc5bbe28b
--- /dev/null
+++ b/src/main/java/forge/view/toolbox/FProgressBar.java
@@ -0,0 +1,116 @@
+package forge.view.toolbox;
+
+
+import java.util.Date;
+
+import javax.swing.JProgressBar;
+import javax.swing.SwingUtilities;
+
+/**
+ * A simple progress bar component using the Forge skin.
+ *
+ * Can show
+ *
+ */
+public class FProgressBar extends JProgressBar {
+ private static final long serialVersionUID = 3479715871723156426L;
+ private int tempVal = 0;
+ private long startMillis = 0;
+ private long tempMillis = 0;
+ private float timePerUnit = 0;
+ private int eta = 0;
+ private boolean isIncrementing = false;
+ private int hours, minutes, seconds;
+ private String desc = "";
+ private String str = "";
+ private boolean showETA = true;
+ private boolean showCount = true;
+
+ /** */
+ public FProgressBar() {
+ super();
+ this.reset();
+ this.setStringPainted(true);
+ }
+
+ /** @param s0 A description to prepend before statistics. */
+ public void setDescription(final String s0) {
+ this.desc = s0;
+ this.setString(s0);
+ }
+
+ /** */
+ public void increment() {
+ if (isIncrementing) { System.out.println("Rejected."); return; }
+
+ isIncrementing = true;
+ tempVal++;
+ this.setValue(tempVal);
+ str = desc;
+ if (showCount) { calculateCount(tempVal); }
+ if (showETA) { calculateETA(tempVal); }
+ updateString();
+ isIncrementing = false;
+ }
+
+ private void calculateCount(int v0) {
+ str += " " + v0 + " of " + this.getMaximum();
+ }
+
+ /** */
+ private void calculateETA(int v0) {
+ tempMillis = new Date().getTime();
+ timePerUnit = (tempMillis - startMillis) / (float) v0;
+ eta = (int) ((this.getMaximum() - v0) * timePerUnit) / 1000;
+
+ seconds = eta;
+ hours = seconds >= 3600 ? (seconds / 3600) : 0;
+ seconds = eta % 3600;
+ minutes = seconds >= 60 ? (seconds / 60) : 0;
+ seconds = eta % 60 + 1;
+
+ str += ", ETA " + String.format("%02d", hours) + ":"
+ + String.format("%02d", minutes) + ":"
+ + String.format("%02d", seconds);
+ }
+
+ private void updateString() {
+ this.setString(str);
+ }
+
+ /** Resets the various values required for this class. */
+ public void reset() {
+ if (!SwingUtilities.isEventDispatchThread()) {
+ throw new IllegalStateException(
+ "FProgressBar > reset() must be accessed from an event dispatch thread.");
+ }
+
+ this.setIndeterminate(true);
+ this.setValue(0);
+ this.tempVal = 0;
+ this.startMillis = new Date().getTime();
+ this.setIndeterminate(false);
+ this.setShowETA(true);
+ this.setShowCount(true);
+ }
+
+ /** @param b0 Boolean, show the ETA statistic or not */
+ public void setShowETA(boolean b0) {
+ this.showETA = b0;
+ }
+
+ /** @return b0 Boolean, show the ETA statistic or not */
+ public boolean isShowETA() {
+ return showETA;
+ }
+
+ /** @param b0 Boolean, show the ETA statistic or not */
+ public void setShowCount(boolean b0) {
+ this.showCount = b0;
+ }
+
+ /** @return b0 Boolean, show the ETA statistic or not */
+ public boolean isShowCount() {
+ return showCount;
+ }
+}
diff --git a/src/main/java/forge/view/toolbox/FSkin.java b/src/main/java/forge/view/toolbox/FSkin.java
index 05dd1c8d7d3..9af71fd462e 100644
--- a/src/main/java/forge/view/toolbox/FSkin.java
+++ b/src/main/java/forge/view/toolbox/FSkin.java
@@ -30,7 +30,11 @@ import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.LineBorder;
+import forge.Singletons;
import forge.gui.GuiUtils;
/**
@@ -47,11 +51,6 @@ public class FSkin {
BG_TEXTURE, /** */
BG_MATCH, /** */
- PRELOAD_EMPTY_BG, /** */
- PRELOAD_EMPTY_TXT, /** */
- PRELOAD_FULL_BG, /** */
- PRELOAD_FULL_TXT, /** */
-
CLR_THEME, /** */
CLR_BORDERS, /** */
CLR_ZEBRA, /** */
@@ -135,13 +134,13 @@ public class FSkin {
private BufferedImage bimDefaultSprite;
private BufferedImage bimPreferredSprite;
private int preferredH, preferredW;
+ private FProgressBar barProgress;
/**
* FSkin constructor. No arguments, will generate default skin settings,
* fonts, and backgrounds.
- * @throws IOException for splash image file
*/
- public FSkin() throws IOException {
+ public FSkin() {
this("default");
}
@@ -169,11 +168,11 @@ public class FSkin {
this.setIcon(SkinProp.BG_SPLASH, img.getSubimage(0, 0, w, h - 100));
- this.setColor(SkinProp.PRELOAD_EMPTY_BG, this.getColorFromPixel(img.getRGB(25, h - 75)));
- this.setColor(SkinProp.PRELOAD_EMPTY_TXT, this.getColorFromPixel(img.getRGB(75, h - 75)));
- this.setColor(SkinProp.PRELOAD_FULL_BG, this.getColorFromPixel(img.getRGB(25, h - 25)));
- this.setColor(SkinProp.PRELOAD_FULL_TXT, this.getColorFromPixel(img.getRGB(75, h - 25)));
-
+ UIManager.put("ProgressBar.background", this.getColorFromPixel(img.getRGB(25, h - 75)));
+ UIManager.put("ProgressBar.selectionBackground", this.getColorFromPixel(img.getRGB(75, h - 75)));
+ UIManager.put("ProgressBar.foreground", this.getColorFromPixel(img.getRGB(25, h - 25)));
+ UIManager.put("ProgressBar.selectionForeground", this.getColorFromPixel(img.getRGB(75, h - 25)));
+ UIManager.put("ProgressBar.border", new LineBorder(Color.BLACK, 0));
} catch (final IOException e) {
System.err.println(this.notfound + preferredDir + FILE_SPLASH);
e.printStackTrace();
@@ -185,21 +184,34 @@ public class FSkin {
* collection of all symbols) and the preferred (which may be
* incomplete).
*
+ * Font must be present in the skin folder, and will not
+ * be replaced by default. The fonts are pre-derived
+ * in this method and saved in a HashMap for future access.
+ *
* Color swatches must be present in the preferred
* sprite, and will not be replaced by default.
*
* Background images must be present in skin folder,
* and will not be replaced by default.
*
- * Font must be present in the skin folder, and will not
- * be replaced by default. The fonts are pre-derived
- * in this method and saved in a HashMap for future access.
- *
* Icons, however, will be pulled from the two sprites. Obviously,
* preferred takes precedence over default, but if something is
* missing, the default picture is retrieved.
*/
- public void loadFontAndImages() {
+ public void loadFontsAndImages() {
+ barProgress = Singletons.getView().getProgressBar();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ barProgress.reset();
+ barProgress.setShowETA(false);
+ barProgress.setDescription("Processing fonts and image sprites: ");
+ }
+ });
+
+ barProgress.setMaximum(57);
+
// Grab and test the two sprite files.
final File f1 = new File(defaultDir + FILE_SPRITE);
final File f2 = new File(preferredDir + FILE_SPRITE);
@@ -220,27 +232,27 @@ public class FSkin {
// Exceptions handled inside method.
this.font = GuiUtils.newFont(FILE_SKINS_DIR + preferredName + "/" + FILE_FONT);
plainFonts = new HashMap();
- plainFonts.put(10, font.deriveFont(Font.PLAIN, 10));
- plainFonts.put(11, font.deriveFont(Font.PLAIN, 11));
- plainFonts.put(12, font.deriveFont(Font.PLAIN, 12));
- plainFonts.put(13, font.deriveFont(Font.PLAIN, 13));
- plainFonts.put(14, font.deriveFont(Font.PLAIN, 14));
- plainFonts.put(15, font.deriveFont(Font.PLAIN, 15));
- plainFonts.put(16, font.deriveFont(Font.PLAIN, 16));
- plainFonts.put(18, font.deriveFont(Font.PLAIN, 18));
- plainFonts.put(20, font.deriveFont(Font.PLAIN, 20));
- plainFonts.put(22, font.deriveFont(Font.PLAIN, 22));
+ setFontAndIncrement(10);
+ setFontAndIncrement(11);
+ setFontAndIncrement(12);
+ setFontAndIncrement(13);
+ setFontAndIncrement(14);
+ setFontAndIncrement(15);
+ setFontAndIncrement(16);
+ setFontAndIncrement(18);
+ setFontAndIncrement(20);
+ setFontAndIncrement(22);
boldFonts = new HashMap();
- boldFonts.put(12, font.deriveFont(Font.BOLD, 12));
- boldFonts.put(14, font.deriveFont(Font.BOLD, 14));
- boldFonts.put(16, font.deriveFont(Font.BOLD, 16));
- boldFonts.put(18, font.deriveFont(Font.BOLD, 18));
- boldFonts.put(20, font.deriveFont(Font.BOLD, 20));
+ setBoldFontAndIncrement(12);
+ setBoldFontAndIncrement(14);
+ setBoldFontAndIncrement(16);
+ setBoldFontAndIncrement(18);
+ setBoldFontAndIncrement(20);
italicFonts = new HashMap();
- italicFonts.put(12, font.deriveFont(Font.ITALIC, 12));
- italicFonts.put(14, font.deriveFont(Font.ITALIC, 14));
+ setItalicFontAndIncrement(12);
+ setItalicFontAndIncrement(14);
// Put various images into map (except sprite and splash).
// Exceptions handled inside method.
@@ -250,6 +262,7 @@ public class FSkin {
// Sprite
final File file = new File(preferredDir + FILE_SPRITE);
BufferedImage image;
+
try {
image = ImageIO.read(file);
@@ -260,61 +273,61 @@ public class FSkin {
this.setColor(SkinProp.CLR_ACTIVE, this.getColorFromPixel(image.getRGB(70, 90)));
this.setColor(SkinProp.CLR_INACTIVE, this.getColorFromPixel(image.getRGB(70, 110)));
this.setColor(SkinProp.CLR_TEXT, this.getColorFromPixel(image.getRGB(70, 130)));
-
- this.setIcon(SkinProp.ICON_ZONE_HAND, 280, 40, 40, 40);
- this.setIcon(SkinProp.ICON_ZONE_LIBRARY, 280, 0, 40, 40);
- this.setIcon(SkinProp.ICON_ZONE_GRAVEYARD, 320, 0, 40, 40);
- this.setIcon(SkinProp.ICON_ZONE_EXILE, 320, 40, 40, 40);
- this.setIcon(SkinProp.ICON_ZONE_FLASHBACK, 280, 80, 40, 40);
- this.setIcon(SkinProp.ICON_ZONE_POISON, 320, 80, 40, 40);
-
- this.setIcon(SkinProp.ICON_MANA_BLACK, 360, 160, 40, 40);
- this.setIcon(SkinProp.ICON_MANA_BLUE, 360, 200, 40, 40);
- this.setIcon(SkinProp.ICON_MANA_RED, 400, 160, 40, 40);
- this.setIcon(SkinProp.ICON_MANA_GREEN, 400, 200, 40, 40);
- this.setIcon(SkinProp.ICON_MANA_WHITE, 440, 200, 40, 40);
- this.setIcon(SkinProp.ICON_MANA_COLORLESS, 440, 240, 40, 40);
-
- this.setIcon(SkinProp.ICON_DOCK_SETTINGS, 80, 640, 80, 80);
- this.setIcon(SkinProp.ICON_DOCK_SHORTCUTS, 160, 640, 80, 80);
- this.setIcon(SkinProp.ICON_DOCK_CONCEDE, 240, 640, 80, 80);
- this.setIcon(SkinProp.ICON_DOCK_ENDTURN, 320, 640, 80, 80);
- this.setIcon(SkinProp.ICON_DOCK_DECKLIST, 400, 640, 80, 80);
-
- this.setIcon(SkinProp.IMG_LOGO, 480, 0, 200, 200);
- this.setIcon(SkinProp.IMG_FAVICON, 0, 720, 80, 80);
-
- this.setIcon(SkinProp.IMG_BTN_START_UP, 480, 200, 160, 80);
- this.setIcon(SkinProp.IMG_BTN_START_OVER, 480, 280, 160, 80);
- this.setIcon(SkinProp.IMG_BTN_START_DOWN, 480, 360, 160, 80);
-
- this.setIcon(SkinProp.IMG_BTN_UP_LEFT, 80, 0, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_UP_CENTER, 120, 0, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_UP_RIGHT, 160, 0, 40, 40);
-
- this.setIcon(SkinProp.IMG_BTN_OVER_LEFT, 80, 40, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_OVER_CENTER, 120, 40, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_OVER_RIGHT, 160, 40, 40, 40);
-
- this.setIcon(SkinProp.IMG_BTN_DOWN_LEFT, 80, 80, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_DOWN_CENTER, 120, 80, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_DOWN_RIGHT, 160, 80, 40, 40);
-
- this.setIcon(SkinProp.IMG_BTN_FOCUS_LEFT, 80, 120, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_FOCUS_CENTER, 120, 120, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_FOCUS_RIGHT, 160, 120, 40, 40);
-
- this.setIcon(SkinProp.IMG_BTN_TOGGLE_LEFT, 80, 160, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_TOGGLE_CENTER, 120, 160, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_TOGGLE_RIGHT, 160, 160, 40, 40);
-
- this.setIcon(SkinProp.IMG_BTN_DISABLED_LEFT, 80, 200, 40, 40);
- this.setIcon(SkinProp.IMG_BTN_DISABLED_CENTER, 120, 200, 1, 40);
- this.setIcon(SkinProp.IMG_BTN_DISABLED_RIGHT, 160, 200, 40, 40);
} catch (final IOException e) {
System.err.println(this.notfound + preferredDir + FILE_SPRITE);
e.printStackTrace();
}
+
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_HAND, 280, 40, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_LIBRARY, 280, 0, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_GRAVEYARD, 320, 0, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_EXILE, 320, 40, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_FLASHBACK, 280, 80, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_ZONE_POISON, 320, 80, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.ICON_MANA_BLACK, 360, 160, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_MANA_BLUE, 360, 200, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_MANA_RED, 400, 160, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_MANA_GREEN, 400, 200, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_MANA_WHITE, 440, 200, 40, 40);
+ this.setIconAndIncrement(SkinProp.ICON_MANA_COLORLESS, 440, 240, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.ICON_DOCK_SETTINGS, 80, 640, 80, 80);
+ this.setIconAndIncrement(SkinProp.ICON_DOCK_SHORTCUTS, 160, 640, 80, 80);
+ this.setIconAndIncrement(SkinProp.ICON_DOCK_CONCEDE, 240, 640, 80, 80);
+ this.setIconAndIncrement(SkinProp.ICON_DOCK_ENDTURN, 320, 640, 80, 80);
+ this.setIconAndIncrement(SkinProp.ICON_DOCK_DECKLIST, 400, 640, 80, 80);
+
+ this.setIconAndIncrement(SkinProp.IMG_LOGO, 480, 0, 200, 200);
+ this.setIconAndIncrement(SkinProp.IMG_FAVICON, 0, 720, 80, 80);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_START_UP, 480, 200, 160, 80);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_START_OVER, 480, 280, 160, 80);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_START_DOWN, 480, 360, 160, 80);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_UP_LEFT, 80, 0, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_UP_CENTER, 120, 0, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_UP_RIGHT, 160, 0, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_OVER_LEFT, 80, 40, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_OVER_CENTER, 120, 40, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_OVER_RIGHT, 160, 40, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DOWN_LEFT, 80, 80, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DOWN_CENTER, 120, 80, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DOWN_RIGHT, 160, 80, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_FOCUS_LEFT, 80, 120, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_FOCUS_CENTER, 120, 120, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_FOCUS_RIGHT, 160, 120, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_TOGGLE_LEFT, 80, 160, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_TOGGLE_CENTER, 120, 160, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_TOGGLE_RIGHT, 160, 160, 40, 40);
+
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DISABLED_LEFT, 80, 200, 40, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DISABLED_CENTER, 120, 200, 1, 40);
+ this.setIconAndIncrement(SkinProp.IMG_BTN_DISABLED_RIGHT, 160, 200, 40, 40);
}
/**
@@ -349,6 +362,20 @@ public class FSkin {
return plainFonts.get(size);
}
+ private void setFontAndIncrement(int size) {
+ plainFonts.put(size, font.deriveFont(Font.PLAIN, size));
+ if (barProgress != null) { barProgress.increment(); }
+ }
+
+ private void setBoldFontAndIncrement(int size) {
+ boldFonts.put(size, font.deriveFont(Font.BOLD, size));
+ if (barProgress != null) { barProgress.increment(); }
+ }
+
+ private void setItalicFontAndIncrement(int size) {
+ italicFonts.put(size, font.deriveFont(Font.ITALIC, size));
+ if (barProgress != null) { barProgress.increment(); }
+ }
/**
* @param size - integer, pixel size
* @return {@link java.awt.font} font1
@@ -451,7 +478,7 @@ public class FSkin {
* @param w0 Width of sub-image
* @param h0 Height of sub-image
*/
- public void setIcon(final SkinProp s0,
+ private void setIconAndIncrement(final SkinProp s0,
final int x0, final int y0, final int w0, final int h0) {
// Test if requested sub-image in inside bounds of preferred sprite.
// (Height and width of preferred sprite were set in loadFontAndImages.)
@@ -498,6 +525,7 @@ public class FSkin {
BufferedImage img = (exists ? bimPreferredSprite : bimDefaultSprite);
BufferedImage bi0 = img.getSubimage(x0, y0, w0, h0);
this.icons.put(s0, new ImageIcon(bi0));
+ if (barProgress != null) { barProgress.increment(); }
}
/**