Fast-forward master to working and delete working #1
|
@ -1,58 +0,0 @@
|
|||
package cz.tefek.pluto.io.asl.resource.type;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import cz.tefek.pluto.io.asl.resource.Resource;
|
||||
import cz.tefek.pluto.io.asl.resource.ResourceAddress;
|
||||
import cz.tefek.pluto.io.asl.resource.ResourceHelper;
|
||||
import cz.tefek.pluto.io.logger.Logger;
|
||||
import cz.tefek.pluto.io.logger.SmartSeverity;
|
||||
|
||||
/**
|
||||
* {@link ResourceAddress} in, {@link BufferedImage} out.
|
||||
*
|
||||
* @author 493msi
|
||||
*/
|
||||
public class ResourceImage extends Resource<BufferedImage>
|
||||
{
|
||||
public ResourceImage(ResourceAddress raddress, boolean virtual)
|
||||
{
|
||||
super(raddress, virtual);
|
||||
}
|
||||
|
||||
public ResourceImage(ResourceAddress raddress)
|
||||
{
|
||||
super(raddress, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage loadFromFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ImageIO.read(new File(this.address.toPath()));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Logger.log(SmartSeverity.ERROR, "Could not load BufferedImage: " + this.address.toString() + ", will load placeholder.");
|
||||
Logger.log(e);
|
||||
|
||||
try
|
||||
{
|
||||
return ImageIO.read(new File(ResourceHelper.GLOBAL_ROOT + "data/assets/err/missingTex.png"));
|
||||
}
|
||||
catch (IOException e1)
|
||||
{
|
||||
Logger.log(SmartSeverity.ERROR, "Placeholder BufferedImage not found: " + ResourceHelper.GLOBAL_ROOT + "data/assets/err/missingTex.png");
|
||||
Logger.log("This is not good! :C");
|
||||
|
||||
Logger.log(e1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package cz.tefek.pluto.io.asl.resource.type;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import cz.tefek.pluto.io.asl.resource.Resource;
|
||||
import cz.tefek.pluto.io.asl.resource.ResourceAddress;
|
||||
import cz.tefek.pluto.io.logger.Logger;
|
||||
import cz.tefek.pluto.io.logger.SmartSeverity;
|
||||
|
||||
/**
|
||||
* {@link ResourceAddress} in, {@link InputStream} out.
|
||||
*
|
||||
* @author 493msi
|
||||
*/
|
||||
public class ResourceInputStream extends Resource<InputStream>
|
||||
{
|
||||
public ResourceInputStream(ResourceAddress raddress)
|
||||
{
|
||||
super(raddress, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream loadFromFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Files.newInputStream(this.address.toNIOPath());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Logger.log(SmartSeverity.ERROR, "Failed to open " + this.address + "!");
|
||||
Logger.log(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package cz.tefek.pluto.io.asl.textio;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import cz.tefek.pluto.io.asl.resource.ResourceAddress;
|
||||
import cz.tefek.pluto.io.logger.Logger;
|
||||
|
||||
/**
|
||||
* A simple text file reader. Apart from generic methods of loading, you can use
|
||||
* a {@link ResourceAddress}. For writing use {@link TextOut}.
|
||||
*
|
||||
* @author 493msi
|
||||
*/
|
||||
public class TextIn
|
||||
{
|
||||
public static String load(URL url)
|
||||
{
|
||||
try
|
||||
{
|
||||
load(url.toURI());
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
Logger.log(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String load(URI uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Files.readString(Paths.get(uri));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.log(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String load(Path path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Files.readString(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.log(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String loadInternal(String filename)
|
||||
{
|
||||
return load(TextIn.class.getResource("/" + filename));
|
||||
}
|
||||
|
||||
public static String loadExternal(String filename)
|
||||
{
|
||||
return load(new File(filename).toURI());
|
||||
}
|
||||
|
||||
public static String fromAddress(ResourceAddress address)
|
||||
{
|
||||
return load(address.toNIOPath());
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package cz.tefek.pluto.io.asl.textio;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Simplifies text writer creation. For reading use {@link TextIn}.
|
||||
*
|
||||
* @author 493msi
|
||||
*/
|
||||
|
||||
public class TextOut
|
||||
{
|
||||
public static PrintStream createPrintStream(String filePath) throws IOException
|
||||
{
|
||||
PrintStream printstream = new PrintStream(createFOStream(filePath));
|
||||
|
||||
return printstream;
|
||||
}
|
||||
|
||||
public static FileOutputStream createFOStream(String filePath) throws IOException
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(filePath);
|
||||
|
||||
return fos;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package cz.tefek.pluto.io.logger;
|
||||
|
||||
/**
|
||||
* Message severity.
|
||||
*
|
||||
* @author 493msi
|
||||
*
|
||||
* @deprecated Use {@link SmartSeverity} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public enum Severity implements ISeverity
|
||||
{
|
||||
INFO("[INFO] ", false),
|
||||
WARNING("[WARNING] ", true),
|
||||
ERROR("[ERROR] ", true),
|
||||
EXCEPTION("[EXCEPTION] ", true),
|
||||
NONE("", false);
|
||||
|
||||
private String displayName;
|
||||
private boolean usesStdErr;
|
||||
|
||||
Severity(String name, boolean usesStdErr)
|
||||
{
|
||||
this.displayName = name;
|
||||
this.usesStdErr = usesStdErr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStdErr()
|
||||
{
|
||||
return this.usesStdErr;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue