/*
* [Photo.java]
*
* Summary: Generate a reference to Photo. Click on the camera icon to see photo. Not otherwise displayed.
*
* Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
*
* Licence: This software may be copied and used freely for any purpose but military.
* http://mindprod.com/contact/nonmil.html
*
* Requires: JDK 1.8+
*
* Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
*
* Version History:
* 1.8 2009-02-06 include go package in ZIP bundle.
* for local file image/ prefix is presumed.
* for remote file, left as is.
*/
package com.mindprod.htmlmacros.macro;
import com.mindprod.amper.Amper;
import com.mindprod.fastcat.FastCat;
import com.mindprod.htmlmacros.support.BuildImage;
import com.mindprod.htmlmacros.support.ImageAlignment;
import com.mindprod.htmlmacros.support.Tools;
import static java.lang.System.*;
/**
* Generate a reference to Photo. Click on the camera icon to see photo. Not otherwise displayed.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.8 2009-02-06 include go package in ZIP bundle.
* for local file image/ prefix is presumed.
* for remote file, left as is.
* @since 2009
*/
public final class Photo extends Macro
{
/**
* how to use the macro
*/
private static final String USAGE = "\nPhoto macro needs imageFile(without lead mindprod/image/)";
/**
* guts to Generate reference to a Photo reference, Used by Reunion and LL macrons too.
*
* @param photoURL unqualified image-relative reference to an image or absolute ref starting with http://
*
* @return expanded reference with icon.
*/
public String expand( String photoURL )
{
final FastCat sb = new FastCat( 300 );
if ( photoURL.startsWith( "http://" ) || photoURL.startsWith( "https://" ) )
{
sb.append( "" );
}
else
{
sb.append( "" );
}
sb.append( BuildImage.buildImgTag( "icon32/camera.png",
"click to see photograph",
ImageAlignment.middle,
null,
fileBeingProcessed ) );
sb.append( "" );
return sb.toString();
}
/**
* Generate camera icon to click to see a photo. typical use: Expands:
*
* @param parms first is raw imagename in images directory, e.g. roedy.jpg
* @param quiet true if want output suppressed.
* @param verbose @return expanded macro HTML
*/
public String expandMacro( String[] parms,
final boolean quiet, final boolean verbose )
{
if ( !quiet )
{
out.print( "C" );
}
if ( parms.length != 1 )
{
throw new IllegalArgumentException( USAGE );
}
String photo = parms[ 0 ];
return expand( photo );
}
}