it.tidalwave.bluebill.mobile.taxonomy.factsheet.ui.stillimage.DefaultTaxonStillImageFactSheetViewController Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* blueBill Mobile - Android - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile
* SCM: https://java.net/hg/bluebill-mobile~android-src
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.taxonomy.factsheet.ui.stillimage;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import it.tidalwave.util.Id;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.util.thread.annotation.ThreadConfined;
import it.tidalwave.mobile.media.Media;
import it.tidalwave.bluebill.taxonomy.mobile.Taxon;
import it.tidalwave.bluebill.mobile.taxonomy.factsheet.spi.TaxonFactSheetViewControllerSupport;
import lombok.extern.slf4j.Slf4j;
import static it.tidalwave.util.thread.ThreadType.*;
import static it.tidalwave.role.ui.Presentable.Presentable;
import static it.tidalwave.semantic.vocabulary.FoafVocabulary.*;
import static it.tidalwave.mobile.media.Media.*;
import static it.tidalwave.bluebill.factsheet.Documentable.Documentable;
/***********************************************************************************************************************
*
* @stereotype Controller
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
@Slf4j
public class DefaultTaxonStillImageFactSheetViewController extends TaxonFactSheetViewControllerSupport
implements TaxonStillImageFactSheetViewController
{
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public DefaultTaxonStillImageFactSheetViewController (final @Nonnull TaxonStillImageFactSheetView view)
{
super(view);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@ThreadConfined(type=NOT_UI)
protected void createPresentationModels (final @Nonnull Taxon taxon)
throws NotFoundException
{
log.info("createPresentationModels({})", taxon);
// stillImages.addAll(taxon.as(Documentable).getFactSheet().getMultiple(FOAF_IMAGE));
for (final Media stillImage : taxon.as(Documentable).getFactSheet().getMultiple(FOAF_IMAGE))
{
addPresentationModel(stillImage.with(ID, replacedId(stillImage.get(ID))).as(Presentable).createPresentationModel());
}
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public void showImage (final @Nonnegative int index)
{
log.info("showImage({})", index);
view.renderImage(getPresentationModel(index));
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
private Id replacedId (final @Nonnull Id id)
{
String x = id.stringValue();
if (x.startsWith("http://upload.wikimedia.org")) // FIXME
{
x = "http://bluebill.tidalwave.it/media/1/480/" + x.substring(7); /// FIXME: pick the proper size
}
return new Id(x);
}
}