Skip to content

Commit

Permalink
Added comments and more refactoring to DashboardLogic and DashboardUI
Browse files Browse the repository at this point in the history
  • Loading branch information
sguergachi committed Oct 24, 2012
1 parent d51a3ae commit 622428a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 65 deletions.
16 changes: 8 additions & 8 deletions src/aurora/V1/core/screen_logic/DashboardLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@
* .------------------------------------------------------------------------.
* |
* |
* | This Class is the Logic component of the Dashboard Screen. Its instanced
* | In DashboardUI.
* |
* |
* |
* |
* |
* |
* |
* |
* |
* | This class is supposed to handle all of the Long Processing of UI or
* | Actions generated by the Handler. Reusable processing and long logic
* | methods should go here.
* |
* .........................................................................
*
Expand Down Expand Up @@ -95,6 +92,8 @@ public DashboardLogic(final DashboardUI dashboardUi) {
this.dashboardHandler = dashboardUI.getDashboardHandler();
this.storage = dashboardUI.getStorage();



}

/**
Expand All @@ -117,6 +116,7 @@ public final aImagePane getLibraryIcon() {
aImagePane icon;

//* Double check there are no games in Storage *//
System.out.println(storage);
if (storage.getStoredLibrary().getBoxArtPath() == null || storage.
getStoredLibrary().getBoxArtPath().isEmpty()) {

Expand Down
111 changes: 54 additions & 57 deletions src/aurora/V1/core/screen_ui/DashboardUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,6 @@ public class DashboardUI extends AuroraApp {
*/
private ArrayList<String> infoArray;

/**
* The Panel that contains the InfoFeed component.
*/
private JPanel pnlInfoFeed;

/**
* Button in frame controls to go back to Dashboard.
*/
Expand Down Expand Up @@ -353,6 +348,9 @@ public class DashboardUI extends AuroraApp {
public DashboardUI(final AuroraCoreUI auroraCoreUi,
final StartScreenUI startScreenUi) {

//* Other core objects *//
this.startUI = startScreenUi;
this.storage = startUI.getAuroraStorage();

//* Core UI Canvas *//
this.coreUI = auroraCoreUi;
Expand All @@ -362,9 +360,7 @@ public DashboardUI(final AuroraCoreUI auroraCoreUi,
this.handler = new DashboardHandler(this);
this.logic = new DashboardLogic(this);

//* All other core objects *//
this.startUI = startScreenUi;
this.storage = startUI.getAuroraStorage();



}
Expand Down Expand Up @@ -428,7 +424,6 @@ public final void loadUI() {

infoFeed = new aInfoFeed("InfoBar.png", infobarWidth,
infobarHeight, logic.createFeed(null));
pnlInfoFeed = new JPanel(new BorderLayout());
//------------------------------|||-----------------------------------//


Expand Down Expand Up @@ -527,40 +522,34 @@ public final void buildUI() {
//----------------------------INFOFEED--------------------------------//
infoFeed.go();

pnlInfoFeed.add(infoFeed, BorderLayout.SOUTH);
pnlInfoFeed.setOpaque(false);

//------------------------------|||-----------------------------------//



//----------------------------CORE UI---------------------------------//

//* Remove KeyListener attached to frame. *//

coreUI.getFrame().removeKeyListener(startUI.getStartKeyHandler());

//* Set bigger Logo to Header *//
coreUI.getImgLogo().setImgURl("Aurora_Header2.png");
coreUI.getImgLogo().setImageSize(logoWidth, logoHeight);

coreUI.getPnlBottom().setPreferredSize(new Dimension(coreUI.
getPnlBottom().getWidth(), bottomPaneHeightAdjust));
coreUI.getPnlBottom().setImageHeight(bottomPaneHeightAdjust);
//* Set bigger background image for Frame Control panel *//
coreUI.getPnlFrameControl().setImage("Aurora_FrameButton2.png");

//* Set size of Top panel in CoreUI *//
coreUI.getPnlTop().setImageHeight(topHeight);
coreUI.getPnlTop().setPreferredSize(new Dimension(coreUI.getPnlTop().
getWidth(), coreUI.getPnlTop().getImageHeight() + coreUI.
getPnlFrameControl().getHeight()));

coreUI.getPnlFrameControl().removeAll();


btnBack.setToolTipText("Back");

coreUI.getPnlFrameControl().add(coreUI.getBtnMin());
coreUI.getPnlFrameControl().add(coreUI.getBtnExit());
coreUI.getPnlFrameControl().setImage("Aurora_FrameButton2.png");
//* Set size of Bottom panel in CoreUI *//
coreUI.getPnlBottom().setPreferredSize(new Dimension(coreUI.
getPnlBottom().getWidth(), bottomPaneHeightAdjust));
coreUI.getPnlBottom().setImageHeight(bottomPaneHeightAdjust);

//* Set size of Top Panels *//
coreUI.getPnlSouthFromTop().setPreferredSize(new Dimension(coreUI.
getPnlSouthFromTop().getWidth(), coreUI.getPnlFrameControl().
getHeight()));
Expand All @@ -569,7 +558,7 @@ public final void buildUI() {
getPnlFrameControl().getHeight()));
coreUI.getPnlSouthFromTop().revalidate();


//* Set Font of Keyboard Action Label *//
lblKeyAction.setFont(coreUI.getDefaultFont().deriveFont(Font.PLAIN,
coreUI.getSIZE_keysFont()));
lblKeyAction.setForeground(Color.YELLOW);
Expand All @@ -580,27 +569,33 @@ public final void buildUI() {


//* Add Back Button to Frame Controls *//
coreUI.getPnlFrameControl().add(btnBack);
coreUI.getPnlFrameControl().add(btnBack, 0);
btnBack.setToolTipText("Back");


//* Add Arrow Keys Icons *//
coreUI.getPnlKeyToPress().add(keyArrows);
coreUI.getPnlKeyToPress().add(lblKeyAction);


//* Add Enter Key Icons *//

coreUI.getPnlKeyToPress().add(coreUI.getImgKeyIco());
coreUI.getPnlKeyToPress().add(coreUI.getLblKeyAction());

//* Add Carousel to Center Panel *//
coreUI.getPnlCenter().add(BorderLayout.CENTER, carousel);

//* Add To Bottom Panel InfoFeed and both Carousel Buttons*//
coreUI.getPnlCenterFromBottom().add(BorderLayout.EAST, btnCarouselRight);
coreUI.getPnlCenterFromBottom().add(infoFeed, BorderLayout.CENTER);
coreUI.getPnlCenterFromBottom().add(BorderLayout.CENTER, infoFeed);
coreUI.getPnlCenterFromBottom().add(BorderLayout.WEST, btnCarouselLeft);


//* Finalize CoreUI *//
//* CoreUI Listeners *//

//* Remove ENTER KeyListener attached to frame. *//
coreUI.getFrame().removeKeyListener(startUI.getStartKeyHandler());

//* Add Carousel KeyListener to Background *//
coreUI.getFrame().getContentPane().
addKeyListener(handler.new CarouselKeyListener());
coreUI.getFrame().addKeyListener(handler.new CarouselKeyListener());
Expand All @@ -610,16 +605,26 @@ public final void buildUI() {
//* Finished loading so change text *//
coreUI.getLblInfo().setText(" Dashboard ");

//* Final Refresh and Refocus *//
coreUI.getFrame().repaint();
coreUI.getFrame().requestFocus();

//------------------------------|||-----------------------------------//



}


/**
* .-----------------------------------------------------------------------.
* | setSizes()
* .-----------------------------------------------------------------------.
* |
* | This method generates the initial size of each component in this UI
* |
* | The set size uses some trial and error based calculations to determine
* | sizes for large screens and for small screens. This method is not
* | Perfect but its an improvement on previous implementations
* |
*/
private void setSizes() {

int Ratio = (coreUI.getFrame().getHeight() / coreUI.getFrame().
Expand All @@ -634,21 +639,21 @@ private void setSizes() {
getFrame().getWidth() / 6);
gameCoverHeight = carouselHeight - (2 * carouselHeight / 6);
gameCoverWidth = (int) carouselWidth - (int) (carouselWidth / 4);
carouselImageWidth = carouselHeight - (2 * carouselHeight / 6) -
(Ratio / 8);
carouselImageHeight = (int) carouselWidth -
(int) (carouselWidth / 4) - 20;
carouselImageWidth = carouselHeight - (2 * carouselHeight / 6)
- (Ratio / 8);
carouselImageHeight = (int) carouselWidth
- (int) (carouselWidth / 4) - 20;
logoHeight = topHeight / 2 + 20;
logoWidth = coreUI.getFrame().getWidth() / 2 + 20;

bottomPaneHeightAdjust = coreUI.getSIZE_pnlBottom() / 2 + coreUI.
getFrame().getHeight() / 50 + 25;
topPaneHeighAdjust = coreUI.getPnlCenter().getHeight() / 5 - Ratio /
10;
topPaneHeighAdjust = coreUI.getPnlCenter().getHeight() / 5 - Ratio
/ 10;
carouselButtonWidth = coreUI.getFrame().getWidth() / 12 + 10;
carouselButtonHeight = coreUI.getFrame().getHeight() / 15 + 10;
infobarWidth = coreUI.getFrame().getSize().width -
(carouselButtonWidth * 2 + 65);
infobarWidth = coreUI.getFrame().getSize().width
- (carouselButtonWidth * 2 + 65);
infobarHeight = 75;


Expand All @@ -661,21 +666,21 @@ private void setSizes() {
getFrame().getWidth() / 6);
gameCoverHeight = carouselHeight - (2 * carouselHeight / 6);
gameCoverWidth = (int) carouselWidth - (int) (carouselWidth / 4);
carouselImageWidth = (int) carouselWidth - (int) (400 / 2) -
(Ratio * 2);
carouselImageHeight = (int) carouselHeight - (450 / 2) - (Ratio * 2) -
55;
carouselImageWidth = (int) carouselWidth - (int) (400 / 2) - (Ratio
* 2);
carouselImageHeight = (int) carouselHeight - (450 / 2) - (Ratio * 2)
- 55;
logoHeight = topHeight / 2 + 20;
logoWidth = coreUI.getFrame().getWidth() / 2 + 20;

bottomPaneHeightAdjust = coreUI.getSIZE_pnlBottom() / 2 + coreUI.
getFrame().getHeight() / 90 + 25;
topPaneHeighAdjust = coreUI.getPnlCenter().getHeight() / 5 - Ratio /
10;
topPaneHeighAdjust = coreUI.getPnlCenter().getHeight() / 5 - Ratio
/ 10;
carouselButtonWidth = coreUI.getFrame().getWidth() / 12;
carouselButtonHeight = coreUI.getFrame().getHeight() / 15;
infobarWidth = coreUI.getFrame().getSize().width -
(carouselButtonWidth * 2 + 60);
infobarWidth = coreUI.getFrame().getSize().width
- (carouselButtonWidth * 2 + 60);
infobarHeight = carouselButtonHeight - bottomPaneHeightAdjust / 18;


Expand Down Expand Up @@ -1040,14 +1045,6 @@ public void setCarouselButtonHeight(int carouselButtonHeight) {
this.carouselButtonHeight = carouselButtonHeight;
}

public JPanel getPnlInfo() {
return pnlInfoFeed;
}

public void setPnlInfo(JPanel pnlInfo) {
this.pnlInfoFeed = pnlInfo;
}

public aCarousel getCarousel() {
return carousel;
}
Expand Down

0 comments on commit 622428a

Please sign in to comment.