3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Copy Kernel class to WorldEdit to avoid loading AWT.

Java 8's Kernel statically loads the AWT library, which
can apparently cause some issues on some systems, for some reason.

Either way, there is no need to load AWT if it's not needed (Java pls).
Dieser Commit ist enthalten in:
wizjany 2017-01-06 19:00:29 -05:00
Ursprung 10da4a4786
Commit 66aa881b0c
4 geänderte Dateien mit 75 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.math.convolution;
import java.awt.image.Kernel;
/**
* A Gaussian Kernel generator (2D bellcurve).
*/

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.math.convolution;
import java.awt.image.Kernel;
import static com.google.common.base.Preconditions.checkNotNull;
/**

Datei anzeigen

@ -0,0 +1,75 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.math.convolution;
/*
* This class was originally part of the JDK, java.awt.image.Kernel,
* and has been modified to not load the entire AWT toolkit, since
* that was apparently added in Java 8, even though this class
* is completely standalone.
*/
public class Kernel {
private int width;
private int height;
private int xOrigin;
private int yOrigin;
private float[] data;
public Kernel(int width, int height, float[] data) {
this.width = width;
this.height = height;
this.xOrigin = (width - 1) >> 1;
this.yOrigin = (height - 1) >> 1;
int len = width * height;
if (data.length < len) {
throw new IllegalArgumentException("Data array too small (is " + data.length + " and should be " + len);
}
this.data = new float[len];
System.arraycopy(data, 0, this.data, 0, len);
}
public final int getXOrigin() {
return xOrigin;
}
public final int getYOrigin() {
return yOrigin;
}
public final int getWidth() {
return width;
}
public final int getHeight() {
return height;
}
public final float[] getKernelData(float[] data) {
if (data == null) {
data = new float[this.data.length];
} else if (data.length < this.data.length) {
throw new IllegalArgumentException("Data array too small (should be " + this.data.length + " but is " + data.length + " )");
}
System.arraycopy(this.data, 0, data, 0, this.data.length);
return data;
}
}

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.math.convolution;
import java.awt.image.Kernel;
/**
* A linear Kernel generator (all cells weight the same)
*/