finished implementation of autoscaling leaderboard

This commit is contained in:
fmittag committed 2014-10-09 12:25:30 +02:00
1 parent 2692107960
commit 46aa1189cd
6 files changed
+50 -21

No files matched your search

@@ -72,9 +72,11 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
private boolean showWindChart;
private final RaceBoardViewConfiguration raceboardViewConfig;
private final PlayerView playerView;
private final int SAP_HEADER_HEIGHT = 80;
private Widget currentContentWidget;
private static int SAP_HEADER_HEIGHT = 70;
private static double MIN_SCALE_FACTOR = 0.8;
public AutoPlayController(SailingServiceAsync sailingService, MediaServiceAsync mediaService,
ErrorReporter errorReporter, String leaderboardGroupName, String leaderboardName, final String leaderboardZoom, UserAgentDetails userAgent,
long delayToLiveInMillis, boolean showRaceDetails, RaceBoardViewConfiguration raceboardViewConfig, PlayerView playerView) {
@@ -131,8 +133,6 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
updateRaceTimesInfoProvider();
}
};
// leaderboardPanel.getContentWidget().getElement().getStyle().setProperty("margin", "0 auto");
// leaderboardPanel.getContentWidget().getElement().getStyle().setPosition(Position.ABSOLUTE);
leaderboardPanel.getContentWidget().getElement().getStyle().setFontWeight(FontWeight.BOLD);
return leaderboardPanel;
}
@@ -172,6 +172,7 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
LeaderboardPanel leaderboardPanel = createLeaderboardPanel(leaderboardGroupName, leaderboardName, showRaceDetails);
OldLeaderboard oldLeaderboard = new OldLeaderboard(leaderboardPanel);
leaderboardPanel.addLeaderboardUpdateListener(oldLeaderboard);
currentContentWidget = oldLeaderboard.getContentWidget();
@@ -213,8 +214,7 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
private void scaleContentWidget(int headerHeight, Widget contentWidget, double scaleFactor, double diffX) {
if(scaleFactor > 0.0) {
CSS3Util.setProperty(contentWidget.getElement().getStyle(),
"transform", "translateX(" + diffX / 2.0 + "px) scale(" + scaleFactor + ")");
CSS3Util.setProperty(contentWidget.getElement().getStyle(), "transform", "translateX(" + diffX / 2.0 + "px) scale(" + scaleFactor + ")");
CSS3Util.setProperty(contentWidget.getElement().getStyle(), "transformOrigin", "0 0");
}
}
@@ -239,6 +239,9 @@ public class AutoPlayController implements RaceTimesInfoProviderListener {
double scaleFactorY = clientHeight / (double) contentHeight;
Double scaleFactor = scaleFactorX > scaleFactorY ? scaleFactorY : scaleFactorX;
if(scaleFactor < MIN_SCALE_FACTOR) {
scaleFactor = MIN_SCALE_FACTOR;
}
double diffX = clientWidth - contentWidth * scaleFactor;
scaleContentWidget(headerHeight, contentWidget, scaleFactor, diffX);
@@ -3,7 +3,7 @@
font-size: 1rem;
background: #333;
border-bottom: 5px solid #f0ab00;
min-height: 4.33em;
height: 70px;
line-height: 4em;
width: 100%;
overflow: hidden;
@@ -35,6 +35,7 @@
.logotitle {
display: inline;
color: #f6f9fc;
font-weight: bold;
}
.pagetitle {
color: #ffffff;
@@ -1,6 +1,5 @@
.oldLeaderboardPanel {
background-color:#f8f8f8;
padding: 10px 10px 10px 10px;
width: 100%;
font-weight: bold;
}
@@ -8,3 +7,22 @@
.leaderboardAndTitlePanel {
display: inline-block;
}
.leaderboardAndTitleTable {
margin-bottom: 0.75em;
}
.regattaleaderboard_meta_scoring,
.regattaleaderboard_meta_update {
font-weight: bold;
margin-top: 0.5em;
}
.regattaleaderboard_meta_scoring_comment,
.regattaleaderboard_meta_scoring_type,
.regattaleaderboard_meta_update_timestamp,
.regattaleaderboard_meta_update_text {
margin: 0;
}
.regattaleaderboard_meta_update {
text-align: right;
}
@@ -4,21 +4,22 @@ import java.util.Date;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.ParagraphElement;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.domain.common.RaceIdentifier;
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
import com.sap.sailing.gwt.common.client.i18n.TextMessages;
import com.sap.sailing.gwt.home.client.place.event.regattaleaderboard.EventRegattaLeaderboardResources;
import com.sap.sailing.gwt.ui.client.LeaderboardUpdateListener;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
import com.sap.sailing.gwt.ui.leaderboard.LeaderboardPanel;
import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
public class OldLeaderboard extends Composite {
public class OldLeaderboard extends Composite implements LeaderboardUpdateListener {
private static LeaderboardUiBinder uiBinder = GWT.create(LeaderboardUiBinder.class);
interface LeaderboardUiBinder extends UiBinder<Widget, OldLeaderboard> {
@@ -37,7 +38,6 @@ public class OldLeaderboard extends Composite {
public OldLeaderboard(LeaderboardPanel leaderboardPanel) {
this.leaderboardPanel = leaderboardPanel;
EventRegattaLeaderboardResources.INSTANCE.css().ensureInjected();
OldLeaderboardResources.INSTANCE.css().ensureInjected();
initWidget(uiBinder.createAndBindUi(this));
@@ -49,7 +49,7 @@ public class OldLeaderboard extends Composite {
return contentPanel;
}
public void updatedLeaderboard(LeaderboardDTO leaderboard, boolean hasLiveRace) {
public void updatedLeaderboard(LeaderboardDTO leaderboard) {
if(leaderboard != null) {
lastScoringCommentDiv.setInnerText(leaderboard.getComment() != null ? leaderboard.getComment() : "");
scoringSchemeDiv.setInnerText(leaderboard.scoringScheme != null ? ScoringSchemeTypeFormatter.format(leaderboard.scoringScheme, StringMessages.INSTANCE) : "");
@@ -63,7 +63,10 @@ public class OldLeaderboard extends Composite {
lastScoringUpdateTimeDiv.setInnerText("");
lastScoringUpdateTextDiv.setInnerText("");
}
lastScoringUpdateTimeDiv.getStyle().setVisibility(!hasLiveRace ? Visibility.VISIBLE : Visibility.HIDDEN);
}
}
@Override
public void currentRaceSelected(RaceIdentifier raceIdentifier, RaceColumnDTO raceColumn) {
}
}
@@ -3,26 +3,22 @@
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field="i18n" type="com.sap.sailing.gwt.common.client.i18n.TextMessages"/>
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
<ui:with field="local_res" type="com.sap.sailing.gwt.home.client.place.event.regattaleaderboard.EventRegattaLeaderboardResources" />
<ui:with field="local_res2" type="com.sap.sailing.gwt.autoplay.client.shared.oldleaderboard.OldLeaderboardResources" />
<ui:with field="local_res" type="com.sap.sailing.gwt.autoplay.client.shared.oldleaderboard.OldLeaderboardResources" />
<g:HTMLPanel>
<g:HTMLPanel ui:field="contentPanel" styleName="{local_res2.css.leaderboardAndTitlePanel}">
<table>
<g:HTMLPanel ui:field="contentPanel" styleName="{local_res.css.leaderboardAndTitlePanel}">
<table class="{local_res.css.leaderboardAndTitleTable}">
<tr>
<td width="50%">
<div class="{local_res.css.regattaleaderboard_meta_scoring}">
<p ui:field="lastScoringCommentDiv"
class="{local_res.css.regattaleaderboard_meta_scoring_comment}"></p>
<p ui:field="lastScoringCommentDiv" class="{local_res.css.regattaleaderboard_meta_scoring_comment}"></p>
<p ui:field="scoringSchemeDiv" class="{local_res.css.regattaleaderboard_meta_scoring_type}"></p>
</div>
</td>
<td width="50%">
<div class="{local_res.css.regattaleaderboard_meta_settings}">
<div class="{local_res.css.regattaleaderboard_meta_update}">
<p ui:field="lastScoringUpdateTextDiv" class="{local_res.css.regattaleaderboard_meta_update_text}"></p>
<p ui:field="lastScoringUpdateTimeDiv" class="{local_res.css.regattaleaderboard_meta_update_timestamp}"></p>
</div>
</div>
</td>
</tr>
<tr>
@@ -13,5 +13,13 @@ public interface OldLeaderboardResources extends ClientBundle {
public interface LocalCss extends CssResource {
String oldLeaderboardPanel();
String leaderboardAndTitlePanel();
String leaderboardAndTitleTable();
String regattaleaderboard_meta_scoring();
String regattaleaderboard_meta_scoring_comment();
String regattaleaderboard_meta_scoring_type();
String regattaleaderboard_meta_update();
String regattaleaderboard_meta_update_text();
String regattaleaderboard_meta_update_timestamp();
}
}