one.empty3.io.ProcessNFiles Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
package one.empty3.io;
import one.empty3.feature.PixM;
import one.empty3.feature.ProcessBean;
import one.empty3.feature.process.InProcessCode;
import one.empty3.library.core.script.Code;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class ProcessNFiles {
private InProcessCode code;
public List processNFiles = new ArrayList<>();
protected ObjectWithProperties properties;
public ProcessBean bean;
protected int maxRes = 400;
private Properties property;
private File outputDirectory = null;
private List imagesStack = new ArrayList<>();
public ProcessNFiles() {
initProperties(this);
}
public void initProperties(ProcessNFiles processFile) {
if (properties == null) {
properties = new ObjectWithProperties(processFile);
}
getProperties().addProperty("maxRes", ObjectWithProperties.ClassTypes.AtomicInt, this.maxRes);
this.processNFiles.add(this);
}
public void onInstanceInit() {
}
protected static boolean isImage(File in) {
return in != null && (in.getAbsolutePath().toLowerCase().endsWith(".jpg")
|| in.getAbsolutePath().toLowerCase().endsWith(".png"));
}
public File getOutputDirectory() {
return outputDirectory;
}
public void setOutputDirectory(File outputDirectory) {
this.outputDirectory = outputDirectory;
}
public PixM getSource(String s) {
try {
Properties p = getProperty();
String property = p.getProperty(s);
File file = new File(property);
BufferedImage read = null;
read = ImageIO.read(file);
return (new PixM(read));
} catch (Exception ex) {
}
return null;
}
private Properties getProperty() {
return property;
}
public void setProperty(Properties property) {
this.property = property;
}
public boolean processMem(PixM in, PixM out) {
return in != null && out != null;
}
public void setMaxRes(int maxRes) {
this.maxRes = maxRes;
}
@Deprecated
public File getStackItem(int index) {
System.out.printf("STACK %d : %s", index, imagesStack.get(index));
return imagesStack.get(index);
}
@Deprecated
public void setStack(List files1) {
this.imagesStack = files1;
}
public void addSource(File fo) {
imagesStack.add(fo);
}
public boolean processFiles(File out, File... ins) {
if (this instanceof ProcessFile) {
return ((ProcessFile) this).process(ins[0], out);
}
return false;
}
public void addFilter(ProcessNFiles stackItem) {
this.processNFiles.add(stackItem);
}
public List getProcessNFiles() {
return processNFiles;
}
public void setProcessNFiles(List processNFiles) {
this.processNFiles = processNFiles;
}
public ObjectWithProperties getProperties() {
if (properties == null) {
properties = new ObjectWithProperties(this);
}
return properties;
}
public void setProperties(ObjectWithProperties properties) {
this.properties = properties;
}
public InProcessCode getCode() {
return code;
}
public void setCode(InProcessCode inProcessCode) {
this.code = inProcessCode;
}
}