001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.progmodel.facets.value.imageawt; 021 022import java.awt.Image; 023 024import org.apache.isis.core.commons.config.IsisConfiguration; 025import org.apache.isis.core.metamodel.adapter.ObjectAdapter; 026import org.apache.isis.core.metamodel.facetapi.FacetHolder; 027import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext; 028import org.apache.isis.core.progmodel.facets.value.image.ImageValueSemanticsProviderAbstract; 029 030public class JavaAwtImageValueSemanticsProvider extends ImageValueSemanticsProviderAbstract<Image> { 031 032 public JavaAwtImageValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) { 033 super(holder, Image.class, configuration, context); 034 } 035 036 @Override 037 public int getHeight(final ObjectAdapter object) { 038 return image(object).getHeight(null); 039 } 040 041 private Image image(final ObjectAdapter object) { 042 return (Image) object.getObject(); 043 } 044 045 @Override 046 public Image getImage(final ObjectAdapter object) { 047 return image(object); 048 } 049 050 @Override 051 protected int[][] getPixels(final Object object) { 052 return grabPixels((Image) object); 053 } 054 055 public Class<?> getValueClass() { 056 return Image.class; 057 } 058 059 @Override 060 public int getWidth(final ObjectAdapter object) { 061 return image(object).getWidth(null); 062 } 063 064 @Override 065 protected Image setPixels(final int[][] pixels) { 066 return createImage(pixels); 067 } 068 069 @Override 070 public boolean isNoop() { 071 return false; 072 } 073 074 @Override 075 public String toString() { 076 return "JavaAwtImageValueSemanticsProvider: "; 077 } 078 079 @Override 080 public ObjectAdapter createValue(final Image image) { 081 return getAdapterManager().adapterFor(image); 082 } 083 084}