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 * Original 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 CmsOriginalFormatRestriction 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 CmsOriginalFormatRestriction(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.reset(); 063 croppingParam.setFormatName(getName()); 064 } 065 066 /** 067 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getHeight(int, int) 068 */ 069 public int getHeight(int orgHeight, int orgWidth) { 070 071 return orgHeight; 072 } 073 074 /** 075 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getLabel() 076 */ 077 public String getLabel() { 078 079 return m_label; 080 } 081 082 /** 083 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getName() 084 */ 085 public String getName() { 086 087 return m_name; 088 } 089 090 /** 091 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#getWidth(int, int) 092 */ 093 public int getWidth(int orgHeight, int orgWidth) { 094 095 return orgWidth; 096 } 097 098 /** 099 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isCroppingEnabled() 100 */ 101 public boolean isCroppingEnabled() { 102 103 return false; 104 } 105 106 /** 107 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isFixedRatio() 108 */ 109 public boolean isFixedRatio() { 110 111 return true; 112 } 113 114 /** 115 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isHeightEditable() 116 */ 117 public boolean isHeightEditable() { 118 119 return false; 120 } 121 122 /** 123 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#isWidthEditable() 124 */ 125 public boolean isWidthEditable() { 126 127 return false; 128 } 129 130 /** 131 * @see org.opencms.ade.galleries.client.preview.I_CmsFormatRestriction#matchesCroppingParam(org.opencms.ade.galleries.client.preview.CmsCroppingParamBean) 132 */ 133 public boolean matchesCroppingParam(CmsCroppingParamBean croppingParam) { 134 135 return CmsStringUtil.isEmpty(croppingParam.toString()); 136 } 137 138}