id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
94de4cb8-96d1-48c4-a4fb-db708e4478d4 | public FloatBuffer asBuffer() {
FloatBuffer buf = BufferUtils.createFloatBuffer(Color.size());
buf.put(r);
buf.put(g);
buf.put(b);
buf.rewind();
return buf;
} |
37f47d5e-ead4-40e3-a9b8-b36635b1feee | public void fillBuffer(FloatBuffer buf) {
buf.put(r);
buf.put(g);
buf.put(b);
} |
98348682-233b-40ae-94b0-fd99789c8c58 | public int toAwtColor() {
Color c = clip();
return (toInt(1.0f) << 24) | (toInt(c.r) << 16) | (toInt(c.g) << 8)
| toInt(c.b);
} |
66794c8f-b877-45ad-b6d6-7a0546e99d82 | private static int toInt(float c) {
return Math.round(c * 255.0f);
} |
cd6dedf5-87a8-49ec-8eb4-0a2f757d1888 | public String toString() {
return "(" + r + ", " + g + ", " + b + ")";
} |
884d567f-ec26-4383-a9ba-b519f2ff8379 | @Override
public boolean equals(final Object o) {
if (!(o instanceof Color))
return false;
final Color c = (Color) o;
return r == c.r && g == c.g && b == c.b;
} |
8a9d05bd-44a0-425e-beb8-21d98fa6ce77 | @Override
public int compareTo(Color o) {
if (r != o.r)
return (r < o.r ? -1 : 1);
if (g != o.g)
return (g < o.g ? -1 : 1);
if (b != o.b)
return (b < o.b ? -1 : 1);
return 0;
} |
d6a1441b-fbdd-4be4-9947-9b1d4bd93364 | public static int size() {
return 3;
} |
6c08f1ba-7038-4a3f-9471-f80b2070e998 | public Vector(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
} |
8a572d32-e8ce-41f4-8c88-8a73e6f4972d | public Vector add(Vector v) {
return new Vector(x + v.x, y + v.y, z + v.z);
} |
264f77af-c495-413b-a1bb-e10b5853193c | public Vector sub(Vector v) {
return new Vector(x - v.x, y - v.y, z - v.z);
} |
12b55911-3c96-4e33-9d54-226b19201b1d | public Vector mult(float s) {
return new Vector(x * s, y * s, z * s);
} |
fb364379-c4af-4636-a96f-7048257af8da | public Vector mult(Vector v) {
return new Vector(x * v.x, y * v.y, z * v.z);
} |
5851cb7c-aa5c-4449-a9d3-496340cdd25c | public float length() {
return (float) Math.sqrt(x * x + y * y + z * z);
} |
90bb674e-bdda-4a6c-9335-a58030363a79 | public Vector normalize() {
return mult(1.0f / length());
} |
5a9850b3-070c-453a-9ecf-53d485052972 | public float dot(Vector v) {
return x * v.x + y * v.y + z * v.z;
} |
72215027-d953-4670-915e-4f831fb22a85 | public Vector cross(Vector v) {
return new Vector(y * v.z - z * v.y, -x * v.z + z * v.x, x * v.y - y * v.x);
} |
43d6b80e-4e44-4e7c-b2a6-9e879d187557 | public float[] asArray() {
float[] v = { x, y, z };
return v;
} |
60600cf1-ba2f-4a7a-941f-51f21d33b582 | public FloatBuffer asBuffer() {
FloatBuffer b = BufferUtils.createFloatBuffer(Vector.size());
b.put(x);
b.put(y);
b.put(z);
b.rewind();
return b;
} |
67b697a9-f12b-481a-adf7-171204ad5d95 | public void fillBuffer(FloatBuffer buf) {
buf.put(x);
buf.put(y);
buf.put(z);
} |
97212c6e-5223-4102-9dbd-a10e99db2f74 | public String toString() {
return "(" + x + ", " + y + ", " + z + ")";
} |
72e92397-23e6-46ae-b4c1-2150e8560bc4 | @Override
public boolean equals(final Object o) {
if (!(o instanceof Vector))
return false;
final Vector v = (Vector) o;
return x == v.x && y == v.y && z == v.z;
} |
c14d4521-18f8-4aa7-8803-c8ee8e7c12e6 | @Override
public int compareTo(Vector o) {
if (x != o.x)
return (x < o.x ? -1 : 1);
if (y != o.y)
return (y < o.y ? -1 : 1);
if (z != o.z)
return (z < o.z ? -1 : 1);
return 0;
} |
af817eb7-7f48-4d69-a7df-0f5a26212532 | public static int size() {
return 3;
} |
c1337071-5229-4fad-b7cd-329e6a6e083e | private Matrix() {
makeIdent();
} |
77e920c1-cfae-490f-a102-2010f6e33fbf | public Matrix(float m00, float m01, float m02, float m03, float m10,
float m11, float m12, float m13, float m20, float m21, float m22,
float m23, float m30, float m31, float m32, float m33) {
makeIdent();
set(0, 0, m00);
set(0, 1, m01);
set(0, 2, m02);
set(0, 3, m03);
set(1, 0, m10);... |
a1003b70-1315-4145-8f13-9064e36e1f8e | public Matrix(Vector b0, Vector b1, Vector b2) {
makeIdent();
set(0, 0, b0.x);
set(1, 0, b0.y);
set(2, 0, b0.z);
set(0, 1, b1.x);
set(1, 1, b1.y);
set(2, 1, b1.z);
set(0, 2, b2.x);
set(1, 2, b2.y);
set(2, 2, b2.z);
} |
e01bab1d-6328-4300-8527-270e505d6f43 | public Matrix(float[] m) {
values = m.clone();
} |
c965df96-f3f0-4e52-80e1-ca51d749c417 | public Matrix(Quaternion q) {
float qx2 = q.x * q.x;
float qy2 = q.y * q.y;
float qz2 = q.z * q.z;
// float qw2 = q.w * q.w;
values = new float[] { (1 - 2 * qy2 - 2 * qz2),
(2 * q.x * q.y - 2 * q.z * q.w), (2 * q.x * q.z + 2 * q.y * q.w), 0,
(2 * q.x * q.y + 2 * q.z * q.w), (1 - 2 *... |
7c48e7bb-a2c4-455e-bbb5-66cf884bd883 | public static Matrix translate(Vector t) {
Matrix m = new Matrix();
m.set(3, 0, t.x);
m.set(3, 1, t.y);
m.set(3, 2, t.z);
return m;
} |
f9d49d02-29ca-4f6d-abc7-4b87dbaf7832 | public static Matrix translate(float x, float y, float z) {
Matrix m = new Matrix();
m.set(3, 0, x);
m.set(3, 1, y);
m.set(3, 2, z);
return m;
} |
f141b80d-e0a9-4d0f-b010-14856503baef | public static Matrix rotate(Vector axis, float angle) {
final Matrix m = new Matrix();
final float rad = (angle / 180.0f) * ((float) Math.PI);
final float cosa = (float) Math.cos(rad);
final float sina = (float) Math.sin(rad);
final Vector naxis = axis.normalize();
final float rx = naxis.x;
... |
c817efe3-5210-4592-a856-56adffbe5c1b | public static Matrix rotate(float ax, float ay, float az, float angle) {
return rotate(new Vector(ax, ay, az), angle);
} |
e5758b07-bf34-4027-b3e3-9dd1c4ac10d6 | public static Matrix scale(Vector s) {
Matrix m = new Matrix();
m.set(0, 0, s.x);
m.set(1, 1, s.y);
m.set(2, 2, s.z);
return m;
} |
a415b86c-a4c1-4427-9608-f8b060608518 | public static Matrix scale(float x, float y, float z) {
Matrix m = new Matrix();
m.set(0, 0, x);
m.set(1, 1, y);
m.set(2, 2, z);
return m;
} |
dd41dfdf-4a8a-452c-ae65-664bc4b8a6bb | public static Matrix lookat(Vector eye, Vector center, Vector up) {
Vector backwards = eye.sub(center).normalize();
Vector side = up.cross(backwards).normalize();
up = backwards.cross(side).normalize();
Matrix r = new Matrix(side, up, backwards);
Matrix t = Matrix.translate(eye.mult(-1.0f));
ret... |
9ae638bc-1bab-496a-bc78-af1b33ef7e69 | public static Matrix frustum(float left, float right, float bottom,
float top, float zNear, float zFar) {
if (zNear <= 0.0f || zFar < 0.0f) {
throw new RuntimeException(
"Frustum: zNear and zFar must be positive, and zNear>0");
}
if (left == right || top == bottom) {
throw new Runt... |
ba24b108-f620-409a-9caf-09bed493a962 | public static Matrix perspective(float fovy, float aspect, float zNear,
float zFar) {
float top = (float) Math.tan(fovy * ((float) Math.PI) / 360.0f) * zNear;
float bottom = -1.0f * top;
float left = aspect * bottom;
float right = aspect * top;
return frustum(left, right, bottom, top, zNear, z... |
26fe32d2-6b45-4932-8120-1c37a07f50c9 | public float get(int c, int r) {
return values[4 * c + r];
} |
01593d49-5dfc-4aa8-a4f0-8dec57b780a5 | private void set(int c, int r, float v) {
values[4 * c + r] = v;
} |
84b7e70c-bf5a-4c63-859c-64b3b85b1932 | public Matrix mult(Matrix m) {
// Optimzed version.
Matrix n = new Matrix();
{
{
float v = 0;
v += values[4 * 0 + 0] * m.values[4 * 0 + 0];
v += values[4 * 1 + 0] * m.values[4 * 0 + 1];
v += values[4 * 2 + 0] * m.values[4 * 0 + 2];
v += values[4 * 3 + 0] * m.val... |
6ffcd1b1-9642-4cea-a065-c425cff94a2a | public Matrix multSlow(Matrix m) {
Matrix n = new Matrix();
for (int c = 0; c != 4; c++) {
for (int r = 0; r != 4; r++) {
float v = 0;
for (int k = 0; k != 4; k++)
v += get(k, r) * m.get(c, k);
n.set(c, r, v);
}
}
return n;
} |
732cb90c-9ce8-49f7-a9ba-64375715bedd | public Vector transformPoint(Vector v) {
final float x = get(0, 0) * v.x + get(1, 0) * v.y + get(2, 0) * v.z
+ get(3, 0);
final float y = get(0, 1) * v.x + get(1, 1) * v.y + get(2, 1) * v.z
+ get(3, 1);
final float z = get(0, 2) * v.x + get(1, 2) * v.y + get(2, 2) * v.z
+ get(3, 2);
... |
4d5f7d63-777f-436c-bbe1-98f5e3039f30 | public Vector transformDirection(Vector v) {
float x = get(0, 0) * v.x + get(1, 0) * v.y + get(2, 0) * v.z;
float y = get(0, 1) * v.x + get(1, 1) * v.y + get(2, 1) * v.z;
float z = get(0, 2) * v.x + get(1, 2) * v.y + get(2, 2) * v.z;
return new Vector(x, y, z);
} |
e95c1eda-d7e8-471d-818f-cae111d31547 | public Vector transformNormal(Vector v) {
return transformDirection(v);
} |
bcaa1135-08ec-49ab-bb44-9e0b7d20762f | public Matrix transpose() {
Matrix n = new Matrix();
for (int c = 0; c != 4; c++) {
for (int r = 0; r != 4; r++) {
n.set(c, r, get(r, c));
}
}
return n;
} |
080b4d23-98db-4cd8-b48b-21c045e13f6a | public Matrix invertRigid() {
/*
* this only works for rigid body transformations!
*/
/*
* calculate the inverse rotation by transposing the upper 3x3 submatrix.
*/
Matrix ri = new Matrix();
for (int c = 0; c != 3; c++)
for (int r = 0; r != 3; r++)
ri.set(c, r, get(r, c... |
5e3f366c-b4a9-4de3-9c08-9ad118efd8db | private Matrix makeIdent() {
values = new float[16];
set(0, 0, 1.0f);
set(1, 1, 1.0f);
set(2, 2, 1.0f);
set(3, 3, 1.0f);
return this;
} |
c743dc1b-4293-4820-b37b-115f4bdaf361 | public Matrix invertFull() {
Matrix ret = new Matrix();
float[] mat = values;
float[] dst = ret.values;
float[] tmp = new float[12];
/* temparray for pairs */
float src[] = new float[16];
/* array of transpose source matrix */
float det;
/* determinant */
/*
* transpose m... |
278dc113-8f0a-4847-8f27-342c3ea5d4e1 | public float[] asArray() {
return values.clone();
} |
718b3080-7fd3-4efb-b556-f05fb5e71dfc | public FloatBuffer asBuffer() {
FloatBuffer b = BufferUtils.createFloatBuffer(values.length);
b.put(values);
b.rewind();
return b;
} |
a2b41d82-7638-4c41-a90c-43f59969405f | public void fillBuffer(FloatBuffer buf) {
buf.rewind();
buf.put(values).rewind();
} |
ab5af57f-d8de-4bd7-9c68-239ea6b67dcc | public Matrix getRotation() {
Matrix r = new Matrix();
r.set(0, 0, get(0, 0));
r.set(1, 0, get(1, 0));
r.set(2, 0, get(2, 0));
r.set(0, 1, get(0, 1));
r.set(1, 1, get(1, 1));
r.set(2, 1, get(2, 1));
r.set(0, 2, get(0, 2));
r.set(1, 2, get(1, 2));
r.set(2, 2, get(2, 2));
retur... |
6687121d-f8c3-4a9a-ad88-33f26f2ff860 | public Matrix getTranslation() {
Matrix t = new Matrix();
t.set(3, 0, get(3, 0));
t.set(3, 1, get(3, 1));
t.set(3, 2, get(3, 2));
return t;
} |
124fe72b-30aa-40fb-a737-d51ee6fba4c5 | public Vector getPosition() {
return new Vector(get(3, 0), get(3, 1), get(3, 2));
} |
ce7742c4-0c2e-4964-b9e2-4fb8693ab712 | public String toString() {
String s = "";
for (int r = 0; r < 4; r++) {
s += "[ ";
for (int c = 0; c < 4; c++) {
s += get(c, r) + " ";
}
s += "]\n";
}
return s;
} |
e8b99a4e-08be-4cd2-8098-a8ed4e66d6db | @Override
public boolean equals(Object o) {
if (!(o instanceof Matrix))
return false;
Matrix m = (Matrix) o;
for (int i = 0; i != 16; i++)
if (values[i] != m.values[i])
return false;
return true;
} |
eb741d9c-7435-47cb-893a-f7676283bf74 | public boolean equals(Matrix m, float epsilon) {
for (int i = 0; i != 16; i++)
if (Math.abs(values[i] - m.values[i]) > epsilon)
return false;
return true;
} |
f6ae63df-cf61-4f0a-9602-94a349b60e2b | public Quaternion(float x, float y, float z, float w) {
float mag;
mag = 1.0f / (float) Math.sqrt(x * x + y * y + z * z + w * w);
this.x = x * mag;
this.y = y * mag;
this.z = z * mag;
this.w = w * mag;
} |
c5ebf3af-413f-4ff8-83fd-1478014028c0 | public Quaternion(float[] q) {
float mag;
mag = 1.0f / (float) Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]
+ q[3] * q[3]);
x = q[0] * mag;
y = q[1] * mag;
z = q[2] * mag;
w = q[3] * mag;
} |
ecc73623-c0b5-4154-8445-83564163ae34 | public Quaternion() {
x = 0.0f;
y = 0.0f;
z = 0.0f;
w = 0.0f;
} |
39f40e8a-f0cf-4bd9-9de7-c8fde35be35b | public Quaternion(Matrix m) {
float ww = 0.25f * (m.get(0, 0) + m.get(1, 1) + m.get(2, 2) + m.get(3, 3));
if (ww >= 0) {
if (ww >= EPS2) {
w = (float) Math.sqrt(ww);
ww = 0.25f / w;
x = ((m.get(2, 1) - m.get(1, 2)) * ww);
y = ((m.get(0, 2) - m.get(2, 0)) * ww);
z =... |
da2be1b5-7ece-456f-9e08-40ead063585c | public static Quaternion rotate(Vector axis, float angle) {
return new Quaternion(Matrix.rotate(axis, angle));
} |
0323992e-c81a-45a8-8fd2-758aa3d28c82 | public final Quaternion negate() {
return new Quaternion(-x, -y, -z, -w);
} |
0d30bc51-5ea0-498d-a9b2-8f7af3df4945 | public final Quaternion conjugate() {
return new Quaternion(-x, -y, -z, w);
} |
23454c85-2777-40df-a493-1e439a8a7c12 | public final Quaternion mul(Quaternion q) {
return new Quaternion(w * q.x + q.w * x + y * q.z - z * q.y, w * q.y + q.w
* y - x * q.z + z * q.x, w * q.z + q.w * z + x * q.y - y * q.x, w * q.w
- x * q.x - y * q.y - z * q.z);
} |
29bd93c3-0bf6-42f3-b8bc-1f568cfeb0de | public final Quaternion inverse() {
float norm = 1.0f / (w * w + x * x + y * y + z * z);
return new Quaternion(norm * w, -norm * x, -norm * y, -norm * z);
} |
8caa36e8-7670-46ac-80c4-20ecf9c798bd | public final Quaternion normalize() {
float norm = w * w + x * x + y * y + z * z;
if (norm > 0.0f) {
norm = 1.0f / (float) Math.sqrt(norm);
return new Quaternion(x * norm, y * norm, z * norm, w * norm);
} else {
return new Quaternion();
}
} |
b8af3ed5-64d8-435e-bc20-17192d40e73c | public final Quaternion interpolate(Quaternion q, float alpha) {
// From "Advanced Animation and Rendering Techniques"
// by Watt and Watt pg. 364, function as implemented appeared to be
// incorrect. Fails to choose the same quaternion for the float
// covering. Resulting in change of direction for rot... |
c74d4447-c45c-44e4-980f-546aa9354994 | public Color pixelColorAt(int x, int y, int resolutionX, int resolutionY); |
e516205d-3c6f-46ce-a569-08ed04195678 | @Override
public Color pixelColorAt(int i, int j, int resolutionX, int resolutionY) {
int x = (i * 8) / resolutionX;
int y = (j * 8) / resolutionY;
System.out.println();
// this is just a little hint -
// but not yet the solution to paint an 8x8 checkerboard for any given
// resolution
if (x % 2 + y % ... |
a2d7e98f-4736-48b7-82a3-f7e28b15e378 | public static void main(String[] args) {
// get the user's home directory - should work on all operating systems
String path = System.getProperty("user.home");
// ************ test painting a checkerboard ************
{
// String filename = path
// + "/Documents/BHfT/Computergrafik II/Warmup/"
// + "... |
d6b4ab78-28cd-4414-8b8f-693c28bf3baa | public ImageGenerator(Painter painter, int resolutionX, int resolutionY, String filename, String imgformat) {
generate(painter,resolutionX,resolutionY,filename,imgformat);
} |
3658a114-1e15-4984-9cbd-fcae7a81f2be | static public boolean showImage(String filename) {
try {
File file = new File(filename);
Desktop.getDesktop().open(file);
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
} |
c81cce62-63ad-4ae1-afee-6ead4a9b2e75 | private boolean generate(Painter painter, int resolutionX, int resolutionY, String filename, String imgformat) {
// create a buffered image object using RGB+A pixel format
BufferedImage image = new BufferedImage(resolutionX, resolutionY, BufferedImage.TYPE_INT_ARGB);
// Set a color for each pixel. Y pi... |
9d1bec12-5f71-437b-9df9-97521887b0c5 | public static void main(String[] args) throws NoSuchAlgorithmException, IOException, ParseException {
// TODO code application logic here
// getFileCheckSum("F:/360云盘/图片/分类");
// getFileCheckSum("F:/360云盘/图片/待处理");
// HuabanGrab.grabPetOldPhoto(Const.huaBanPetLastPinId, 5);
// ImageF... |
9a1a4123-cb91-4bc3-a2cc-73bcf4a81df3 | public static void getFileCheckSum(String path) throws NoSuchAlgorithmException, IOException {
String desPath = path + "_temp";
File desDirectory = new File(desPath);
if (!desDirectory.exists()) {
desDirectory.mkdir();
}
File directory = new File(path);
File[]... |
b0877c88-b45a-45d5-aba7-747b5c5d14fd | public static void widthFilter(String folderPath, int minWidth) throws IOException {
File folder = new File(folderPath);
if (!folder.exists()) {
return;
}
String destFolderPath = folder + "lessWidth";
File[] files = folder.listFiles();
for (int index = 0; inde... |
2f858e69-c912-4d92-8ae0-891b121e092f | public static String decodeUnicode(String dataStr) {
int start = 0;
int end = 0;
StringBuffer buffer = new StringBuffer();
while(start > -1){
end = dataStr.indexOf("\\u", start);
if(end == -1){
buffer.append(dataStr.substring(start,dataStr... |
3823f730-9a96-4213-b15b-9078d06a5603 | public static String getRandomString(int length) { //length表示生成字符串的长度
String base = "abcdefghijklmnopqrstuvwxyz0123456789"; //生成字符串从此序列中取
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.... |
f95ff867-b67a-4b56-a6f6-d2bbc7f93b1a | public static boolean move(File srcFile, String destPath) {
//目标位置所在文件夹
File dir = new File(destPath);
if (!dir.exists()) {
dir.mkdirs();
}
//更名
boolean success = srcFile.renameTo(new File(dir, srcFile.getName()));
return success;
} |
364fc0e6-4412-4e9a-a15b-f38e633d0182 | public static boolean deleteFile(File srcFile) {
if (srcFile.isDirectory()) {
return false;
}
if (!srcFile.exists()) {
return false;
}
srcFile.delete();
return true;
} |
f97dd002-0b3d-4259-8735-42b3da52d969 | public static boolean deleteFile(String srcFilePath) {
File srcFile = new File(srcFilePath);
return deleteFile(srcFile);
} |
3a2d20ee-a369-4907-ae93-d1e3cc819430 | public static boolean deleteDirectory(File directory) {
if (!directory.isDirectory()) {
return false;
}
if (!directory.exists()) {
return false;
}
File[] fileList = directory.listFiles();
for (int index = 0; index < fileList.length; index++) {
... |
8dbc9694-e86b-46da-8154-8c4962d65c45 | public static boolean deleteDirectory(String directoryPath) {
File directory = new File(directoryPath);
return deleteDirectory(directory);
} |
d1be1aa7-c922-4e86-a878-2a4fa44d28fb | public static boolean move(String srcFilePath, String destPath) {
File srcFile = new File(srcFilePath);
return move(srcFile, destPath);
} |
7d67e986-d26e-4a23-a952-acb780947b98 | public static long calculateCheckSum(File file) throws NoSuchAlgorithmException, IOException {
AbstractChecksum jacksum = JacksumAPI.getChecksumInstance("md5", true);
return jacksum.readFile(file.getAbsolutePath());
} |
c888591e-84ef-4518-828a-40247deea656 | public static long calculateCheckSum(String filePath) throws NoSuchAlgorithmException, IOException {
File file = new File(filePath);
if (!file.exists()) {
return 0;
}
return calculateCheckSum(file);
} |
1c53e8bc-3e73-4288-9f1a-0c3600833fbe | public static void download(String urlString, String filePath)
throws Exception {
// 构造URL
URL url = new URL(urlString);
// 打开连接
URLConnection con = url.openConnection();
// 输入流
InputStream is = con.getInputStream();
// 1K的数据缓冲
byte[] bs = new ... |
b0474c73-84a4-49cb-a954-48feba35b810 | public static boolean checkWidthLimit(String filePath, int widthLimit) throws IOException {
File file = new File(filePath);
BufferedImage buff = FileUtil.getImageInfo(file);
System.out.println(buff.getWidth());// 得到图片的宽度
int width = buff.getWidth();
if (width < widthLimit) {
... |
10632c0b-9118-42f5-bb63-13f4ac63d976 | public static boolean checkHeightLimit(String filePath, int heightLimit) throws IOException {
File file = new File(filePath);
BufferedImage buff = FileUtil.getImageInfo(file);
System.out.println(buff.getWidth());// 得到图片的高度
int height = buff.getHeight();
if (height < heightLimit)... |
7fa7bbd7-9a0d-4556-9190-cebeab820521 | public static boolean checkSquareImage(String filePath) throws IOException {
File file = new File(filePath);
BufferedImage buff = FileUtil.getImageInfo(file);
if (buff.getWidth() == buff.getHeight()) {
return true;
} else {
return false;
}
} |
5414af34-e948-4807-944d-31cf4cdbf6ba | public static boolean checkNearlySquareImage(String filePath, float nearlyValue) throws IOException {
File file = new File(filePath);
BufferedImage buff = FileUtil.getImageInfo(file);
float width = buff.getWidth();
float height = buff.getHeight();
float s = 0;
if (width =... |
18d4c210-1a75-4ab1-91a5-3945a9cd93d5 | public static BufferedImage getImageInfo(File image) throws IOException, IOException {
BufferedImage bufferedImage;
try {
bufferedImage = ImageIO.read(image);
} catch (CMMException ex) {
InputStream is = new FileInputStream(image);
bufferedImage = JAI.create("... |
98e7a8d5-7b5f-47ee-a322-c488094fdf9a | public static Object getMap4Json(String jsonString) {
JSONReader reader = new JSONReader();
jsonString = StringUtil.decodeUnicode(jsonString);
Object obj = reader.read(jsonString);
return obj;
} |
00e81fef-00b4-41c9-9e33-a0ad041fda63 | public static String getPageSource(String pageUrl) throws IOException {
URL url = new URL(pageUrl);
URLConnection urlConn = url.openConnection(); // 打开网站链接s
BufferedReader reader = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), "UTF-8")); // 实例化输入流,并获取网页代码
String s; /... |
1912030e-4d4a-4616-af6d-a68a6ed2577b | public static String getPageSourceByHTTPClient(String pageUrl, String host, String referer, String userAgent) throws IOException {
HttpClient client = new HttpClient();
if (host != null) {
client.getHostConfiguration().setHost(host, 80, "http");
}
GetMethod getMethod = new Ge... |
d24dc9a3-651d-4f8c-9bd0-1a098bac7d32 | public static String getPageSourceByHTTPClientPost(String pageUrl, String host, String referer, String userAgent, Map paras) throws IOException {
HttpClient client = new HttpClient();
if (host != null) {
client.getHostConfiguration().setHost(host, 80, "http");
}
PostMethod po... |
61c6933f-fbd6-4e62-8869-d8b62ebd9c66 | public static void grabPhoto(int pageNumber) throws IOException {
String pageUrl = Const.duiTangPageUrl + pageNumber;
String pageContent = NetUtil.getPageSource(pageUrl);
List blogs = (List) ((Map) ((Map) JsonUtil.getMap4Json(pageContent)).get("data")).get("blogs");
for (int j = 0; j < b... |
e7f05683-38a2-471f-a414-a4b2c7d155e6 | public static void grabPhoto(int pageNumber) throws IOException {
String pageUrl = Const.woXiHuanPageUrl + pageNumber;
String pageContent = NetUtil.getPageSource(pageUrl);
String body = (String) ((Map) JsonUtil.getMap4Json(pageContent)).get("body");
Pattern photoPattern = Pattern.compi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.