001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ade.galleries.client.preview; 029 030import org.opencms.util.CmsStringUtil; 031 032/** 033 * User defined image format restriction. To be used within the image format tab of the image preview.<p> 034 * 035 * @since 8.0.0 036 */ 037public class CmsUserFormatRestriction implements I_CmsFormatRestriction { 038 039 /** The format label. */ 040 private String m_label; 041 042 /** The format name. */ 043 private String m_name; 044 045 /** 046 * Constructor.<p> 047 * 048 * @param name the format name 049 * @param label the format label 050 */ 051 public CmsUserFormatRestriction(String name, String label) { 052 053 m_name = name; 054 m_label = label; 055 } 056 057 /** 058 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#adjustCroppingParam(org.opencms.ade.galleries.client.preview.CmsCroppingParamBean) 059 */ 060 public void adjustCroppingParam(CmsCroppingParamBean croppingParam) { 061 062 croppingParam.setFormatName(getName()); 063 } 064 065 /** 066 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getHeight(int, int) 067 */ 068 public int getHeight(int orgHeight, int orgWidth) { 069 070 return orgHeight; 071 } 072 073 /** 074 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getLabel() 075 */ 076 public String getLabel() { 077 078 return m_label; 079 } 080 081 /** 082 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getName() 083 */ 084 public String getName() { 085 086 return m_name; 087 } 088 089 /** 090 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getWidth(int, int) 091 */ 092 public int getWidth(int orgHeight, int orgWidth) { 093 094 return orgWidth; 095 } 096 097 /** 098 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isCroppingEnabled() 099 */ 100 public boolean isCroppingEnabled() { 101 102 return true; 103 } 104 105 /** 106 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isFixedRatio() 107 */ 108 public boolean isFixedRatio() { 109 110 return false; 111 } 112 113 /** 114 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isHeightEditable() 115 */ 116 public boolean isHeightEditable() { 117 118 return true; 119 } 120 121 /** 122 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isWidthEditable() 123 */ 124 public boolean isWidthEditable() { 125 126 return true; 127 } 128 129 /** 130 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#matchesCroppingParam(org.opencms.ade.galleries.client.preview.CmsCroppingParamBean) 131 */ 132 public boolean matchesCroppingParam(CmsCroppingParamBean croppingParam) { 133 134 return CmsStringUtil.isNotEmptyOrWhitespaceOnly(croppingParam.toString()); 135 } 136 137}