2 * Copyright (c) 2018-2019. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.img;
19 import java.awt.image.BufferedImage;
20 import java.io.InputStream;
21 import java.util.HashMap;
24 import org.hedgecode.chess.img.bitmap.BitmapImageShaper;
25 import org.hedgecode.chess.img.vector.VectorImageShaper;
27 import static org.hedgecode.chess.img.ImageFormat.Type;
30 * Shaper for images, indicated by type format.
32 * @author Dmitry Samoshin aka gotty
34 public final class ImageFormatShaper {
36 private static ImageFormatShaper _instance = new ImageFormatShaper();
38 private Map<Type, ImageShaper> imageShapers = new HashMap<>();
40 private ImageFormatShaper() {
43 BitmapImageShaper.create()
47 VectorImageShaper.create()
51 public BufferedImage shape(String imageFormat, InputStream imageStream, int size)
54 ImageFormat format = ImageFormat.findFormat(imageFormat);
56 ImageShaper imageShaper = imageShapers.get(
59 return imageShaper.shape(imageStream, size);
61 throw new ImageException("image.unknown.image.format", imageFormat);
65 public static ImageFormatShaper getInstance() {