Content of file ShootingDataInterpolator.java.html
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>ShootingDataInterpolator.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">NorthernWind :: Frontend :: Media :: Spring MVC</a> > <a href="../index.html" class="el_bundle">it-tidalwave-northernwind-frontend-media</a> > <a href="index.source.html" class="el_package">it.tidalwave.northernwind.frontend.media.impl.interpolator</a> > <span class="el_source">ShootingDataInterpolator.java</span></div><h1>ShootingDataInterpolator.java</h1><pre class="source lang-java linenums">/*
* #%L
* *********************************************************************************************************************
*
* NorthernWind - lightweight CMS
* http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
* %%
* Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://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.
*
* *********************************************************************************************************************
*
*
* *********************************************************************************************************************
* #L%
*/
package it.tidalwave.northernwind.frontend.media.impl.interpolator;
import javax.annotation.Nonnull;
import java.util.Map;
import java.text.DecimalFormat;
import org.imajine.image.Rational;
import org.imajine.image.metadata.EXIF;
import org.imajine.image.metadata.XMP;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
*
**********************************************************************************************************************/
public class ShootingDataInterpolator extends MetadataInterpolatorSupport
{
public ShootingDataInterpolator()
{
<span class="fc" id="L45"> super("shootingData");</span>
<span class="fc" id="L46"> }</span>
@Override @Nonnull
public String interpolate (@Nonnull final String template, @Nonnull final Context context)
{
<span class="fc" id="L51"> final EXIF exif = context.getMetadata().getDirectory(EXIF.class);</span>
<span class="fc" id="L52"> final Map<String, String> xmpProperties = context.getMetadata().getDirectory(XMP.class).getXmpProperties();</span>
<span class="fc" id="L53"> final Map<String, String> lensMap = context.getLensMap();</span>
<span class="fc" id="L55"> final StringBuilder builder = new StringBuilder();</span>
<span class="fc" id="L56"> builder.append(formatted(exif.getModel()));</span>
<span class="fc" id="L57"> builder.append(" + ");</span>
<span class="fc" id="L59"> String lens = formatted(lensMap.get(xmpProperties.get("aux:LensID")));</span>
<span class="pc bpc" id="L61" title="1 of 2 branches missed."> if ("".equals(lens))</span>
{
<span class="nc" id="L63"> lens = formatted(lookup(lensMap, xmpProperties.get("aux:Lens")));</span>
}
<span class="fc" id="L66"> builder.append(lens);</span>
<span class="fc" id="L67"> builder.append(" @ ");</span>
<span class="fc" id="L68"> builder.append(exif.getFocalLength().intValue()).append(" mm, ");</span>
// FIXME: eventually teleconverter
<span class="fc" id="L70"> builder.append(exif.getExposureTime()).append(" sec @ \u0192/");</span>
<span class="fc" id="L71"> builder.append(new DecimalFormat("0.#").format(exif.getFNumber().floatValue()));</span>
<span class="fc" id="L73"> final Rational exposureBiasValue = exif.getExposureBiasValue();</span>
<span class="pc bpc" id="L75" title="1 of 2 branches missed."> if (exposureBiasValue.getNumerator() != 0)</span>
{
<span class="fc" id="L77"> builder.append(String.format(", %+.2f EV", exposureBiasValue.floatValue()));</span>
}
<span class="fc" id="L80"> builder.append(", ISO ").append(exif.getISOSpeedRatings().intValue());</span>
<span class="fc" id="L82"> return template.replace("$" + macro + "$", builder.toString());</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>