diff --git a/classlib/src/main/java/org/teavm/classlib/java/awt/TColor.java b/classlib/src/main/java/org/teavm/classlib/java/awt/TColor.java new file mode 100644 index 000000000..140bad78d --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/awt/TColor.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.awt; + +public class TColor { + + private int r; + private int g; + private int b; + private int a; + + public static final TColor BLACK = new TColor(0, 0, 0); + public static final TColor WHITE = new TColor(255, 255, 255); + + public TColor(int r, int g, int b) { + this(r, g, b, 255); + } + + public TColor(int r, int g, int b, int a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + + public TColor(float r, float g, float b) { + this(r, g, b, 1f); + } + + public TColor(float r, float g, float b, float a) { + this(Math.round(r * 255f), Math.round(g * 255f), + Math.round(b * 255f), Math.round(a * 255f)); + } + + public TColor(int value) { + this.r = (value >> 16) & 0xFF; + this.g = (value >> 8) & 0xFF; + this.b = value & 0xFF; + this.a = (value >> 24) & 0xFF; + } + + public int getRed() { + return r; + } + + public int getGreen() { + return g; + } + + public int getBlue() { + return b; + } + + public int getAlpha() { + return a; + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/awt/TDimension.java b/classlib/src/main/java/org/teavm/classlib/java/awt/TDimension.java new file mode 100644 index 000000000..03e683028 --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/awt/TDimension.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.awt; + +public class TDimension { + + public int width; + public int height; + + public TDimension(int width, int height) { + this.width = width; + this.height = height; + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/awt/TPoint.java b/classlib/src/main/java/org/teavm/classlib/java/awt/TPoint.java new file mode 100644 index 000000000..1495ea6ea --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/awt/TPoint.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.awt; + +public class TPoint { + + public int x; + public int y; + + public TPoint(int x, int y) { + this.x = x; + this.y = y; + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java b/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java index c3b551bae..99342e42c 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TSpliterator.java @@ -57,7 +57,7 @@ public interface TSpliterator { throw new IllegalStateException(); } - interface OfPrimitive> { + public interface OfPrimitive> { S trySplit(); boolean tryAdvance(C action); @@ -69,7 +69,7 @@ public interface TSpliterator { } } - interface OfInt extends OfPrimitive { + public interface OfInt extends OfPrimitive { default boolean tryAdvance(Consumer action) { return tryAdvance((IntConsumer) action::accept); } @@ -81,7 +81,7 @@ public interface TSpliterator { } } - interface OfLong extends OfPrimitive { + public interface OfLong extends OfPrimitive { default boolean tryAdvance(Consumer action) { return tryAdvance((LongConsumer) action::accept); } @@ -93,7 +93,7 @@ public interface TSpliterator { } } - interface OfDouble extends OfPrimitive { + public interface OfDouble extends OfPrimitive { default boolean tryAdvance(Consumer action) { return tryAdvance((DoubleConsumer) action::accept); } diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TUUID.java b/classlib/src/main/java/org/teavm/classlib/java/util/TUUID.java new file mode 100644 index 000000000..1ed20453b --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TUUID.java @@ -0,0 +1,58 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.util; + +public class TUUID { + + private String value; + + private TUUID(String value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (o instanceof TUUID) { + TUUID other = (TUUID) o; + return value.equals(other.value); + } else { + return false; + } + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public String toString() { + return value; + } + + public static TUUID randomUUID() { + String value = s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4(); + return new TUUID(value); + } + + private static String s4() { + return Integer.toString((int) Math.floor((1 + Math.random()) * 65536), 16).substring(1); + } + + public static TUUID fromString(String value) { + return new TUUID(value); + } +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TFormatter.java b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TFormatter.java new file mode 100644 index 000000000..d631df97e --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TFormatter.java @@ -0,0 +1,23 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.util.logging; + +import java.util.logging.LogRecord; + +public abstract class TFormatter { + + public abstract String format(LogRecord record); +} diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogManager.java b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogManager.java new file mode 100644 index 000000000..d8dff67a3 --- /dev/null +++ b/classlib/src/main/java/org/teavm/classlib/java/util/logging/TLogManager.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 Alexey Andreev. + * + * 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 org.teavm.classlib.java.util.logging; + +import java.io.InputStream; + +public class TLogManager { + + public void readConfiguration(InputStream stream) { + // Ignore the configuration, keep using the default logging + // configuration instead. + } + + public static TLogManager getLogManager() { + return new TLogManager(); + } +}