001package org.gwtbootstrap3.client.ui; 002 003/* 004 * #%L 005 * GwtBootstrap3 006 * %% 007 * Copyright (C) 2013 GwtBootstrap3 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import org.gwtbootstrap3.client.ui.base.HasPull; 024import org.gwtbootstrap3.client.ui.base.HasResponsiveness; 025import org.gwtbootstrap3.client.ui.base.HasType; 026import org.gwtbootstrap3.client.ui.base.helper.StyleHelper; 027import org.gwtbootstrap3.client.ui.base.mixin.PullMixin; 028import org.gwtbootstrap3.client.ui.constants.DeviceSize; 029import org.gwtbootstrap3.client.ui.constants.ImageType; 030import org.gwtbootstrap3.client.ui.constants.Pull; 031import org.gwtbootstrap3.client.ui.constants.Styles; 032 033import com.google.gwt.resources.client.ImageResource; 034import com.google.gwt.safehtml.shared.SafeUri; 035 036/** 037 * @author Joshua Godi 038 */ 039public class Image extends com.google.gwt.user.client.ui.Image implements HasType<ImageType>, HasResponsiveness, 040 HasPull { 041 042 private final PullMixin<Image> pullMixin = new PullMixin<Image>(this); 043 044 public Image() { 045 super(); 046 setStyleName(""); 047 } 048 049 public Image(final ImageResource resource) { 050 super(resource); 051 setStyleName(""); 052 } 053 054 public Image(final SafeUri url, final int left, final int top, final int width, final int height) { 055 super(url, left, top, width, height); 056 setStyleName(""); 057 } 058 059 public Image(final SafeUri url) { 060 super(url); 061 setStyleName(""); 062 } 063 064 public Image(final String url, final int left, final int top, final int width, final int height) { 065 super(url, left, top, width, height); 066 setStyleName(""); 067 } 068 069 public Image(final String url) { 070 super(url); 071 setStyleName(""); 072 } 073 074 @Override 075 public void setType(final ImageType type) { 076 StyleHelper.addEnumStyleName(this, type); 077 } 078 079 @Override 080 public ImageType getType() { 081 return ImageType.fromStyleName(getStyleName()); 082 } 083 084 @Override 085 public void setVisibleOn(final DeviceSize deviceSize) { 086 StyleHelper.setVisibleOn(this, deviceSize); 087 } 088 089 @Override 090 public void setHiddenOn(final DeviceSize deviceSize) { 091 StyleHelper.setHiddenOn(this, deviceSize); 092 } 093 094 public void setResponsive(final boolean responsive) { 095 StyleHelper.toggleStyleName(this, responsive, Styles.IMG_RESPONSIVE); 096 } 097 098 public void setAsMediaObject(final boolean asMediaObject) { 099 StyleHelper.toggleStyleName(this, asMediaObject, Styles.MEDIA_OBJECT); 100 } 101 102 @Override 103 public void setPull(final Pull pull) { 104 pullMixin.setPull(pull); 105 } 106 107 @Override 108 public Pull getPull() { 109 return pullMixin.getPull(); 110 } 111}