2 * Copyright (c) 2018. 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;
20 import java.util.HashSet;
23 import javax.imageio.ImageIO;
25 import org.hedgecode.chess.position.Position;
30 * @author Dmitry Samoshin aka gotty
32 public class DiagramBuilder implements ImageBuilder {
34 private static ImageBuilder _instance = new DiagramBuilder();
36 private DiagramBuilder() {
40 public String build(Position position) {
46 public Image build(Position position, String type) {
48 // Image image = ImageIO.read(new URL(urlname));
49 // Graphics.drawImage()
52 Image image = ImageIO.read(new File("f://image1.jpg"));
54 ImageIO.write(image, "JPEG", new File("f://image2.jpg"));
60 public static ImageBuilder getInstance() {
65 public static void main(String[] args) {
67 Set<String> set = new HashSet<>();
69 formatNames = ImageIO.getReaderFormatNames();
70 for (String formatName : formatNames)
71 set.add(formatName.toLowerCase());
72 System.out.println("Supported read formats: " + set);
76 formatNames = ImageIO.getWriterFormatNames();
77 for (String formatName : formatNames)
78 set.add(formatName.toLowerCase());
79 System.out.println("Supported write formats: " + set);
83 formatNames = ImageIO.getReaderMIMETypes();
84 for (String formatName : formatNames)
85 set.add(formatName.toLowerCase());
86 System.out.println("Supported read MIME types: " + set);
90 formatNames = ImageIO.getWriterMIMETypes();
91 for (String formatName : formatNames)
92 set.add(formatName.toLowerCase());
93 System.out.println("Supported write MIME types: " + set);